/* 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
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)) {
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_*).
*/
&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,
}
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"