if (stripes == LOV_ALL_STRIPES)
stripes = 0;
- if (lmm_magic == LOV_MAGIC_V3)
- return sizeof(struct lov_mds_md_v3) +
- stripes * sizeof(struct lov_ost_data_v1);
- else
+ if (lmm_magic == LOV_MAGIC_V1)
return sizeof(struct lov_mds_md_v1) +
stripes * sizeof(struct lov_ost_data_v1);
+ else /* LOV_MAGIC_V3 and LOV_MAGIC_SPECIFIC */
+ return sizeof(struct lov_mds_md_v3) +
+ stripes * sizeof(struct lov_ost_data_v1);
}
static inline __u32
int lod_init_comp_foreign(struct lod_layout_component *lod_comp, void *lmm);
/* lod_pool.c */
-struct lod_pool_desc *lod_find_pool(struct lod_device *lod, char *poolname);
+struct lod_pool_desc *lod_find_pool(struct lod_device *lod, const char *poolname);
void lod_pool_putref(struct lod_pool_desc *pool);
int lod_pool_del(struct obd_device *obd, char *poolname);
int lod_check_index_in_pool(__u32 idx, struct lod_pool_desc *pool);
const struct lu_buf *);
int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo,
const struct lu_buf *buf);
+void lod_qos_set_pool(struct lod_object *lo, int pos, const char *pool_name);
int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
struct lu_attr *attr, struct thandle *th,
int comp_idx, __u64 reserve);
char **poolname);
void lod_spill_target_refresh(const struct lu_env *env, struct lod_device *lod,
struct lod_pool_desc *pool);
-struct lod_pool_desc *lod_pool_find(struct lod_device *lod, char *poolname);
+struct lod_pool_desc *lod_pool_find(struct lod_device *lod, const char *poolname);
int lod_tgt_weights_seq_show(struct seq_file *m, struct lod_device *lod,
struct lu_tgt_pool *tgts, bool mdt);
int lod_tgt_weights_seq_write(struct seq_file *m, const char __user *buf,
lod_comp = &lo->ldo_comp_entries[comp_idx];
magic = lod_comp->llc_pool != NULL ? LOV_MAGIC_V3 : LOV_MAGIC_V1;
+ if (is_dir && lod_comp->llc_ostlist.op_count)
+ magic = LOV_MAGIC_SPECIFIC;
+
if (lod_comp->llc_pattern == 0) /* default striping */
lod_comp->llc_pattern = LOV_PATTERN_RAID0;
} else {
struct lov_mds_md_v3 *v3 = (struct lov_mds_md_v3 *)lmm;
size_t cplen = strscpy(v3->lmm_pool_name,
- lod_comp->llc_pool,
+ lod_comp->llc_pool ? : "\0",
sizeof(v3->lmm_pool_name));
if (cplen < 0)
RETURN(cplen);
if (!is_dir && lo->ldo_is_composite)
lod_comp_shrink_stripe_count(lod_comp, &stripe_count);
- if (is_dir || lod_comp->llc_pattern & LOV_PATTERN_F_RELEASED)
+ if ((is_dir && magic != LOV_MAGIC_SPECIFIC) ||
+ lod_comp->llc_pattern & LOV_PATTERN_F_RELEASED)
GOTO(done, rc = 0);
/* generate ost_idx of this component stripe */
struct lod_layout_component *entry;
enum lod_uses_hint flags = LOD_USES_ASSIGNED_STRIPE;
- if (is_dir)
- return 0;
+ if (is_dir) {
+ entry = &lo->ldo_def_striping->lds_def_comp_entries[comp_idx];
+ return entry->llc_ostlist.op_count;
+ }
entry = &lo->ldo_comp_entries[comp_idx];
if (lod_comp_inited(entry))
if (!is_dir && is_composite)
lod_comp_shrink_stripe_count(&comp_entries[i],
&stripe_count);
+ if (is_dir && comp_entries[i].llc_ostlist.op_count)
+ magic = LOV_MAGIC_SPECIFIC;
size += lov_user_md_size(stripe_count, magic);
}
lod_comp->llc_stripe_offset =
def_comp->llc_stripe_offset;
if (lod_comp->llc_pool == NULL)
- lod_obj_set_pool(lc, 0, def_comp->llc_pool);
+ lod_qos_set_pool(lc, 0, def_comp->llc_pool);
}
}
out:
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);
+ lod_qos_set_pool(lc, 0, ah->dah_append_pool);
}
EXIT;
return pool != NULL;
}
-struct lod_pool_desc *lod_pool_find(struct lod_device *lod, char *poolname)
+struct lod_pool_desc *lod_pool_find(struct lod_device *lod, const char *poolname)
{
struct lod_pool_desc *pool;
* \retval pointer to pool descriptor on success
* \retval NULL if \a poolname could not be found or poolname is empty
*/
-struct lod_pool_desc *lod_find_pool(struct lod_device *lod, char *poolname)
+struct lod_pool_desc *lod_find_pool(struct lod_device *lod, const char *poolname)
{
struct lod_pool_desc *pool;
RETURN(rc);
}
-static void lod_qos_set_pool(struct lod_object *lo, int pos, char *pool_name,
- struct lov_user_md_v1 *v1)
+void lod_qos_set_pool(struct lod_object *lo, int pos, const char *pool_name)
{
struct lod_device *d = lu2lod_dev(lod2lu_obj(lo)->lo_dev);
struct lod_layout_component *lod_comp;
if (pool_name)
pool = lod_find_pool(d, pool_name);
- if (!pool)
- goto out_setpool;
+ if (!pool) {
+ lod_obj_set_pool(lo, pos, pool_name);
+ return;
+ }
lod_comp = &lo->ldo_comp_entries[pos];
- if (lod_comp->llc_stripe_offset == LOV_OFFSET_DEFAULT)
- goto out_checkcount;
-
- if (v1->lmm_magic == LOV_USER_MAGIC_SPECIFIC) {
- struct lov_user_md_v3 *v3;
-
- v3 = (struct lov_user_md_v3 *)v1;
- for (j = 0; j < v3->lmm_stripe_count; j++) {
- idx = lod_comp->llc_ostlist.op_array[j];
+ if (lod_comp->llc_stripe_offset != LOV_OFFSET_DEFAULT) {
+ if (lod_comp->llc_ostlist.op_count) {
+ for (j = 0; j < lod_comp->llc_ostlist.op_count; j++) {
+ idx = lod_comp->llc_ostlist.op_array[j];
+ rc = lod_check_index_in_pool(idx, pool);
+ if (rc)
+ break;
+ }
+ } else {
+ idx = lod_comp->llc_stripe_offset;
rc = lod_check_index_in_pool(idx, pool);
- if (rc)
- break;
}
- } else {
- idx = lod_comp->llc_stripe_offset;
- rc = lod_check_index_in_pool(idx, pool);
- }
-
- if (!rc)
- goto out_checkcount;
- CDEBUG(D_LAYOUT,
- "%s: index %u is not in the pool %s, dropping the pool\n",
- lod2obd(d)->obd_name, idx, pool_name);
- pool_name = NULL;
- goto out_putref;
+ if (rc) {
+ CDEBUG(D_LAYOUT, "%s: index %u is not in the pool %s, "
+ "dropping the pool\n", lod2obd(d)->obd_name,
+ idx, pool_name);
+ pool_name = NULL;
+ }
+ }
-out_checkcount:
- if (lod_comp->llc_stripe_count > pool_tgt_count(pool) &&
+ if (pool_name &&
+ lod_comp->llc_stripe_count > pool_tgt_count(pool) &&
!(lod_comp->llc_pattern & LOV_PATTERN_OVERSTRIPING))
lod_comp->llc_stripe_count = pool_tgt_count(pool);
-out_putref:
+
lod_pool_putref(pool);
-out_setpool:
lod_obj_set_pool(lo, pos, pool_name);
-
}
/**
lod_comp->llc_stripe_size);
lod_comp->llc_stripe_offset = v1->lmm_stripe_offset;
- lod_qos_set_pool(lo, i, pool_name, v1);
+ lod_qos_set_pool(lo, i, pool_name);
}
RETURN(0);
}
run_test 27I "check that root dir striping does not break parent dir one"
+test_27Ia() {
+ (( $MDS1_VERSION >= $(version_code 2.15.61.225) )) ||
+ skip "need MDS >= 2.15.61.255 for pool inheritance fix"
+
+ (( $OSTCOUNT >= 2 )) || skip_env "needs >= 2 OSTs"
+
+ save_layout_restore_at_exit $MOUNT
+ pool_add $TESTNAME || error "pool_add failed"
+ pool_add_targets $TESTNAME 1 || error "pool_add_targets failed"
+
+ $LFS setstripe -p $TESTNAME $MOUNT
+
+ test_mkdir $DIR/$tdir
+ $LFS setstripe -i0 $DIR/$tdir
+ $MULTIOP $DIR/$tdir/$tfile.1 Oc || error_noexit "multiop failed"
+ $LFS getstripe $DIR/$tdir/$tfile.1
+
+ $LFS setstripe -d $DIR/$tdir
+ $LFS setstripe -o 0,1 $DIR/$tdir
+ $MULTIOP $DIR/$tdir/$tfile.2 Oc || error_noexit "multiop failed"
+ $LFS getstripe $DIR/$tdir/$tfile.2
+
+ test_mkdir $DIR/$tdir/d1
+ $MULTIOP $DIR/$tdir/d1/$tfile.3 Oc || error_noexit "multiop failed"
+ $LFS getstripe $DIR/$tdir/d1/$tfile.3
+
+ $LFS setstripe -d $DIR/$tdir
+ $LFS setstripe -E 128G -o 0,1 -E-1 $DIR/$tdir
+ test_mkdir $DIR/$tdir/d2
+ $MULTIOP $DIR/$tdir/d2/$tfile.4 Oc || error_noexit "multiop failed"
+ $LFS getstripe $DIR/$tdir/d2/$tfile.4
+}
+run_test 27Ia "check that root dir pool is dropped with conflict parent dir settings"
+
test_27J() {
(( $MDS1_VERSION > $(version_code 2.12.51) )) ||
skip "Need MDS version newer than 2.12.51"
echo "Adding targets to pool"
local pool=$1
local first=$2
- local last=$3
+ local last=${3:-$first}
local step=${4:-1}
- if [ -z $last ]; then
- local list=$first
- last=$first
- else
- local list=$(seq $first $step $last)
- fi
+ local list=$(seq $first $step $last)
local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
local tg=$(for i in $list;