.B -C\fR, \fB--overstripe-count \fR\fISTRIPE_COUNT\fR
The number of stripes to create, creating > 1 stripe per OST if count exceeds
the number of OSTs in the file system. \fB0 \fRmeans to use the filesystem-wide
-default stripe count (default 1), and \fB-1 \fRmeans to stripe over all
-available OSTs.
+default stripe count (default 1), and \fB range -1 to -32\fRmeans to stripe
+over all available OSTs in multiple of OST count. For example, \fB-1\fR means
+one stripe per OST, -2 means two stripes per OST, and so on.
.TP
.B -S\fR, \fB--stripe-size \fR\fISTRIPE_SIZE\fR
The number of bytes to store on each OST before moving to the next OST. A
/* number of pointers at 2nd level */
#define TGT_PTRS_PER_BLOCK (PAGE_SIZE / sizeof(void *))
/* number of pointers at 1st level - only need as many as max OST/MDT count */
-#define TGT_PTRS ((LOV_ALL_STRIPES + 1) / TGT_PTRS_PER_BLOCK)
+#define TGT_PTRS ((LOV_ALL_STRIPES_MAX + 1) / TGT_PTRS_PER_BLOCK)
struct lu_tgt_desc_idx {
struct lu_tgt_desc *ldi_tgt[TGT_PTRS_PER_BLOCK];
* When specified or returned as the value for stripe count, all
* available OSTs will be used.
*/
-#define LLAPI_LAYOUT_WIDE (LLAPI_LAYOUT_INVALID + 2)
+#define LLAPI_MIN_STRIPE_COUNT (-1)
+#define LLAPI_MAX_STRIPE_COUNT (-32)
+#define LLAPI_LAYOUT_WIDE_MIN (LLAPI_LAYOUT_INVALID + 2)
+#define LLAPI_LAYOUT_WIDE_MAX (LLAPI_LAYOUT_WIDE_MIN + 32)
/**
* When specified as the value for layout pattern, file objects will be
static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
{
- if (stripes == LOV_ALL_STRIPES)
+ if (stripes >= LOV_ALL_STRIPES_MIN && stripes <= LOV_ALL_STRIPES_MAX)
stripes = 0;
if (lmm_magic == LOV_MAGIC_V1)
* (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1)
*/
#define LOV_MAX_STRIPE_COUNT 2000 /* ~((12 * 4096 - 256) / 24) */
-#define LOV_ALL_STRIPES 0xffff /* only valid for directories */
+
+/* Below given max and min values are used to check range of stripe count */
+/* LOV_ALL_STRIPES_MAX LLAPI_MIN_STRIPE_COUNT */
+/* LOV_ALL_STRIPES_MIN LLAPI_MIN_STRIPE_COUNT+ LLAPI_MAX_STRIPE_COUNT */
+#define LOV_ALL_STRIPES_MAX 0xffff
+#define LOV_ALL_STRIPES_MIN 0xffdf
#define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */
#define XATTR_LUSTRE_PREFIX "lustre."
static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
{
- if (stripes == LOV_ALL_STRIPES)
+ if (stripes >= LOV_ALL_STRIPES_MIN && stripes <= LOV_ALL_STRIPES_MAX)
stripes = 0;
if (lmm_magic == LOV_USER_MAGIC_V1)
entry = &lo->ldo_comp_entries[comp_idx];
if (lod_comp_inited(entry))
return entry->llc_stripe_count;
- if (entry->llc_stripe_count == LOV_ALL_STRIPES)
+ if (entry->llc_stripe_count >= LOV_ALL_STRIPES_MIN &&
+ entry->llc_stripe_count <= LOV_ALL_STRIPES_MAX)
return lod_get_stripe_count_plain(lod, lo,
entry->llc_stripe_count,
entry->llc_pattern &
(lod_comp_inited(lod_comp) ||
lod_comp->llc_extent.e_start <
lod_comp->llc_extent.e_end) &&
- lod_comp->llc_stripe_count != LOV_ALL_STRIPES &&
+ !(lod_comp->llc_stripe_count >= LOV_ALL_STRIPES_MIN &&
+ lod_comp->llc_stripe_count <= LOV_ALL_STRIPES_MAX) &&
ext->e_end != OBD_OBJECT_EOF &&
(__u64)(lod_comp->llc_stripe_count *
lod_comp->llc_stripe_size) >
{
struct lov_desc *lov_desc = &lod->lod_ost_descs.ltd_lov_desc;
- if (!stripe_count)
- stripe_count = lov_desc->ld_default_stripe_count;
-
/* Overstriping allows more stripes than targets */
- if (stripe_count > lov_desc->ld_active_tgt_count && !overstriping) {
- *flags |= LOD_USES_DEFAULT_STRIPE;
- if (stripe_count == LOV_ALL_STRIPES && lod->lod_max_stripecount)
- stripe_count = lod->lod_max_stripecount;
- else
- stripe_count = lov_desc->ld_active_tgt_count;
+ if (stripe_count > lov_desc->ld_active_tgt_count) {
+ if (overstriping) {
+ if (stripe_count >= LOV_ALL_STRIPES_MIN &&
+ stripe_count <= LOV_ALL_STRIPES_MAX) {
+ stripe_count =
+ ((stripe_count - LOV_ALL_STRIPES_MIN) + 1) *
+ lov_desc->ld_active_tgt_count;
+ }
+ } else {
+ *flags |= LOD_USES_DEFAULT_STRIPE;
+ if ((stripe_count >= LOV_ALL_STRIPES_MIN &&
+ stripe_count <= LOV_ALL_STRIPES_MAX) &&
+ lod->lod_max_stripecount)
+ stripe_count = lod->lod_max_stripecount;
+ else
+ stripe_count = lov_desc->ld_active_tgt_count;
+ }
}
+
if (!stripe_count)
- stripe_count = 1;
+ stripe_count = lov_desc->ld_default_stripe_count;
if (overstriping && stripe_count > LOV_MAX_STRIPE_COUNT)
stripe_count = LOV_MAX_STRIPE_COUNT;
(lod_comp_inited(lod_comp) ||
lod_comp->llc_extent.e_start <
lod_comp->llc_extent.e_end) &&
- lod_comp->llc_stripe_count != LOV_ALL_STRIPES &&
+ !(lod_comp->llc_stripe_count >= LOV_ALL_STRIPES_MIN &&
+ lod_comp->llc_stripe_count <= LOV_ALL_STRIPES_MAX) &&
lod_comp->llc_extent.e_end != OBD_OBJECT_EOF &&
(__u64)lod_comp->llc_stripe_count *
lod_comp->llc_stripe_size >
*/
if (lo->ldo_is_composite &&
!(lod_comp->llc_flags & LCME_FL_EXTENSION) &&
- lod_comp->llc_stripe_count != LOV_ALL_STRIPES &&
+ !(lod_comp->llc_stripe_count >= LOV_ALL_STRIPES_MIN &&
+ lod_comp->llc_stripe_count <= LOV_ALL_STRIPES_MAX) &&
(lod_comp_inited(lod_comp) ||
lod_comp->llc_extent.e_start <
lod_comp->llc_extent.e_end) &&
DIE("assertion '%s' failed: "fmt, #cond, ## __VA_ARGS__);\
} while (0) \
+#define IN_RANGE(value, low, high) ((value >= low) && (value <= high))
+
static char *lustre_dir;
static char *poolname;
static bool run_list_provided;
rc = llapi_layout_stripe_count_get(filelayout, &fcount);
ASSERTF(rc == 0, "errno = %d", errno);
ASSERTF(fcount == dcount || dcount == LLAPI_LAYOUT_DEFAULT ||
- dcount == LLAPI_LAYOUT_WIDE,
+ IN_RANGE(dcount, LLAPI_LAYOUT_WIDE_MIN, LLAPI_LAYOUT_WIDE_MAX),
"%"PRIu64" != %"PRIu64, fcount, dcount);
rc = llapi_layout_stripe_size_get(filelayout, &fsize);
rc = llapi_layout_stripe_size_get(filelayout, &fsize);
ASSERTF(rc == 0, "errno = %d", errno);
ASSERTF(fcount == dcount || dcount == LLAPI_LAYOUT_DEFAULT ||
- dcount == LLAPI_LAYOUT_WIDE,
+ IN_RANGE(dcount, LLAPI_LAYOUT_WIDE_MIN, LLAPI_LAYOUT_WIDE_MAX),
"%"PRIu64" != %"PRIu64, fcount, dcount);
ASSERTF(fsize == dsize, "%"PRIu64" != %"PRIu64, fsize, dsize);
ASSERTF(rc == 0 || errno == ENOENT, "errno = %d", errno);
layout = llapi_layout_alloc();
ASSERTF(layout != NULL, "errno = %d", errno);
- rc = llapi_layout_stripe_count_set(layout, LLAPI_LAYOUT_WIDE);
+ rc = llapi_layout_stripe_count_set(layout, LLAPI_LAYOUT_WIDE_MIN);
ASSERTF(rc == 0, "errno = %d", errno);
fd = llapi_layout_file_create(path, 0, 0640, layout);
ASSERTF(fd >= 0, "errno = %d", errno);
rc = llapi_layout_stripe_count_get(deflayout, &dcount);
ASSERTF(rc == 0, "errno = %d", errno);
ASSERTF(fcount == dcount || dcount == LLAPI_LAYOUT_DEFAULT ||
- dcount == LLAPI_LAYOUT_WIDE,
+ IN_RANGE(dcount, LLAPI_LAYOUT_WIDE_MIN, LLAPI_LAYOUT_WIDE_MAX),
"%"PRIu64" != %"PRIu64, fcount, dcount);
rc = llapi_layout_stripe_size_get(filelayout, &fsize);
rc = llapi_layout_stripe_count_get(layout, &count);
ASSERTF(rc == 0, "errno = %d\n", errno);
- ASSERTF(count == LLAPI_LAYOUT_WIDE, "count = %"PRIu64"\n", count);
+ ASSERTF((count >= LLAPI_LAYOUT_WIDE_MIN &&
+ count <= LLAPI_LAYOUT_WIDE_MAX),
+ "count = %"PRIu64"\n", count);
llapi_layout_free(layout);
}
# verify components ${ids[6]}, ${ids[8]} and ${ids[10]}
for i in 6 8 10; do
verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
- verify_comp_attr stripe-count $tf ${ids[$i]} -1
+ # ffdf which is -33 and matches LOV_ALL_STRIPES_MIN
+ local decimal_lov_lower_limit=-33
+ #C_opt is -c option which can be -1 to -32
+ local C_opt=-1
+ local count_exp=$(($decimal_lov_lower_limit + $C_opt + 1))
+
+ verify_comp_attr stripe-count $tf ${ids[$i]} $count_exp
verify_comp_attr pool $tf ${ids[$i]} archive
verify_comp_extent $tf ${ids[$i]} 536870912 EOF
done
# verify components ${ids[9]}, ${ids[11]} and ${ids[13]}
for i in 9 11 13; do
verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
- verify_comp_attr stripe-count $tf ${ids[$i]} -1
+ # ffdf which is -33 and matches LOV_ALL_STRIPES_MIN
+ local decimal_lov_lower_limit=-33
+ #C_opt is -c option which can be -1 to -32
+ local C_opt=-1
+ local count_exp=$(($decimal_lov_lower_limit + $C_opt + 1))
+
+ verify_comp_attr stripe-count $tf ${ids[$i]} $count_exp
verify_comp_attr pool $tf ${ids[$i]} archive
verify_comp_extent $tf ${ids[$i]} 536870912 EOF
done
}
run_test 27Ci "add an overstriping component"
+test_27Cj() {
+ [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
+ skip "server does not support overstriping"
+ (( $MDS1_VERSION >= $(version_code 2.15.61.76) )) ||
+ skip "need MDS >= 2.15.61.76"
+
+ stack_trap "rm -f $DIR/$tfile"
+ # start_full_debug_logging
+ # number of stripes created will be 32*ost count
+ $LFS setstripe -C -32 $DIR/$tfile || error "create $tfile failed"
+ local count=$($LFS getstripe -c $DIR/$tfile)
+ local stripe_cnt=$(($OSTCOUNT * 32))
+ (( $count == $stripe_cnt )) ||
+ error "$DIR/$tfile stripe count $count != $OSTCOUNT"
+ #check that beyond -32 it fails
+ !($LFS setstripe -C -34 $DIR/$tfile) || error "setstripe should fail"
+}
+run_test 27Cj "overstriping with -C for max values in multiple of targets"
+
test_27D() {
[ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
[ -n "$FILESET" ] && skip "SKIP due to FILESET set"
if (lsa->lsa_stripe_count > 0 &&
lsa->lsa_stripe_count != LLAPI_LAYOUT_DEFAULT &&
- lsa->lsa_stripe_count != LLAPI_LAYOUT_WIDE &&
+ !(lsa->lsa_stripe_count >= LLAPI_LAYOUT_WIDE_MIN &&
+ lsa->lsa_stripe_count <= LLAPI_LAYOUT_WIDE_MAX) &&
lsa->lsa_nr_tgts != lsa->lsa_stripe_count) {
fprintf(stderr, "stripe_count(%lld) != nr_tgts(%d)\n",
lsa->lsa_stripe_count,
errno = 0;
lsa.lsa_stripe_count = strtoul(optarg, &end, 0);
if (errno != 0 || *end != '\0'|| optarg == end ||
- lsa.lsa_stripe_count < -1 ||
+ lsa.lsa_stripe_count < LLAPI_MAX_STRIPE_COUNT ||
lsa.lsa_stripe_count > LOV_MAX_STRIPE_COUNT) {
fprintf(stderr,
"%s %s: invalid stripe count '%s'\n",
goto usage_error;
}
- if (lsa.lsa_stripe_count == -1)
- lsa.lsa_stripe_count = LLAPI_LAYOUT_WIDE;
+ if (lsa.lsa_stripe_count <= LLAPI_MIN_STRIPE_COUNT &&
+ lsa.lsa_stripe_count >= LLAPI_MAX_STRIPE_COUNT) {
+ lsa.lsa_stripe_count = LLAPI_LAYOUT_WIDE_MIN +
+ abs(lsa.lsa_stripe_count + 1);
+ }
break;
case 'd':
if (migrate_mode) {
if (lsa.lsa_stripe_size != LLAPI_LAYOUT_DEFAULT)
param->lsp_stripe_size = lsa.lsa_stripe_size;
if (lsa.lsa_stripe_count != LLAPI_LAYOUT_DEFAULT) {
- if (lsa.lsa_stripe_count == LLAPI_LAYOUT_WIDE)
- param->lsp_stripe_count = -1;
+ if (lsa.lsa_stripe_count >= LLAPI_LAYOUT_WIDE_MIN &&
+ lsa.lsa_stripe_count < LLAPI_LAYOUT_WIDE_MAX)
+ param->lsp_stripe_count = LOV_ALL_STRIPES_MIN +
+ (lsa.lsa_stripe_count - LLAPI_LAYOUT_WIDE_MIN);
else
param->lsp_stripe_count = lsa.lsa_stripe_count;
}
if (!(tp->st_op & ops))
continue;
- for (index = 0; index < LOV_ALL_STRIPES &&
+ for (index = 0; index < LOV_ALL_STRIPES_MAX &&
(!lsb || lsb->sb_count < LL_STATFS_MAX); index++) {
memset(&stat_buf, 0, sizeof(struct obd_statfs));
memset(&uuid_buf, 0, sizeof(struct obd_uuid));
errno = 0;
lsa.lsa_stripe_count = strtoul(optarg, &end, 0);
if (errno != 0 || *end != '\0' ||
- lsa.lsa_stripe_count < -1 ||
+ lsa.lsa_stripe_count < LLAPI_MAX_STRIPE_COUNT ||
lsa.lsa_stripe_count > LOV_MAX_STRIPE_COUNT) {
fprintf(stderr,
"%s: invalid stripe count '%s'\n",
else
comp->llc_stripe_size = v1->lmm_stripe_size;
- if (v1->lmm_stripe_count == (typeof(v1->lmm_stripe_count))-1)
- comp->llc_stripe_count = LLAPI_LAYOUT_WIDE;
+ if (v1->lmm_stripe_count >= (typeof(v1->lmm_stripe_count))
+ LOV_ALL_STRIPES_MIN && v1->lmm_stripe_count <=
+ (typeof(v1->lmm_stripe_count)) LOV_ALL_STRIPES_MAX)
+ comp->llc_stripe_count =
+ LLAPI_LAYOUT_WIDE_MIN +
+ (v1->lmm_stripe_count - LOV_ALL_STRIPES_MIN);
else if (v1->lmm_stripe_count == 0)
comp->llc_stripe_count = LLAPI_LAYOUT_DEFAULT;
else
if (comp->llc_stripe_count == LLAPI_LAYOUT_DEFAULT)
blob->lmm_stripe_count = 0;
- else if (comp->llc_stripe_count == LLAPI_LAYOUT_WIDE)
- blob->lmm_stripe_count = LOV_ALL_STRIPES;
+ else if (comp->llc_stripe_count >= LLAPI_LAYOUT_WIDE_MIN &&
+ comp->llc_stripe_count <= LLAPI_LAYOUT_WIDE_MAX) {
+ blob->lmm_stripe_count = LOV_ALL_STRIPES_MIN +
+ (comp->llc_stripe_count - LLAPI_LAYOUT_WIDE_MIN);
+ }
else
blob->lmm_stripe_count = comp->llc_stripe_count;
bool llapi_layout_stripe_count_is_valid(int64_t stripe_count)
{
return stripe_count == LLAPI_LAYOUT_DEFAULT ||
- stripe_count == LLAPI_LAYOUT_WIDE ||
- (stripe_count != 0 && stripe_count != -1 &&
+ (stripe_count >= LLAPI_LAYOUT_WIDE_MIN &&
+ stripe_count <= LLAPI_LAYOUT_WIDE_MAX) ||
+ (stripe_count != 0 && !(stripe_count <=
+ LLAPI_MIN_STRIPE_COUNT &&
+ stripe_count >= LLAPI_MAX_STRIPE_COUNT) &&
llapi_stripe_count_is_valid(stripe_count));
}
errno = EINVAL;
return -1;
}
-
comp->llc_stripe_count = count;
return 0;
static inline bool llapi_stripe_count_is_valid(int64_t count)
{
- return count >= -1 && count <= LOV_MAX_STRIPE_COUNT;
+ return (count >= LOV_ALL_STRIPES_MIN && count <= LOV_ALL_STRIPES_MAX) ||
+ count <= LOV_MAX_STRIPE_COUNT;
}
static inline bool llapi_stripe_index_is_valid(int64_t index)