mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add --metadataignore to pvcreate.
Allow metadataignore flag to be passed in to pvcreate. Ideally, more refactoring of the mda allocation / initialization is warranted, but for now, we just add another parameter to 'add_mda' to take an existing mda ignored flag. We need to do this or pv_write loses the state of the mda 'ignored' flag before copying and writing to disk.
This commit is contained in:
parent
6af5155529
commit
a5bf70018b
@ -59,6 +59,7 @@
|
||||
#define DEFAULT_FORMAT "lvm2"
|
||||
|
||||
#define DEFAULT_STRIPESIZE 64 /* KB */
|
||||
#define DEFAULT_PVMETADATAIGNORE 0
|
||||
#define DEFAULT_PVMETADATASIZE 255
|
||||
#define DEFAULT_PVMETADATACOPIES 1
|
||||
#define DEFAULT_VGMETADATACOPIES 0
|
||||
|
@ -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))
|
||||
mda_size1, 0))
|
||||
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)) return 0;
|
||||
mda_size2, 0)) return 0;
|
||||
if (!dev_set(pv->dev, start2,
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? : mda_size1), 0)) {
|
||||
@ -1440,7 +1440,7 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
|
||||
mdac->area.start >> SECTOR_SHIFT,
|
||||
mdac->area.size >> SECTOR_SHIFT);
|
||||
add_mda(fmt, NULL, &info->mdas, mdac->area.dev,
|
||||
mdac->area.start, mdac->area.size);
|
||||
mdac->area.start, mdac->area.size, mda_is_ignored(mda));
|
||||
}
|
||||
/* FIXME Temporary until mda creation supported by tools */
|
||||
} else if (!info->mdas.n) {
|
||||
|
@ -56,7 +56,7 @@ int add_da(struct dm_pool *mem, struct dm_list *das,
|
||||
void del_das(struct dm_list *das);
|
||||
|
||||
int add_mda(const struct format_type *fmt, struct dm_pool *mem, struct dm_list *mdas,
|
||||
struct device *dev, uint64_t start, uint64_t size);
|
||||
struct device *dev, uint64_t start, uint64_t size, unsigned ignored);
|
||||
void del_mdas(struct dm_list *mdas);
|
||||
|
||||
#endif
|
||||
|
@ -182,8 +182,9 @@ void del_das(struct dm_list *das)
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: refactor this function with other mda constructor code */
|
||||
int add_mda(const struct format_type *fmt, struct dm_pool *mem, struct dm_list *mdas,
|
||||
struct device *dev, uint64_t start, uint64_t size)
|
||||
struct device *dev, uint64_t start, uint64_t size, unsigned ignored)
|
||||
{
|
||||
/* FIXME List size restricted by pv_header SECTOR_SIZE */
|
||||
struct metadata_area *mdal;
|
||||
@ -222,6 +223,7 @@ int add_mda(const struct format_type *fmt, struct dm_pool *mem, struct dm_list *
|
||||
mdac->area.size = size;
|
||||
mdac->free_sectors = UINT64_C(0);
|
||||
memset(&mdac->rlocn, 0, sizeof(mdac->rlocn));
|
||||
mda_set_ignored(mdal, ignored);
|
||||
|
||||
dm_list_add(mdas, &mdal->list);
|
||||
return 1;
|
||||
@ -294,7 +296,7 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf,
|
||||
dlocn_xl++;
|
||||
while ((offset = xlate64(dlocn_xl->offset))) {
|
||||
add_mda(info->fmt, NULL, &info->mdas, dev, offset,
|
||||
xlate64(dlocn_xl->size));
|
||||
xlate64(dlocn_xl->size), 0);
|
||||
dlocn_xl++;
|
||||
}
|
||||
|
||||
|
@ -453,6 +453,7 @@ struct pvcreate_params {
|
||||
const char *restorefile; /* 0 if no --restorefile option */
|
||||
force_t force;
|
||||
unsigned yes;
|
||||
unsigned mda_ignore;
|
||||
};
|
||||
|
||||
struct physical_volume *pvcreate_single(struct cmd_context *cmd,
|
||||
|
@ -1580,6 +1580,7 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
|
||||
pp->restorefile = 0;
|
||||
pp->force = PROMPT;
|
||||
pp->yes = 0;
|
||||
pp->mda_ignore = DEFAULT_PVMETADATAIGNORE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1602,6 +1603,7 @@ 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)
|
||||
@ -1667,6 +1669,13 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd,
|
||||
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
pv_name);
|
||||
|
||||
if (pp->mda_ignore) {
|
||||
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;
|
||||
|
@ -517,8 +517,8 @@ xx(pvcreate,
|
||||
|
||||
dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG,
|
||||
labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, pvmetadatacopies_ARG,
|
||||
metadatasize_ARG, physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG,
|
||||
yes_ARG, zero_ARG)
|
||||
metadatasize_ARG, metadataignore_ARG, physicalvolumesize_ARG,
|
||||
restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG)
|
||||
|
||||
xx(pvdata,
|
||||
"Display the on-disk metadata for physical volume(s)",
|
||||
|
@ -1377,6 +1377,18 @@ int pvcreate_params_validate(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, metadataignore_ARG)) {
|
||||
pp->mda_ignore = !strcmp(arg_str_value(cmd,
|
||||
metadataignore_ARG,
|
||||
"n"), "y");
|
||||
}
|
||||
if (arg_count(cmd, pvmetadatacopies_ARG) &&
|
||||
!arg_int_value(cmd, pvmetadatacopies_ARG, -1) &&
|
||||
pp->mda_ignore) {
|
||||
log_error("metadataignore only applies to metadatacopies > 0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, zero_ARG))
|
||||
pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user