extern struct lustre_foreign_type lu_foreign_types[];
+/**
+ * When specified or returned as the value for stripe count, all
+ * available MDTs will be used.
+ */
+#define LMV_OVERSTRIPE_COUNT_MIN ((__s16)0xffff) /* -1 */
+#define LMV_OVERSTRIPE_COUNT_MAX ((__s16)0xfffb) /* -5 */
+
/* Got this according to how get LOV_MAX_STRIPE_COUNT, see above,
* (max buffer size - lmv+rpc header) / sizeof(struct lmv_user_mds_data)
*/
if (S_ISDIR(child_mode)) {
const struct lmv_user_md_v1 *lum1 = ah->dah_eadata;
- int max_stripe_count;
+ int max_stripe_count = 0;
+ int mdt_count = d->lod_remote_mdt_count + 1;
/* other default values are 0 */
lc->ldo_dir_stripe_offset = LMV_OFFSET_DEFAULT;
}
}
- /* shrink the stripe count to max_mdt_stripecount if it is -1
- * and max_mdt_stripecount is not 0
+ /*
+ * 1. overstriped case(< 0), adjust stripe count given
+ * overstriped factor by mdt_countmdt_count;
+ * 1.1 use lod_max_mdt_stripecount as max_stripe_count;
+ * 2. overstriped case(> 0), multiply max_stripe_count by
+ * max_stripes_per_mdt;
*/
- if (lc->ldo_dir_stripe_count == (__u16)(-1) &&
- d->lod_max_mdt_stripecount)
- lc->ldo_dir_stripe_count = d->lod_max_mdt_stripecount;
-
- max_stripe_count = d->lod_remote_mdt_count + 1;
- if (lc->ldo_dir_hash_type & LMV_HASH_FLAG_OVERSTRIPED)
+ max_stripe_count = mdt_count;
+ if ((__s16)lc->ldo_dir_stripe_count >=
+ LMV_OVERSTRIPE_COUNT_MAX &&
+ (__s16)lc->ldo_dir_stripe_count <=
+ LMV_OVERSTRIPE_COUNT_MIN) {
+ lc->ldo_dir_stripe_count = mdt_count *
+ -(__s16)lc->ldo_dir_stripe_count;
+ max_stripe_count = d->lod_max_mdt_stripecount ?:
+ mdt_count * d->lod_max_stripes_per_mdt;
+ } else if (lc->ldo_dir_hash_type & LMV_HASH_FLAG_OVERSTRIPED) {
max_stripe_count *= d->lod_max_stripes_per_mdt;
-
+ }
/* shrink the stripe_count to max stripe count */
if (lc->ldo_dir_stripe_count > max_stripe_count &&
!CFS_FAIL_CHECK(OBD_FAIL_LARGE_STRIPE)) {
mkdir $dir2
stripe_count=$($LFS getdirstripe -c $dir2)
- (( $stripe_count == $max_count )) || error "wrong stripe count"
+ if (( $MDSCOUNT == 2 &&
+ $MDS1_VERSION >= $(version_code 2.16.0) )); then
+ (( $stripe_count == 0 )) || error "(0) wrong stripe count"
+ else
+ (( $stripe_count == $max_count )) ||
+ error "(1) wrong stripe count"
+ fi
}
run_test 300t "test max_mdt_stripecount"
}
run_test 300ui "overstripe is not supported on one MDT system"
+test_300uj() {
+ (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
+ (( MDS1_VERSION >= $(version_code 2.16.0) )) ||
+ skip "need MDS >= 2.16.0 for llog timestamps"
+
+ local setcount=-2
+ local expected_count=$((MDSCOUNT * 2))
+
+ mkdir $DIR/$tdir
+ $LFS mkdir -C $setcount $DIR/$tdir/${tdir}.0 ||
+ error "(0) failed overstriped dir creation with -C -N test"
+ local getstripe_count=$($LFS getdirstripe -c $DIR/$tdir/${tdir}.0)
+ (( getstripe_count == expected_count )) ||
+ error "(1) incorrect stripe count for -C -N overstriped dir"
+ rm -f $DIR/$tdir/${tdir}.0
+
+ # limit testing
+ setcount=-6
+ $LFS setdirstripe -C $setcount $DIR/$tdir/${tdir}.1 2>&1 |
+ grep "invalid stripe count" ||
+ error "(0) failed overstriped dir creation limit test"
+}
+run_test 300uj "overstriped dir with -C -N sanity test"
+
(( max_stripes_per_mdt == 0 )) ||
do_nodes $mdts $LCTL set_param -n \
lod.$FSNAME-MDT*.max_stripes_per_mdt=$max_stripes_per_mdt
case 'T':
errno = 0;
lsa.lsa_stripe_count = strtoul(optarg, &end, 0);
+ /* only allow count -1..-5 for overstriped dirs */
if (errno != 0 || *end != '\0' ||
- lsa.lsa_stripe_count < LLAPI_OVERSTRIPE_COUNT_MAX ||
- lsa.lsa_stripe_count > LOV_MAX_STRIPE_COUNT) {
+ lsa.lsa_stripe_count <
+ (overstriped ? LMV_OVERSTRIPE_COUNT_MAX :
+ LLAPI_OVERSTRIPE_COUNT_MIN) ||
+ lsa.lsa_stripe_count > LMV_MAX_STRIPE_COUNT) {
fprintf(stderr,
"%s: invalid stripe count '%s'\n",
progname, optarg);
* initialize stripe parameters, in case param is converted to specific,
* i.e, 'lfs mkdir -i -1 -c N', always allocate space for lsp_tgts.
*/
- param = calloc(1, offsetof(typeof(*param),
- lsp_tgts[lsa.lsa_stripe_count != LLAPI_LAYOUT_DEFAULT ?
- lsa.lsa_stripe_count : lsa.lsa_nr_tgts]));
+ if (lsa.lsa_stripe_count == LLAPI_LAYOUT_DEFAULT ||
+ lsa.lsa_stripe_count <= LLAPI_OVERSTRIPE_COUNT_MIN) {
+ param = calloc(1, offsetof(typeof(*param),
+ lsp_tgts[lsa.lsa_nr_tgts]));
+ } else {
+ param = calloc(1, offsetof(typeof(*param),
+ lsp_tgts[lsa.lsa_stripe_count]));
+ }
if (!param) {
fprintf(stderr,
"%s %s: cannot allocate memory for parameters: %s\n",
}
param->lsp_max_inherit = max_inherit;
if (default_stripe) {
-
if (max_inherit_rr == LAYOUT_INHERIT_UNSET)
max_inherit_rr = LMV_INHERIT_RR_DEFAULT;
param->lsp_max_inherit_rr = max_inherit_rr;
static inline bool llapi_dir_stripe_count_is_valid(int64_t count)
{
- return count >= -1 && count <= LMV_MAX_STRIPE_COUNT;
+ return count >= LMV_OVERSTRIPE_COUNT_MAX &&
+ count <= LMV_MAX_STRIPE_COUNT;
}
static inline bool llapi_dir_stripe_index_is_valid(int64_t index)