From 063892770e343916343ab0a4ee21601b8b23922e Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Tue, 19 Feb 2013 20:45:15 +0800 Subject: [PATCH] LU-2904 llite: use 32bitapi for re-export Lustre via NFS 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 Change-Id: I367ebe07d9bd645b312f37d78dfaa10f9f4b8200 Reviewed-on: http://review.whamcloud.com/5711 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/fld/fld_handler.c | 13 ++----------- lustre/fld/fld_index.c | 11 +++++++++++ lustre/llite/llite_lib.c | 10 +++++++--- lustre/llite/llite_nfs.c | 3 ++- lustre/osd-ldiskfs/osd_scrub.c | 2 +- lustre/osd-zfs/osd_oi.c | 1 - 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 7fe5d7e..dbab93b 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -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); diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index a6f9be5..577d388 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -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); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 0f09dc8..81916ce 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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) { diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index f231fb2..fd1c17a 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -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; diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 75b0b8a..2661d97 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -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 */ diff --git a/lustre/osd-zfs/osd_oi.c b/lustre/osd-zfs/osd_oi.c index 9cb4f1f..8b780fc 100644 --- a/lustre/osd-zfs/osd_oi.c +++ b/lustre/osd-zfs/osd_oi.c @@ -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 } }; -- 1.8.3.1