1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

pvcreate: fix ignored --dataalignment/dataalignment offset for pvcreate --restorefile

There were two bugs before when using pvcreate --restorefile together
with data alignment and its offset specified:

  - the --dataalignment was always ignored due to missing braces in the
    code when validating the divisibility of supplied --dataalignment
    argument with pe_start which we're just restoring:

	if (pp->rp.pe_start % pp->data_alignment)
		log_warn("WARNING: Ignoring data alignment %" PRIu64
			 " incompatible with --restorefile value (%"
			 PRIu64").", pp->data_alignment, pp->rp.pe_start);
        pp->data_alignment = 0

    The pp->data_alignment should be zeroed only if the pe_start is not
    divisible with data_alignment.

  - the check for compatibility of restored pe_start was incorrect too
    since it did not properly count with the dataalignmentoffset that
    could be supplied together with dataalignment

The proper formula is:

  X * dataalignment + dataalignmentoffset == pe_start

So it should be:

  if ((pp->rp.pe_start % pp->data_alignment) != pp->data_alignment_offset) {
	...ignore supplied dataalignment and dataalignment offset...
  }
This commit is contained in:
Peter Rajnoha 2014-04-10 13:43:46 +02:00
parent b45d2768a8
commit 6c79556f4f
2 changed files with 10 additions and 13 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.106 - Version 2.02.106 -
==================================== ====================================
Fix ignored --dataalignment/dataalignment offset for pvcreate --restorefile.
Fix lost information about bootloader area when using lvmetad. Fix lost information about bootloader area when using lvmetad.
Don't require --major to be specified when using -My option on kernels > 2.4. Don't require --major to be specified when using -My option on kernels > 2.4.
Add configure --disable-thin_check_needs_check to support old thin_check. Add configure --disable-thin_check_needs_check to support old thin_check.

View File

@ -1580,14 +1580,6 @@ int pvcreate_params_validate(struct cmd_context *cmd,
return 0; return 0;
} }
if (pp->data_alignment && pp->rp.pe_start != PV_PE_START_CALC) {
if (pp->rp.pe_start % pp->data_alignment)
log_warn("WARNING: Ignoring data alignment %" PRIu64
" incompatible with --restorefile value (%"
PRIu64").", pp->data_alignment, pp->rp.pe_start);
pp->data_alignment = 0;
}
if (arg_sign_value(cmd, dataalignmentoffset_ARG, SIGN_NONE) == SIGN_MINUS) { if (arg_sign_value(cmd, dataalignmentoffset_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Physical volume data alignment offset may not be negative"); log_error("Physical volume data alignment offset may not be negative");
return 0; return 0;
@ -1599,12 +1591,16 @@ int pvcreate_params_validate(struct cmd_context *cmd,
return 0; return 0;
} }
if (pp->data_alignment_offset && pp->rp.pe_start != PV_PE_START_CALC) { if ((pp->data_alignment + pp->data_alignment_offset) &&
log_warn("WARNING: Ignoring data alignment offset %" PRIu64 (pp->rp.pe_start != PV_PE_START_CALC)) {
" incompatible with --restorefile value (%" if ((pp->rp.pe_start % pp->data_alignment) != pp->data_alignment_offset) {
PRIu64").", pp->data_alignment_offset, pp->rp.pe_start); 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);
pp->data_alignment = 0;
pp->data_alignment_offset = 0; pp->data_alignment_offset = 0;
} }
}
if (arg_sign_value(cmd, metadatasize_ARG, SIGN_NONE) == SIGN_MINUS) { if (arg_sign_value(cmd, metadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Metadata size may not be negative"); log_error("Metadata size may not be negative");