Whamcloud - gitweb
LU-13918 lfs: let lfs mirror extend to use prefer flag 98/39698/5
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 20 Aug 2020 09:45:21 +0000 (12:45 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 12 Sep 2020 15:45:42 +0000 (15:45 +0000)
so that lfs mirror extend -N --flags=prefer create new
mirror with prefer flag set and new IO go to the just
created mirror.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I2eb771fce3c14491eb193b053f3e97cc689b29c3
Reviewed-on: https://review.whamcloud.com/39698
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/sanity-flr.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi_layout.c

index 08d2596..858c2ce 100644 (file)
@@ -2906,6 +2906,24 @@ test_204f() {
 }
 run_test 204f "FLR write/stale/resync sel w/forced extension"
 
+function test_205() {
+       local tf=$DIR/$tfile
+       local mirrors
+
+       $LFS setstripe -c1 $tf
+       $LFS mirror extend -N $tf
+       mirrors=$($LFS getstripe $tf | grep lcme_mirror_id | wc -l )
+       (( $mirrors == 2 )) || error "no new mirror was created?"
+
+       $LFS mirror extend -N --flags=prefer $tf
+       mirrors=$($LFS getstripe $tf | grep lcme_mirror_id | wc -l )
+       (( $mirrors == 3 )) || error "no new mirror was created?"
+
+       $($LFS getstripe $tf | grep lcme_flags: | tail -1 | grep -q prefer) ||
+               error "prefer flag was not set on the new mirror"
+}
+run_test 205 "lfs mirror extend to set prefer flag"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status
index f3bbf0e..5f3555f 100644 (file)
@@ -1766,7 +1766,7 @@ out:
 }
 
 static int mirror_extend_layout(char *name, struct llapi_layout *m_layout,
-                               bool inherit)
+                               bool inherit, uint32_t flags)
 {
        struct llapi_layout *f_layout = NULL;
        struct ll_ioc_lease *data = NULL;
@@ -1794,6 +1794,7 @@ static int mirror_extend_layout(char *name, struct llapi_layout *m_layout,
                        goto out;
                }
        }
+       llapi_layout_comp_flags_set(m_layout, flags);
        rc = migrate_open_files(name, 0, NULL, m_layout, &fd, &fdv);
        if (rc < 0)
                goto out;
@@ -1863,7 +1864,8 @@ static int mirror_extend(char *fname, struct mirror_args *mirror_list,
                        while (mirror_count > 0) {
                                rc = mirror_extend_layout(fname,
                                                        mirror_list->m_layout,
-                                                       mirror_list->m_inherit);
+                                                       mirror_list->m_inherit,
+                                                       mirror_list->m_flags);
                                if (rc)
                                        break;
 
index 87ed8c8..3f85197 100644 (file)
@@ -3179,7 +3179,8 @@ static int llapi_layout_sanity_cb(struct llapi_layout *layout,
                        if (comp->llc_flags & ~LCME_USER_COMP_FLAGS)
                                args->lsa_rc = LSE_FLAGS;
                } else {
-                       if (comp->llc_flags & ~LCME_FL_EXTENSION)
+                       if (comp->llc_flags &
+                           ~(LCME_FL_EXTENSION | LCME_FL_PREF_RW))
                                args->lsa_rc = LSE_FLAGS;
                }
        }