summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2012-03-03 18:32:53 +0000
committerAlasdair Kergon <agk@redhat.com>2012-03-03 18:32:53 +0000
commit35216ca66c497820e35a11977e87c76ae174a7fb (patch)
tree5fa0aac61bb3ddaef4c64d691945f8630d187ff6 /lib
parent59a5361fc4b4a404229acce72156be444e75fced (diff)
downloadlvm2-35216ca66c497820e35a11977e87c76ae174a7fb.tar.gz
lvm2-35216ca66c497820e35a11977e87c76ae174a7fb.tar.xz
lvm2-35216ca66c497820e35a11977e87c76ae174a7fb.zip
Scan all devices for lvmetad if 'pvscan --cache' used without device list.
Diffstat (limited to 'lib')
-rw-r--r--lib/cache/lvmetad.c52
-rw-r--r--lib/cache/lvmetad.h17
2 files changed, 13 insertions, 56 deletions
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index f3e3727a..47b71fee 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -607,7 +607,7 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_
return result;
}
-static int _lvmetad_pv_gone(dev_t device, const char *pv_name)
+int lvmetad_pv_gone(dev_t device, const char *pv_name)
{
int result;
int found;
@@ -625,9 +625,9 @@ static int _lvmetad_pv_gone(dev_t device, const char *pv_name)
return result;
}
-int lvmetad_pv_gone(struct device *dev)
+int lvmetad_pv_gone_by_dev(struct device *dev)
{
- return _lvmetad_pv_gone(dev->dev, dev_name(dev));
+ return lvmetad_pv_gone(dev->dev, dev_name(dev));
}
int lvmetad_active(void)
@@ -663,33 +663,8 @@ static int _pvscan_lvmetad_single(struct metadata_area *mda, void *baton)
return 1;
}
-static dev_t _parse_devt(const char *str)
-{ /* Oh. */
- char *where = (char *) str;
- int major = strtol(str, &where, 10);
- int minor;
-
- if (where == str)
- return -1;
-
- if (*where != ':')
- return -1;
-
- str = ++where;
- minor = strtol(str, &where, 10);
-
- if (where == str)
- return -1;
-
- if (*where)
- return -1;
-
- return MKDEV(major, minor);
-}
-
-int pvscan_lvmetad_single(struct cmd_context *cmd, const char *pv_name)
+int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev)
{
- struct device *dev;
struct label *label;
struct lvmcache_info *info;
struct physical_volume pv;
@@ -702,26 +677,9 @@ int pvscan_lvmetad_single(struct cmd_context *cmd, const char *pv_name)
return 0;
}
- dev = dev_cache_get(pv_name, NULL);
- if (!dev && _parse_devt(pv_name) != -1)
- dev = dev_cache_get_by_devt(_parse_devt(pv_name), NULL);
-
- if (!dev) {
- if (_parse_devt(pv_name) == -1) {
- log_error("Unrecognised device name %s. (Use MAJOR:MINOR for new devices.)", pv_name);
- return 0;
- }
-
- if (!_lvmetad_pv_gone(_parse_devt(pv_name), pv_name))
- goto_bad;
-
- log_print("Device %s not found. Cleared from lvmetad cache.", pv_name);
- return 1;
- }
-
if (!label_read(dev, &label, 0)) {
log_print("No PV label found on %s.", dev_name(dev));
- if (!lvmetad_pv_gone(dev))
+ if (!lvmetad_pv_gone_by_dev(dev))
goto_bad;
return 1;
}
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index c59c775d..091ff5e3 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -67,11 +67,10 @@ int lvmetad_pv_found(struct id pvid, struct device *device,
struct volume_group *vg);
/*
- * Inform the daemon that the device no longer exists. We do not support
- * multiple device names, so this needs a unique and stable name, the same as
- * provided to lvmetad_pv_found.
+ * Inform the daemon that the device no longer exists.
*/
-int lvmetad_pv_gone(struct device *dev);
+int lvmetad_pv_gone(dev_t devno, const char *pv_name);
+int lvmetad_pv_gone_by_dev(struct device *dev);
/*
* Request a list of all PVs available to lvmetad. If requested, this will also
@@ -101,10 +100,9 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd,
const char *vgname, const char *vgid);
/*
- * Scan a single device and update lvmetad with the result(s). If the device
- * node does not exist, it must be supplied in a major:minor format.
+ * Scan a single device and update lvmetad with the result(s).
*/
-int pvscan_lvmetad_single(struct cmd_context *cmd, const char *pv_name);
+int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev);
# else /* LVMETAD_SUPPORT */
@@ -114,13 +112,14 @@ int pvscan_lvmetad_single(struct cmd_context *cmd, const char *pv_name);
# define lvmetad_vg_update(vg) (1)
# define lvmetad_vg_remove(vg) (1)
# define lvmetad_pv_found(pvid, device, fmt, label_sector, vg) (1)
-# define lvmetad_pv_gone(dev) (1)
+# define lvmetad_pv_gone(devno, pv_name) (1)
+# define lvmetad_pv_gone_by_dev(dev) (1)
# define lvmetad_pv_list_to_lvmcache(cmd) (1)
# define lvmetad_pv_lookup(cmd, pvid, found) (0)
# define lvmetad_pv_lookup_by_dev(cmd, dev, found) (0)
# define lvmetad_vg_list_to_lvmcache(cmd) (1)
# define lvmetad_vg_lookup(cmd, vgname, vgid) (NULL)
-# define pvscan_lvmetad_single(cmd, pv_name) (0)
+# define pvscan_lvmetad_single(cmd, dev) (0)
# endif /* LVMETAD_SUPPORT */