Whamcloud - gitweb
LU-13142 lod: cleanup layout checking 67/37267/4
authorSebastien Buisson <sbuisson@ddn.com>
Fri, 17 Jan 2020 13:15:25 +0000 (22:15 +0900)
committerOleg Drokin <green@whamcloud.com>
Sat, 1 Feb 2020 08:10:41 +0000 (08:10 +0000)
Cleanup layout checking in lod layer and lfs command-line utility,
for DoM components.

Reported-by: Clement Barthelemy <clement.barthelemy@nextino.eu>
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: Ib8b184a31d26442ed10241dc12a0452e5243d0e8
Reviewed-on: https://review.whamcloud.com/37267
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lod/lod_lov.c
lustre/lod/lod_qos.c
lustre/utils/lfs.c

index e449db6..48fa030 100644 (file)
@@ -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);
index 149b06f..30f1ca0 100644 (file)
@@ -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;
 
index da2477e..9a4a194 100644 (file)
@@ -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