1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvresize: fix stripe size validation

While stripe size is twice the physical extent size,
the original code will not reduce stripe size to maximum
(physical extent size).

Signed-off-by: Zhiqing Zhang <zhangzq.fnst@cn.fujitsu.com>
This commit is contained in:
Zhiqing Zhang 2014-02-26 10:14:18 +08:00 committed by Zdenek Kabelac
parent b5e03c88b8
commit 014ba37cb1
4 changed files with 17 additions and 8 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
Do not allow stripe size to be bigger then extent size for lvresize.
Zero snapshot COW header when creating read-only snapshot.
Comment out config lines in dumpconfig output without default values defined.
Improve detection of clustered mirror support.

View File

@ -3406,6 +3406,7 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
#define SIZE_BUF 128
/* TODO: unify stripe size validation across source code */
static int _validate_stripesize(struct cmd_context *cmd,
const struct volume_group *vg,
struct lvresize_params *lp)
@ -3419,11 +3420,11 @@ static int _validate_stripesize(struct cmd_context *cmd,
if (!(vg->fid->fmt->features & FMT_SEGMENTS))
log_warn("Varied stripesize not supported. Ignoring.");
else if (lp->ac_stripesize_value > (uint64_t) vg->extent_size * 2) {
log_error("Reducing stripe size %s to maximum, "
"physical extent size %s",
display_size(cmd,lp->ac_stripesize_value),
display_size(cmd, (uint64_t) vg->extent_size));
else if (lp->ac_stripesize_value > vg->extent_size) {
log_print_unless_silent("Reducing stripe size %s to maximum, "
"physical extent size %s",
display_size(cmd, lp->ac_stripesize_value),
display_size(cmd, vg->extent_size));
lp->stripe_size = vg->extent_size;
} else
lp->stripe_size = lp->ac_stripesize_value;

View File

@ -95,7 +95,9 @@ Defaults to whatever the last segment of the Logical Volume uses.
Not applicable to LVs using the original metadata LVM format, which
must use a single value throughout.
.br
StripeSize must be 2^n (n = 2 to 9).
StripeSize must be 2^n (n = 2 to 9) for metadata in LVM1 format.
For metadata in LVM2 format, the stripe size may be a larger
power of 2 but must not exceed the physical extent size.
.TP
.B \-\-noudevsync
Disable udev synchronisation. The

View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved.
# Copyright (C) 2007-2014 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@ -11,7 +11,7 @@
. lib/test
aux prepare_vg 2
aux prepare_vg 2 80
lvcreate -L 10M -n lv -i2 $vg
lvresize -l +4 $vg/lv
@ -19,3 +19,8 @@ lvremove -ff $vg
lvcreate -L 64M -n $lv -i2 $vg
not lvresize -v -l +4 xxx/$lv
# Check stripe size is reduced to extent size when it's bigger
ESIZE=$(get vg_field $vg vg_extent_size --units b)
lvextend -L+64m -i 2 -I$(( ${ESIZE%%B} * 2 ))B $vg/$lv 2>&1 | tee err
grep "Reducing stripe size" err