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.
#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
/* 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,
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)) {
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) {
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
}
}
+/* 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;
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;
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++;
}
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,
pp->restorefile = 0;
pp->force = PROMPT;
pp->yes = 0;
+ pp->mda_ignore = DEFAULT_PVMETADATAIGNORE;
}
/*
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)
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;
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)",
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");