LINUX: Minor osi_vfsop.c cleanup
[openafs.git] / src / afs / LINUX / osi_vfsops.c
index cad4555..0adfc38 100644 (file)
@@ -40,7 +40,7 @@ extern struct dentry_operations afs_dentry_operations;
 
 /* Forward declarations */
 static int afs_root(struct super_block *afsp);
-int afs_fill_super(struct super_block *sb, void *data, int silent);
+static int afs_fill_super(struct super_block *sb, void *data, int silent);
 
 
 /*
@@ -52,19 +52,22 @@ int afs_fill_super(struct super_block *sb, void *data, int silent);
 #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) {
+         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) {
+          const char *dev_name, void *data, struct vfsmount *mnt)
+{
     return get_sb_nodev(fs_type, flags, data, afs_fill_super, mnt);
 }
 #else
 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
@@ -83,7 +86,7 @@ struct file_system_type afs_fs_type = {
 
 struct backing_dev_info *afs_backing_dev_info;
 
-int
+static int
 afs_fill_super(struct super_block *sb, void *data, int silent)
 {
     int code = 0;
@@ -104,7 +107,11 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
    __module_get(THIS_MODULE);
 
     afs_globalVFS = sb;
+#if defined(SB_NOATIME)
+    sb->s_flags |= SB_NOATIME;
+#else
     sb->s_flags |= MS_NOATIME;
+#endif
     sb->s_blocksize = 1024;
     sb->s_blocksize_bits = 10;
     sb->s_magic = AFS_VFSMAGIC;
@@ -113,7 +120,13 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
 #if defined(STRUCT_SUPER_BLOCK_HAS_S_D_OP)
     sb->s_d_op = &afs_dentry_operations;
 #endif
-
+#if defined(HAVE_LINUX_SUPER_SETUP_BDI)
+    code = super_setup_bdi(sb);
+    if (code)
+        goto out;
+    sb->s_bdi->name = "openafs";
+    sb->s_bdi->ra_pages = 32;
+#else
     /* used for inodes backing_dev_info field, also */
     afs_backing_dev_info = kzalloc(sizeof(struct backing_dev_info), GFP_NOFS);
 #if defined(HAVE_LINUX_BDI_INIT)
@@ -131,6 +144,7 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
     /* The name specified here will appear in the flushing thread name - flush-afs */
     bdi_register(afs_backing_dev_info, NULL, "afs");
 #endif
+#endif /* HAVE_LINUX_SUPER_SETUP_BDI */
 #if !defined(AFS_NONFSTRANS)
     sb->s_export_op = &afs_export_ops;
 #endif
@@ -157,7 +171,9 @@ out:
        if (bdi_init_done)
            bdi_destroy(afs_backing_dev_info);
 #endif
+#if !defined(HAVE_LINUX_SUPER_SETUP_BDI)
        kfree(afs_backing_dev_info);
+#endif
         module_put(THIS_MODULE);
     }
 
@@ -171,13 +187,13 @@ static int
 afs_root(struct super_block *afsp)
 {
     afs_int32 code = 0;
-    struct vrequest treq;
     struct vcache *tvp = 0;
 
     AFS_STATCNT(afs_root);
     if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
        tvp = afs_globalVp;
     } else {
+       struct vrequest *treq = NULL;
        cred_t *credp = crref();
 
        if (afs_globalVp) {
@@ -185,29 +201,34 @@ afs_root(struct super_block *afsp)
            afs_globalVp = NULL;
        }
 
-       if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) {
-           tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+       if (!(code = afs_CreateReq(&treq, credp)) && !(code = afs_CheckInit())) {
+           tvp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
            if (tvp) {
                struct inode *ip = AFSTOV(tvp);
-               struct vattr vattr;
+               struct vattr *vattr = NULL;
 
-               afs_getattr(tvp, &vattr, credp);
-               afs_fill_inode(ip, &vattr);
+               code = afs_CreateAttr(&vattr);
+               if (!code) {
+                   afs_getattr(tvp, vattr, credp);
+                   afs_fill_inode(ip, vattr);
 
-               /* setup super_block and mount point inode. */
-               afs_globalVp = tvp;
+                   /* setup super_block and mount point inode. */
+                   afs_globalVp = tvp;
 #if defined(HAVE_LINUX_D_MAKE_ROOT)
-               afsp->s_root = d_make_root(ip);
+                   afsp->s_root = d_make_root(ip);
 #else
-               afsp->s_root = d_alloc_root(ip);
+                   afsp->s_root = d_alloc_root(ip);
 #endif
 #if !defined(STRUCT_SUPER_BLOCK_HAS_S_D_OP)
-               afsp->s_root->d_op = &afs_dentry_operations;
+                   afsp->s_root->d_op = &afs_dentry_operations;
 #endif
+                   afs_DestroyAttr(vattr);
+               }
            } else
-               code = ENOENT;
+               code = EIO;
        }
        crfree(credp);
+       afs_DestroyReq(treq);
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, afs_globalVp,
@@ -352,7 +373,7 @@ afs_put_super(struct super_block *sbp)
  * statp is in user space, so we need to cobble together a statfs, then
  * copy it.
  */
-int
+static int
 #if defined(STATFS_TAKES_DENTRY)
 afs_statfs(struct dentry *dentry, struct kstatfs *statp)
 #else