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

Fix _mda_setup() to not check first mda's size before pe_align rounding.

Without this fix rounding the end of the first mda to a pe_align
boundary could silently exceed the disk_size.

Final 'if (start1 + mda_size1 > disk_size)' block serves as a safety
net.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
Mike Snitzer 2009-07-30 17:19:31 +00:00
parent 2143b169b1
commit ad273af9c7
2 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.51 -
================================
Fix _mda_setup() to not check first mda's size before pe_align rounding.
Formalize pe_start policy as split between .pv_setup and .pv_write.
Document -I option of clvmd in the man page.
Fix configure script to handle multiple clvmd selections.

View File

@ -1214,6 +1214,15 @@ static int _mda_setup(const struct format_type *fmt,
start1 += (pagesize - mda_adjustment);
}
/* Round up to pe_align boundary */
mda_adjustment = (mda_size1 + start1) % alignment;
if (mda_adjustment) {
mda_size1 += (alignment - mda_adjustment);
/* Revert if it's now too large */
if (start1 + mda_size1 > disk_size)
mda_size1 -= (alignment - mda_adjustment);
}
/* Ensure it's not going to be bigger than the disk! */
if (start1 + mda_size1 > disk_size) {
log_warn("WARNING: metadata area fills disk leaving no "
@ -1221,15 +1230,19 @@ static int _mda_setup(const struct format_type *fmt,
/* Leave some free space for rounding */
/* Avoid empty data area as could cause tools problems */
mda_size1 = disk_size - start1 - alignment * 2;
if (start1 + mda_size1 > disk_size) {
log_error("Insufficient space for first mda on %s",
pv_dev_name(pv));
return 0;
}
/* Round up to pe_align boundary */
mda_adjustment = (mda_size1 + start1) % alignment;
if (mda_adjustment)
mda_size1 += (alignment - mda_adjustment);
/* Only have 1 mda in this case */
pvmetadatacopies = 1;
}
/* Round up to pe_align() boundary */
mda_adjustment = (mda_size1 + start1) % alignment;
if (mda_adjustment)
mda_size1 += (alignment - mda_adjustment);
/* If we already have PEs, avoid overlap */
if (pe_start || pe_end) {
if (pe_start <= start1)