]> sourceware.org Git - lvm2.git/blobdiff - tools/lvresize.c
Remove 'up' from rounding message that sometimes rounds down.
[lvm2.git] / tools / lvresize.c
index b71720e3ca328dd2caa4932f1a4b64936268cba0..9662eb9ded0f79833c0b0fe0f49db032ce94deb6 100644 (file)
@@ -454,6 +454,12 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
 
        alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lv->alloc);
 
+       /*
+        * First adjust to an exact multiple of extent size.
+        * When extending by a relative amount we round that amount up.
+        * When reducing by a relative amount we remove at most that amount.
+        * When changing to an absolute size, we round that size up.
+        */
        if (lp->size) {
                if (lp->size % vg->extent_size) {
                        if (lp->sign == SIGN_MINUS)
@@ -462,7 +468,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
                                lp->size += vg->extent_size -
                                    (lp->size % vg->extent_size);
 
-                       log_print("Rounding up size to full physical extent %s",
+                       log_print("Rounding size to boundary between physical extents: %s",
                                  display_size(cmd, lp->size));
                }
 
@@ -590,7 +596,10 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
        if ((lp->extents > lv->le_count) &&
            !(lp->stripes == 1 || (lp->stripes > 1 && lp->stripe_size))) {
                /* FIXME Don't assume mirror seg will always be AREA_LV */
-               dm_list_iterate_items(seg, seg_mirrors ? &seg_lv(mirr_seg, 0)->segments : &lv->segments) {
+               /* FIXME We will need to support resize for metadata LV as well,
+                *       and data LV could be any type (i.e. mirror)) */
+               dm_list_iterate_items(seg, seg_mirrors ? &seg_lv(mirr_seg, 0)->segments :
+                                     lv_is_thin_pool(lv) ? &seg_lv(first_seg(lv), 0)->segments : &lv->segments) {
                        if (!seg_is_striped(seg))
                                continue;
 
@@ -711,6 +720,15 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
                        return EINVALID_CMD_LINE;
                }
                lp->resize = LV_EXTEND;
+       } else if (lp->extents == lv->le_count) {
+               if (use_policy)
+                       return ECMD_PROCESSED; /* Nothing to do. */
+               if (!lp->resizefs) {
+                       log_error("New size (%d extents) matches existing size "
+                                 "(%d extents)", lp->extents, lv->le_count);
+                       return EINVALID_CMD_LINE;
+               }
+               lp->resize = LV_EXTEND;
        }
 
        if (lv_is_origin(lv)) {
@@ -739,13 +757,6 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
                        log_warn("Thin pool volumes do not have filesystem.");
                        lp->resizefs = 0;
                }
-
-               if (!lp->stripes) {
-                       /* Try to use the same strip settings for underlying pool data LV */
-                       lp->stripes = last_seg(seg_lv(first_seg(lv), 0))->area_count;
-                       if (!lp->stripe_size)
-                               lp->stripe_size = last_seg(seg_lv(first_seg(lv), 0))->stripe_size;
-               }
        }
 
        if ((lp->resize == LV_REDUCE) && lp->argc)
This page took 0.027145 seconds and 5 git commands to generate.