From 0bff64be320fd95d80ae21b1362e1a2892bd450a Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Thu, 16 Nov 2017 23:06:24 -0800 Subject: [PATCH] LU-9771 flr: to not support dom+flr for phase 1 To exclude the support of dom+flr. Test-Parameters: testlist=sanity-flr Signed-off-by: Jinshan Xiong Change-Id: I3b2ff9bf5dd77f2703d8292226b164a9789134b1 Reviewed-on: https://review.whamcloud.com/29609 Reviewed-by: Jian Yu Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/tests/sanity-flr.sh | 22 +++++++++++++ lustre/utils/lfs.c | 81 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 84 insertions(+), 19 deletions(-) diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 146270c..c0454e71 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -663,6 +663,28 @@ test_5() { } run_test 5 "Make sure init size work for mirrored layout" +# LU=10112: disable dom+flr for phase 1 +test_6() { + local tf=$DIR/$tfile + + $LFS mirror create -N -E 1M -L mdt -E eof -N -E eof $tf && + error "expect failure to create mirrored file with DoM" + + $LFS mirror create -N -E 1M -E eof -N -E 1M -L mdt -E eof $tf && + error "expect failure to create mirrored file with DoM" + + $LFS setstripe -E 1M -L mdt -E eof $tf + $LFS mirror extend -N2 $tf && + error "expect failure to extend mirror with DoM" + + $LFS mirror create -N2 -E 1M -E eof $tf-2 + $LFS mirror extend -N -f $tf $tf-2 && + error "expect failure to extend mirrored file with DoM extent" + + true +} +run_test 6 "DoM and FLR won't co-exist for phase 1" + test_21() { local tf=$DIR/$tfile local tf2=$DIR/$tfile-2 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3cce36e..2136201 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -1004,6 +1004,44 @@ struct mirror_args { struct mirror_args *m_next; }; +static inline int mirror_sanity_check_one(struct llapi_layout *layout) +{ + uint64_t start, end; + uint64_t pattern; + int rc; + + /* LU-10112: do not support dom+flr in phase 1 */ + rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST); + if (rc) + return -errno; + + rc = llapi_layout_pattern_get(layout, &pattern); + if (rc) + return -errno; + + if (pattern == LOV_PATTERN_MDT || pattern == LLAPI_LAYOUT_MDT) { + fprintf(stderr, "error: %s: doesn't support dom+flr for now\n", + progname); + return -ENOTSUP; + } + + rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_LAST); + if (rc) + return -errno; + + rc = llapi_layout_comp_extent_get(layout, &start, &end); + if (rc) + return -errno; + + if (end != LUSTRE_EOF) { + fprintf(stderr, "error: %s: mirror layout doesn't reach eof\n", + progname); + return -EINVAL; + } + + return 0; +} + /** * enum mirror_flags - Flags for extending a mirrored file. * @NO_VERIFY: Indicates not to verify the mirror(s) from victim file(s) @@ -1025,7 +1063,8 @@ enum mirror_flags { * * Return: 0 on success or a negative error code on failure. */ -static int mirror_create_sanity_check(struct mirror_args *list) +static int mirror_create_sanity_check(const char *fname, + struct mirror_args *list) { int rc = 0; bool has_m_file = false; @@ -1034,9 +1073,25 @@ static int mirror_create_sanity_check(struct mirror_args *list) if (list == NULL) return -EINVAL; - while (list != NULL) { - uint64_t start, end; + if (fname) { + struct llapi_layout *layout; + + layout = llapi_layout_get_by_path(fname, 0); + if (!layout) { + fprintf(stderr, + "error: %s: file '%s' couldn't get layout\n", + progname, fname); + return -ENODATA; + } + + rc = mirror_sanity_check_one(layout); + llapi_layout_free(layout); + + if (rc) + return rc; + } + while (list != NULL) { if (list->m_file != NULL) { has_m_file = true; llapi_layout_free(list->m_layout); @@ -1059,21 +1114,9 @@ static int mirror_create_sanity_check(struct mirror_args *list) } } - rc = llapi_layout_comp_use(list->m_layout, - LLAPI_LAYOUT_COMP_USE_LAST); - if (rc) - return -errno; - - rc = llapi_layout_comp_extent_get(list->m_layout, &start, &end); + rc = mirror_sanity_check_one(list->m_layout); if (rc) - return -errno; - - if (end != LUSTRE_EOF) { - fprintf(stderr, - "error: %s: mirror layout doesn't reach eof\n", - progname); - return -EINVAL; - } + return rc; list = list->m_next; } @@ -1106,7 +1149,7 @@ static int mirror_create(char *fname, struct mirror_args *mirror_list) int i = 0; int rc = 0; - rc = mirror_create_sanity_check(mirror_list); + rc = mirror_create_sanity_check(NULL, mirror_list); if (rc) return rc; @@ -1295,7 +1338,7 @@ static int mirror_extend(char *fname, struct mirror_args *mirror_list, { int rc; - rc = mirror_create_sanity_check(mirror_list); + rc = mirror_create_sanity_check(fname, mirror_list); if (rc) return rc; -- 1.8.3.1