static int lod_get_default_lov_striping(const struct lu_env *env,
struct lod_object *lo,
struct lod_default_striping *lds,
- struct dt_allocation_hint *ah)
+ struct dt_allocation_hint *dah)
{
struct lod_thread_info *info = lod_env_info(env);
struct lov_user_md_v1 *v1 = NULL;
struct lov_user_md_v3 *v3 = NULL;
- struct lov_comp_md_v1 *comp_v1 = NULL;
- __u16 comp_cnt;
- __u16 mirror_cnt;
- bool composite;
+ struct lov_comp_md_v1 *lcm = NULL;
+ __u32 magic;
+ int append_stripe_count = dah != NULL ? dah->dah_append_stripe_count : 0;
+ const char *append_pool = (dah != NULL &&
+ dah->dah_append_pool != NULL &&
+ dah->dah_append_pool[0] != '\0') ?
+ dah->dah_append_pool : NULL;
+ __u16 entry_count = 1;
+ __u16 mirror_count = 0;
+ bool want_composite = false;
int rc, i, j;
ENTRY;
if (rc < (typeof(rc))sizeof(struct lov_user_md))
RETURN(0);
- v1 = info->lti_ea_store;
- if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V1)) {
- lustre_swab_lov_user_md_v1(v1);
- } else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V3)) {
- v3 = (struct lov_user_md_v3 *)v1;
- lustre_swab_lov_user_md_v3(v3);
- } else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_SPECIFIC)) {
- v3 = (struct lov_user_md_v3 *)v1;
+ magic = *(__u32 *)info->lti_ea_store;
+ if (magic == __swab32(LOV_USER_MAGIC_V1)) {
+ lustre_swab_lov_user_md_v1(info->lti_ea_store);
+ } else if (magic == __swab32(LOV_USER_MAGIC_V3)) {
+ lustre_swab_lov_user_md_v3(info->lti_ea_store);
+ } else if (magic == __swab32(LOV_USER_MAGIC_SPECIFIC)) {
+ v3 = (struct lov_user_md_v3 *)info->lti_ea_store;
lustre_swab_lov_user_md_v3(v3);
lustre_swab_lov_user_md_objects(v3->lmm_objects,
v3->lmm_stripe_count);
- } else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_COMP_V1) ||
- v1->lmm_magic == __swab32(LOV_USER_MAGIC_SEL)) {
- comp_v1 = (struct lov_comp_md_v1 *)v1;
- lustre_swab_lov_comp_md_v1(comp_v1);
+ } else if (magic == __swab32(LOV_USER_MAGIC_COMP_V1) ||
+ magic == __swab32(LOV_USER_MAGIC_SEL)) {
+ lustre_swab_lov_comp_md_v1(info->lti_ea_store);
}
- if (v1->lmm_magic != LOV_MAGIC_V3 && v1->lmm_magic != LOV_MAGIC_V1 &&
- v1->lmm_magic != LOV_MAGIC_COMP_V1 &&
- v1->lmm_magic != LOV_MAGIC_SEL &&
- v1->lmm_magic != LOV_USER_MAGIC_SPECIFIC)
+ switch (magic) {
+ case LOV_MAGIC_V1:
+ case LOV_MAGIC_V3:
+ case LOV_USER_MAGIC_SPECIFIC:
+ v1 = info->lti_ea_store;
+ break;
+ case LOV_MAGIC_COMP_V1:
+ case LOV_MAGIC_SEL:
+ lcm = info->lti_ea_store;
+ entry_count = lcm->lcm_entry_count;
+ if (entry_count == 0)
+ RETURN(-EINVAL);
+
+ mirror_count = lcm->lcm_mirror_count + 1;
+ want_composite = true;
+ break;
+ default:
RETURN(-ENOTSUPP);
+ }
- if ((v1->lmm_magic == LOV_MAGIC_COMP_V1 ||
- v1->lmm_magic == LOV_MAGIC_SEL) &&
- !(ah && ah->dah_append_stripes)) {
- comp_v1 = (struct lov_comp_md_v1 *)v1;
- comp_cnt = comp_v1->lcm_entry_count;
- if (comp_cnt == 0)
- RETURN(-EINVAL);
- mirror_cnt = comp_v1->lcm_mirror_count + 1;
- composite = true;
- } else {
- comp_cnt = 1;
- mirror_cnt = 0;
- composite = false;
+ if (append_stripe_count != 0 || append_pool != NULL) {
+ entry_count = 1;
+ mirror_count = 0;
+ want_composite = false;
}
/* realloc default comp entries if necessary */
- rc = lod_def_striping_comp_resize(lds, comp_cnt);
+ rc = lod_def_striping_comp_resize(lds, entry_count);
if (rc < 0)
RETURN(rc);
- lds->lds_def_comp_cnt = comp_cnt;
- lds->lds_def_striping_is_composite = composite;
- lds->lds_def_mirror_cnt = mirror_cnt;
+ lds->lds_def_comp_cnt = entry_count;
+ lds->lds_def_striping_is_composite = want_composite;
+ lds->lds_def_mirror_cnt = mirror_count;
- for (i = 0; i < comp_cnt; i++) {
- struct lod_layout_component *lod_comp;
- char *pool;
+ for (i = 0; i < entry_count; i++) {
+ struct lod_layout_component *llc = &lds->lds_def_comp_entries[i];
+ const char *pool;
- lod_comp = &lds->lds_def_comp_entries[i];
/*
- * reset lod_comp values, llc_stripes is always NULL in
- * the default striping template, llc_pool will be reset
- * later below.
+ * reset llc values, llc_stripes is always NULL in the
+ * default striping template, llc_pool will be reset
+ * later below using lod_set_pool().
+ *
+ * XXX At this point llc_pool may point to valid (!)
+ * kmalloced strings from previous RPCs.
*/
- memset(lod_comp, 0, offsetof(typeof(*lod_comp), llc_pool));
-
- if (composite) {
- v1 = (struct lov_user_md *)((char *)comp_v1 +
- comp_v1->lcm_entries[i].lcme_offset);
- lod_comp->llc_extent =
- comp_v1->lcm_entries[i].lcme_extent;
- /* We only inherit certain flags from the layout */
- lod_comp->llc_flags =
- comp_v1->lcm_entries[i].lcme_flags &
+ memset(llc, 0, offsetof(typeof(*llc), llc_pool));
+
+ if (lcm != NULL) {
+ v1 = (struct lov_user_md *)((char *)lcm +
+ lcm->lcm_entries[i].lcme_offset);
+
+ if (want_composite) {
+ llc->llc_extent = lcm->lcm_entries[i].lcme_extent;
+ /* We only inherit certain flags from the layout */
+ llc->llc_flags = lcm->lcm_entries[i].lcme_flags &
LCME_TEMPLATE_FLAGS;
+ }
}
+ CDEBUG(D_LAYOUT, DFID" magic = %#08x, pattern = %#x, stripe_count = %hu, stripe_size = %u, stripe_offset = %hu, append_pool = '%s', append_stripe_count = %d\n",
+ PFID(lu_object_fid(&lo->ldo_obj.do_lu)),
+ v1->lmm_magic,
+ v1->lmm_pattern,
+ v1->lmm_stripe_count,
+ v1->lmm_stripe_size,
+ v1->lmm_stripe_offset,
+ append_pool ?: "",
+ append_stripe_count);
+
if (!lov_pattern_supported(v1->lmm_pattern) &&
!(v1->lmm_pattern & LOV_PATTERN_F_RELEASED)) {
lod_free_def_comp_entries(lds);
RETURN(-EINVAL);
}
- CDEBUG(D_LAYOUT, DFID" stripe_count=%d stripe_size=%d stripe_offset=%d append_stripes=%d\n",
- PFID(lu_object_fid(&lo->ldo_obj.do_lu)),
- (int)v1->lmm_stripe_count, (int)v1->lmm_stripe_size,
- (int)v1->lmm_stripe_offset,
- ah ? ah->dah_append_stripes : 0);
+ llc->llc_stripe_count = v1->lmm_stripe_count;
+ llc->llc_stripe_size = v1->lmm_stripe_size;
+ llc->llc_stripe_offset = v1->lmm_stripe_offset;
+ llc->llc_pattern = v1->lmm_pattern;
- if (ah && ah->dah_append_stripes)
- lod_comp->llc_stripe_count = ah->dah_append_stripes;
- else
- lod_comp->llc_stripe_count = v1->lmm_stripe_count;
- lod_comp->llc_stripe_size = v1->lmm_stripe_size;
- lod_comp->llc_stripe_offset = v1->lmm_stripe_offset;
- lod_comp->llc_pattern = v1->lmm_pattern;
+ if (append_stripe_count != 0 || append_pool != NULL)
+ llc->llc_pattern = LOV_PATTERN_RAID0;
+
+ if (append_stripe_count != 0)
+ llc->llc_stripe_count = append_stripe_count;
pool = NULL;
- if (ah && ah->dah_append_pool && ah->dah_append_pool[0]) {
- pool = ah->dah_append_pool;
+ if (append_pool != NULL) {
+ pool = append_pool;
} else if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
/* XXX: sanity check here */
- v3 = (struct lov_user_md_v3 *) v1;
+ v3 = (struct lov_user_md_v3 *)v1;
if (v3->lmm_pool_name[0] != '\0')
pool = v3->lmm_pool_name;
}
- lod_set_def_pool(lds, i, pool);
- if (v1->lmm_magic == LOV_USER_MAGIC_SPECIFIC) {
+
+ lod_set_pool(&llc->llc_pool, pool);
+
+ if (append_stripe_count != 0 || append_pool != NULL) {
+ /* Ignore specific striping for append. */
+ } else if (v1->lmm_magic == LOV_USER_MAGIC_SPECIFIC) {
v3 = (struct lov_user_md_v3 *)v1;
- rc = lod_comp_copy_ost_lists(lod_comp, v3);
+ rc = lod_comp_copy_ost_lists(llc, v3);
if (rc)
RETURN(rc);
- } else if (lod_comp->llc_ostlist.op_array &&
- lod_comp->llc_ostlist.op_count) {
- for (j = 0; j < lod_comp->llc_ostlist.op_count; j++)
- lod_comp->llc_ostlist.op_array[j] = -1;
- lod_comp->llc_ostlist.op_count = 0;
+ } else if (llc->llc_ostlist.op_array &&
+ llc->llc_ostlist.op_count) {
+ for (j = 0; j < llc->llc_ostlist.op_count; j++)
+ llc->llc_ostlist.op_array[j] = -1;
+ llc->llc_ostlist.op_count = 0;
}
}
}
static inline bool lod_need_inherit_more(struct lod_object *lo, bool from_root,
- char *append_pool)
+ const char *append_pool)
{
struct lod_layout_component *lod_comp;
LASSERT(child);
- if (ah->dah_append_stripes == -1)
- ah->dah_append_stripes =
+ if (ah->dah_append_stripe_count == -1)
+ ah->dah_append_stripe_count =
d->lod_ost_descs.ltd_lov_desc.ld_tgt_count;
if (likely(parent)) {
LASSERT(!lc->ldo_is_composite);
lod_comp = &lc->ldo_comp_entries[0];
desc = &d->lod_ost_descs.ltd_lov_desc;
- lod_adjust_stripe_info(lod_comp, desc, ah->dah_append_stripes);
+ lod_adjust_stripe_info(lod_comp, desc,
+ ah->dah_append_stripe_count);
if (ah->dah_append_pool && ah->dah_append_pool[0])
lod_obj_set_pool(lc, 0, ah->dah_append_pool);
}
remote_mds_nodsh && skip "remote MDS with nodsh"
[[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
- test_mkdir $DIR/$tdir
-
# Set default striping on directory
local setcount=4
local stripe_opt
+ local mdts=$(comma_list $(mdts_nodes))
# if we run against a 2.12 server which lacks overstring support
# then the connect_flag will not report overstriping, even if client
else
skip "server does not support overstriping"
fi
+
+ test_mkdir $DIR/$tdir
+
+ # Validate existing append_* params and ensure restore
+ local pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
+ [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
+ stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
+
+ local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
+ ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count"
+ stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1"
+
$LFS setstripe $stripe_opt $DIR/$tdir
echo 1 > $DIR/$tdir/${tfile}.1
[ $count -eq $setcount ] ||
error "(1) stripe count $count, should be $setcount"
- # Capture existing append_stripe_count setting for restore
- local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
- local mdts=$(comma_list $(mdts_nodes))
- stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
-
local appendcount=$orig_count
echo 1 >> $DIR/$tdir/${tfile}.2_append
count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
error "(9) stripe count $count, should be $appendcount for append"
# Now test O_APPEND striping with pools
- do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
- stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
-
- # Create the pool
pool_add $TESTNAME || error "pool creation failed"
pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
+ do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
echo 1 >> $DIR/$tdir/${tfile}.10_append
}
run_test 27T "no eio on close on partial write due to enosp"
+test_27U() {
+ local dir=$DIR/$tdir
+ local file=$dir/$tfile
+ local append_pool=${TESTNAME}-append
+ local normal_pool=${TESTNAME}-normal
+ local pool
+ local stripe_count
+ local stripe_count2
+ local mdts=$(comma_list $(mdts_nodes))
+
+ # FIMXE
+ # (( $MDS1_VERSION >= $(version_code 2.15.42) )) ||
+ # skip "Need MDS version at least 2.15.42"
+
+ # Validate existing append_* params and ensure restore
+ pool=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_pool)
+ [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'"
+ stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none"
+
+ stripe_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
+ ((stripe_count == 1)) || error "expected append_stripe_count != 0, got $stripe_count"
+ stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$stripe_count"
+
+ pool_add $append_pool || error "pool creation failed"
+ pool_add_targets $append_pool 0 1 || error "Pool add targets failed"
+
+ pool_add $normal_pool || error "pool creation failed"
+ pool_add_targets $normal_pool 0 1 || error "Pool add targets failed"
+
+ test_mkdir $dir
+ $LFS setstripe -E 1M -c 1 -p $normal_pool -E 2M -c 2 -p $normal_pool -E eof -c -1 $dir
+
+ echo XXX >> $file.1
+ $LFS getstripe $file.1
+
+ pool=$($LFS getstripe -p $file.1)
+ [[ "$pool" == "$normal_pool" ]] || error "got pool '$pool', expected '$normal_pool'"
+
+ stripe_count2=$($LFS getstripe -c $file.1)
+ ((stripe_count2 == stripe_count)) ||
+ error "got stripe_count '$stripe_count2', expected '$stripe_count'"
+
+ do_nodes $mdts $LCTL set_param mdd.*.append_pool=$append_pool
+
+ echo XXX >> $file.2
+ $LFS getstripe $file.2
+
+ pool=$($LFS getstripe -p $file.2)
+ [[ "$pool" == "$append_pool" ]] || error "got pool '$pool', expected '$append_pool'"
+
+ do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
+
+ echo XXX >> $file.3
+ $LFS getstripe $file.3
+
+ stripe_count2=$($LFS getstripe -c $file.3)
+ ((stripe_count2 == 2)) || error "got stripe_count '$stripe_count2', expected 2"
+}
+run_test 27U "append pool and stripe count work with composite default layout"
+
# createtest also checks that device nodes are created and
# then visible correctly (#2091)
test_28() { # bug 2091