Whamcloud - gitweb
LU-2904 llite: use 32bitapi for re-export Lustre via NFS
authorFan Yong <yong.fan@whamcloud.com>
Tue, 19 Feb 2013 12:45:15 +0000 (20:45 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 Apr 2013 15:28:40 +0000 (11:28 -0400)
Since Lustre-2.4, non-IGIF FID for root object will be
returned to client. For 64bit client, it converts such
root FID into a local ino#, which is larger than 2^32.

For the case of re-exporting Lustre via NFS, it works
only when the ino# less than 2^32, which is NFS defect.
So if without proper handling, it cannot re-export the
Lustre root via NFS. Similar issue exists all along on
old version for re-exporting non-root via NFS.

Current solution is that the user who want to re-export
Lustre (in spite of root or not) via NFS needs to mount
the Lustre client with the options "-o 32bitapi". Then
the client will convert 128-bits FID into 32-bits ino#.

This patch handles the options "32bitapi" for the FID
to ino# conversion. And some code cleanup.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I367ebe07d9bd645b312f37d78dfaa10f9f4b8200
Reviewed-on: http://review.whamcloud.com/5711
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/fld/fld_handler.c
lustre/fld/fld_index.c
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/osd-ldiskfs/osd_scrub.c
lustre/osd-zfs/osd_oi.c

index 7fe5d7e..dbab93b 100644 (file)
@@ -385,7 +385,6 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
                    __u32 lsr_flags)
 {
         int cache_size, cache_threshold;
-        struct lu_seq_range range;
         int rc;
         ENTRY;
 
@@ -420,16 +419,8 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
 
         fld->lsf_control_exp = NULL;
 
-       if (lsr_flags == LU_SEQ_RANGE_MDT) {
-               /* Insert reserved sequence of "ROOT" and ".lustre"
-                * into fld cache. */
-               range.lsr_start = FID_SEQ_LOCAL_FILE;
-               range.lsr_end = FID_SEQ_DOT_LUSTRE + 1;
-               range.lsr_index = 0;
-               range.lsr_flags = lsr_flags;
-               fld_cache_insert(fld->lsf_cache, &range);
-       }
-        EXIT;
+       GOTO(out, rc);
+
 out:
        if (rc)
                fld_server_fini(env, fld);
index a6f9be5..577d388 100644 (file)
@@ -71,6 +71,13 @@ static const struct lu_seq_range IGIF_FLD_RANGE = {
        .lsr_flags = LU_SEQ_RANGE_MDT
 };
 
+static const struct lu_seq_range DOT_LUSTRE_FLD_RANGE = {
+       .lsr_start = FID_SEQ_DOT_LUSTRE,
+       .lsr_end   = FID_SEQ_DOT_LUSTRE + 1,
+       .lsr_index = 0,
+       .lsr_flags = LU_SEQ_RANGE_MDT
+};
+
 static const struct lu_seq_range ROOT_FLD_RANGE = {
        .lsr_start = FID_SEQ_ROOT,
        .lsr_end   = FID_SEQ_ROOT + 1,
@@ -304,6 +311,10 @@ static int fld_insert_special_entries(const struct lu_env *env,
        if (rc != 0)
                RETURN(rc);
 
+       rc = fld_insert_entry(env, fld, &DOT_LUSTRE_FLD_RANGE);
+       if (rc != 0)
+               RETURN(rc);
+
        rc = fld_insert_entry(env, fld, &ROOT_FLD_RANGE);
 
        RETURN(rc);
index 0f09dc8..81916ce 100644 (file)
@@ -528,7 +528,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
        }
 
         LASSERT(fid_is_sane(&sbi->ll_root_fid));
-        root = ll_iget(sb, cl_fid_build_ino(&sbi->ll_root_fid, 0), &lmd);
+       root = ll_iget(sb, cl_fid_build_ino(&sbi->ll_root_fid,
+                                           ll_need_32bit_api(sbi)),
+                      &lmd);
         md_free_lustre_md(sbi->ll_md_exp, &lmd);
         ptlrpc_req_finished(request);
 
@@ -1735,7 +1737,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                spin_unlock(&lli->lli_lock);
        }
 #endif
-        inode->i_ino = cl_fid_build_ino(&body->fid1, 0);
+       inode->i_ino = cl_fid_build_ino(&body->fid1, ll_need_32bit_api(sbi));
         inode->i_generation = cl_fid_build_gen(&body->fid1);
 
         if (body->valid & OBD_MD_FLATIME) {
@@ -2163,7 +2165,9 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
                  */
                 LASSERT(fid_is_sane(&md.body->fid1));
 
-                *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1, 0), &md);
+               *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1,
+                                                     ll_need_32bit_api(sbi)),
+                                &md);
                 if (*inode == NULL || IS_ERR(*inode)) {
 #ifdef CONFIG_FS_POSIX_ACL
                         if (md.posix_acl) {
index f231fb2..fd1c17a 100644 (file)
@@ -73,7 +73,8 @@ struct inode *search_inode_for_lustre(struct super_block *sb,
         struct ptlrpc_request *req = NULL;
         struct inode          *inode = NULL;
         int                   eadatalen = 0;
-        unsigned long         hash = (unsigned long) cl_fid_build_ino(fid, 0);
+       unsigned long         hash = cl_fid_build_ino(fid,
+                                                     ll_need_32bit_api(sbi));
         struct  md_op_data    *op_data;
         int                   rc;
         ENTRY;
index 75b0b8a..2661d97 100644 (file)
@@ -1093,7 +1093,7 @@ static const struct osd_lf_map osd_lf_maps[] = {
        { "PENDING", { FID_SEQ_LOCAL_FILE, MDD_ORPHAN_OID, 0 }, 0, NULL, NULL },
 
        /* ROOT */
-       { "ROOT", { FID_SEQ_LOCAL_FILE, MDD_ROOT_INDEX_OID, 0 },
+       { "ROOT", { FID_SEQ_ROOT, 1, 0 },
                OLF_SCAN_SUBITEMS | OLF_HIDE_FID, osd_ios_ROOT_scan, NULL },
 
        /* capa_keys */
index 9cb4f1f..8b780fc 100644 (file)
@@ -102,7 +102,6 @@ static const struct named_oid oids[] = {
        { OFD_HEALTH_CHECK_OID,         HEALTH_CHECK },
        { ACCT_USER_OID,                "acct_usr_inode" },
        { ACCT_GROUP_OID,               "acct_grp_inode" },
-       { MDD_ROOT_INDEX_OID,           NULL },
        { MDD_ORPHAN_OID,               NULL },
        { 0,                            NULL }
 };