@@ -288,6 +288,8 @@ struct cl_layout {
size_t cl_size;
/** Layout generation. */
u32 cl_layout_gen;
+ /** whether layout is a composite one */
+ bool cl_is_composite;
};
/**
@@ -1551,6 +1551,7 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file,
{
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ struct cl_object *obj = lli->lli_clob;
struct ll_grouplock grouplock;
int rc;
@@ -1572,6 +1573,31 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file,
LASSERT(!fd->fd_grouplock.lg_lock);
spin_unlock(&lli->lli_lock);
+ /**
+ * XXX: group lock needs to protect all OST objects while PFL
+ * can add new OST objects during the IO, so we'd instantiate
+ * all OST objects before getting its group lock.
+ */
+ if (obj) {
+ struct cl_layout cl = {
+ .cl_is_composite = false,
+ };
+ struct lu_env *env;
+ u16 refcheck;
+
+ env = cl_env_get(&refcheck);
+ if (IS_ERR(env))
+ return PTR_ERR(env);
+
+ rc = cl_object_layout_get(env, obj, &cl);
+ if (!rc && cl.cl_is_composite)
+ rc = ll_layout_write_intent(inode, 0, OBD_OBJECT_EOF);
+
+ cl_env_put(env, &refcheck);
+ if (rc)
+ return rc;
+ }
+
rc = cl_get_grouplock(ll_i2info(inode)->lli_clob,
arg, (file->f_flags & O_NONBLOCK), &grouplock);
if (rc)
@@ -1637,6 +1637,7 @@ static int lov_object_layout_get(const struct lu_env *env,
cl->cl_size = lov_comp_md_size(lsm);
cl->cl_layout_gen = lsm->lsm_layout_gen;
+ cl->cl_is_composite = lsm_is_composite(lsm->lsm_magic);
rc = lov_lsm_pack(lsm, buf->lb_buf, buf->lb_len);
lov_lsm_put(lsm);