dt_conf_get(env, &lod->lod_dt_dev, &ddp);
lod->lod_osd_max_easize = ddp.ddp_max_ea_size;
lod->lod_dom_stripesize_max_kb = (1ULL << 10); /* 1Mb is default */
+ lod->lod_max_stripecount = 0;
/* initialize local statfs cached values */
rc = lod_lsfs_init(env, lod);
/* ROOT object, used to fetch FS default striping */
struct lod_object *lod_md_root;
+
+ /* max stripe count if stripe count is set to -1. 0 means unlimited */
+ unsigned int lod_max_stripecount;
};
#define lod_ost_bitmap lod_ost_descs.ltd_tgt_bitmap
/* max stripe count is based on OSD ea size */
unsigned int easize = lod->lod_osd_max_easize;
int i;
+ ENTRY;
+ if (stripe_count == (__u16)(-1) && lod->lod_max_stripecount)
+ stripe_count = lod->lod_max_stripecount;
if (!stripe_count)
stripe_count =
lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_count;
max_stripes = lov_mds_md_max_stripe_count(easize, LOV_MAGIC_V3);
max_stripes = (max_stripes == 0) ? 0 : max_stripes - 1;
- return (stripe_count < max_stripes) ? stripe_count : max_stripes;
+ stripe_count = min_t(__u16, stripe_count, max_stripes);
+ RETURN(stripe_count);
}
/**
LUSTRE_RW_ATTR(stripeoffset);
+static ssize_t max_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_stripecount);
+}
+
+static ssize_t max_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 > LOV_MAX_STRIPE_COUNT)
+ return -ERANGE;
+
+ lod->lod_max_stripecount = val;
+
+ return count;
+}
+
+LUSTRE_RW_ATTR(max_stripecount);
+
/**
* Show default striping pattern (LOV_PATTERN_*).
*/
&lustre_attr_stripesize.attr,
&lustre_attr_stripeoffset.attr,
&lustre_attr_stripecount.attr,
+ &lustre_attr_max_stripecount.attr,
&lustre_attr_stripetype.attr,
&lustre_attr_activeobd.attr,
&lustre_attr_desc_uuid.attr,
}
run_test 27Q "llapi_file_get_stripe() works on symlinks"
+test_27R() {
+ (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
+ skip "need MDS 2.14.55 or later"
+ (( $OSTCOUNT >= 2 )) || skip_env "needs at least 2 OSTs"
+
+ local testdir="$DIR/$tdir"
+ test_mkdir -p $testdir
+ stack_trap "rm -rf $testdir"
+ $LFS setstripe -c -1 $testdir || error "setstripe failed"
+
+ local f1="$testdir/f1"
+ touch $f1 || error "failed to touch $f1"
+ local count=$($LFS getstripe -c $f1)
+ (( $count == $OSTCOUNT )) || error "wrong stripe count"
+
+ do_facet $SINGLEMDS $LCTL set_param lod.*.max_stripecount=-1
+ (( $? == 34 )) || error "setting max_stripecount to -1 should fail and return ERANGE"
+
+ local maxcount=$(($OSTCOUNT - 1))
+ local mdts=$(comma_list $(mdts_nodes))
+ do_nodes $mdts $LCTL set_param lod.*.max_stripecount=$maxcount
+ stack_trap "do_nodes $mdts $LCTL set_param lod.*.max_stripecount=0"
+
+ local f2="$testdir/f2"
+ touch $f2 || error "failed to touch $f2"
+ local count=$($LFS getstripe -c $f2)
+ (( $count == $maxcount )) || error "wrong stripe count"
+}
+run_test 27R "test max_stripecount limitation when stripe count is set to -1"
+
# createtest also checks that device nodes are created and
# then visible correctly (#2091)
test_28() { # bug 2091