*/
static int lod_insert(const struct lu_env *env, struct dt_object *dt,
const struct dt_rec *rec, const struct dt_key *key,
- struct thandle *th, int ign)
+ struct thandle *th)
{
- return lod_sub_insert(env, dt_object_child(dt), rec, key, th, ign);
+ return lod_sub_insert(env, dt_object_child(dt), rec, key, th);
}
/**
return rc;
}
- filter_fid_le_to_cpu(ff, ff, sizeof(*ff));
-
/*
- * mdd_declare_migrate_create() declares this via source object because
- * target is not ready yet, so declare anyway.
+ * locd_buf is set if it's called by dir migration, which doesn't check
+ * pfid and comp id.
*/
- if (!data->locd_declare &&
- lu_fid_eq(lu_object_fid(&lo->ldo_obj.do_lu), &ff->ff_parent) &&
- ff->ff_layout.ol_comp_id == comp->llc_id)
- return 0;
+ if (data->locd_buf) {
+ memset(ff, 0, sizeof(*ff));
+ ff->ff_parent = *(struct lu_fid *)data->locd_buf->lb_buf;
+ } else {
+ filter_fid_le_to_cpu(ff, ff, sizeof(*ff));
+
+ if (lu_fid_eq(lod_object_fid(lo), &ff->ff_parent) &&
+ ff->ff_layout.ol_comp_id == comp->llc_id)
+ return 0;
+
+ memset(ff, 0, sizeof(*ff));
+ ff->ff_parent = *lu_object_fid(&lo->ldo_obj.do_lu);
+ }
/* rewrite filter_fid */
- memset(ff, 0, sizeof(*ff));
- ff->ff_parent = *lu_object_fid(&lo->ldo_obj.do_lu);
ff->ff_parent.f_ver = stripe_idx;
ff->ff_layout.ol_stripe_size = comp->llc_stripe_size;
ff->ff_layout.ol_stripe_count = comp->llc_stripe_count;
*/
static int lod_replace_parent_fid(const struct lu_env *env,
struct dt_object *dt,
+ const struct lu_buf *buf,
struct thandle *th, bool declare)
{
struct lod_object *lo = lod_dt_obj(dt);
struct lod_thread_info *info = lod_env_info(env);
- struct lu_buf *buf = &info->lti_buf;
struct filter_fid *ff;
struct lod_obj_stripe_cb_data data = { { 0 } };
int rc;
RETURN(rc);
}
- buf->lb_buf = info->lti_ea_store;
- buf->lb_len = info->lti_ea_store_size;
-
data.locd_declare = declare;
data.locd_stripe_cb = lod_obj_stripe_replace_parent_fid_cb;
+ data.locd_buf = buf;
rc = lod_obj_for_each_stripe(env, lo, th, &data);
RETURN(rc);
for (i = 0; i < comp_v1->lcm_entry_count; i++) {
__u32 id = comp_v1->lcm_entries[i].lcme_id;
__u32 flags = comp_v1->lcm_entries[i].lcme_flags;
+ __u32 mirror_flag = flags & LCME_MIRROR_FLAGS;
+ bool neg = flags & LCME_FL_NEG;
if (flags & LCME_FL_INIT) {
if (changed)
RETURN(-EINVAL);
}
+ flags &= ~(LCME_MIRROR_FLAGS | LCME_FL_NEG);
for (j = 0; j < lo->ldo_comp_cnt; j++) {
lod_comp = &lo->ldo_comp_entries[j];
- if (id != lod_comp->llc_id)
+
+ /* lfs only put one flag in each entry */
+ if ((flags && id != lod_comp->llc_id) ||
+ (mirror_flag && mirror_id_of(id) !=
+ mirror_id_of(lod_comp->llc_id)))
continue;
- if (flags & LCME_FL_NEG) {
- flags &= ~LCME_FL_NEG;
- lod_comp->llc_flags &= ~flags;
+ if (neg) {
+ if (flags)
+ lod_comp->llc_flags &= ~flags;
+ if (mirror_flag)
+ lod_comp->llc_flags &= ~mirror_flag;
} else {
- lod_comp->llc_flags |= flags;
+ if (flags)
+ lod_comp->llc_flags |= flags;
+ if (mirror_flag) {
+ lod_comp->llc_flags |= mirror_flag;
+ if (mirror_flag & LCME_FL_NOSYNC)
+ lod_comp->llc_timestamp =
+ ktime_get_real_seconds();
+ }
}
changed = true;
}
rc = lod_dir_declare_layout_add(env, dt, buf, th);
else if (strcmp(op, "del") == 0)
rc = lod_dir_declare_layout_delete(env, dt, buf, th);
+ else if (strcmp(op, "set") == 0)
+ rc = lod_sub_declare_xattr_set(env, next, buf,
+ XATTR_NAME_LMV, fl, th);
RETURN(rc);
} else if (S_ISDIR(mode)) {
rc = lod_dir_declare_xattr_set(env, dt, buf, name, fl, th);
} else if (strcmp(name, XATTR_NAME_FID) == 0) {
- rc = lod_replace_parent_fid(env, dt, th, true);
+ rc = lod_replace_parent_fid(env, dt, buf, th, true);
} else {
rc = lod_sub_declare_xattr_set(env, next, buf, name, fl, th);
}
rec->rec_fid = lu_object_fid(&dto->do_lu);
rc = lod_sub_insert(env, dto,
(const struct dt_rec *)rec,
- (const struct dt_key *)dot, th, 0);
+ (const struct dt_key *)dot, th);
if (rc != 0)
GOTO(out, rc);
}
rec->rec_fid = lu_object_fid(&dt->do_lu);
rc = lod_sub_insert(env, dto, (struct dt_rec *)rec,
- (const struct dt_key *)dotdot, th, 0);
+ (const struct dt_key *)dotdot, th);
if (rc != 0)
GOTO(out, rc);
rec->rec_fid = lu_object_fid(&dto->do_lu);
rc = lod_sub_insert(env, dt_object_child(dt),
(const struct dt_rec *)rec,
- (const struct dt_key *)stripe_name, th, 0);
+ (const struct dt_key *)stripe_name, th);
if (rc != 0)
GOTO(out, rc);
const char *op = name + strlen(XATTR_NAME_LMV) + 1;
rc = -ENOTSUPP;
- if (strcmp(op, "del") == 0)
- rc = lod_dir_layout_delete(env, dt, buf, th);
/*
* XATTR_NAME_LMV".add" is never called, but only declared,
* because lod_xattr_set_lmv() will do the addition.
*/
+ if (strcmp(op, "del") == 0)
+ rc = lod_dir_layout_delete(env, dt, buf, th);
+ else if (strcmp(op, "set") == 0)
+ rc = lod_sub_xattr_set(env, next, buf, XATTR_NAME_LMV,
+ fl, th);
RETURN(rc);
} else if (S_ISDIR(dt->do_lu.lo_header->loh_attr) &&
}
RETURN(rc);
} else if (strcmp(name, XATTR_NAME_FID) == 0) {
- rc = lod_replace_parent_fid(env, dt, th, false);
+ rc = lod_replace_parent_fid(env, dt, buf, th, false);
RETURN(rc);
}
for (i = 0; i < comp_cnt; i++) {
struct lod_layout_component *lod_comp;
- struct lu_extent *ext;
char *pool;
lod_comp = &lds->lds_def_comp_entries[i];
if (composite) {
v1 = (struct lov_user_md *)((char *)comp_v1 +
comp_v1->lcm_entries[i].lcme_offset);
- ext = &comp_v1->lcm_entries[i].lcme_extent;
- lod_comp->llc_extent = *ext;
+ 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 &
+ LCME_TEMPLATE_FLAGS;
}
if (v1->lmm_pattern != LOV_PATTERN_RAID0 &&
struct lod_layout_component *def_comp =
&lds->lds_def_comp_entries[i];
- CDEBUG(D_LAYOUT, "Inherite from default: size:%hu "
- "nr:%u offset:%u pattern %#x %s\n",
+ CDEBUG(D_LAYOUT, "Inherit from default: flags=%#x "
+ "size=%hu nr=%u offset=%u pattern=%#x pool=%s\n",
+ def_comp->llc_flags,
def_comp->llc_stripe_size,
def_comp->llc_stripe_count,
def_comp->llc_stripe_offset,
dlmflags |= LDLM_FL_COS_INCOMPAT;
LASSERT(ns != NULL);
- rc = ldlm_cli_enqueue_local(ns, res_id, LDLM_IBITS,
+ rc = ldlm_cli_enqueue_local(env, ns, res_id, LDLM_IBITS,
policy, einfo->ei_mode,
&dlmflags, blocking,
completion, NULL,
*/
static ssize_t lod_write(const struct lu_env *env, struct dt_object *dt,
const struct lu_buf *buf, loff_t *pos,
- struct thandle *th, int iq)
+ struct thandle *th)
{
LASSERT(S_ISREG(dt->do_lu.lo_header->loh_attr) ||
S_ISLNK(dt->do_lu.lo_header->loh_attr));
- return lod_sub_write(env, dt_object_child(dt), buf, pos, th, iq);
+ return lod_sub_write(env, dt_object_child(dt), buf, pos, th);
}
static int lod_declare_punch(const struct lu_env *env, struct dt_object *dt,