public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib format_text/format-text.c metadata/me ...
@ 2010-06-28 20:35 wysochanski
0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2010-06-28 20:35 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2010-06-28 20:35:17
Modified files:
lib/format_text: format-text.c
lib/metadata : metadata.c
Log message:
Update _vg_read and _text_create_text_instance to use fid_add_mda[s].
When we are constructing the vg, we may need to adjust the list of
metadata_areas if there are ignored mdas. At label read time, we
do not read the metadata of ignored mdas, and as a result, they do
not get placed on vg->fid->metadata_areas inside _text_create_text_instance
since lvmcache does not have these areas attached to vginfo->infos.
However, when we're checking the pvids inside _vg_read, after having
read another metadata area from another PV, we do have the opportunity
to update the metadata_area and metadata_areas_ignored lists based
on the read metadata_area. We need accurate mda lists for the reporting
functions that count the ignored mdas, as well as general correctness
of mda balancing.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.354&r2=1.355
--- LVM2/lib/format_text/format-text.c 2010/06/28 20:33:23 1.132
+++ LVM2/lib/format_text/format-text.c 2010/06/28 20:35:17 1.133
@@ -1891,11 +1891,11 @@
{
struct format_instance *fid;
struct text_fid_context *fidtc;
- struct metadata_area *mda, *mda_new;
+ struct metadata_area *mda;
struct mda_context *mdac;
struct dir_list *dl;
struct raw_list *rl;
- struct dm_list *dir_list, *raw_list, *mdas;
+ struct dm_list *dir_list, *raw_list;
char path[PATH_MAX];
struct lvmcache_vginfo *vginfo;
struct lvmcache_info *info;
@@ -1923,7 +1923,7 @@
return_NULL;
mda->ops = &_metadata_text_file_backup_ops;
mda->metadata_locn = context;
- dm_list_add(&fid->metadata_areas_in_use, &mda->list);
+ fid_add_mda(fid, mda);
} else {
dir_list = &((struct mda_lists *) fmt->private)->dirs;
@@ -1940,7 +1940,7 @@
return_NULL;
mda->ops = &_metadata_text_file_ops;
mda->metadata_locn = context;
- dm_list_add(&fid->metadata_areas_in_use, &mda->list);
+ fid_add_mda(fid, mda);
}
raw_list = &((struct mda_lists *) fmt->private)->raws;
@@ -1960,7 +1960,7 @@
memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
mda->ops = &_metadata_text_raw_ops;
/* FIXME MISTAKE? mda->metadata_locn = context; */
- dm_list_add(&fid->metadata_areas_in_use, &mda->list);
+ fid_add_mda(fid, mda);
}
/* Scan PVs in VG for any further MDAs */
@@ -1968,14 +1968,8 @@
if (!(vginfo = vginfo_from_vgname(vgname, vgid)))
goto_out;
dm_list_iterate_items(info, &vginfo->infos) {
- mdas = &info->mdas;
- dm_list_iterate_items(mda, mdas) {
- /* FIXME Check it holds this VG */
- mda_new = mda_copy(fmt->cmd->mem, mda);
- if (!mda_new)
- return_NULL;
- dm_list_add(&fid->metadata_areas_in_use, &mda_new->list);
- }
+ if (!fid_add_mdas(fid, &info->mdas))
+ return_NULL;
}
/* FIXME Check raw metadata area count - rescan if required */
}
--- LVM2/lib/metadata/metadata.c 2010/06/28 20:34:58 1.354
+++ LVM2/lib/metadata/metadata.c 2010/06/28 20:35:17 1.355
@@ -2723,7 +2723,8 @@
if (correct_vg) {
/*
* If the VG has PVs without mdas, or ignored mdas, they may
- * still be orphans in the cache: update the cache state here.
+ * still be orphans in the cache: update the cache state here,
+ * and update the metadata lists in the vg.
*/
if (!inconsistent &&
dm_list_size(&correct_vg->pvs) > dm_list_size(pvids)) {
@@ -2747,6 +2748,9 @@
inconsistent_pvs = 1;
break;
}
+ if (dm_list_size(&info->mdas) &&
+ !fid_add_mdas(fid, &info->mdas))
+ return_NULL;
}
/* If the check passed, let's update VG and recalculate pvids */
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib format_text/format-text.c metadata/me ...
@ 2010-06-29 22:37 wysochanski
0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2010-06-29 22:37 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2010-06-29 22:37:32
Modified files:
lib/format_text: format-text.c
lib/metadata : metadata.c metadata.h
Log message:
Improve logging for metadata ignore by printing device name.
Print device name when setting or clearing metadata ignore bit.
Example:
label/label.c:160 /dev/loop2: lvm2 label detected
cache/lvmcache.c:1136 lvmcache: /dev/loop2: now in VG #orphans_lvm2 (#orphans_lvm2)
metadata/metadata.c:4142 Setting mda ignored flag for metadata_locn /dev/loop2.
format_text/text_label.c:318 Skipping mda with ignored flag on device /dev/loop2 at offset 4096
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.365&r2=1.366
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.212&r2=1.213
--- LVM2/lib/format_text/format-text.c 2010/06/29 14:52:57 1.135
+++ LVM2/lib/format_text/format-text.c 2010/06/29 22:37:32 1.136
@@ -1639,6 +1639,17 @@
return mdac_new;
}
+/*
+ * Return a string description of the metadata location.
+ */
+static const char * _metadata_locn_desc_raw(void *metadata_locn)
+{
+ struct mda_context *mdac;
+
+ mdac = (struct mda_context *) metadata_locn;
+ return dev_name(mdac->area.dev);
+}
+
static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
struct physical_volume *pv, struct dm_list *mdas,
@@ -1732,6 +1743,7 @@
.vg_commit = _vg_commit_raw,
.vg_revert = _vg_revert_raw,
.mda_metadata_locn_copy = _metadata_locn_copy_raw,
+ .mda_metadata_locn_desc = _metadata_locn_desc_raw,
.mda_free_sectors = _mda_free_sectors_raw,
.mda_total_sectors = _mda_total_sectors_raw,
.mda_in_vg = _mda_in_vg_raw,
--- LVM2/lib/metadata/metadata.c 2010/06/29 22:25:58 1.365
+++ LVM2/lib/metadata/metadata.c 2010/06/29 22:37:32 1.366
@@ -4119,15 +4119,23 @@
void mda_set_ignored(struct metadata_area *mda, unsigned ignored)
{
+ void *locn = mda->metadata_locn;
+
if (ignored) {
mda->flags |= MDA_IGNORED;
- log_verbose("Setting mda ignored flag for metadata_locn %p.",
- mda->metadata_locn);
} else {
mda->flags &= ~MDA_IGNORED;
- log_verbose("Clearing mda ignored flag for metadata_locn %p.",
- mda->metadata_locn);
}
+ if (mda->ops->mda_metadata_locn_desc)
+ log_verbose("%s mda ignored flag for "
+ "metadata_locn %s.",
+ ignored ? "Setting" : "Clearing",
+ mda->ops->mda_metadata_locn_desc(locn));
+ else
+ log_verbose("%s mda ignored flag for "
+ "metadata_locn %p.",
+ ignored ? "Setting" : "Clearing",
+ locn);
}
uint32_t pv_mda_count(const struct physical_volume *pv)
--- LVM2/lib/metadata/metadata.h 2010/06/29 22:25:58 1.212
+++ LVM2/lib/metadata/metadata.h 2010/06/29 22:37:32 1.213
@@ -139,6 +139,10 @@
* Per location copy constructor.
*/
void *(*mda_metadata_locn_copy) (struct dm_pool *mem, void *metadata_locn);
+ /*
+ * Per location description - useful for logging.
+ */
+ const char *(*mda_metadata_locn_desc) (void *metadata_locn);
/*
* Returns number of free sectors in given metadata area.
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib format_text/format-text.c metadata/me ...
@ 2010-06-28 20:32 wysochanski
0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2010-06-28 20:32 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2010-06-28 20:31:59
Modified files:
lib/format_text: format-text.c
lib/metadata : metadata.c metadata.h
Log message:
Add mda location specific mda_copy constructor.
Because of the way mdas are handled internally, where a PV in a VG
has mdas on both info->mdas and vg->fid->metadata_areas list, we
need a location independent copy constructor for struct
metadata_area. Break up the existing format-text specific copy
constructor into a format independent piece and a format dependent
piece.
This function is necessary to properly implement pv_set_mda_ignored().
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.129&r2=1.130
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.348&r2=1.349
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.207&r2=1.208
--- LVM2/lib/format_text/format-text.c 2010/06/28 20:31:38 1.129
+++ LVM2/lib/format_text/format-text.c 2010/06/28 20:31:59 1.130
@@ -1622,32 +1622,20 @@
}
/*
- * Copy constructor for a metadata_area.
+ * Copy constructor for a metadata_locn.
*/
-static struct metadata_area *_mda_copy(struct dm_pool *mem,
- struct metadata_area *mda)
+static void *_metadata_locn_copy_raw(struct dm_pool *mem, void *metadata_locn)
{
- struct metadata_area *mda_new;
struct mda_context *mdac, *mdac_new;
- if (!(mda_new = dm_pool_alloc(mem, sizeof(*mda_new)))) {
- log_error("metadata_area allocation failed");
- return NULL;
- }
- /* FIXME: Should have a per-format constructor here */
- mdac = (struct mda_context *) mda->metadata_locn;
+ mdac = (struct mda_context *) metadata_locn;
if (!(mdac_new = dm_pool_alloc(mem, sizeof(*mdac_new)))) {
log_error("mda_context allocation failed");
- dm_pool_free(mem, mda_new);
return NULL;
}
- memcpy(mda_new, mda, sizeof(*mda));
memcpy(mdac_new, mdac, sizeof(*mdac));
- mda_new->metadata_locn = mdac_new;
-
- /* FIXME mda 'list' left invalid here */
- return mda_new;
+ return mdac_new;
}
@@ -1675,7 +1663,7 @@
/* Add copy of mdas to supplied list */
dm_list_iterate_items(mda, &info->mdas) {
- mda_new = _mda_copy(fmt->cmd->mem, mda);
+ mda_new = mda_copy(fmt->cmd->mem, mda);
if (!mda_new)
return 0;
dm_list_add(mdas, &mda_new->list);
@@ -1742,6 +1730,7 @@
.vg_precommit = _vg_precommit_raw,
.vg_commit = _vg_commit_raw,
.vg_revert = _vg_revert_raw,
+ .mda_metadata_locn_copy = _metadata_locn_copy_raw,
.mda_free_sectors = _mda_free_sectors_raw,
.mda_total_sectors = _mda_total_sectors_raw,
.mda_in_vg = _mda_in_vg_raw,
@@ -1812,7 +1801,7 @@
if (found)
continue;
- mda_new = _mda_copy(fmt->cmd->mem, mda);
+ mda_new = mda_copy(fmt->cmd->mem, mda);
if (!mda_new)
return_0;
dm_list_add(mdas, &mda_new->list);
@@ -1980,7 +1969,7 @@
mdas = &info->mdas;
dm_list_iterate_items(mda, mdas) {
/* FIXME Check it holds this VG */
- mda_new = _mda_copy(fmt->cmd->mem, mda);
+ mda_new = mda_copy(fmt->cmd->mem, mda);
if (!mda_new)
return_NULL;
dm_list_add(&fid->metadata_areas, &mda_new->list);
--- LVM2/lib/metadata/metadata.c 2010/06/28 20:31:38 1.348
+++ LVM2/lib/metadata/metadata.c 2010/06/28 20:31:59 1.349
@@ -3856,6 +3856,32 @@
}
/*
+ * Copy constructor for a metadata_area.
+ */
+struct metadata_area *mda_copy(struct dm_pool *mem,
+ struct metadata_area *mda)
+{
+ struct metadata_area *mda_new;
+
+ if (!(mda_new = dm_pool_alloc(mem, sizeof(*mda_new)))) {
+ log_error("metadata_area allocation failed");
+ return NULL;
+ }
+ memcpy(mda_new, mda, sizeof(*mda));
+ if (mda->ops->mda_metadata_locn_copy && mda->metadata_locn) {
+ mda_new->metadata_locn =
+ mda->ops->mda_metadata_locn_copy(mem, mda->metadata_locn);
+ if (!mda_new->metadata_locn) {
+ dm_pool_free(mem, mda_new);
+ return NULL;
+ }
+ }
+
+ /* FIXME mda 'list' left invalid here */
+
+ return mda_new;
+}
+/*
* This function provides a way to answer the question on a format specific
* basis - does the format specfic context of these two metadata areas
* match?
--- LVM2/lib/metadata/metadata.h 2010/06/28 20:31:38 1.207
+++ LVM2/lib/metadata/metadata.h 2010/06/28 20:31:59 1.208
@@ -136,6 +136,11 @@
struct metadata_area * mda);
/*
+ * Per location copy constructor.
+ */
+ void *(*mda_metadata_locn_copy) (struct dm_pool *mem, void *metadata_locn);
+
+ /*
* Returns number of free sectors in given metadata area.
*/
uint64_t (*mda_free_sectors) (struct metadata_area *mda);
@@ -172,6 +177,8 @@
void *metadata_locn;
uint32_t flags;
};
+struct metadata_area *mda_copy(struct dm_pool *mem,
+ struct metadata_area *mda);
unsigned mda_is_ignored(struct metadata_area *mda);
void mda_set_ignored(struct metadata_area *mda, int value);
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib format_text/format-text.c metadata/me ...
@ 2010-06-28 20:31 wysochanski
0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2010-06-28 20:31 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2010-06-28 20:31:39
Modified files:
lib/format_text: format-text.c
lib/metadata : metadata.c metadata.h
Log message:
Add mda_locns_match() internal library function for mapping pv/device to VG mda.
A metadata_area is defined independent of the location. One downside
is that there is no obvious mapping from a pv to an mda. For a PV in
a VG, we need a way to start with a PV and end up with an MDA, if we
are to manage mdas starting with a device/pv. This function provides
us a way to go down the list of PVs on a VG, and identify which ones
match a particular PV.
I'm not entirely happy with this approach, but it does fit into the
existing structures in a reasonable way.
An alternative solution might be to refactor the VG - PV interface such
that mdas are a list tied to a PV. However, this seemed a bit tricky since
a PV does not come into existence until after the list of mdas is
constructed (see _vg_read() - we create a 'fid' and attach mdas to it,
then we go through them and attach pvs).
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.347&r2=1.348
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.206&r2=1.207
--- LVM2/lib/format_text/format-text.c 2010/06/28 20:31:18 1.128
+++ LVM2/lib/format_text/format-text.c 2010/06/28 20:31:38 1.129
@@ -121,6 +121,20 @@
return 0;
}
+static unsigned _mda_locns_match_raw(struct metadata_area *mda1,
+ struct metadata_area *mda2)
+{
+ struct mda_context *mda1c = (struct mda_context *) mda1->metadata_locn;
+ struct mda_context *mda2c = (struct mda_context *) mda2->metadata_locn;
+
+ if ((mda1c->area.dev == mda2c->area.dev) &&
+ (mda1c->area.start == mda2c->area.start) &&
+ (mda1c->area.size == mda2c->area.size))
+ return 1;
+
+ return 0;
+}
+
/*
* For circular region between region_start and region_start + region_size,
* back up one SECTOR_SIZE from 'region_ptr' and return the value.
@@ -1732,6 +1746,7 @@
.mda_total_sectors = _mda_total_sectors_raw,
.mda_in_vg = _mda_in_vg_raw,
.pv_analyze_mda = _pv_analyze_mda_raw,
+ .mda_locns_match = _mda_locns_match_raw
};
/* pvmetadatasize in sectors */
--- LVM2/lib/metadata/metadata.c 2010/06/28 20:30:14 1.347
+++ LVM2/lib/metadata/metadata.c 2010/06/28 20:31:38 1.348
@@ -3855,6 +3855,36 @@
return pv_field(pv, pe_alloc_count);
}
+/*
+ * This function provides a way to answer the question on a format specific
+ * basis - does the format specfic context of these two metadata areas
+ * match?
+ *
+ * A metatdata_area is defined to be independent of the underlying context.
+ * This has the benefit that we can use the same abstraction to read disks
+ * (see _metadata_text_raw_ops) or files (see _metadata_text_file_ops).
+ * However, one downside is there is no format-independent way to determine
+ * whether a given metadata_area is attached to a specific device - in fact,
+ * it may not be attached to a device at all.
+ *
+ * Thus, LVM is structured such that an mda is not a member of struct
+ * physical_volume. The location of the mda depends on whether
+ * the PV is in a volume group. A PV not in a VG has an mda on the
+ * 'info->mda' list in lvmcache, while a PV in a VG has an mda on
+ * the vg->fid->metadata_areas list. For further details, see _vg_read(),
+ * and the sequence of creating the format_instance with fid->metadata_areas
+ * list, as well as the construction of the VG, with list of PVs (comes
+ * after the construction of the fid and list of mdas).
+ */
+unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2)
+{
+ if (!mda1->ops->mda_locns_match || !mda2->ops->mda_locns_match ||
+ mda1->ops->mda_locns_match != mda2->ops->mda_locns_match)
+ return 0;
+
+ return mda1->ops->mda_locns_match(mda1, mda2);
+}
+
unsigned mda_is_ignored(struct metadata_area *mda)
{
return (mda->flags & MDA_IGNORED);
--- LVM2/lib/metadata/metadata.h 2010/06/28 20:30:14 1.206
+++ LVM2/lib/metadata/metadata.h 2010/06/28 20:31:38 1.207
@@ -156,6 +156,12 @@
int (*pv_analyze_mda) (const struct format_type * fmt,
struct metadata_area *mda);
+ /*
+ * Do these two metadata_areas match with respect to their underlying
+ * location?
+ */
+ unsigned (*mda_locns_match)(struct metadata_area *mda1,
+ struct metadata_area *mda2);
};
#define MDA_IGNORED 0x00000001
@@ -169,6 +175,7 @@
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);
#define seg_pvseg(seg, s) (seg)->areas[(s)].u.pv.pvseg
#define seg_dev(seg, s) (seg)->areas[(s)].u.pv.pvseg->pv->dev
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib format_text/format-text.c metadata/me ...
@ 2005-04-17 23:57 agk
0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2005-04-17 23:57 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2005-04-17 23:57:44
Modified files:
lib/format_text: format-text.c
lib/metadata : metadata.c metadata.h
Log message:
get_pv_from_vg_by_id
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.114&r2=1.115
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-29 22:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-28 20:35 LVM2/lib format_text/format-text.c metadata/me wysochanski
-- strict thread matches above, loose matches on Subject: below --
2010-06-29 22:37 wysochanski
2010-06-28 20:32 wysochanski
2010-06-28 20:31 wysochanski
2005-04-17 23:57 agk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).