]> sourceware.org Git - lvm2.git/commitdiff
Fix extent rounding for striped segments.
authorMilan Broz <mbroz@redhat.com>
Thu, 9 Jun 2011 19:34:49 +0000 (19:34 +0000)
committerMilan Broz <mbroz@redhat.com>
Thu, 9 Jun 2011 19:34:49 +0000 (19:34 +0000)
We should never remove more extents than requested by user,
so round up to next stripe boundary during lvreduce.

Also this fixes round to zero sized LV bug:

# lvcreate -i2 -I 64k -l10 -n lvs vg_test
# lvreduce -f -l1 vg_test/lvs
  Rounding size (1 extents) down to stripe boundary size for segment (0 extents)
  WARNING: Reducing active logical volume to 0
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Reducing logical volume lvs to 0
  Failed to suspend lvs

WHATS_NEW
test/t-lvextend-percent-extents.sh
tools/lvresize.c

index 01032aed6562ec84851bd85747aff847e51d229f..4b77b95c821fa0c666d8be2c5d96e5c639b7d245 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Fix extent rounding for striped volumes (never reduce more than requested).
   Fix create_temp_name to replace any '/' found in the hostname with '?'.
   Always use append to file in lvmdump (selinux policy - no file truncation).
   Propagate test mode to clvmd to skip activation and changes to held locks.
index 24fac607648cf62d4799ca3a755952eea360fd90..ecd5a1b29578547f0082c0251352278292743407 100755 (executable)
@@ -99,3 +99,8 @@ check lv_field $vg/$lv seg_count 2
 lvreduce -f -l -$(( $pe_count * 1 )) $vg/$lv
 check lv_field $vg/$lv seg_count 1
 
+# do not reduce to 0 extents
+lvremove -f $vg/$lv
+lvcreate -i2 -I 64k -l10 -n $lv $vg
+lvreduce -f -l1 $vg/$lv
+check lv_field $vg/$lv lv_size "8.00m"
index b9084e627f0f2540dcd811becfc8cafe2c580dc5..30e0bf0161d757c60c75e24a77e6d863174b6a57 100644 (file)
@@ -575,11 +575,17 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
                return EINVALID_CMD_LINE;
        }
 
-       if ((lp->stripes > 1)) {
+       if (lp->stripes > 1) {
                if (!(stripesize_extents = lp->stripe_size / vg->extent_size))
                        stripesize_extents = 1;
 
-               if ((size_rest = seg_size % (lp->stripes * stripesize_extents))) {
+               size_rest = seg_size % (lp->stripes * stripesize_extents);
+               if (size_rest && lp->resize == LV_REDUCE) {
+                       log_print("Rounding size (%d extents) up to stripe "
+                                 "boundary size for segment (%d extents)",
+                                 lp->extents, lp->extents + size_rest);
+                       lp->extents = lp->extents + size_rest;
+               } else if (size_rest) {
                        log_print("Rounding size (%d extents) down to stripe "
                                  "boundary size for segment (%d extents)",
                                  lp->extents, lp->extents - size_rest);
This page took 0.040018 seconds and 5 git commands to generate.