Whamcloud - gitweb
LU-10910 mdd: deny layout swap for DoM file 44/32044/5
authorMikhail Pershin <mike.pershin@intel.com>
Wed, 18 Apr 2018 07:17:10 +0000 (10:17 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 6 May 2018 03:39:48 +0000 (03:39 +0000)
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 <mike.pershin@intel.com>
Change-Id: I8b9deaea7aab0d5694a4c5d9fe2f9f36d2cdd382
Reviewed-on: https://review.whamcloud.com/32044
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdc/mdc_dev.c
lustre/mdd/mdd_object.c

index 3672ed1..14b0e65 100644 (file)
@@ -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);
index 8f9085c..7f73595 100644 (file)
@@ -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);