}
static inline void lod_adjust_stripe_info(struct lod_layout_component *comp,
- struct lov_desc *desc)
+ struct lov_desc *desc,
+ int append_stripes)
{
if (comp->llc_pattern != LOV_PATTERN_MDT) {
- if (!comp->llc_stripe_count)
+ if (append_stripes) {
+ comp->llc_stripe_count = append_stripes;
+ } else if (!comp->llc_stripe_count) {
comp->llc_stripe_count =
desc->ld_default_stripe_count;
+ }
}
if (comp->llc_stripe_size <= 0)
comp->llc_stripe_size = desc->ld_default_stripe_size;
continue;
tgt_dt = tgt->ltd_tgt;
- rc = dt_statfs(env, tgt_dt, &info->lti_osfs, NULL);
+ rc = dt_statfs(env, tgt_dt, &info->lti_osfs);
if (rc) {
/* this OSP doesn't feel well */
rc = 0;
lod_comp->llc_stripe_count = v1->lmm_stripe_count;
lod_comp->llc_stripe_size = v1->lmm_stripe_size;
- lod_adjust_stripe_info(lod_comp, desc);
+ lod_adjust_stripe_info(lod_comp, desc, 0);
if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
v3 = (struct lov_user_md_v3 *) v1;
struct lov_comp_md_v1 *cur_lcm;
struct lov_comp_md_v1 *merge_lcm;
struct lov_comp_md_entry_v1 *lcme;
+ struct lov_mds_md_v1 *lmm;
size_t size = 0;
size_t offset;
__u16 cur_entry_count;
__u16 mirror_id = 0;
__u32 mirror_count;
int rc, i;
+ bool merge_has_dom;
+
ENTRY;
merge_lcm = mbuf->lb_buf;
}
mirror_id = mirror_id_of(id) + 1;
+
+ /* check if first entry in new layout is DOM */
+ lmm = (struct lov_mds_md_v1 *)((char *)merge_lcm +
+ merge_lcm->lcm_entries[0].lcme_offset);
+ merge_has_dom = lov_pattern(le32_to_cpu(lmm->lmm_pattern)) ==
+ LOV_PATTERN_MDT;
+
for (i = 0; i < merge_entry_count; i++) {
struct lov_comp_md_entry_v1 *merge_lcme;
*lcme = *merge_lcme;
lcme->lcme_offset = cpu_to_le32(offset);
+ if (merge_has_dom && i == 0)
+ lcme->lcme_flags |= cpu_to_le32(LCME_FL_STALE);
id = pflr_id(mirror_id, i + 1);
lcme->lcme_id = cpu_to_le32(id);
/* if it's source stripe of migrating directory, don't create */
if (!((lo->ldo_dir_hash_type & LMV_HASH_FLAG_MIGRATION) &&
i >= lo->ldo_dir_migrate_offset)) {
- dt_write_lock(env, dto, MOR_TGT_CHILD);
+ dt_write_lock(env, dto, DT_TGT_CHILD);
rc = lod_sub_create(env, dto, attr, NULL, dof, th);
if (rc != 0) {
dt_write_unlock(env, dto);
ENTRY;
+ LASSERT(lo->ldo_is_composite);
+ LASSERT(lo->ldo_comp_cnt > 0 && lo->ldo_comp_entries != NULL);
+
rc = lod_layout_data_init(info, lo->ldo_comp_cnt);
if (rc)
RETURN(rc);
struct lu_attr *attr = &lod_env_info(env)->lti_attr;
int rc;
- LASSERT(lo->ldo_is_composite);
LASSERT(lo->ldo_mirror_count == 1);
- LASSERT(lo->ldo_comp_cnt > 0 && lo->ldo_comp_entries != NULL);
rc = lod_layout_del_prep_layout(env, lo, th);
if (rc < 0)
static int lod_get_default_lov_striping(const struct lu_env *env,
struct lod_object *lo,
- struct lod_default_striping *lds);
+ struct lod_default_striping *lds,
+ struct dt_allocation_hint *ah);
/**
* Implementation of dt_object_operations::do_xattr_set.
*
bool is_del;
/* get existing striping config */
- rc = lod_get_default_lov_striping(env, lod_dt_obj(dt), lds);
+ rc = lod_get_default_lov_striping(env, lod_dt_obj(dt), lds,
+ NULL);
if (rc)
RETURN(rc);
if (!S_ISDIR(dt->do_lu.lo_header->loh_attr))
RETURN(0);
- /* set xattr to each stripes, if needed */
+ /* NB: don't delete stripe LMV, because when we do this, normally we
+ * will remove stripes, besides, if directory LMV is corrupt, this will
+ * prevent deleting its LMV and fixing it (via LFSCK).
+ */
+ if (!strcmp(name, XATTR_NAME_LMV))
+ RETURN(0);
+
rc = lod_striping_load(env, lo);
if (rc != 0)
RETURN(rc);
if (rc != 0 || !S_ISDIR(dt->do_lu.lo_header->loh_attr))
RETURN(rc);
+ if (!strcmp(name, XATTR_NAME_LMV))
+ RETURN(0);
+
if (lo->ldo_dir_stripe_count == 0)
RETURN(0);
*/
static int lod_get_default_lov_striping(const struct lu_env *env,
struct lod_object *lo,
- struct lod_default_striping *lds)
+ struct lod_default_striping *lds,
+ struct dt_allocation_hint *ah)
{
struct lod_thread_info *info = lod_env_info(env);
struct lov_user_md_v1 *v1 = NULL;
v1->lmm_magic != LOV_USER_MAGIC_SPECIFIC)
RETURN(-ENOTSUPP);
- if (v1->lmm_magic == LOV_MAGIC_COMP_V1 ||
- v1->lmm_magic == LOV_MAGIC_SEL) {
+ 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);
}
- CDEBUG(D_LAYOUT, DFID" stripe_count=%d stripe_size=%d "
- "stripe_offset=%d\n",
+ 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);
+ (int)v1->lmm_stripe_offset,
+ ah ? ah->dah_append_stripes : 0);
- lod_comp->llc_stripe_count = v1->lmm_stripe_count;
+ 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;
pool = NULL;
- if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
+ if (ah && ah->dah_append_pool && ah->dah_append_pool[0]) {
+ pool = ah->dah_append_pool;
+ } else if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
/* XXX: sanity check here */
v3 = (struct lov_user_md_v3 *) v1;
if (v3->lmm_pool_name[0] != '\0')
{
int rc, rc1;
- rc = lod_get_default_lov_striping(env, lo, lds);
+ rc = lod_get_default_lov_striping(env, lo, lds, NULL);
rc1 = lod_get_default_lmv_striping(env, lo, lds);
if (rc == 0 && rc1 < 0)
rc = rc1;
if (!lo->ldo_is_composite)
continue;
- lod_adjust_stripe_info(obj_comp, desc);
+ lod_adjust_stripe_info(obj_comp, desc, 0);
}
} else if (lds->lds_dir_def_striping_set && S_ISDIR(mode)) {
if (lo->ldo_dir_stripe_count == 0)
}
}
-static inline bool lod_need_inherit_more(struct lod_object *lo, bool from_root)
+static inline bool lod_need_inherit_more(struct lod_object *lo, bool from_root,
+ char *append_pool)
{
struct lod_layout_component *lod_comp;
lod_comp->llc_stripe_offset == LOV_OFFSET_DEFAULT))
return true;
+ if (append_pool && append_pool[0])
+ return true;
+
return false;
}
LASSERT(child);
+ if (ah->dah_append_stripes == -1)
+ ah->dah_append_stripes = d->lod_desc.ld_tgt_count;
+
if (likely(parent)) {
nextp = dt_object_child(parent);
lp = lod_dt_obj(parent);
* Try from the parent first.
*/
if (likely(lp != NULL)) {
- rc = lod_get_default_lov_striping(env, lp, lds);
+ rc = lod_get_default_lov_striping(env, lp, lds, ah);
if (rc == 0)
lod_striping_from_default(lc, lds, child_mode);
}
* - parent has plain(v1/v3) default layout, and some attributes
* are not specified in the default layout;
*/
- if (d->lod_md_root != NULL && lod_need_inherit_more(lc, true)) {
- rc = lod_get_default_lov_striping(env, d->lod_md_root, lds);
+ if (d->lod_md_root != NULL &&
+ lod_need_inherit_more(lc, true, ah->dah_append_pool)) {
+ rc = lod_get_default_lov_striping(env, d->lod_md_root, lds,
+ ah);
if (rc)
goto out;
if (lc->ldo_comp_cnt == 0) {
* fs default striping may not be explicitly set, or historically set
* in config log, use them.
*/
- if (lod_need_inherit_more(lc, false)) {
+ if (lod_need_inherit_more(lc, false, ah->dah_append_pool)) {
if (lc->ldo_comp_cnt == 0) {
rc = lod_alloc_comp_entries(lc, 0, 1);
if (rc)
LASSERT(!lc->ldo_is_composite);
lod_comp = &lc->ldo_comp_entries[0];
desc = &d->lod_desc;
- lod_adjust_stripe_info(lod_comp, desc);
+ lod_adjust_stripe_info(lod_comp, desc, ah->dah_append_stripes);
+ if (ah->dah_append_pool && ah->dah_append_pool[0])
+ lod_obj_set_pool(lc, 0, ah->dah_append_pool);
}
EXIT;
struct lod_tgt_descs *ltd;
struct lod_tgt_desc *tgt = NULL;
bool found_mdt = false;
- int i;
lod = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
ltd = &lod->lod_mdt_descs;
- cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
- tgt = LTD_TGT(ltd, i);
+ ltd_foreach_tgt(ltd, tgt) {
if (tgt->ltd_index ==
lo->ldo_dir_stripe_offset) {
found_mdt = true;
if (!OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_SPEOBJ) ||
i == cfs_fail_val) {
- dt_write_lock(env, stripe, MOR_TGT_CHILD);
+ dt_write_lock(env, stripe, DT_TGT_CHILD);
rc = lod_sub_ref_del(env, stripe, th);
dt_write_unlock(env, stripe);
if (rc != 0)
break;
}
- rc = dt_statfs(env, ost->ltd_ost, sfs, &info);
+ rc = dt_statfs_info(env, ost->ltd_ost, sfs, &info);
if (rc) {
CDEBUG(D_LAYOUT, "statfs failed for ost %d, error %d\n",
index, rc);