libafs: Flush vcaches in afs_shutdown
[openafs.git] / src / afs / LINUX / osi_vfsops.c
index 8104dea..596d064 100644 (file)
@@ -21,7 +21,6 @@
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
 #include "afs/afs_stats.h"
-#include <linux/smp_lock.h>
 
 #include "osi_compat.h"
 
@@ -45,7 +44,19 @@ static int afs_root(struct super_block *afsp);
 int afs_fill_super(struct super_block *sb, void *data, int silent);
 
 
-#ifdef GET_SB_HAS_STRUCT_VFSMOUNT
+/*
+ * afs_mount (2.6.37+) and afs_get_sb (2.6.36-) are the entry
+ * points from the vfs when mounting afs.  The super block
+ * structure is setup in the afs_fill_super callback function.
+ */
+
+#if defined(STRUCT_FILE_SYSTEM_TYPE_HAS_MOUNT)
+static struct dentry *
+afs_mount(struct file_system_type *fs_type, int flags,
+           const char *dev_name, void *data) {
+    return mount_nodev(fs_type, flags, data, afs_fill_super);
+}
+#elif defined(GET_SB_HAS_STRUCT_VFSMOUNT)
 static int
 afs_get_sb(struct file_system_type *fs_type, int flags,
           const char *dev_name, void *data, struct vfsmount *mnt) {
@@ -62,7 +73,11 @@ afs_get_sb(struct file_system_type *fs_type, int flags,
 struct file_system_type afs_fs_type = {
     .owner = THIS_MODULE,
     .name = "afs",
+#if defined(STRUCT_FILE_SYSTEM_TYPE_HAS_MOUNT)
+    .mount = afs_mount,
+#else
     .get_sb = afs_get_sb,
+#endif
     .kill_sb = kill_anon_super,
     .fs_flags = FS_BINARY_MOUNTDATA,
 };
@@ -92,6 +107,11 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
     sb->s_blocksize_bits = 10;
     sb->s_magic = AFS_VFSMAGIC;
     sb->s_op = &afs_sops;      /* Super block (vfs) ops */
+
+#if defined(STRUCT_SUPER_BLOCK_HAS_S_D_OP)
+    sb->s_d_op = &afs_dentry_operations;
+#endif
+
     /* used for inodes backing_dev_info field, also */
     afs_backing_dev_info = osi_Alloc(sizeof(struct backing_dev_info));
 #if defined(HAVE_LINUX_BDI_INIT)
@@ -126,7 +146,7 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
     code = afs_root(sb);
     if (code) {
        afs_globalVFS = NULL;
-       osi_linux_free_inode_pages();
+       afs_FlushAllVCaches();
         module_put(THIS_MODULE);
     }
 
@@ -166,7 +186,9 @@ afs_root(struct super_block *afsp)
                /* setup super_block and mount point inode. */
                afs_globalVp = tvp;
                afsp->s_root = d_alloc_root(ip);
+#if !defined(STRUCT_SUPER_BLOCK_HAS_S_D_OP)
                afsp->s_root->d_op = &afs_dentry_operations;
+#endif
            } else
                code = ENOENT;
        }
@@ -319,7 +341,6 @@ afs_put_super(struct super_block *sbp)
     afs_globalVFS = 0;
     afs_globalVp = 0;
 
-    osi_linux_free_inode_pages();      /* invalidate and release remaining AFS inodes. */
     afs_shutdown();
     mntput(afs_cacheMnt);
 
@@ -442,27 +463,3 @@ vattr2inode(struct inode *ip, struct vattr *vp)
     ip->i_ctime.tv_sec = vp->va_ctime.tv_sec;
     ip->i_ctime.tv_nsec = 0;
 }
-
-/* osi_linux_free_inode_pages
- *
- * Free all vnodes remaining in the afs hash.  Must be done before
- * shutting down afs and freeing all memory.
- */
-void
-osi_linux_free_inode_pages(void)
-{
-    int i;
-    struct vcache *tvc, *nvc;
-    extern struct vcache *afs_vhashT[VCSIZE];
-
-    for (i = 0; i < VCSIZE; i++) {
-       for (tvc = afs_vhashT[i]; tvc; ) {
-           int slept;
-       
-           nvc = tvc->hnext;
-           if (afs_FlushVCache(tvc, &slept))           /* slept always 0 for linux? */
-               printf("Failed to invalidate all pages on inode 0x%p\n", tvc);
-           tvc = nvc;
-       }
-    }
-}