Whamcloud - gitweb
LU-2904 llite: return compatible fsid for statfs 35/7435/2
authorFan Yong <fan.yong@intel.com>
Mon, 15 Jul 2013 17:02:04 +0000 (01:02 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 31 Aug 2013 18:33:07 +0000 (18:33 +0000)
Lustre uses 64-bits inode number to identify object on client side.
When re-export Lustre via NFS, NFS will detect whether support fsid
via statfs(). For the non-support case, it will only recognizes and
packs low 32-bits inode number in nfs handle. Such handle cannot be
used to locate the object properly.
To avoid patch linux kernel, Lustre client should generate fsid and
return it via statfs() to up layer.

To be compatible with old Lustre client (NFS server), the fsid will
be generated from super_block::s_dev.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Id30ff2b2aa5c67c52b09765f50b2afa70cb6d1e3
Reviewed-on: http://review.whamcloud.com/7435
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Reviewed-by: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c

index 2e4d260..6f867d5 100644 (file)
@@ -512,7 +512,6 @@ struct ll_sb_info {
                                                  * clustred nfs */
         struct rmtacl_ctl_table   ll_rct;
         struct eacl_table         ll_et;
-       __kernel_fsid_t           ll_fsid;
 };
 
 #define LL_DEFAULT_MAX_RW_CHUNK      (32 * 1024 * 1024)
@@ -877,7 +876,6 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
 /* llite/llite_nfs.c */
 extern struct export_operations lustre_export_operations;
 __u32 get_uuid2int(const char *name, int len);
-void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid);
 struct inode *search_inode_for_lustre(struct super_block *sb,
                                      const struct lu_fid *fid);
 
index 24363a6..b2332fc 100644 (file)
@@ -595,10 +595,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         /* s_dev is also used in lt_compare() to compare two fs, but that is
          * only a node-local comparison. */
         uuid = obd_get_uuid(sbi->ll_md_exp);
-       if (uuid != NULL) {
+       if (uuid != NULL)
                sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid));
-               get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid);
-       }
 
         if (data != NULL)
                 OBD_FREE_PTR(data);
@@ -1652,6 +1650,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
 {
        struct super_block *sb = de->d_sb;
        struct obd_statfs osfs;
+       __u64 fsid = huge_encode_dev(sb->s_dev);
        int rc;
 
         CDEBUG(D_VFSTRACE, "VFS Op: at "LPU64" jiffies\n", get_jiffies_64());
@@ -1683,7 +1682,8 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
         sfs->f_blocks = osfs.os_blocks;
         sfs->f_bfree = osfs.os_bfree;
         sfs->f_bavail = osfs.os_bavail;
-       sfs->f_fsid = ll_s2sbi(sb)->ll_fsid;
+       sfs->f_fsid.val[0] = (__u32)fsid;
+       sfs->f_fsid.val[1] = (__u32)(fsid >> 32);
        return 0;
 }
 
index fe1a90c..f840e23 100644 (file)
@@ -60,22 +60,6 @@ __u32 get_uuid2int(const char *name, int len)
         return (key0 << 1);
 }
 
-void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid)
-{
-       __u64 key = 0, key0 = 0x12a3fe2d, key1 = 0x37abe8f9;
-
-       while (len--) {
-               key = key1 + (key0 ^ (*name++ * 7152373));
-               if (key & 0x8000000000000000ULL)
-                       key -= 0x7fffffffffffffffULL;
-               key1 = key0;
-               key0 = key;
-       }
-
-       fsid->val[0] = key;
-       fsid->val[1] = key >> 32;
-}
-
 static int ll_nfs_test_inode(struct inode *inode, void *opaque)
 {
         return lu_fid_eq(&ll_i2info(inode)->lli_fid,