From acb037657cf4ffb5b36e20881bdffd954e6249cf Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 10 Dec 2010 22:39:52 +0000 Subject: Fix scanning of VGs without in-PV mdas. Set cmd->independent_metadata_areas if metadata/dirs or disk_areas in use. - Identify and record this state. Don't skip full scan when independent mdas are present even if memlock is set. - Clusters and OOM aren't supported, so no problem doing the proper scans. Avoid revalidating the label cache immediately after scanning. - A simple optimisation. Support scanning for a single VG in independent mdas. - Not used by the fix but I left it in anyway as later patches might use it. --- lib/cache/lvmcache.c | 23 ++++++++++++++++------- lib/cache/lvmcache.h | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'lib/cache') diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index ab16536c..d5455631 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -366,7 +366,7 @@ struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname, const char *vgid) return vginfo; } -const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid) +const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels) { struct lvmcache_vginfo *vginfo; struct lvmcache_info *info; @@ -379,8 +379,16 @@ const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid) if (!(vginfo = vginfo_from_vgname(vgname, vgid))) return NULL; - /* This function is normally called before reading metadata so - * we check cached labels here. Unfortunately vginfo is volatile. */ + /* + * If this function is called repeatedly, only the first one needs to revalidate. + */ + if (!revalidate_labels) + goto out; + + /* + * This function is normally called before reading metadata so + * we check cached labels here. Unfortunately vginfo is volatile. + */ dm_list_init(&devs); dm_list_iterate_items(info, &vginfo->infos) { if (!(devl = dm_malloc(sizeof(*devl)))) { @@ -405,6 +413,7 @@ const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid) strncmp(vginfo->vgid, vgid_found, ID_LEN)) return NULL; +out: return vginfo->fmt; } @@ -588,10 +597,10 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan) _has_scanned = 1; /* Perform any format-specific scanning e.g. text files */ - dm_list_iterate_items(fmt, &cmd->formats) { - if (fmt->ops->scan && !fmt->ops->scan(fmt)) - goto out; - } + if (cmd->independent_metadata_areas) + dm_list_iterate_items(fmt, &cmd->formats) + if (fmt->ops->scan && !fmt->ops->scan(fmt, NULL)) + goto out; /* * If we are a long-lived process, write out the updated persistent diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h index 28f85418..06838dc8 100644 --- a/lib/cache/lvmcache.h +++ b/lib/cache/lvmcache.h @@ -88,7 +88,7 @@ void lvmcache_unlock_vgname(const char *vgname); int lvmcache_verify_lock_order(const char *vgname); /* Queries */ -const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid); +const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels); struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname, const char *vgid); struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid); -- cgit