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

wrap PE_ALIGN

This commit is contained in:
Alasdair Kergon 2006-08-17 19:30:59 +00:00
parent ee37789be0
commit b5d761e1d2
4 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,6 @@
Version 2.02.09 - Version 2.02.09 -
================================== ==================================
Separate out LVM1_PE_ALIGN. Separate out LVM1_PE_ALIGN and pe_align().
Add lvm_getpagesize wrapper. Add lvm_getpagesize wrapper.
Add --maxphysicalvolumes to vgchange. Add --maxphysicalvolumes to vgchange.

View File

@ -994,7 +994,7 @@ static int _text_scan(const struct format_type *fmt)
} }
/* For orphan, creates new mdas according to policy. /* For orphan, creates new mdas according to policy.
Always have an mda between end-of-label and PE_ALIGN boundary */ Always have an mda between end-of-label and pe_align() boundary */
static int _mda_setup(const struct format_type *fmt, static int _mda_setup(const struct format_type *fmt,
uint64_t pe_start, uint64_t pe_end, uint64_t pe_start, uint64_t pe_end,
int pvmetadatacopies, int pvmetadatacopies,
@ -1009,11 +1009,11 @@ static int _mda_setup(const struct format_type *fmt,
if (!pvmetadatacopies) { if (!pvmetadatacopies) {
/* Space available for PEs */ /* Space available for PEs */
pv->size -= PE_ALIGN; pv->size -= pe_align();
return 1; return 1;
} }
alignment = PE_ALIGN << SECTOR_SHIFT; alignment = pe_align() << SECTOR_SHIFT;
disk_size = pv->size << SECTOR_SHIFT; disk_size = pv->size << SECTOR_SHIFT;
pe_start <<= SECTOR_SHIFT; pe_start <<= SECTOR_SHIFT;
pe_end <<= SECTOR_SHIFT; pe_end <<= SECTOR_SHIFT;
@ -1055,7 +1055,7 @@ static int _mda_setup(const struct format_type *fmt,
pvmetadatacopies = 1; pvmetadatacopies = 1;
} }
/* Round up to PE_ALIGN boundary */ /* Round up to pe_align() boundary */
mda_adjustment = (mda_size1 + start1) % alignment; mda_adjustment = (mda_size1 + start1) % alignment;
if (mda_adjustment) if (mda_adjustment)
mda_size1 += (alignment - mda_adjustment); mda_size1 += (alignment - mda_adjustment);
@ -1189,7 +1189,7 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
/* Set pe_start to first aligned sector after any metadata /* Set pe_start to first aligned sector after any metadata
* areas that begin before pe_start */ * areas that begin before pe_start */
pv->pe_start = PE_ALIGN; pv->pe_start = pe_align();
list_iterate_items(mda, &info->mdas) { list_iterate_items(mda, &info->mdas) {
mdac = (struct mda_context *) mda->metadata_locn; mdac = (struct mda_context *) mda->metadata_locn;
if (pv->dev == mdac->area.dev && if (pv->dev == mdac->area.dev &&
@ -1198,9 +1198,9 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
(pv->pe_start << SECTOR_SHIFT))) { (pv->pe_start << SECTOR_SHIFT))) {
pv->pe_start = (mdac->area.start + mdac->area.size) pv->pe_start = (mdac->area.start + mdac->area.size)
>> SECTOR_SHIFT; >> SECTOR_SHIFT;
adjustment = pv->pe_start % PE_ALIGN; adjustment = pv->pe_start % pe_align();
if (adjustment) if (adjustment)
pv->pe_start += (PE_ALIGN - adjustment); pv->pe_start += (pe_align() - adjustment);
} }
} }
if (!add_da if (!add_da

View File

@ -24,6 +24,11 @@
#include "pv_alloc.h" #include "pv_alloc.h"
#include "activate.h" #include "activate.h"
unsigned long pe_align(void)
{
return (65536UL >> SECTOR_SHIFT);
}
static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg, static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
const char *pv_name) const char *pv_name)
{ {
@ -78,8 +83,8 @@ static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
/* FIXME Do proper rounding-up alignment? */ /* FIXME Do proper rounding-up alignment? */
/* Reserved space for label; this holds 0 for PVs created by LVM1 */ /* Reserved space for label; this holds 0 for PVs created by LVM1 */
if (pv->pe_start < PE_ALIGN) if (pv->pe_start < pe_align())
pv->pe_start = PE_ALIGN; pv->pe_start = pe_align();
/* /*
* The next two fields should be corrected * The next two fields should be corrected

View File

@ -33,7 +33,6 @@
#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1) #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ #define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
#define PE_ALIGN (65536UL >> SECTOR_SHIFT) /* PE alignment */
#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */ #define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
/* Various flags */ /* Various flags */
@ -403,6 +402,7 @@ struct format_handler {
/* /*
* Utility functions * Utility functions
*/ */
unsigned long pe_align(void);
int vg_validate(struct volume_group *vg); int vg_validate(struct volume_group *vg);
int vg_write(struct volume_group *vg); int vg_write(struct volume_group *vg);
int vg_commit(struct volume_group *vg); int vg_commit(struct volume_group *vg);