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

tests: add test for pvcreate --dataalignment --dataalignmentoffset --restorefile compatibility

Also, avoid division by zero in the pvcreate's param validation
in case someone supplies "pvcreate --dataalignment 0".
This commit is contained in:
Peter Rajnoha 2014-04-10 14:46:40 +02:00
parent 05eb6a167e
commit 35721ee134
2 changed files with 21 additions and 4 deletions

View File

@ -124,6 +124,22 @@ vgcfgrestore -f $backupfile $vg1
vgremove -f $vg1
pvremove -f "$dev1"
# pvcreate --restorefile should handle --dataalignment and --dataalignmentoffset
# and check it's compatible with pe_start value being restored
# X * dataalignment + dataalignmentoffset == pe_start
pvcreate --norestorefile --uuid $uuid1 --dataalignment 600k --dataalignmentoffset 32k "$dev1"
vgcreate $vg1 "$dev1"
vgcfgbackup -f $backupfile $vg1
vgremove -ff $vg1
pvremove -ff "$dev1"
# the dataalignment and dataalignmentoffset is ignored here since they're incompatible with pe_start
pvcreate --restorefile $backupfile --uuid $uuid1 --dataalignment 500k --dataalignmentoffset 10k "$dev1" 2> err
grep "incompatible with restored pe_start value" err
# 300k is multiple of 600k so this should pass
pvcreate --restorefile $backupfile --uui $uuid1 --dataalignment 300k --dataalignmentoffset 32k "$dev1" 2> err
not grep "incompatible with restored pe_start value" err
rm -f $backupfile
# pvcreate rejects non-existent uuid given with restorefile
not pvcreate --uuid $uuid1 --restorefile $backupfile "$dev1"

View File

@ -1593,10 +1593,11 @@ int pvcreate_params_validate(struct cmd_context *cmd,
if ((pp->data_alignment + pp->data_alignment_offset) &&
(pp->rp.pe_start != PV_PE_START_CALC)) {
if ((pp->rp.pe_start % pp->data_alignment) != pp->data_alignment_offset) {
log_warn("WARNING: Ignoring data alignment %" PRIu64
" incompatible with restored pe_start value %" PRIu64").",
pp->data_alignment + pp->data_alignment_offset, pp->rp.pe_start);
if ((pp->data_alignment ? pp->rp.pe_start % pp->data_alignment : pp->rp.pe_start) != pp->data_alignment_offset) {
log_warn("WARNING: Ignoring data alignment %s"
" incompatible with restored pe_start value %s)",
display_size(cmd, pp->data_alignment + pp->data_alignment_offset),
display_size(cmd, pp->rp.pe_start));
pp->data_alignment = 0;
pp->data_alignment_offset = 0;
}