mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-11 09:18:25 +03:00
Pass struct physical_volume to pe_align.
This commit is contained in:
parent
5ee86fc5d0
commit
30d2940c67
@ -1,5 +1,6 @@
|
||||
Version 2.02.40 -
|
||||
================================
|
||||
Pass struct physical_volume to pe_align.
|
||||
Store sysfs location in struct cmd_context.
|
||||
Avoid shuffling remaining mirror images when removing one, retaining primary.
|
||||
Add missing LV error target activation in _remove_mirror_images.
|
||||
|
@ -95,6 +95,7 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
|
||||
pv->pe_start = pvd->pe_start;
|
||||
pv->pe_count = pvd->pe_total;
|
||||
pv->pe_alloc_count = 0;
|
||||
pv->pe_align = 0;
|
||||
|
||||
/* Fix up pv size if missing or impossibly large */
|
||||
if (!pv->size || pv->size > (1ULL << 62)) {
|
||||
|
@ -173,6 +173,7 @@ int import_pool_pv(const struct format_type *fmt, struct dm_pool *mem,
|
||||
pv->pe_start = POOL_PE_START;
|
||||
pv->pe_count = pv->size / POOL_PE_SIZE;
|
||||
pv->pe_alloc_count = 0;
|
||||
pv->pe_align = 0;
|
||||
|
||||
list_init(&pv->tags);
|
||||
list_init(&pv->segments);
|
||||
|
@ -1166,7 +1166,7 @@ static int _mda_setup(const struct format_type *fmt,
|
||||
if (!pvmetadatacopies)
|
||||
return 1;
|
||||
|
||||
alignment = pe_align() << SECTOR_SHIFT;
|
||||
alignment = pe_align(pv) << SECTOR_SHIFT;
|
||||
disk_size = pv->size << SECTOR_SHIFT;
|
||||
pe_start <<= SECTOR_SHIFT;
|
||||
pe_end <<= SECTOR_SHIFT;
|
||||
@ -1333,7 +1333,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(pv);
|
||||
list_iterate_items(mda, &info->mdas) {
|
||||
mdac = (struct mda_context *) mda->metadata_locn;
|
||||
if (pv->dev == mdac->area.dev &&
|
||||
@ -1342,9 +1342,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(pv);
|
||||
if (adjustment)
|
||||
pv->pe_start += (pe_align() - adjustment);
|
||||
pv->pe_start += (pe_align(pv) - adjustment);
|
||||
}
|
||||
}
|
||||
if (!add_da
|
||||
|
@ -243,6 +243,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||
pv->pe_size = vg->extent_size;
|
||||
|
||||
pv->pe_alloc_count = 0;
|
||||
pv->pe_align = 0;
|
||||
pv->fmt = fid->fmt;
|
||||
|
||||
/* Fix up pv size if missing or impossibly large */
|
||||
|
@ -168,6 +168,7 @@ struct physical_volume {
|
||||
uint64_t pe_start;
|
||||
uint32_t pe_count;
|
||||
uint32_t pe_alloc_count;
|
||||
unsigned long pe_align;
|
||||
|
||||
struct list segments; /* Ordered pv_segments covering complete PV */
|
||||
struct list tags;
|
||||
|
@ -64,9 +64,12 @@ static struct pv_list *_find_pv_in_vg(const struct volume_group *vg,
|
||||
static struct physical_volume *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
||||
const struct id *id);
|
||||
|
||||
unsigned long pe_align(void)
|
||||
unsigned long pe_align(struct physical_volume *pv)
|
||||
{
|
||||
return MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
|
||||
if (!pv->pe_align)
|
||||
pv->pe_align = MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
|
||||
|
||||
return pv->pe_align;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,8 +129,8 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
|
||||
|
||||
/* 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))
|
||||
pv->pe_start = pe_align(pv);
|
||||
|
||||
/*
|
||||
* pe_count must always be calculated by pv_setup
|
||||
@ -771,7 +774,7 @@ static void _free_pv(struct dm_pool *mem, struct physical_volume *pv)
|
||||
dm_pool_free(mem, pv);
|
||||
}
|
||||
|
||||
static struct physical_volume *_alloc_pv(struct dm_pool *mem)
|
||||
static struct physical_volume *_alloc_pv(struct dm_pool *mem, struct device *dev)
|
||||
{
|
||||
struct physical_volume *pv = dm_pool_zalloc(mem, sizeof(*pv));
|
||||
|
||||
@ -787,7 +790,9 @@ static struct physical_volume *_alloc_pv(struct dm_pool *mem)
|
||||
pv->pe_start = 0;
|
||||
pv->pe_count = 0;
|
||||
pv->pe_alloc_count = 0;
|
||||
pv->pe_align = 0;
|
||||
pv->fmt = NULL;
|
||||
pv->dev = dev;
|
||||
|
||||
pv->status = ALLOCATABLE_PV;
|
||||
|
||||
@ -808,7 +813,7 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,
|
||||
uint64_t pvmetadatasize, struct list *mdas)
|
||||
{
|
||||
struct dm_pool *mem = fmt->cmd->mem;
|
||||
struct physical_volume *pv = _alloc_pv(mem);
|
||||
struct physical_volume *pv = _alloc_pv(mem, dev);
|
||||
|
||||
if (!pv)
|
||||
return NULL;
|
||||
@ -821,8 +826,6 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
pv->dev = dev;
|
||||
|
||||
if (!dev_get_size(pv->dev, &pv->size)) {
|
||||
log_error("%s: Couldn't get size.", pv_dev_name(pv));
|
||||
goto bad;
|
||||
|
@ -239,7 +239,7 @@ struct format_handler {
|
||||
/*
|
||||
* Utility functions
|
||||
*/
|
||||
unsigned long pe_align(void);
|
||||
unsigned long pe_align(struct physical_volume *pv);
|
||||
int vg_validate(struct volume_group *vg);
|
||||
|
||||
int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
|
||||
|
Loading…
Reference in New Issue
Block a user