linux-kmem-destroy-fix-20070609
[openafs.git] / src / afs / LINUX / osi_vfsops.c
index 762c309..64699d1 100644 (file)
@@ -60,11 +60,6 @@ int afs_fill_super(struct super_block *sb, void *data, int silent);
  * 2) Mount call comes to us via do_mount -> read_super -> afs_read_super.
  *    We are expected to setup the super_block. See afs_read_super.
  */
-#if defined(AFS_LINUX26_ENV)
-struct backing_dev_info afs_backing_dev_info = {
-       .ra_pages       = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE,
-       .state          = 0,
-};
 
 
 /* afs_read_super
@@ -72,11 +67,12 @@ struct backing_dev_info afs_backing_dev_info = {
  * 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
+int
 afs_get_sb(struct file_system_type *fs_type, int flags,
           const char *dev_name, void *data, struct vfsmount *mnt)
 #else
+static struct superblock *
 afs_get_sb(struct file_system_type *fs_type, int flags,
           const char *dev_name, void *data)
 #endif
@@ -108,6 +104,10 @@ struct file_system_type afs_fs_type = {
 };
 #endif
 
+#if defined(AFS_LINUX26_ENV)
+struct backing_dev_info afs_backing_dev_info = {
+    .ra_pages          = 0, /* disable readahead, afs does prefetch */
+};
 
 int
 afs_fill_super(struct super_block *sb, void *data, int silent)
@@ -276,7 +276,11 @@ afs_alloc_inode(struct super_block *sb)
 {
     struct vcache *vcp;
 
+#if defined(SLAB_KERNEL)
     vcp = (struct vcache *) kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL);
+#else
+    vcp = (struct vcache *) kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
+#endif
     if (!vcp)
        return NULL;
 
@@ -318,8 +322,8 @@ afs_init_inodecache(void)
 void
 afs_destroy_inodecache(void)
 {
-    if (kmem_cache_destroy(afs_inode_cachep))
-       printk(KERN_INFO "afs_inode_cache: not all structures were freed\n");
+    if (afs_inode_cachep)
+       (void) kmem_cache_destroy(afs_inode_cachep);
 }
 #else
 int
@@ -350,23 +354,6 @@ afs_clear_inode(struct inode *ip)
 #endif
 }
 
-/* afs_put_inode
- * Linux version of inactive.  When refcount == 2, we are about to
- * decrement to 1 and the only reference remaining should be for
- * the VLRU
- */
-
-static void
-afs_put_inode(struct inode *ip)
-{
-    struct vcache *vcp = VTOAFS(ip);
-
-    AFS_GLOCK();
-    if (VREFCOUNT(vcp) == 2) 
-       afs_InactiveVCache(vcp, NULL);
-    AFS_GUNLOCK();
-}
-
 /* afs_put_super
  * Called from unmount to release super_block. */
 static void
@@ -409,7 +396,11 @@ afs_put_super(struct super_block *sbp)
  */
 #if defined(AFS_LINUX26_ENV)
 int
+#if defined(STATFS_TAKES_DENTRY)
+afs_statfs(struct dentry *dentry, struct kstatfs *statp)
+#else
 afs_statfs(struct super_block *sbp, struct kstatfs *statp)
+#endif
 #elif defined(AFS_LINUX24_ENV)
 int
 afs_statfs(struct super_block *sbp, struct statfs *statp)
@@ -432,8 +423,13 @@ afs_statfs(struct super_block *sbp, struct statfs *__statp, int size)
 
     AFS_STATCNT(afs_statfs);
 
-    statp->f_type = 0;         /* Can we get a real type sometime? */
+    /* hardcode in case that which is giveth is taken away */
+    statp->f_type = 0x5346414F;
+#if defined(STATFS_TAKES_DENTRY)
+    statp->f_bsize = dentry->d_sb->s_blocksize;
+#else
     statp->f_bsize = sbp->s_blocksize;
+#endif
     statp->f_blocks = statp->f_bfree = statp->f_bavail = statp->f_files =
        statp->f_ffree = 9000000;
     statp->f_fsid.val[0] = AFS_VFSMAGIC;
@@ -452,7 +448,6 @@ struct super_operations afs_sops = {
   .destroy_inode =     afs_destroy_inode,
 #endif
   .clear_inode =       afs_clear_inode,
-  .put_inode =         afs_put_inode,
   .put_super =         afs_put_super,
   .statfs =            afs_statfs,
 #if !defined(AFS_LINUX24_ENV)
@@ -512,6 +507,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_BLKBITS
+    ip->i_blkbits = AFS_BLKBITS;
+#endif
 #ifdef STRUCT_INODE_HAS_I_BLKSIZE
     ip->i_blksize = vp->va_blocksize;
 #endif