From: Di Wang Date: Mon, 9 Jan 2017 15:17:09 +0000 (-0500) Subject: LU-8994 lmv: honour the specified stripe index X-Git-Tag: 2.9.52~30 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F24777%2F3;p=fs%2Flustre-release.git LU-8994 lmv: honour the specified stripe index when creating the striped directory, specified stripe index should always be used even the parent has default stripe index. Signed-off-by: Di Wang Change-Id: Ief00af3790282a0887b9d28c581ccf0070cc758f Reviewed-on: https://review.whamcloud.com/24777 Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Tested-by: Jenkins Reviewed-by: Lai Siyao Tested-by: Maloo --- diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index f6104e3..b171f3e 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -466,7 +466,7 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, if (unlikely(lump->lum_magic != LMV_USER_MAGIC)) RETURN(-EINVAL); - CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p) name %s" + CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p) name %s " "stripe_offset %d, stripe_count: %u\n", PFID(ll_inode2fid(parent)), parent, dirname, (int)lump->lum_stripe_offset, lump->lum_stripe_count); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 344af429..f9ae025 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1166,7 +1166,9 @@ hsm_req_err: static int lmv_placement_policy(struct obd_device *obd, struct md_op_data *op_data, u32 *mds) { - struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_user_md *lum; + ENTRY; LASSERT(mds != NULL); @@ -1176,31 +1178,22 @@ static int lmv_placement_policy(struct obd_device *obd, RETURN(0); } - if (op_data->op_default_stripe_offset != -1) { + lum = op_data->op_data; + /* Choose MDS by + * 1. See if the stripe offset is specified by lum. + * 2. Then check if there is default stripe offset. + * 3. Finally choose MDS by name hash if the parent + * is striped directory. (see lmv_locate_mds()). */ + if (op_data->op_cli_flags & CLI_SET_MEA && lum != NULL && + le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) { + *mds = le32_to_cpu(lum->lum_stripe_offset); + } else if (op_data->op_default_stripe_offset != (__u32)-1) { *mds = op_data->op_default_stripe_offset; - RETURN(0); - } - - /** - * If stripe_offset is provided during setdirstripe - * (setdirstripe -i xx), xx MDS will be choosen. - */ - if (op_data->op_cli_flags & CLI_SET_MEA && op_data->op_data != NULL) { - struct lmv_user_md *lum; - - lum = op_data->op_data; - - if (le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) { - *mds = le32_to_cpu(lum->lum_stripe_offset); - } else { - /* -1 means default, which will be in the same MDT with - * the stripe */ - *mds = op_data->op_mds; - lum->lum_stripe_offset = cpu_to_le32(op_data->op_mds); - } + op_data->op_mds = *mds; + /* Correct the stripe offset in lum */ + if (lum != NULL) + lum->lum_stripe_offset = cpu_to_le32(*mds); } else { - /* Allocate new fid on target according to operation type and - * parent home mds. */ *mds = op_data->op_mds; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index c736941..ae98d6a 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14850,6 +14850,24 @@ test_300g() { mkdir $DIR/$tdir mkdir $DIR/$tdir/normal_dir + #Checking when client cache stripe index + $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir + $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir || + error "create striped_dir failed" + + mkdir $DIR/$tdir/striped_dir/dir1 || + error "create dir1 fails" + stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1) + [ $stripe_index -eq 1 ] || + error "dir1 expect 1 got $stripe_index" + + $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 || + error "create dir2 fails" + stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2) + [ $stripe_index -eq 2 ] || + error "dir2 expect 2 got $stripe_index" + + #check default stripe count/stripe index test_300_check_default_striped_dir normal_dir $MDSCOUNT 1 test_300_check_default_striped_dir normal_dir 1 0 test_300_check_default_striped_dir normal_dir 2 1