Whamcloud - gitweb
LU-11739 lod: subdir under ROOT should honor default layout 04/35204/7
authorLai Siyao <lai.siyao@whamcloud.com>
Mon, 30 Sep 2019 17:14:51 +0000 (10:14 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Oct 2019 03:37:48 +0000 (03:37 +0000)
Though sub directories under ROOT don't inherit ROOT default
layout, they should hornor ROOT default layout in creation.

Add sub test in sanity.sh 65n to verify this.

Fixes: 0a988cae95 ("LU-11739 lod: don't inherit default
                    layout from root directory")

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I1edf91da7944a8871652df7bca2104d00f66163a
Reviewed-on: https://review.whamcloud.com/35204
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/lod/lod_object.c
lustre/tests/sanity.sh

index db457a4..f26198d 100644 (file)
@@ -5244,12 +5244,15 @@ static void lod_ah_init(const struct lu_env *env,
                 * If parent object is not root directory,
                 * then get default striping from parent object.
                 */
-               if (likely(lp != NULL) && !fid_is_root(lod_object_fid(lp)))
+               if (likely(lp != NULL)) {
                        lod_get_default_striping(env, lp, lds);
 
-               /* set child default striping info, default value is NULL */
-               if (lds->lds_def_striping_set || lds->lds_dir_def_striping_set)
-                       lc->ldo_def_striping = lds;
+                       /* inherit default striping except ROOT */
+                       if ((lds->lds_def_striping_set ||
+                            lds->lds_dir_def_striping_set) &&
+                           !fid_is_root(lod_object_fid(lp)))
+                               lc->ldo_def_striping = lds;
+               }
 
                /* It should always honour the specified stripes */
                /* Note: old client (< 2.7)might also do lfs mkdir, whose EA
index 644563f..c409edb 100644 (file)
@@ -7841,6 +7841,29 @@ test_65n() {
        local dir5_layout=$(get_layout_param $dir5)
        [[ "$dir4_layout" = "$dir5_layout" ]] ||
                error "$dir5 should inherit the default layout from $dir4"
+
+       # though subdir under ROOT doesn't inherit default layout, but
+       # its sub dir/file should be created with default layout.
+       [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
+       [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
+               skip "Need MDS version at least 2.12.59"
+
+       local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
+       local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
+       local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
+
+       if [ $default_lmv_hash == "none" ]; then
+               stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
+       else
+               stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
+                       -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
+       fi
+
+       $LFS setdirstripe -D -c 2 $MOUNT ||
+               error "setdirstripe -D -c 2 failed"
+       mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
+       local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
+       [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
 }
 run_test 65n "don't inherit default layout from root for new subdirectories"