From cc8fb042b7aa6f4147900b739d3b8b891d1677c7 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 20 Aug 2020 12:45:21 +0300 Subject: [PATCH] LU-13918 lfs: let lfs mirror extend to use prefer flag 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 Change-Id: I2eb771fce3c14491eb193b053f3e97cc689b29c3 Reviewed-on: https://review.whamcloud.com/39698 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: Gu Zheng Reviewed-by: Yingjin Qian Tested-by: Maloo --- lustre/tests/sanity-flr.sh | 18 ++++++++++++++++++ lustre/utils/lfs.c | 6 ++++-- lustre/utils/liblustreapi_layout.c | 3 ++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 08d2596..858c2ce 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -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 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index f3bbf0e..5f3555f 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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; diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index 87ed8c8..3f85197 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -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; } } -- 1.8.3.1