1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

filters: better message for excluding LV

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)
This commit is contained in:
David Teigland 2021-03-03 12:07:57 -06:00
parent d0b0c20077
commit e9d10f3711
6 changed files with 15 additions and 6 deletions

View 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;
}

View 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

View 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;
}

View 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)

View 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,7 +146,10 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
break;
}
if (!(r = device_is_usable(dev, ucp))) {
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));
}

View 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 */