Whamcloud - gitweb
LU-8994 lmv: honour the specified stripe index 77/24777/3
authorDi Wang <di.wang@intel.com>
Mon, 9 Jan 2017 15:17:09 +0000 (10:17 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 24 Jan 2017 05:20:11 +0000 (05:20 +0000)
when creating the striped directory, specified
stripe index should always be used even the parent
has default stripe index.

Signed-off-by: Di Wang <di.wang@intel.com>
Change-Id: Ief00af3790282a0887b9d28c581ccf0070cc758f
Reviewed-on: https://review.whamcloud.com/24777
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/llite/dir.c
lustre/lmv/lmv_obd.c
lustre/tests/sanity.sh

index f6104e3..b171f3e 100644 (file)
@@ -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);
index 344af42..f9ae025 100644 (file)
@@ -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;
        }
 
index c736941..ae98d6a 100755 (executable)
@@ -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