1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-24 17:57:48 +03:00

pvscan: print more reasons for ignoring devices

This commit is contained in:
David Teigland 2019-04-05 14:03:38 -05:00
parent 48e9f116ae
commit 6f18186bfd
4 changed files with 31 additions and 9 deletions

View File

@ -1505,7 +1505,7 @@ static struct device *_dev_cache_seek_devt(dev_t dev)
* TODO This is very inefficient. We probably want a hash table indexed by
* major:minor for keys to speed up these lookups.
*/
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t dev, struct dev_filter *f)
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t dev, struct dev_filter *f, int *filtered)
{
char path[PATH_MAX];
const char *sysfs_dir;
@ -1513,6 +1513,9 @@ struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t dev, struct
struct device *d = _dev_cache_seek_devt(dev);
int ret;
if (filtered)
*filtered = 0;
if (d && (d->flags & DEV_REGULAR))
return d;
@ -1557,6 +1560,8 @@ struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t dev, struct
if (ret)
return d;
if (filtered)
*filtered = 1;
return NULL;
}

View File

@ -55,8 +55,7 @@ int dev_cache_add_dir(const char *path);
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
const char *dev_cache_filtered_reason(const char *name);
// TODO
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t device, struct dev_filter *f);
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t device, struct dev_filter *f, int *filtered);
void dev_set_preferred_name(struct dm_str_list *sl, struct device *dev);

View File

@ -1091,7 +1091,7 @@ void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv
return;
devt = MKDEV(lvinfo.major, lvinfo.minor);
if ((dev = dev_cache_get_by_devt(cmd, devt, NULL)))
if ((dev = dev_cache_get_by_devt(cmd, devt, NULL, NULL)))
label_scan_invalidate(dev);
}

View File

@ -785,6 +785,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
int all_devs;
struct arg_value_group_list *current_group;
dev_t devno;
int filtered;
int do_activate = arg_is_set(cmd, activate_ARG);
int add_errors = 0;
int add_single_count = 0;
@ -840,6 +841,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
log_debug("pvscan arg %s not found.", pv_name);
if ((dev = dev_cache_get(cmd, pv_name, NULL))) {
/* nothing to do for this dev name */
log_print("pvscan[%d] device %s excluded by filter.", getpid(), dev_name(dev));
} else {
log_error("Physical Volume %s not found.", pv_name);
ret = ECMD_FAILED;
@ -863,8 +865,15 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
}
devno = MKDEV(major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->filter))) {
log_debug("pvscan arg %d:%d not found.", major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->filter, &filtered))) {
if (filtered) {
if ((dev = dev_cache_get_by_devt(cmd, devno, NULL, NULL)))
log_print("pvscan[%d] device %d:%d %s excluded by filter.", getpid(), major, minor, dev_name(dev));
else
log_print("pvscan[%d] device %d:%d excluded by filter.", getpid(), major, minor);
} else
log_print("pvscan[%d] device %d:%d not found.", getpid(), major, minor);
if (!(dev = dm_pool_zalloc(cmd->mem, sizeof(struct device))))
return_0;
if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
@ -897,8 +906,15 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
devno = MKDEV(major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->filter))) {
log_debug("pvscan arg %d:%d not found.", major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->filter, &filtered))) {
if (filtered) {
if ((dev = dev_cache_get_by_devt(cmd, devno, NULL, NULL)))
log_print("pvscan[%d] device %d:%d %s excluded by filter.", getpid(), major, minor, dev_name(dev));
else
log_print("pvscan[%d] device %d:%d excluded by filter.", getpid(), major, minor);
} else
log_print("pvscan[%d] device %d:%d not found.", getpid(), major, minor);
if (!(dev = dm_pool_zalloc(cmd->mem, sizeof(struct device))))
return_0;
if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
@ -969,8 +985,10 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
dm_list_iterate_items(devl, &add_devs) {
dev = devl->dev;
if (dev->flags & DEV_FILTER_OUT_SCAN)
if (dev->flags & DEV_FILTER_OUT_SCAN) {
log_print("pvscan[%d] device %s excluded by filter.", getpid(), dev_name(dev));
continue;
}
add_single_count++;