From b5d761e1d2488e71534e4ec4001476b3f67cf154 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 17 Aug 2006 19:30:59 +0000 Subject: [PATCH] wrap PE_ALIGN --- WHATS_NEW | 2 +- lib/format_text/format-text.c | 14 +++++++------- lib/metadata/metadata.c | 9 +++++++-- lib/metadata/metadata.h | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index b54b4aae9..30c54d689 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,6 +1,6 @@ Version 2.02.09 - ================================== - Separate out LVM1_PE_ALIGN. + Separate out LVM1_PE_ALIGN and pe_align(). Add lvm_getpagesize wrapper. Add --maxphysicalvolumes to vgchange. diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 7586dca63..2647a03f7 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -994,7 +994,7 @@ static int _text_scan(const struct format_type *fmt) } /* 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, uint64_t pe_start, uint64_t pe_end, int pvmetadatacopies, @@ -1009,11 +1009,11 @@ static int _mda_setup(const struct format_type *fmt, if (!pvmetadatacopies) { /* Space available for PEs */ - pv->size -= PE_ALIGN; + pv->size -= pe_align(); return 1; } - alignment = PE_ALIGN << SECTOR_SHIFT; + alignment = pe_align() << SECTOR_SHIFT; disk_size = pv->size << SECTOR_SHIFT; pe_start <<= SECTOR_SHIFT; pe_end <<= SECTOR_SHIFT; @@ -1055,7 +1055,7 @@ static int _mda_setup(const struct format_type *fmt, pvmetadatacopies = 1; } - /* Round up to PE_ALIGN boundary */ + /* Round up to pe_align() boundary */ mda_adjustment = (mda_size1 + start1) % alignment; if (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 * areas that begin before pe_start */ - pv->pe_start = PE_ALIGN; + pv->pe_start = pe_align(); list_iterate_items(mda, &info->mdas) { mdac = (struct mda_context *) mda->metadata_locn; 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 = (mdac->area.start + mdac->area.size) >> SECTOR_SHIFT; - adjustment = pv->pe_start % PE_ALIGN; + adjustment = pv->pe_start % pe_align(); if (adjustment) - pv->pe_start += (PE_ALIGN - adjustment); + pv->pe_start += (pe_align() - adjustment); } } if (!add_da diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index e936cf5d7..a04ab9371 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -24,6 +24,11 @@ #include "pv_alloc.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, 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? */ /* Reserved space for label; this holds 0 for PVs created by LVM1 */ - if (pv->pe_start < PE_ALIGN) - pv->pe_start = PE_ALIGN; + if (pv->pe_start < pe_align()) + pv->pe_start = pe_align(); /* * The next two fields should be corrected diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 88db68009..e8626f9c8 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -33,7 +33,6 @@ #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1) #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 */ /* Various flags */ @@ -403,6 +402,7 @@ struct format_handler { /* * Utility functions */ +unsigned long pe_align(void); int vg_validate(struct volume_group *vg); int vg_write(struct volume_group *vg); int vg_commit(struct volume_group *vg); -- 2.43.5