From 4ce8a29d8bfc5b77893b642cdf2c33ceed960866 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Fri, 17 Jan 2020 22:15:25 +0900 Subject: [PATCH] LU-13142 lod: cleanup layout checking Cleanup layout checking in lod layer and lfs command-line utility, for DoM components. Reported-by: Clement Barthelemy Signed-off-by: Sebastien Buisson Change-Id: Ib8b184a31d26442ed10241dc12a0452e5243d0e8 Reviewed-on: https://review.whamcloud.com/37267 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/lod/lod_lov.c | 18 ++++++++++++++++++ lustre/lod/lod_qos.c | 11 ++++++++--- lustre/utils/lfs.c | 12 ++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index e449db6..48fa030d 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -1913,6 +1913,24 @@ recheck: RETURN(rc); } } + /* Any stripe count is forbidden on DoM component */ + if (lum->lmm_stripe_count) { + CDEBUG(D_LAYOUT, + "invalid DoM layout stripe count %u, must be 0\n", + le16_to_cpu(lum->lmm_stripe_count)); + RETURN(-EINVAL); + } + + /* Any pool is forbidden on DoM component */ + if (lum->lmm_magic == LOV_USER_MAGIC_V3) { + struct lov_user_md_v3 *v3 = (void *)lum; + + if (v3->lmm_pool_name[0] != '\0') { + CDEBUG(D_LAYOUT, + "DoM component cannot have pool assigned\n"); + RETURN(-EINVAL); + } + } } prev_end = le64_to_cpu(ext->e_end); diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 149b06f..30f1ca0 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -2188,12 +2188,17 @@ int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo, lov_pattern(v1->lmm_pattern) == LOV_PATTERN_MDT) lod_comp->llc_stripe_count = v1->lmm_stripe_count; + if (lov_pattern(lod_comp->llc_pattern) == LOV_PATTERN_MDT && + lod_comp->llc_stripe_count != 0) { + CDEBUG(D_LAYOUT, "%s: invalid stripe count: %u\n", + lod2obd(d)->obd_name, + lod_comp->llc_stripe_count); + GOTO(free_comp, rc = -EINVAL); + } + lod_comp->llc_stripe_offset = v1->lmm_stripe_offset; lod_obj_set_pool(lo, i, pool_name); - LASSERT(ergo(lov_pattern(lod_comp->llc_pattern) == - LOV_PATTERN_MDT, lod_comp->llc_stripe_count == 0)); - if (pool_name == NULL) continue; diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index da2477e..9a4a194 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -3255,6 +3255,12 @@ static int lfs_setstripe_internal(int argc, char **argv, migration_block = true; break; case 'C': + if (lsa.lsa_pattern == LLAPI_LAYOUT_MDT) { + fprintf(stderr, + "%s %s: -C|--overstripe-count incompatible with DoM layout\n", + progname, argv[0]); + goto usage_error; + } lsa.lsa_pattern = LLAPI_LAYOUT_OVERSTRIPING; /* fall through */ case 'c': @@ -3480,6 +3486,12 @@ static int lfs_setstripe_internal(int argc, char **argv, fprintf(stderr, "warning: '--ost-list' is " "deprecated, use '--ost' instead\n"); #endif + if (lsa.lsa_pattern == LLAPI_LAYOUT_MDT) { + fprintf(stderr, + "%s %s: -o|--ost incompatible with DoM layout\n", + progname, argv[0]); + goto usage_error; + } /* -o allows overstriping, and must note it because * parse_targets is shared with MDT striping, which * does not allow duplicates -- 1.8.3.1