Whamcloud - gitweb
LU-15307 lod: add option to set max dir stripe count 24/45724/7
authorLei Feng <flei@whamcloud.com>
Fri, 3 Dec 2021 11:09:13 +0000 (19:09 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Jan 2022 05:12:27 +0000 (05:12 +0000)
Add an option to limit max dir stripe count when the default
dir stripe count is set to -1.

Signed-off-by: Lei Feng <flei@whamcloud.com>
Change-Id: I12dd5be15012a28bda30da85f24bc726c37f1ac7
Reviewed-on: https://review.whamcloud.com/45724
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lod/lod_internal.h
lustre/lod/lod_object.c
lustre/lod/lproc_lod.c
lustre/tests/sanity.sh

index 61d5199..49b5568 100644 (file)
@@ -158,6 +158,7 @@ struct lod_device {
 
        /* max stripe count if stripe count is set to -1. 0 means unlimited */
        unsigned int            lod_max_stripecount;
+       unsigned int            lod_max_mdt_stripecount;
 };
 
 #define lod_ost_bitmap         lod_ost_descs.ltd_tgt_bitmap
index 1003ad1..22411dc 100644 (file)
@@ -5606,6 +5606,13 @@ static void lod_ah_init(const struct lu_env *env,
                                lc->ldo_dir_stripe_count = 0;
                }
 
+               /* shrink the stripe count to max_mdt_stripecount if it is -1
+                * and max_mdt_stripecount is not 0
+                */
+               if (lc->ldo_dir_stripe_count == (__u16)(-1) &&
+                   d->lod_max_mdt_stripecount)
+                       lc->ldo_dir_stripe_count = d->lod_max_mdt_stripecount;
+
                /* shrink the stripe_count to the avaible MDT count */
                if (lc->ldo_dir_stripe_count > d->lod_remote_mdt_count + 1 &&
                    !OBD_FAIL_CHECK(OBD_FAIL_LARGE_STRIPE)) {
index 6ca8647..7949106 100644 (file)
@@ -313,6 +313,39 @@ static ssize_t max_stripecount_store(struct kobject *kobj,
 
 LUSTRE_RW_ATTR(max_stripecount);
 
+static ssize_t max_mdt_stripecount_show(struct kobject *kobj,
+                                   struct attribute *attr, char *buf)
+{
+       struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
+       struct lod_device *lod = dt2lod_dev(dt);
+
+       return scnprintf(buf, PAGE_SIZE, "%u\n", lod->lod_max_mdt_stripecount);
+}
+
+static ssize_t max_mdt_stripecount_store(struct kobject *kobj,
+                                    struct attribute *attr,
+                                    const char *buffer, size_t count)
+{
+       struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
+       struct lod_device *lod = dt2lod_dev(dt);
+       long val;
+       int rc;
+
+       rc = kstrtol(buffer, 0, &val);
+       if (rc)
+               return rc;
+
+       if (val < 0 || val > LMV_MAX_STRIPE_COUNT) /* any limitation? */
+               return -ERANGE;
+
+       lod->lod_max_mdt_stripecount = val;
+
+       return count;
+}
+
+LUSTRE_RW_ATTR(max_mdt_stripecount);
+
+
 /**
  * Show default striping pattern (LOV_PATTERN_*).
  */
@@ -1211,6 +1244,7 @@ static struct attribute *lod_attrs[] = {
        &lustre_attr_stripeoffset.attr,
        &lustre_attr_stripecount.attr,
        &lustre_attr_max_stripecount.attr,
+       &lustre_attr_max_mdt_stripecount.attr,
        &lustre_attr_stripetype.attr,
        &lustre_attr_activeobd.attr,
        &lustre_attr_desc_uuid.attr,
index 0878c8c..64cbe5c 100755 (executable)
@@ -23733,6 +23733,38 @@ test_300s() {
 }
 run_test 300s "test lfs mkdir -c without -i"
 
+test_300t() {
+       (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
+               skip "need MDS 2.14.55 or later"
+       (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
+
+       local testdir="$DIR/$tdir/striped_dir"
+       local dir1=$testdir/dir1
+       local dir2=$testdir/dir2
+
+       mkdir -p $testdir
+
+       $LFS setdirstripe -D -c -1 --max-inherit=3 $testdir ||
+               error "failed to set default stripe count for $testdir"
+
+       mkdir $dir1
+       local stripe_count=$($LFS getdirstripe -c $dir1)
+
+       (( $stripe_count == $MDSCOUNT )) || error "wrong stripe count"
+
+       local max_count=$((MDSCOUNT - 1))
+       local mdts=$(comma_list $(mdts_nodes))
+
+       do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=$max_count
+       stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_mdt_stripecount=0"
+
+       mkdir $dir2
+       stripe_count=$($LFS getdirstripe -c $dir2)
+
+       (( $stripe_count == $max_count )) || error "wrong stripe count"
+}
+run_test 300t "test max_mdt_stripecount"
+
 prepare_remote_file() {
        mkdir $DIR/$tdir/src_dir ||
                error "create remote source failed"