From: Mikhail Pershin Date: Wed, 18 Apr 2018 07:17:10 +0000 (+0300) Subject: LU-10910 mdd: deny layout swap for DoM file X-Git-Tag: 2.11.52~39 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=51c11d7cfaffea68cc527f3001af1d11b3967c15 LU-10910 mdd: deny layout swap for DoM file Layout swap is prohibited for DoM files until LU-10177 will be implemented. The only exception is the new layout having the same DoM component. Signed-off-by: Mikhail Pershin Change-Id: I8b9deaea7aab0d5694a4c5d9fe2f9f36d2cdd382 Reviewed-on: https://review.whamcloud.com/32044 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdc/mdc_dev.c b/lustre/mdc/mdc_dev.c index 3672ed1..14b0e65 100644 --- a/lustre/mdc/mdc_dev.c +++ b/lustre/mdc/mdc_dev.c @@ -151,7 +151,8 @@ again: * 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); diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 8f9085c..7f73595 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -2151,6 +2151,30 @@ static inline int mdd_set_lmm_gen(struct lov_mds_md *lmm, __u32 *gen) 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 */ @@ -2217,6 +2241,18 @@ static int mdd_swap_layouts(const struct lu_env *env, struct md_object *obj1, 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);