1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-24 06:04:19 +03:00

Fix extent rounding for striped segments.

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
This commit is contained in:
Milan Broz 2011-06-09 19:34:49 +00:00
parent 4abb15db5f
commit 4964e2d615
3 changed files with 14 additions and 2 deletions

View File

@ -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.

View File

@ -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"

View 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);