LINUX: old kernel warning fixes
[openafs.git] / src / afs / LINUX / osi_vfsops.c
index aa80111..5647897 100644 (file)
@@ -23,6 +23,7 @@
 #include "afs/afs_stats.h"
 #include <linux/smp_lock.h>
 
+#include "osi_compat.h"
 
 struct vcache *afs_globalVp = 0;
 struct vfs *afs_globalVFS = 0;
@@ -64,9 +65,9 @@ afs_get_sb(struct file_system_type *fs_type, int flags,
     return get_sb_nodev(fs_type, flags, data, afs_fill_super, mnt);
 }
 #else
-static struct superblock *
+static struct super_block *
 afs_get_sb(struct file_system_type *fs_type, int flags,
-          const char *dev_name, void *data)
+          const char *dev_name, void *data) {
     return get_sb_nodev(fs_type, flags, data, afs_fill_super);
 }
 #endif
@@ -79,9 +80,7 @@ struct file_system_type afs_fs_type = {
     .fs_flags = FS_BINARY_MOUNTDATA,
 };
 
-struct backing_dev_info afs_backing_dev_info = {
-    .ra_pages          = 32,
-};
+struct backing_dev_info *afs_backing_dev_info;
 
 int
 afs_fill_super(struct super_block *sb, void *data, int silent)
@@ -101,17 +100,24 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
    __module_get(THIS_MODULE);
 
     afs_globalVFS = sb;
+    sb->s_flags |= MS_NOATIME;
     sb->s_blocksize = 1024;
     sb->s_blocksize_bits = 10;
     sb->s_magic = AFS_VFSMAGIC;
     sb->s_op = &afs_sops;      /* Super block (vfs) ops */
-#if defined(HAVE_BDI_INIT)
-    bdi_init(&afs_backing_dev_info);
+    /* 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)
+    bdi_init(afs_backing_dev_info);
+#endif
+#if defined(STRUCT_BACKING_DEV_INFO_HAS_NAME)
+    afs_backing_dev_info->name = "openafs";
 #endif
+    afs_backing_dev_info->ra_pages = 32;
 #if defined (STRUCT_SUPER_BLOCK_HAS_S_BDI)
-    sb->s_bdi = &afs_backing_dev_info;
+    sb->s_bdi = afs_backing_dev_info;
     /* The name specified here will appear in the flushing thread name - flush-afs */
-    bdi_register(&afs_backing_dev_info, NULL, "afs");
+    bdi_register(afs_backing_dev_info, NULL, "afs");
 #endif
 #if !defined(AFS_NONFSTRANS)
     sb->s_export_op = &afs_export_ops;
@@ -133,6 +139,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();
         module_put(THIS_MODULE);
     }
 
@@ -145,9 +152,9 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
 static int
 afs_root(struct super_block *afsp)
 {
-    register afs_int32 code = 0;
+    afs_int32 code = 0;
     struct vrequest treq;
-    register struct vcache *tvp = 0;
+    struct vcache *tvp = 0;
 
     AFS_STATCNT(afs_root);
     if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
@@ -201,7 +208,6 @@ afs_notify_change(struct dentry *dp, struct iattr *iattrp)
     VATTR_NULL(&vattr);
     iattr2vattr(&vattr, iattrp);       /* Convert for AFS vnodeops call. */
 
-    lock_kernel();
     AFS_GLOCK();
     code = afs_setattr(VTOAFS(ip), &vattr, credp);
     if (!code) {
@@ -209,29 +215,20 @@ afs_notify_change(struct dentry *dp, struct iattr *iattrp)
        vattr2inode(ip, &vattr);
     }
     AFS_GUNLOCK();
-    unlock_kernel();
     crfree(credp);
     return -code;
 }
 
 
-#if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
-#if defined(HAVE_KMEM_CACHE_T)
-static kmem_cache_t *afs_inode_cachep;
-#else
-struct kmem_cache *afs_inode_cachep;
-#endif
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
+static afs_kmem_cache_t *afs_inode_cachep;
 
 static struct inode *
 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
+    vcp = (struct vcache *) kmem_cache_alloc(afs_inode_cachep, KALLOC_TYPE);
     if (!vcp)
        return NULL;
 
@@ -244,41 +241,25 @@ afs_destroy_inode(struct inode *inode)
     kmem_cache_free(afs_inode_cachep, inode);
 }
 
-static void
-#if defined(HAVE_KMEM_CACHE_T)
-init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
-#elif defined(KMEM_CACHE_INIT)
-init_once(struct kmem_cache * cachep, void * foo)
-#else
-init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
-#endif
+void
+init_once(void * foo)
 {
     struct vcache *vcp = (struct vcache *) foo;
 
-#if defined(SLAB_CTOR_VERIFY)
-    if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-       SLAB_CTOR_CONSTRUCTOR)
-#endif
-       inode_init_once(AFSTOV(vcp));
+    inode_init_once(AFSTOV(vcp));
 }
 
 int
 afs_init_inodecache(void)
 {
-#ifndef SLAB_RECLAIM_ACCOUNT
-#define SLAB_RECLAIM_ACCOUNT 0
-#endif
-
 #if defined(KMEM_CACHE_TAKES_DTOR)
     afs_inode_cachep = kmem_cache_create("afs_inode_cache",
-                                        sizeof(struct vcache),
-                                        0, SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT,
-                                        init_once, NULL);
+               sizeof(struct vcache), 0,
+               SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT, init_once_func, NULL);
 #else
     afs_inode_cachep = kmem_cache_create("afs_inode_cache",
-                                        sizeof(struct vcache),
-                                        0, SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT,
-                                        init_once);
+               sizeof(struct vcache), 0,
+               SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT, init_once_func);
 #endif
     if (afs_inode_cachep == NULL)
        return -ENOMEM;
@@ -305,6 +286,25 @@ afs_destroy_inodecache(void)
 }
 #endif
 
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_EVICT_INODE)
+static void
+afs_evict_inode(struct inode *ip)
+{
+    struct vcache *vcp = VTOAFS(ip);
+
+    if (vcp->vlruq.prev || vcp->vlruq.next)
+       osi_Panic("inode freed while on LRU");
+    if (vcp->hnext)
+       osi_Panic("inode freed while still hashed");
+
+    truncate_inode_pages(&ip->i_data, 0);
+    end_writeback(ip);
+
+#if !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
+    afs_osi_Free(ip->u.generic_ip, sizeof(struct vcache));
+#endif
+}
+#else
 static void
 afs_clear_inode(struct inode *ip)
 {
@@ -315,10 +315,11 @@ afs_clear_inode(struct inode *ip)
     if (vcp->hnext)
        osi_Panic("inode freed while still hashed");
 
-#if !defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+#if !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
     afs_osi_Free(ip->u.generic_ip, sizeof(struct vcache));
 #endif
 }
+#endif
 
 /* afs_put_super
  * Called from unmount to release super_block. */
@@ -336,9 +337,10 @@ afs_put_super(struct super_block *sbp)
     mntput(afs_cacheMnt);
 
     osi_linux_verify_alloced_memory();
-#if defined(HAVE_BDI_INIT)
-    bdi_destroy(&afs_backing_dev_info);
+#if defined(HAVE_LINUX_BDI_INIT)
+    bdi_destroy(afs_backing_dev_info);
 #endif
+    osi_Free(afs_backing_dev_info, sizeof(struct backing_dev_info));
     AFS_GUNLOCK();
 
     sbp->s_dev = 0;
@@ -378,11 +380,15 @@ afs_statfs(struct super_block *sbp, struct kstatfs *statp)
 }
 
 struct super_operations afs_sops = {
-#if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
   .alloc_inode =       afs_alloc_inode,
   .destroy_inode =     afs_destroy_inode,
 #endif
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_EVICT_INODE)
+  .evict_inode =       afs_evict_inode,
+#else
   .clear_inode =       afs_clear_inode,
+#endif
   .put_super =         afs_put_super,
   .statfs =            afs_statfs,
 };