* VFS and page cache already protect us locally, so lots of readers/
* writers can share a single PW lock. */
mode = mdc_dom_lock_match(env, osc_export(obj), resname, LDLM_IBITS,
- policy, LCK_PR | LCK_PW, &flags, obj, &lockh,
+ policy, LCK_PR | LCK_PW | LCK_GROUP, &flags,
+ obj, &lockh,
dap_flags & OSC_DAP_FL_CANCELING);
if (mode != 0) {
lock = ldlm_handle2lock(&lockh);
return mdd_lmm_gen(lmm, gen, false);
}
+static inline __u64 mdd_lmm_dom_size(void *buf)
+{
+ struct lov_mds_md *lmm = buf;
+ struct lov_comp_md_v1 *comp_v1;
+ struct lov_mds_md *v1;
+ __u32 off;
+
+ if (lmm == NULL)
+ return 0;
+
+ if (le32_to_cpu(lmm->lmm_magic) != LOV_MAGIC_COMP_V1)
+ return 0;
+
+ comp_v1 = (struct lov_comp_md_v1 *)lmm;
+ off = le32_to_cpu(comp_v1->lcm_entries[0].lcme_offset);
+ v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
+
+ /* DoM entry is the first entry always */
+ if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) == LOV_PATTERN_MDT)
+ return le64_to_cpu(comp_v1->lcm_entries[0].lcme_extent.e_end);
+
+ return 0;
+}
+
/**
* swap layouts between 2 lustre objects
*/
if (rc < 0 && rc != -ENODATA)
GOTO(stop, rc);
+ /* check if file is DoM, it can be migrated only to another DoM layout
+ * with the same DoM component size
+ */
+ if (mdd_lmm_dom_size(fst_buf->lb_buf) !=
+ mdd_lmm_dom_size(snd_buf->lb_buf)) {
+ rc = -EOPNOTSUPP;
+ CDEBUG(D_LAYOUT, "cannot swap layout for "DFID": new layout "
+ "must have the same DoM component: rc = %d\n",
+ PFID(mdo2fid(fst_o)), rc);
+ GOTO(stop, rc);
+ }
+
/* swapping 2 non existant layouts is a success */
if (fst_buf->lb_buf == NULL && snd_buf->lb_buf == NULL)
GOTO(stop, rc = 0);