From a5fb2bbff3e0fca37a71a50c2f36cb4268e64509 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Thu, 8 Jul 2010 18:24:29 +0000 Subject: [PATCH] Pass metadataignore to pv_create, pv_setup, _mda_setup, and add_mda. Pass metadataignore through PV creation / setup paths. As a result of this cleanup, we can remove the unnecessary setting of mda_ignore bits inside pvcreate_single(), after call to pv_create. For now, just set metadataignore to '0' in some places. This is equivalent to the prior functionality, although the 0 is given by the caller not hardcoded in _mda_setup() call. Signed-off-by: Dave Wysochanski --- lib/format1/format1.c | 16 +++++++++------- lib/format_pool/format_pool.c | 1 + lib/format_text/archiver.c | 3 ++- lib/format_text/format-text.c | 22 +++++++++++----------- lib/metadata/metadata-exported.h | 21 +++++++++++---------- lib/metadata/metadata.c | 19 +++++++------------ lib/metadata/metadata.h | 4 ++-- tools/vgconvert.c | 2 +- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/format1/format1.c b/lib/format1/format1.c index e0e5ad07b..7c52d2b05 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -294,13 +294,15 @@ static int _format1_pv_read(const struct format_type *fmt, const char *pv_name, } static int _format1_pv_setup(const struct format_type *fmt, - uint64_t pe_start, uint32_t extent_count, - uint32_t extent_size, - unsigned long data_alignment __attribute((unused)), - unsigned long data_alignment_offset __attribute((unused)), - int pvmetadatacopies __attribute((unused)), - uint64_t pvmetadatasize __attribute((unused)), struct dm_list *mdas __attribute((unused)), - struct physical_volume *pv, struct volume_group *vg __attribute((unused))) + uint64_t pe_start, uint32_t extent_count, + uint32_t extent_size, + unsigned long data_alignment __attribute((unused)), + unsigned long data_alignment_offset __attribute((unused)), + int pvmetadatacopies __attribute((unused)), + uint64_t pvmetadatasize __attribute((unused)), + unsigned metadataignore __attribute((unused)), + struct dm_list *mdas __attribute((unused)), + struct physical_volume *pv, struct volume_group *vg __attribute((unused))) { if (pv->size > MAX_PV_SIZE) pv->size--; diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c index 32b8f4ed8..a0eb8278e 100644 --- a/lib/format_pool/format_pool.c +++ b/lib/format_pool/format_pool.c @@ -196,6 +196,7 @@ static int _pool_pv_setup(const struct format_type *fmt __attribute((unused)), unsigned long data_alignment_offset __attribute((unused)), int pvmetadatacopies __attribute((unused)), uint64_t pvmetadatasize __attribute((unused)), + unsigned metadataignore __attribute((unused)), struct dm_list *mdas __attribute((unused)), struct physical_volume *pv __attribute((unused)), struct volume_group *vg __attribute((unused))) diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c index e45d9d217..d8272046d 100644 --- a/lib/format_text/archiver.c +++ b/lib/format_text/archiver.c @@ -327,7 +327,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg) } if (!vg->fid->fmt->ops-> pv_setup(vg->fid->fmt, UINT64_C(0), 0, 0, 0, 0, 0UL, - UINT64_C(0), &vg->fid->metadata_areas_in_use, pv, vg)) { + UINT64_C(0), 0, + &vg->fid->metadata_areas_in_use, pv, vg)) { log_error("Format-specific setup for %s failed", pv_dev_name(pv)); return 0; diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index c6594af48..7ff5f8582 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1248,8 +1248,8 @@ static int _text_scan(const struct format_type *fmt) 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, - uint64_t pvmetadatasize, struct dm_list *mdas, + int pvmetadatacopies, uint64_t pvmetadatasize, + unsigned metadataignore, struct dm_list *mdas, struct physical_volume *pv, struct volume_group *vg __attribute((unused))) { @@ -1337,7 +1337,7 @@ static int _mda_setup(const struct format_type *fmt, /* FIXME If creating new mdas, wipe them! */ if (mda_size1) { if (!add_mda(fmt, fmt->cmd->mem, mdas, pv->dev, start1, - mda_size1, 0)) + mda_size1, metadataignore)) return 0; if (!dev_set((struct device *) pv->dev, start1, @@ -1384,7 +1384,7 @@ static int _mda_setup(const struct format_type *fmt, if (mda_size2) { if (!add_mda(fmt, fmt->cmd->mem, mdas, pv->dev, start2, - mda_size2, 0)) return 0; + mda_size2, metadataignore)) return 0; if (!dev_set(pv->dev, start2, (size_t) (mda_size1 > wipe_size ? : mda_size1), 0)) { @@ -1766,12 +1766,12 @@ static struct metadata_area_ops _metadata_text_raw_ops = { * setting of pv->pe_start to .pv_write */ static int _text_pv_setup(const struct format_type *fmt, - uint64_t pe_start, uint32_t extent_count, - uint32_t extent_size, unsigned long data_alignment, - unsigned long data_alignment_offset, - int pvmetadatacopies, - uint64_t pvmetadatasize, struct dm_list *mdas, - struct physical_volume *pv, struct volume_group *vg) + uint64_t pe_start, uint32_t extent_count, + uint32_t extent_size, unsigned long data_alignment, + unsigned long data_alignment_offset, + int pvmetadatacopies, uint64_t pvmetadatasize, + unsigned metadataignore, struct dm_list *mdas, + struct physical_volume *pv, struct volume_group *vg) { struct metadata_area *mda, *mda_new, *mda2; struct mda_context *mdac, *mdac2; @@ -1894,7 +1894,7 @@ static int _text_pv_setup(const struct format_type *fmt, if (extent_count) pe_end = pe_start + extent_count * extent_size - 1; if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies, - pvmetadatasize, mdas, pv, vg)) + pvmetadatasize, metadataignore, mdas, pv, vg)) return_0; } diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 782400581..a72a6bfd6 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -522,16 +522,17 @@ uint32_t vg_read_error(struct volume_group *vg_handle); /* pe_start and pe_end relate to any existing data so that new metadata * areas can avoid overlap */ struct physical_volume *pv_create(const struct cmd_context *cmd, - struct device *dev, - struct id *id, - uint64_t size, - unsigned long data_alignment, - unsigned long data_alignment_offset, - uint64_t pe_start, - uint32_t existing_extent_count, - uint32_t existing_extent_size, - int pvmetadatacopies, - uint64_t pvmetadatasize, struct dm_list *mdas); + struct device *dev, + struct id *id, + uint64_t size, + unsigned long data_alignment, + unsigned long data_alignment_offset, + uint64_t pe_start, + uint32_t existing_extent_count, + uint32_t existing_extent_size, + int pvmetadatacopies, uint64_t pvmetadatasize, + unsigned metadataignore, + struct dm_list *mdas); int pv_resize(struct physical_volume *pv, struct volume_group *vg, uint32_t new_pe_count); int pv_analyze(struct cmd_context *cmd, const char *pv_name, diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 2913ea2d1..b09580970 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -234,7 +234,7 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, if (!fid->fmt->ops->pv_setup(fid->fmt, UINT64_C(0), 0, vg->extent_size, 0, 0, 0UL, UINT64_C(0), - mdas, pv, vg)) { + 0, mdas, pv, vg)) { log_error("Format-specific setup of physical volume '%s' " "failed.", pv_name); return 0; @@ -1684,7 +1684,6 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd, struct dm_list mdas; struct pvcreate_params default_pp; char buffer[64] __attribute((aligned(8))); - struct metadata_area *mda; pvcreate_params_set_defaults(&default_pp); if (!pp) @@ -1718,8 +1717,8 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd, if (!(pv = pv_create(cmd, dev, pp->idp, pp->size, pp->data_alignment, pp->data_alignment_offset, pp->pe_start, pp->extent_count, pp->extent_size, - pp->pvmetadatacopies, - pp->pvmetadatasize,&mdas))) { + pp->pvmetadatacopies, pp->pvmetadatasize, + pp->metadataignore, &mdas))) { log_error("Failed to setup physical volume \"%s\"", pv_name); goto error; } @@ -1751,10 +1750,6 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd, log_very_verbose("Writing physical volume data to disk \"%s\"", pv_name); - if (pp->metadataignore) - dm_list_iterate_items(mda, &mdas) - mda_set_ignored(mda, 1); - if (!(pv_write(cmd, pv, &mdas, pp->labelsector))) { log_error("Failed to write physical volume \"%s\"", pv_name); goto error; @@ -1827,8 +1822,8 @@ struct physical_volume *pv_create(const struct cmd_context *cmd, uint64_t pe_start, uint32_t existing_extent_count, uint32_t existing_extent_size, - int pvmetadatacopies, - uint64_t pvmetadatasize, struct dm_list *mdas) + int pvmetadatacopies, uint64_t pvmetadatasize, + unsigned metadataignore, struct dm_list *mdas) { const struct format_type *fmt = cmd->fmt; struct dm_pool *mem = fmt->cmd->mem; @@ -1877,8 +1872,8 @@ struct physical_volume *pv_create(const struct cmd_context *cmd, if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count, existing_extent_size, data_alignment, data_alignment_offset, - pvmetadatacopies, pvmetadatasize, mdas, - pv, NULL)) { + pvmetadatacopies, pvmetadatasize, + metadataignore, mdas, pv, NULL)) { log_error("%s: Format-specific setup of physical volume " "failed.", pv_dev_name(pv)); goto bad; diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 80701b53a..25399c7d9 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -244,8 +244,8 @@ struct format_handler { uint64_t pe_start, uint32_t extent_count, uint32_t extent_size, unsigned long data_alignment, unsigned long data_alignment_offset, - int pvmetadatacopies, - uint64_t pvmetadatasize, struct dm_list * mdas, + int pvmetadatacopies, uint64_t pvmetadatasize, + unsigned metadataignore, struct dm_list * mdas, struct physical_volume * pv, struct volume_group * vg); /* diff --git a/tools/vgconvert.c b/tools/vgconvert.c index 288ccd7e1..1808454a4 100644 --- a/tools/vgconvert.c +++ b/tools/vgconvert.c @@ -127,7 +127,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, &existing_pv->id, size, 0, 0, pe_start, pv_pe_count(existing_pv), pv_pe_size(existing_pv), pvmetadatacopies, - pvmetadatasize, &mdas))) { + pvmetadatasize, 0, &mdas))) { log_error("Failed to setup physical volume \"%s\"", pv_dev_name(existing_pv)); if (change_made) -- 2.43.5