master - pvscan: use format feature flags in lvmetad code
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0a13815e68c3d8...
Commit: 0a13815e68c3d85b140f8c6d4d91592ae2f8b992
Parent: 21c3b41ea893fe64e7ca5245411899ace4ae2a81
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jan 8 02:13:13 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jan 8 02:13:13 2014 +0000
pvscan: use format feature flags in lvmetad code
Introduce FMT_OBSOLETE to identify pool metadata and use it and FMT_MDAS
instead of hard-coded format names.
Explain device accesses on pvscan --cache man page.
---
lib/cache/lvmetad.c | 27 ++++++++++++++-------------
lib/format_pool/format_pool.c | 2 +-
lib/metadata/metadata-exported.h | 1 +
man/pvscan.8.in | 9 ++++++++-
4 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 85bbf88..aec6a71 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -20,8 +20,6 @@
#include "lvmcache.h"
#include "lvmetad-client.h"
#include "format-text.h" // TODO for disk_locn, used as a DA representation
-#include "format_pool.h" // for FMT_POOL_NAME
-#include "format1.h" // for FMT_LVM1_NAME
#include "crc.h"
static daemon_handle _lvmetad;
@@ -901,25 +899,28 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
info = (struct lvmcache_info *) label->info;
baton.vg = NULL;
- baton.fid = lvmcache_fmt(info)->ops->create_instance(lvmcache_fmt(info),
- &fic);
+ baton.fid = lvmcache_fmt(info)->ops->create_instance(lvmcache_fmt(info), &fic);
if (!baton.fid)
goto_bad;
- lvmcache_foreach_mda(info, _lvmetad_pvscan_single, &baton);
-
- if (lvmcache_fmt(info) == get_format_by_name(cmd, FMT_POOL_NAME)) {
- log_error("WARNING: Ignoring old GFS pool metadata on device %s "
- "when using lvmetad", dev_name(dev));
+ if (baton.fid->fmt->features & FMT_OBSOLETE) {
+ log_error("WARNING: Ignoring obsolete format of metadata (%s) on device %s when using lvmetad",
+ baton.fid->fmt->name, dev_name(dev));
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
return 0;
}
- /* LVM1 VGs have no MDAs. */
- if (!baton.vg && lvmcache_fmt(info) == get_format_by_name(cmd, FMT_LVM1_NAME))
- baton.vg = ((struct metadata_area *) dm_list_first(&baton.fid->metadata_areas_in_use))->
- ops->vg_read(baton.fid, lvmcache_vgname_from_info(info), NULL, 0);
+ lvmcache_foreach_mda(info, _lvmetad_pvscan_single, &baton);
+
+ /*
+ * LVM1 VGs have no MDAs and lvmcache_foreach_mda isn't worth fixing
+ * to use pseudo-mdas for PVs.
+ * Note that the single_device parameter also gets ignored and this code
+ * can scan further devices.
+ */
+ if (!baton.vg && !(baton.fid->fmt->features & FMT_MDAS))
+ baton.vg = ((struct metadata_area *) dm_list_first(&baton.fid->metadata_areas_in_use))->ops->vg_read(baton.fid, lvmcache_vgname_from_info(info), NULL, 1);
if (!baton.vg)
lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index 0f8f3a3..503005a 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -298,7 +298,7 @@ struct format_type *init_format(struct cmd_context *cmd)
fmt->name = FMT_POOL_NAME;
fmt->alias = NULL;
fmt->orphan_vg_name = FMT_POOL_ORPHAN_VG_NAME;
- fmt->features = 0;
+ fmt->features = FMT_OBSOLETE;
fmt->private = NULL;
dm_list_init(&fmt->mda_ops);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 1cce72c..6a959d1 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -122,6 +122,7 @@
#define FMT_RESTRICTED_READAHEAD 0x00000200U /* Readahead restricted to 2-120? */
#define FMT_BAS 0x000000400U /* Supports bootloader areas? */
#define FMT_CONFIG_PROFILE 0x000000800U /* Supports configuration profiles? */
+#define FMT_OBSOLETE 0x000001000U /* Obsolete format? */
/* Mirror conversion type flags */
#define MIRROR_BY_SEG 0x00000001U /* segment-by-segment mirror */
diff --git a/man/pvscan.8.in b/man/pvscan.8.in
index 37ecaaf..61b15d0 100644
--- a/man/pvscan.8.in
+++ b/man/pvscan.8.in
@@ -57,13 +57,20 @@ supported for logical volumes that are part of partial or clustered volume group
.BR \-b ", " \-\-background
Run the command in the background.
.TP
-.BR \-\-cache " [" \-\-major " " \fImajor " " \-\-minor " " \fIminor " | " \fIDevicePath " ]..."
+.BR \-\-cache " [" \-\-major " " \fImajor " " \-\-minor " " \fIminor " | " \fIDevicePath " | " \fImajor:minor " ]..."
Scan one or more devices and instruct the lvmetad daemon to update its cached
state accordingly. Called internally by udev rules.
All devices listed explicitly are processed \fBregardless\fP of any device
filters set using \fBdevices/filter\fP configuration setting. To filter
devices even in this case, the \fBdevices/global_filter\fP must be used.
+If lvmetad has not yet cached any metadata or the filters have recently been
+changed, then all devices may be scanned, effectively ignoring the rest of
+the command line. Otherwise, if all the devices referenced on the command line
+contain metadata in the default lvm2 format, other devices are not accessed.
+If metadata written using the obsolete GFS pool format is encountered, this is
+ignored and so lvmetad should not be used.
.SH SEE ALSO
.BR lvm (8),
+.BR lvmetad (8),
.BR pvcreate (8),
.BR pvdisplay (8)
10 years, 3 months
master - lvmetad: free fid after vg lookup failure
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=21c3b41ea893fe...
Commit: 21c3b41ea893fe64e7ca5245411899ace4ae2a81
Parent: 3a4efb2f1620b5875395966b66510392d1ebe60a
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jan 8 01:51:23 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jan 8 01:51:23 2014 +0000
lvmetad: free fid after vg lookup failure
---
lib/cache/lvmetad.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 65ed520..85bbf88 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -240,8 +240,9 @@ static int _read_mda(struct lvmcache_info *info,
return 0;
}
-static struct lvmcache_info *_pv_populate_lvmcache(
- struct cmd_context *cmd, struct dm_config_node *cn, dev_t fallback)
+static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
+ struct dm_config_node *cn,
+ dev_t fallback)
{
struct device *dev;
struct id pvid, vgid;
@@ -342,7 +343,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
daemon_reply reply;
int found;
char uuid[64];
- struct format_instance *fid;
+ struct format_instance *fid = NULL;
struct format_instance_ctx fic;
struct dm_config_node *top;
const char *name, *diag_name;
@@ -424,6 +425,8 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
}
out:
+ if (!vg && fid)
+ fid->fmt->ops->destroy_instance(fid);
daemon_reply_destroy(reply);
return vg;
10 years, 3 months
master - Misc: Get rid of some compiler warnings.
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3a4efb2f1620b5...
Commit: 3a4efb2f1620b5875395966b66510392d1ebe60a
Parent: a832120521ea4cd528b8228bf0fe1cf80fa603e9
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Jan 7 19:37:07 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Jan 7 19:37:07 2014 -0600
Misc: Get rid of some compiler warnings.
---
daemons/cmirrord/logging.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/cmirrord/logging.h b/daemons/cmirrord/logging.h
index 40dd462..facc1b2 100644
--- a/daemons/cmirrord/logging.h
+++ b/daemons/cmirrord/logging.h
@@ -63,7 +63,7 @@ extern int log_resend_requests;
#ifdef DEBUG
#define LOG_DBG(f, arg...) LOG_OUTPUT(LOG_DEBUG, f, ## arg)
#else /* DEBUG */
-#define LOG_DBG(f, arg...)
+#define LOG_DBG(f, arg...) do {} while (0)
#endif /* DEBUG */
#define LOG_COND(__X, f, arg...) do {\
10 years, 3 months
master - lvmetad: Flush a VG if it goes completely missing due to pv_found.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a832120521ea4c...
Commit: a832120521ea4cd528b8228bf0fe1cf80fa603e9
Parent: 89e7d81d92274ed60b73332e04ceb966e398a0e6
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jan 7 03:28:20 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jan 7 03:28:20 2014 +0100
lvmetad: Flush a VG if it goes completely missing due to pv_found.
---
daemons/lvmetad/lvmetad-core.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 7409839..19e0b6b 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -859,6 +859,7 @@ static response pv_found(lvmetad_state *s, request r)
const char *pvid = daemon_request_str(r, "pvmeta/id", NULL);
const char *vgname = daemon_request_str(r, "vgname", NULL);
const char *vgid = daemon_request_str(r, "metadata/id", NULL);
+ const char *vgid_old;
struct dm_config_node *pvmeta = dm_config_find_node(r.cft->root, "pvmeta");
uint64_t device;
struct dm_config_tree *cft, *pvmeta_old_dev = NULL, *pvmeta_old_pvid = NULL;
@@ -880,6 +881,12 @@ static response pv_found(lvmetad_state *s, request r)
if ((old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device)))) {
pvmeta_old_dev = dm_hash_lookup(s->pvid_to_pvmeta, old);
dm_hash_remove(s->pvid_to_pvmeta, old);
+
+ if (vgid_old = dm_hash_lookup(s->pvid_to_vgid, pvid)) {
+ lock_vg(s, vgid_old);
+ vg_remove_if_missing(s, vgid_old, 1);
+ unlock_vg(s, vgid_old);
+ }
}
pvmeta_old_pvid = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
10 years, 3 months
master - lvmetad: Fix a corruption-prone race in error path.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=89e7d81d92274e...
Commit: 89e7d81d92274ed60b73332e04ceb966e398a0e6
Parent: 087d33d73b28fcf42f7db5402c80bd174c3d9451
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jan 7 03:04:14 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jan 7 03:04:14 2014 +0100
lvmetad: Fix a corruption-prone race in error path.
---
daemons/lvmetad/lvmetad-core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index bc306f3..7409839 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -903,8 +903,8 @@ static response pv_found(lvmetad_state *s, request r)
if (!dm_hash_insert(s->pvid_to_pvmeta, pvid, cft) ||
!dm_hash_insert_binary(s->device_to_pvid, &device, sizeof(device), (void*)pvid_dup)) {
- unlock_pvid_to_pvmeta(s);
dm_hash_remove(s->pvid_to_pvmeta, pvid);
+ unlock_pvid_to_pvmeta(s);
dm_config_destroy(cft);
dm_free(pvid_dup);
return reply_fail("out of memory");
10 years, 3 months
master - toollib: Fix a mis-merge in _process_all_devs (duplicated pvs -a output).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=087d33d73b28fc...
Commit: 087d33d73b28fcf42f7db5402c80bd174c3d9451
Parent: eaeb33abd4887c668aa88703b6e8981da6f44791
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jan 7 02:49:12 2014 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jan 7 02:49:12 2014 +0100
toollib: Fix a mis-merge in _process_all_devs (duplicated pvs -a output).
---
tools/toollib.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 0429eb9..bf226b9 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -770,9 +770,6 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
ret = process_single_pv(cmd, NULL, pv, handle);
- free_pv_fid(pv);
-
- ret = process_single_pv(cmd, NULL, pv, handle);
if (ret > ret_max)
ret_max = ret;
10 years, 3 months