summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2017-10-17 02:12:41 +0100
committerAlasdair G Kergon <agk@redhat.com>2017-10-17 02:12:41 +0100
commit146745ad88abc0512650b5b40d00ca587784ca36 (patch)
treefeacdbb8f4a6388757ca584f9c77708f5610f858
parent1f359f7558b5ae7750fa629575426ae110781566 (diff)
downloadlvm2-146745ad88abc0512650b5b40d00ca587784ca36.tar.gz
device: Separate errors for dev not found and filtered.
Replaced the confusing device error message "not found (or ignored by filtering)" by either "not found" or "excluded by a filter". (Later we should be able to say which filter.) Left the the liblvm code paths alone.
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/device/dev-cache.c13
-rw-r--r--lib/device/dev-cache.h1
-rw-r--r--lib/metadata/metadata.c3
-rw-r--r--tools/toollib.c4
5 files changed, 18 insertions, 4 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 4ad6b1f88..665517b7c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.176 -
===================================
+ Distinguish between device not found and excluded by filter.
Monitor external origin LVs.
Remove the replicator code, including configure --with-replicators.
Allow lvcreate --type mirror to work with 100%FREE.
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 7802e45c4..83c2b1243 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1370,6 +1370,19 @@ const char *dev_name_confirmed(struct device *dev, int quiet)
return dev_name(dev);
}
+/* Provide a custom reason when a device is ignored */
+const char *dev_cache_filtered_reason(const char *name)
+{
+ const char *reason = "not found";
+ struct device *d = (struct device *) dm_hash_lookup(_cache.names, name);
+
+ if (d)
+ /* FIXME Record which filter caused the exclusion */
+ reason = "excluded by a filter";
+
+ return reason;
+}
+
struct device *dev_cache_get(const char *name, struct dev_filter *f)
{
struct stat buf;
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 04069708c..546b1fe2a 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -55,6 +55,7 @@ int dev_cache_add_dir(const char *path);
int dev_cache_add_loopfile(const char *path);
__attribute__((nonnull(1)))
struct device *dev_cache_get(const char *name, struct dev_filter *f);
+const char *dev_cache_filtered_reason(const char *name);
// TODO
struct device *dev_cache_get_by_devt(dev_t device, struct dev_filter *f);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 1606b3965..496dbee65 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5488,8 +5488,7 @@ int pv_analyze(struct cmd_context *cmd, const char *pv_name,
dev = dev_cache_get(pv_name, cmd->filter);
if (!dev) {
- log_error("Device %s not found (or ignored by filtering).",
- pv_name);
+ log_error("Device %s %s.", pv_name, dev_cache_filtered_reason(pv_name));
return 0;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index b28167b06..fc615f31a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5532,7 +5532,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
* Check if all arg_devices were found by process_each_pv.
*/
dm_list_iterate_items(pd, &pp->arg_devices)
- log_error("Device %s not found (or ignored by filtering).", pd->name);
+ log_error("Device %s %s.", pd->name, dev_cache_filtered_reason(pd->name));
/*
* Can the command continue if some specified devices were not found?
@@ -5652,7 +5652,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
process_each_pv(cmd, 0, NULL, NULL, 1, 0, handle, _pv_confirm_single);
dm_list_iterate_items(pd, &pp->arg_confirm)
- log_error("Device %s not found (or ignored by filtering).", pd->name);
+ log_error("Device %s %s.", pd->name, dev_cache_filtered_reason(pd->name));
/* Some devices were not found during the second check. */
if (!dm_list_empty(&pp->arg_confirm) && must_use_all)