Whamcloud - gitweb
LU-9771 flr: inherit mirror options from directory 76/29576/16
authorJinshan Xiong <jinshan.xiong@intel.com>
Sat, 14 Oct 2017 07:55:23 +0000 (00:55 -0700)
committerJinshan Xiong <jinshan.xiong@intel.com>
Sun, 26 Nov 2017 00:24:25 +0000 (00:24 +0000)
This patch checks and verifies directory inheritance from parent
works both for regular files and directories.

Test-Parameters: testlist=sanity-flr
Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: Ief58805ca736acb9a53fd9ad8fb2bb460d46b748
Reviewed-on: https://review.whamcloud.com/29576
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/include/lustre/lustreapi.h
lustre/lod/lod_object.c
lustre/tests/sanity-flr.sh
lustre/utils/liblustreapi.c

index f711ac0..ab87e15 100644 (file)
@@ -450,7 +450,21 @@ int llapi_ladvise(int fd, unsigned long long flags, int num_advise,
 
 /* llapi_layout user interface */
 
-extern char *lcm_flags_string(__u16 flags);
+static inline const char *lcm_flags_string(__u16 flags)
+{
+       switch (flags & LCM_FL_FLR_MASK) {
+       case LCM_FL_NOT_FLR:
+               return "not_flr";
+       case LCM_FL_RDONLY:
+               return "ro";
+       case LCM_FL_WRITE_PENDING:
+               return "wp";
+       case LCM_FL_SYNC_PENDING:
+               return "sp";
+       default:
+               return "";
+       }
+}
 
 /**
  * An array element storing component info to be resynced during mirror
index 8d1622b..d9a09ae 100644 (file)
@@ -3987,6 +3987,8 @@ static void lod_striping_from_default(struct lod_object *lo,
                        return;
 
                lo->ldo_is_composite = lds->lds_def_striping_is_composite;
+               if (lds->lds_def_mirror_cnt > 1)
+                       lo->ldo_flr_state = LCM_FL_RDONLY;
 
                for (i = 0; i < lo->ldo_comp_cnt; i++) {
                        struct lod_layout_component *obj_comp =
index b2e6ae8..56eb391 100644 (file)
@@ -617,6 +617,38 @@ test_3() {
 }
 run_test 3 "create components from files located on different MDTs"
 
+test_4() {
+       local tf=$DIR/$tdir/$tfile
+       local ids=()
+
+       test_mkdir $DIR/$tdir
+
+       # set mirror with setstripe options to directory
+       $LFS mirror create -N2 -E 1M -E eof $DIR/$tdir ||
+               error "set mirror to directory error"
+
+       [ x$($LFS getstripe -v $DIR/$tdir | awk '/lcm_flags/{print $2}') = \
+               x"mirrored" ] || error "failed to create mirrored dir"
+
+       touch $tf
+       verify_mirror_count $tf 2
+
+       ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+       verify_comp_extent $tf ${ids[0]} 0 1048576
+       verify_comp_extent $tf ${ids[1]} 1048576 EOF
+
+       # sub directory should inherit mirror setting from parent
+       test_mkdir $DIR/$tdir/td
+       [ x$($LFS getstripe -v $DIR/$tdir/td | awk '/lcm_flags/{print $2}') = \
+               x"mirrored" ] || error "failed to inherit mirror from parent"
+
+       # mirror extend won't be applied to directory
+       $LFS mirror extend -N2 $DIR/$tdir &&
+               error "expecting mirror extend failure"
+       true
+}
+run_test 4 "Make sure mirror attributes can be inhertied from directory"
+
 test_21() {
        local tf=$DIR/$tfile
        local tf2=$DIR/$tfile-2
index ecac4c3..dde4ed1 100644 (file)
@@ -2593,22 +2593,6 @@ void lmv_dump_user_lmm(struct lmv_user_md *lum, char *pool_name,
                llapi_printf(LLAPI_MSG_NORMAL, "\n");
 }
 
-char *lcm_flags_string(__u16 flags)
-{
-       switch (flags & LCM_FL_FLR_MASK) {
-       case LCM_FL_NOT_FLR:
-               return "not_flr";
-       case LCM_FL_RDONLY:
-               return "ro";
-       case LCM_FL_WRITE_PENDING:
-               return "wp";
-       case LCM_FL_SYNC_PENDING:
-               return "sp";
-       default:
-               return "";
-       }
-}
-
 static void lov_dump_comp_v1_header(struct find_param *param, char *path,
                                    enum lov_dump_flags flags)
 {
@@ -2627,8 +2611,15 @@ static void lov_dump_comp_v1_header(struct find_param *param, char *path,
                             " ", comp_v1->lcm_magic);
                llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_size:          %u\n",
                             " ", comp_v1->lcm_size);
-               llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_flags:         %s\n",
-                            " ", lcm_flags_string(comp_v1->lcm_flags));
+               if (flags & LDF_IS_DIR)
+                       llapi_printf(LLAPI_MSG_NORMAL,
+                                    "%2slcm_flags:         %s\n", " ",
+                                    comp_v1->lcm_mirror_count > 0 ?
+                                                       "mirrored" : "");
+               else
+                       llapi_printf(LLAPI_MSG_NORMAL,
+                                    "%2slcm_flags:         %s\n",
+                                    " ", lcm_flags_string(comp_v1->lcm_flags));
        }
 
        if (verbose & VERBOSE_GENERATION) {