]> sourceware.org Git - lvm2.git/commitdiff
filters: better message for excluding LV
authorDavid Teigland <teigland@redhat.com>
Wed, 3 Mar 2021 18:07:57 +0000 (12:07 -0600)
committerDavid Teigland <teigland@redhat.com>
Wed, 3 Mar 2021 18:07:57 +0000 (12:07 -0600)
Make the generic "device is not usable" message from filter-usable
more specific in case the device is not usable because it's an LV.
(i.e. when scan_lvs=0)

lib/activate/activate.c
lib/activate/activate.h
lib/activate/dev_manager.c
lib/cache/lvmcache.c
lib/filters/filter-usable.c
lib/filters/filter.h

index de866fb6c0c3b55dcb9bd1b24641f0cd5021788f..75248aa63a3b301b682c6d5fcb8488f466854a2f 100644 (file)
@@ -392,7 +392,7 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
 {
         return 0;
 }
-int device_is_usable(struct device *dev, struct dev_usable_check_params check)
+int device_is_usable(struct device *dev, struct dev_usable_check_params check, int *is_lv)
 {
         return 0;
 }
index 53c8631b4d4355f968852b66a4a0e574f57c4b8c..4c9328a6659ecafd95ccb98e924caa4b9535f3d0 100644 (file)
@@ -253,7 +253,7 @@ struct dev_usable_check_params {
  * Returns 1 if mapped device is not suspended, blocked or
  * is using a reserved name.
  */
-int device_is_usable(struct device *dev, struct dev_usable_check_params check);
+int device_is_usable(struct device *dev, struct dev_usable_check_params check, int *is_lv);
 
 /*
  * Declaration moved here from fs.h to keep header fs.h hidden
index 9a25482138397bbdfa9e5571ffbb1f88ca2d5041..1a8f848acc94524be5413d5e7355be7713d36cda 100644 (file)
@@ -405,7 +405,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
                                               .check_blocked = 1,
                                               .check_suspended = ignore_suspended_devices(),
                                               .check_error_target = 1,
-                                              .check_reserved = 0 }))
+                                              .check_reserved = 0 }, NULL))
                                goto out; /* safe to use */
                        stack;
                }
@@ -620,7 +620,7 @@ static int _ignore_frozen_raid(struct device *dev, const char *params)
  *
  * Returns: 1 if usable, 0 otherwise
  */
-int device_is_usable(struct device *dev, struct dev_usable_check_params check)
+int device_is_usable(struct device *dev, struct dev_usable_check_params check, int *is_lv)
 {
        struct dm_task *dmt;
        struct dm_info info;
@@ -675,6 +675,8 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
 
        if (check.check_lv && uuid && !strncmp(uuid, "LVM-", 4)) {
                /* Skip LVs */
+               if (is_lv)
+                       *is_lv = 1;
                goto out;
        }
 
index 04f6fe0a549317dacad8021feb82946261c81a25..b78262b654a1be2c727b7b0106b60fa1f41ab5df 100644 (file)
@@ -2909,6 +2909,8 @@ const char *dev_filtered_reason(struct device *dev)
                return "device is not in devices file";
        if (dev->filtered_flags & DEV_FILTERED_DEVICES_LIST)
                return "device is not in devices list";
+       if (dev->filtered_flags & DEV_FILTERED_IS_LV)
+               return "device is an LV";
 
        /* flag has not been added here */
        if (dev->filtered_flags)
index 8a5b0d8283a241a9bdbf0bd50736d8d57bc63cbd..43a37afd05cffa4b67b0d0c3a18cab9c2996b33c 100644 (file)
@@ -111,6 +111,7 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
        filter_mode_t mode = data->mode;
        int skip_lvs = data->skip_lvs;
        struct dev_usable_check_params ucp = {0};
+       int is_lv = 0;
        int r = 1;
 
        dev->filtered_flags &= ~DEV_FILTERED_MINSIZE;
@@ -145,8 +146,11 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
                        break;
                }
 
-               if (!(r = device_is_usable(dev, ucp))) {
-                       dev->filtered_flags |= DEV_FILTERED_UNUSABLE;
+               if (!(r = device_is_usable(dev, ucp, &is_lv))) {
+                       if (is_lv)
+                               dev->filtered_flags |= DEV_FILTERED_IS_LV;
+                       else
+                               dev->filtered_flags |= DEV_FILTERED_UNUSABLE;
                        log_debug_devs("%s: Skipping unusable device.", dev_name(dev));
                }
        }
index bd42930906517bd6c4a988540254ece9e0c9d7bc..40fbdeabb0cbf1b45b246fc424a183618cb98699 100644 (file)
@@ -66,5 +66,6 @@ struct dev_filter *usable_filter_create(struct cmd_context *cmd, struct dev_type
 #define DEV_FILTERED_UNUSABLE          0x00000400
 #define DEV_FILTERED_DEVICES_FILE      0x00000800
 #define DEV_FILTERED_DEVICES_LIST      0x00001000
+#define DEV_FILTERED_IS_LV             0x00002000
 
 #endif         /* _LVM_FILTER_H */
This page took 0.044793 seconds and 5 git commands to generate.