summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-03-04 16:30:04 -0600
committerDavid Teigland <teigland@redhat.com>2016-03-04 17:07:38 -0600
commit7a8b5bd3d79745886afa151203914ae5e0fbfdff (patch)
treef6c022603fe82222f9ac18aa6adbde267ea1c73d
parent219e00771b26717add28de982dbd3011ddca28aa (diff)
downloadlvm2-dev-dct-lvm-using-dev-3.tar.gz
pvs: warn if no PV is found for a used devicedev-dct-lvm-using-dev-3
-rw-r--r--lib/activate/activate.c2
-rw-r--r--lib/activate/dev_manager.c20
-rw-r--r--lib/activate/dev_manager.h2
-rw-r--r--lib/device/dev-cache.c3
-rw-r--r--lib/device/device.h2
-rw-r--r--tools/toollib.c7
6 files changed, 26 insertions, 10 deletions
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 88a39fa9f..a222bc134 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2395,7 +2395,7 @@ int pv_uses_vg(struct physical_volume *pv,
*/
int lvs_using_device(struct device *dev)
{
- return dev_manager_lvm_using_device(dev);
+ return dev_manager_lvm_using_device(MAJOR(dev), MINOR(dev), NULL);
}
void activation_release(void)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 78d9b622a..a3722c454 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -3161,7 +3161,7 @@ out:
return r;
}
-static int _is_lvm_uuid(char *dm_name)
+static int _is_lvm_uuid(char *dm_name, char *vg_dlid)
{
struct dm_info info;
struct dm_task *dmt;
@@ -3186,17 +3186,18 @@ static int _is_lvm_uuid(char *dm_name)
if (!(uuid = dm_task_get_uuid(dmt)))
goto out;
- if (!strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
+ if (!strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
+ memcpy(vg_dlid, uuid, sizeof(UUID_PREFIX) + sizeof(struct id) - 1);
ret = 1;
-
- /* Verify that a uuid follows the LVM prefix? */
+ }
out:
dm_task_destroy(dmt);
return ret;
}
-int dev_manager_lvm_using_device(struct device *dev)
+int dev_manager_lvm_using_device(uint32_t major, uint32_t minor, char *vg_dlid)
{
+ char dlid[sizeof(UUID_PREFIX) + sizeof(struct id) - 1] __attribute__((aligned(8)));
struct dm_task *dmt;
struct dm_task *dmt2;
struct dm_deps *deps;
@@ -3219,9 +3220,11 @@ int dev_manager_lvm_using_device(struct device *dev)
do {
names = (struct dm_names *)((char *) names + next);
+
+ memset(&dlid, 0, sizeof(dlid));
dmt2 = NULL;
- if (!_is_lvm_uuid(names->name))
+ if (!_is_lvm_uuid(names->name, &dlid))
goto next;
if (!(dmt2 = _setup_task(names->name, NULL, 0, DM_DEVICE_DEPS, 0, 0, 0)))
@@ -3234,9 +3237,10 @@ int dev_manager_lvm_using_device(struct device *dev)
goto next;
for (i = 0; i < deps->count; i++) {
- if ((MAJOR(dev->dev) == (int) MAJOR(deps->device[i])) &&
- (MINOR(dev->dev) == (int) MINOR(deps->device[i]))) {
+ if ((major == (int) MAJOR(deps->device[i])) &&
+ (minor == (int) MINOR(deps->device[i]))) {
is_used = 1;
+ memcpy(vg_dlid, &dlid, sizeof(dlid));
break;
}
}
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index fb042b6b3..c2ef9cb1c 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -97,6 +97,6 @@ int dev_manager_execute(struct dev_manager *dm);
int dev_manager_device_uses_vg(struct device *dev,
struct volume_group *vg);
-int dev_manager_lvm_using_device(struct device *dev);
+int dev_manager_lvm_using_device(uint32_t major, uint32_t minor, char *vg_dlid);
#endif
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 47ae1403e..7f0b7876b 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -409,6 +409,8 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
+ dev_manager_lvm_using_device(MAJOR(d), MINOR(d), &dev->vg_dlid);
+
return 1;
}
@@ -1110,3 +1112,4 @@ const char *dev_name(const struct device *dev)
return (dev && dev->aliases.n) ? dm_list_item(dev->aliases.n, struct dm_str_list)->str :
unknown_device_name();
}
+
diff --git a/lib/device/device.h b/lib/device/device.h
index 6b01fb6e7..f8860c5c0 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -70,6 +70,8 @@ struct device {
char pvid[ID_LEN + 1];
char _padding[7];
+ char vg_dlid[sizeof(UUID_PREFIX) + sizeof(struct id) - 1];
+ /* FIXME: padding? */
};
struct device_list {
diff --git a/tools/toollib.c b/tools/toollib.c
index 9e866d6f4..bfe9726f9 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3457,6 +3457,13 @@ skip_missed:
ret_max = ECMD_FAILED;
}
+ if (process_all_pvs) {
+ dm_list_iterate_items(dil, &all_devices) {
+ if (dil->dev->vg_dlid[0])
+ log_warn("WARNING: No PV found for device %s which is in use.", dev_name(dil->dev));
+ }
+ }
+
if (!process_all_devices)
goto out;