Whamcloud - gitweb
LU-10808 lod: align wrong DoM stripe values with defaults 73/32073/5
authorMikhail Pershin <mike.pershin@intel.com>
Thu, 19 Apr 2018 13:29:54 +0000 (16:29 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 7 Jun 2018 20:08:01 +0000 (20:08 +0000)
- Align DoM component size to the server limit size instead of
  returning a error. Error is returned still if DoM file creation
  is disabled on the server (DOM limit is set to 0)
- Correct wrong values for dom_stripesize parameter by using minimal
  stripe size if provided value is lower and by aligning it to be a
  multiple of that minimal size.

Signed-off-by: Mikhail Pershin <mike.pershin@intel.com>
Change-Id: Ifcdf60fddda65acda92509bb7e69c9b2951fb6bd
Reviewed-on: https://review.whamcloud.com/32073
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_lov.c
lustre/lod/lproc_lod.c
lustre/tests/sanity.sh

index 18eba3e..092389f 100644 (file)
@@ -1644,6 +1644,52 @@ out:
        RETURN(rc);
 }
 
+int lod_fix_dom_stripe(struct lod_device *d, struct lov_comp_md_v1 *comp_v1)
+{
+       struct lov_comp_md_entry_v1 *ent;
+       struct lu_extent *dom_ext, *ext;
+       struct lov_user_md_v1 *lum;
+       __u32 stripe_size;
+       __u16 mid, dom_mid;
+       int i;
+
+       ent = &comp_v1->lcm_entries[0];
+       dom_ext = &ent->lcme_extent;
+       dom_mid = mirror_id_of(le32_to_cpu(ent->lcme_id));
+       stripe_size = d->lod_dom_max_stripesize;
+
+       lum = (void *)comp_v1 + le32_to_cpu(ent->lcme_offset);
+       CDEBUG(D_LAYOUT, "DoM component size %u was bigger than MDT limit %u, "
+              "new size is %u\n", le32_to_cpu(lum->lmm_stripe_size),
+              d->lod_dom_max_stripesize, stripe_size);
+       lum->lmm_stripe_size = cpu_to_le32(stripe_size);
+
+       for (i = 1; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
+               ent = &comp_v1->lcm_entries[i];
+               mid = mirror_id_of(le32_to_cpu(ent->lcme_id));
+
+               if (mid != dom_mid)
+                       continue;
+
+               ext = &ent->lcme_extent;
+               if (ext->e_start != dom_ext->e_end)
+                       continue;
+
+               /* Found next component after the DoM one with the same
+                * mirror_id and adjust its start with DoM component end.
+                *
+                * NOTE: we are considering here that there can be only one
+                * DoM component in a file, all replicas are located on OSTs
+                * always and don't need adjustment since use own layouts.
+                */
+               ext->e_start = cpu_to_le64(stripe_size);
+               break;
+       }
+       /* Update DoM extent end finally */
+       dom_ext->e_end = cpu_to_le64(stripe_size);
+       return 0;
+}
+
 /**
  * Verify LOV striping.
  *
@@ -1768,8 +1814,6 @@ int lod_verify_striping(struct lod_device *d, struct lod_object *lo,
                        RETURN(-EINVAL);
                }
 
-               prev_end = le64_to_cpu(ext->e_end);
-
                tmp.lb_buf = (char *)comp_v1 + le32_to_cpu(ent->lcme_offset);
                tmp.lb_len = le32_to_cpu(ent->lcme_size);
 
@@ -1786,7 +1830,7 @@ int lod_verify_striping(struct lod_device *d, struct lod_object *lo,
                        stripe_size = le32_to_cpu(lum->lmm_stripe_size);
                        /* There is just one stripe on MDT and it must
                         * cover whole component size. */
-                       if (stripe_size != prev_end) {
+                       if (stripe_size != le64_to_cpu(ext->e_end)) {
                                CDEBUG(D_LAYOUT, "invalid DoM layout "
                                       "stripe size %u != %llu "
                                       "(component size)\n",
@@ -1799,10 +1843,15 @@ int lod_verify_striping(struct lod_device *d, struct lod_object *lo,
                                       "%u is bigger than MDT limit %u, check "
                                       "dom_max_stripesize parameter\n",
                                       stripe_size, d->lod_dom_max_stripesize);
-                               RETURN(-EINVAL);
+                               if (d->lod_dom_max_stripesize)
+                                       lod_fix_dom_stripe(d, comp_v1);
+                               else
+                                       RETURN(-EFBIG);
                        }
                }
 
+               prev_end = le64_to_cpu(ext->e_end);
+
                rc = lod_verify_v1v3(d, &tmp, is_from_disk);
                if (rc)
                        RETURN(rc);
index b7621f1..6749b0d 100644 (file)
@@ -99,8 +99,19 @@ lod_dom_stripesize_seq_write(struct file *file, const char __user *buffer,
        /* 1GB is the limit */
        if (val > (1ULL << 30))
                return -ERANGE;
-       else if (val > 0)
-               lod_fix_desc_stripe_size(&val);
+       else if (val > 0) {
+               if (val < LOV_MIN_STRIPE_SIZE) {
+                       LCONSOLE_INFO("Increasing provided stripe size to "
+                                     "a minimum value %u\n",
+                                     LOV_MIN_STRIPE_SIZE);
+                       val = LOV_MIN_STRIPE_SIZE;
+               } else if (val & (LOV_MIN_STRIPE_SIZE - 1)) {
+                       val &= ~(LOV_MIN_STRIPE_SIZE - 1);
+                       LCONSOLE_WARN("Changing provided stripe size to %llu "
+                                     "(a multiple of minimum %u)\n",
+                                     val, LOV_MIN_STRIPE_SIZE);
+               }
+       }
 
        lod->lod_dom_max_stripesize = val;
 
index 126f73a..438f6aa 100755 (executable)
@@ -16487,7 +16487,8 @@ test_270f() {
                error "Can't set directory default striping"
 
        # exceed maximum stripe size
-       $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
+       $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom
+       [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
                error "Able to create DoM component size more than LOD limit"
 
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
@@ -16503,6 +16504,10 @@ test_270f() {
        [ 30000 -eq ${dom_current} ] &&
                error "Can set too small DoM stripe limit"
 
+       # 64K is a minimal stripe size in Lustre, expect limit of that size
+       [ 65536 -eq ${dom_current} ] ||
+               error "Limit is not set to 64K but ${dom_current}"
+
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
        dom_current=$(do_facet mds1 $LCTL get_param -n \
                                                lod.$mdtname.dom_stripesize)
@@ -16516,7 +16521,8 @@ test_270f() {
                error "Can't create DoM component size after limit change"
        do_facet mds1 $LCTL set_param -n \
                                lod.$mdtname.dom_stripesize=$((dom_limit / 2))
-       $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
+       $LFS setstripe -E $dom_limit -L mdt ${dom}_big
+       [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
                error "Can create big DoM component after limit decrease"
        touch ${dom}_def ||
                error "Can't create file with old default layout"