fid->fmt = fmt;
dm_list_init(&fid->metadata_areas_in_use);
+ dm_list_init(&fid->metadata_areas_ignored);
/* Define a NULL metadata area */
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
fid->fmt = fmt;
dm_list_init(&fid->metadata_areas_in_use);
+ dm_list_init(&fid->metadata_areas_ignored);
/* Define a NULL metadata area */
if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
fid.fmt = fmt;
dm_list_init(&fid.metadata_areas_in_use);
+ dm_list_init(&fid.metadata_areas_ignored);
dm_list_iterate_items(rl, raw_list) {
/* FIXME We're reading mdah twice here... */
fid->fmt = fmt;
dm_list_init(&fid->metadata_areas_in_use);
+ dm_list_init(&fid->metadata_areas_ignored);
if (!vgname) {
if (!(mda = dm_pool_alloc(fmt->cmd->mem, sizeof(*mda))))
struct format_instance {
const struct format_type *fmt;
- struct dm_list metadata_areas_in_use; /* e.g. metadata locations */
+ /*
+ * Each mda in a vg is on exactly one of the below lists.
+ * MDAs on the 'in_use' list will be read from / written to
+ * disk, while MDAs on the 'ignored' list will not be read
+ * or written to.
+ */
+ struct dm_list metadata_areas_in_use;
+ struct dm_list metadata_areas_ignored;
void *private;
};
return pv_field(pv, pe_alloc_count);
}
+void fid_add_mda(struct format_instance *fid, struct metadata_area *mda)
+{
+ if (mda_is_ignored(mda))
+ dm_list_add(&fid->metadata_areas_ignored,
+ &mda->list);
+ else
+ dm_list_add(&fid->metadata_areas_in_use,
+ &mda->list);
+}
+
+int fid_add_mdas(struct format_instance *fid, struct dm_list *mdas)
+{
+ struct metadata_area *mda, *mda_new;
+
+ dm_list_iterate_items(mda, mdas) {
+ mda_new = mda_copy(fid->fmt->cmd->mem, mda);
+ if (!mda_new)
+ return_0;
+ fid_add_mda(fid, mda_new);
+ }
+ return 1;
+}
+
/*
* Copy constructor for a metadata_area.
*/
unsigned mda_is_ignored(struct metadata_area *mda);
void mda_set_ignored(struct metadata_area *mda, int value);
unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2);
+void fid_add_mda(struct format_instance *fid, struct metadata_area *mda);
+int fid_add_mdas(struct format_instance *fid, struct dm_list *mdas);
#define seg_pvseg(seg, s) (seg)->areas[(s)].u.pv.pvseg
#define seg_dev(seg, s) (seg)->areas[(s)].u.pv.pvseg->pv->dev
/* necessary for displaying something for PVs not belonging to VG */
static struct format_instance _dummy_fid = {
.metadata_areas_in_use = { &(_dummy_fid.metadata_areas_in_use), &(_dummy_fid.metadata_areas_in_use) },
+ .metadata_areas_ignored = { &(_dummy_fid.metadata_areas_ignored), &(_dummy_fid.metadata_areas_ignored) },
};
static struct volume_group _dummy_vg = {