linux-change-dentry-cleanup-20050619
[openafs.git] / src / afs / LINUX / osi_vfsops.c
index 05d1e7c..a0ed85e 100644 (file)
@@ -18,6 +18,8 @@
 RCSID
     ("$Header$");
 
+#define __NO_VERSION__         /* don't define kernel_version in module.h */
+#include <linux/module.h> /* early to avoid printf->printk mapping */
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
 #include "afs/afs_stats.h"
@@ -28,14 +30,11 @@ RCSID
 #include "h/smp_lock.h"
 #endif
 
-#define __NO_VERSION__         /* don't define kernel_version in module.h */
-#include <linux/module.h>
-
 
 struct vcache *afs_globalVp = 0;
 struct vfs *afs_globalVFS = 0;
 #if defined(AFS_LINUX24_ENV)
-struct nameidata afs_cacheNd;
+struct vfsmount *afs_cacheMnt;
 #endif
 int afs_was_mounted = 0;       /* Used to force reload if mount/unmount/mount */
 
@@ -52,7 +51,6 @@ static int afs_root(struct super_block *afsp);
 struct super_block *afs_read_super(struct super_block *sb, void *data, int silent);
 int afs_fill_super(struct super_block *sb, void *data, int silent);
 static struct super_block *afs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data);
-void put_inode_on_dummy_list(struct inode *ip);
 
 /* afs_file_system
  * VFS entry for Linux - installed in init_module
@@ -138,12 +136,14 @@ afs_read_super(struct super_block *sb, void *data, int silent)
     sb->s_maxbytes = MAX_NON_LFS;
 #endif
     code = afs_root(sb);
-    if (code)
+    if (code) {
+       afs_globalVFS = NULL;
 #if defined(AFS_LINUX26_ENV)
-       module_put(THIS_MODULE);
+        module_put(THIS_MODULE);
 #else
-       MOD_DEC_USE_COUNT;
+        MOD_DEC_USE_COUNT;
 #endif
+    }
 
 #if !defined(AFS_LINUX24_ENV)
     unlock_super(sb);
@@ -265,7 +265,11 @@ static LIST_HEAD(dummy_inode_list);
  * has synced some pages of a file to disk.
  */
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+#ifdef WRITE_INODE_NOT_VOID
+static int
+#else
 static void
+#endif
 afs_write_inode(struct inode *ip, int unused)
 #else
 static void
@@ -278,13 +282,22 @@ afs_write_inode(struct inode *ip)
 
     /* for now we don't actually update the metadata during msync. This
      * is just to keep linux happy.  */
+#ifdef WRITE_INODE_NOT_VOID
+    return 0;
+#endif
 }
 
-
 static void
 afs_destroy_inode(struct inode *ip)
 {
+    cred_t *credp = crref();
+
+    /* locked by clear_inode() */
+    put_inode_on_dummy_list(ip);
     ip->i_state = 0;
+    afs_InactiveVCache(ITOAFS(ip), credp); /* afs_FlushVCache()? */
+    AFS_GUNLOCK();
+    crfree(credp);
 }
 
 
@@ -295,29 +308,28 @@ afs_destroy_inode(struct inode *ip)
  * That will trigger the call to delete routine.
  */
 
+#if defined(AFS_LINUX24_ENV)
+static void
+afs_clear_inode(struct inode *ip)
+{
+    AFS_GLOCK();       /* unlocked by destroy_inode() */
+}
+#else
 static void
 afs_delete_inode(struct inode *ip)
 {
-    struct vcache *vp = ITOAFS(ip);
-
-#ifdef AFS_LINUX26_ENV
-    put_inode_on_dummy_list(ip);
-#endif
-
-    AFS_GLOCK();
+    AFS_GLOCK();               /* after spin_unlock(inode_lock) */
     osi_clear_inode(ip);
     AFS_GUNLOCK();
 }
-
+#endif
 
 /* afs_put_super
  * Called from unmount to release super_block. */
 static void
 afs_put_super(struct super_block *sbp)
 {
-    extern int afs_afs_cold_shutdown;
     int code = 0;
-    int fv_slept;
 
     AFS_GLOCK();
     AFS_STATCNT(afs_unmount);
@@ -333,11 +345,10 @@ afs_put_super(struct super_block *sbp)
     afs_globalVp = 0;
     afs_shutdown();
 #if defined(AFS_LINUX24_ENV)
-    path_release(&afs_cacheNd);
+    mntput(afs_cacheMnt);
 #endif
 
     osi_linux_verify_alloced_memory();
-  done:
     AFS_GUNLOCK();
 
     if (!code) {
@@ -367,7 +378,7 @@ afs_statfs(struct super_block *sbp, struct statfs *__statp, int size)
 #endif
 {
 #if !defined(AFS_LINUX24_ENV)
-    struct statfs stat;
+    struct statfs stat, *statp;
 
     if (size < sizeof(struct statfs))
        return;
@@ -401,11 +412,12 @@ afs_umount_begin(struct super_block *sbp)
 }
 
 struct super_operations afs_sops = {
-#if defined(AFS_LINUX26_ENV)
-  .drop_inode =                generic_delete_inode,
+#if defined(AFS_LINUX24_ENV)
   .destroy_inode =     afs_destroy_inode,
+  .clear_inode =        afs_clear_inode,
+#else
+  .delete_inode =       afs_delete_inode,
 #endif
-  .delete_inode =      afs_delete_inode,
   .write_inode =       afs_write_inode,
   .put_super =         afs_put_super,
   .statfs =            afs_statfs,