linux-updates-20060811
[openafs.git] / src / afs / LINUX / osi_vfsops.c
index 63d1457..762c309 100644 (file)
@@ -39,6 +39,9 @@ struct vfsmount *afs_cacheMnt;
 int afs_was_mounted = 0;       /* Used to force reload if mount/unmount/mount */
 
 extern struct super_operations afs_sops;
+#if defined(AFS_LINUX26_ENV)
+extern struct export_operations afs_export_ops;
+#endif
 extern afs_rwlock_t afs_xvcache;
 extern struct afs_q VLRU;
 
@@ -49,7 +52,6 @@ static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp);
 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);
 
 /* afs_file_system
  * VFS entry for Linux - installed in init_module
@@ -64,6 +66,29 @@ struct backing_dev_info afs_backing_dev_info = {
        .state          = 0,
 };
 
+
+/* afs_read_super
+ * read the "super block" for AFS - roughly eguivalent to struct vfs.
+ * dev, covered, s_rd_only, s_dirt, and s_type will be set by read_super.
+ */
+#if defined(AFS_LINUX26_ENV)
+static struct super_block *
+#ifdef GET_SB_HAS_STRUCT_VFSMOUNT
+afs_get_sb(struct file_system_type *fs_type, int flags,
+          const char *dev_name, void *data, struct vfsmount *mnt)
+#else
+afs_get_sb(struct file_system_type *fs_type, int flags,
+          const char *dev_name, void *data)
+#endif
+{
+#ifdef GET_SB_HAS_STRUCT_VFSMOUNT
+    return get_sb_nodev(fs_type, flags, data, afs_fill_super, mnt);
+#else
+    return get_sb_nodev(fs_type, flags, data, afs_fill_super);
+#endif
+}
+
+
 struct file_system_type afs_fs_type = {
     .owner = THIS_MODULE,
     .name = "afs",
@@ -83,16 +108,6 @@ struct file_system_type afs_fs_type = {
 };
 #endif
 
-/* afs_read_super
- * read the "super block" for AFS - roughly eguivalent to struct vfs.
- * dev, covered, s_rd_only, s_dirt, and s_type will be set by read_super.
- */
-#if defined(AFS_LINUX26_ENV)
-static struct super_block *
-afs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
-{
-    return get_sb_nodev(fs_type, flags, data, afs_fill_super);
-}
 
 int
 afs_fill_super(struct super_block *sb, void *data, int silent)
@@ -131,6 +146,9 @@ afs_read_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(AFS_LINUX26_ENV)
+    sb->s_export_op = &afs_export_ops;
+#endif
 #if defined(MAX_NON_LFS)
 #ifdef AFS_64BIT_CLIENT
 #if !defined(MAX_LFS_FILESIZE)
@@ -344,10 +362,8 @@ afs_put_inode(struct inode *ip)
     struct vcache *vcp = VTOAFS(ip);
 
     AFS_GLOCK();
-    if (VREFCOUNT(vcp) == 2) {
-       if (VREFCOUNT(vcp) == 2)
-           afs_InactiveVCache(vcp, NULL);
-    }
+    if (VREFCOUNT(vcp) == 2) 
+       afs_InactiveVCache(vcp, NULL);
     AFS_GUNLOCK();
 }
 
@@ -496,7 +512,9 @@ vattr2inode(struct inode *ip, struct vattr *vp)
     ip->i_ino = vp->va_nodeid;
     ip->i_nlink = vp->va_nlink;
     ip->i_blocks = vp->va_blocks;
+#ifdef STRUCT_INODE_HAS_I_BLKSIZE
     ip->i_blksize = vp->va_blocksize;
+#endif
     ip->i_rdev = vp->va_rdev;
     ip->i_mode = vp->va_mode;
     ip->i_uid = vp->va_uid;
@@ -505,6 +523,11 @@ vattr2inode(struct inode *ip, struct vattr *vp)
 #if defined(AFS_LINUX26_ENV)
     ip->i_atime.tv_sec = vp->va_atime.tv_sec;
     ip->i_mtime.tv_sec = vp->va_mtime.tv_sec;
+    /* Set the mtime nanoseconds to the sysname generation number.
+     * This convinces NFS clients that all directories have changed
+     * any time the sysname list changes.
+     */
+    ip->i_mtime.tv_nsec = afs_sysnamegen;
     ip->i_ctime.tv_sec = vp->va_ctime.tv_sec;
 #else
     ip->i_atime = vp->va_atime.tv_sec;
@@ -512,3 +535,27 @@ vattr2inode(struct inode *ip, struct vattr *vp)
     ip->i_ctime = vp->va_ctime.tv_sec;
 #endif
 }
+
+/* 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;
+       }
+    }
+}