1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

devices file: limit warnings about devices file entries not found

All commands were printing a warning if a devices file
entry was not found.  Limit this to commands that report/display
lvm state.
This commit is contained in:
David Teigland 2021-07-27 15:28:34 -05:00
parent bf6dfc248a
commit d3d6a0e820
7 changed files with 23 additions and 12 deletions

View File

@ -193,6 +193,7 @@ struct cmd_context {
unsigned run_by_dmeventd:1; /* command is being run by dmeventd */
unsigned sysinit:1; /* --sysinit is used */
unsigned check_devs_used:1; /* check devs used by LVs */
unsigned print_device_id_not_found; /* print devices file entries not found */
/*
* Devices and filtering.

View File

@ -1511,6 +1511,9 @@ void device_ids_match(struct cmd_context *cmd)
dev_iter_destroy(iter);
}
if (!cmd->print_device_id_not_found)
return;
/*
* Look for entries in devices file for which we found no device.
*/

View File

@ -142,6 +142,7 @@ static inline int dumptype_arg(struct cmd_context *cmd __attribute__((unused)),
#define ALLOW_HINTS 0x00004000
#define ALLOW_EXPORTED 0x00008000
#define CHECK_DEVS_USED 0x00010000
#define DEVICE_ID_NOT_FOUND 0x00020000
/* create foo_CMD enums for command def ID's in command-lines.in */

View File

@ -31,7 +31,7 @@ xx(formats,
xx(fullreport,
"Display full report",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(help,
"Display help for commands",
@ -55,7 +55,7 @@ xx(lvcreate,
xx(lvdisplay,
"Display information about a logical volume",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(lvextend,
"Add space to a logical volume",
@ -71,11 +71,11 @@ xx(lvmconfig,
xx(lvmdevices,
"Manage the devices file",
0)
DEVICE_ID_NOT_FOUND)
xx(lvmdiskscan,
"List devices that may be used as physical volumes",
PERMITTED_READ_ONLY | ENABLE_ALL_DEVS | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ENABLE_ALL_DEVS | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(lvmsadc,
"Collect activity data",
@ -107,11 +107,11 @@ xx(lvresize,
xx(lvs,
"Display information about logical volumes",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(lvscan,
"List all logical volumes in all volume groups",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(pvchange,
"Change attributes of physical volume(s)",
@ -131,7 +131,7 @@ xx(pvdata,
xx(pvdisplay,
"Display various attributes of physical volume(s)",
PERMITTED_READ_ONLY | ENABLE_ALL_DEVS | ENABLE_DUPLICATE_DEVS | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ENABLE_ALL_DEVS | ENABLE_DUPLICATE_DEVS | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
/* ALL_VGS_IS_DEFAULT is for polldaemon to find pvmoves in-progress using process_each_vg. */
@ -149,11 +149,11 @@ xx(pvresize,
xx(pvs,
"Display information about physical volumes",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_ALL_DEVS | ENABLE_DUPLICATE_DEVS | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_ALL_DEVS | ENABLE_DUPLICATE_DEVS | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(pvscan,
"List all physical volumes",
PERMITTED_READ_ONLY | LOCKD_VG_SH | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | LOCKD_VG_SH | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(segtypes,
"List available segment types",
@ -197,7 +197,7 @@ xx(vgcreate,
xx(vgdisplay,
"Display volume group information",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(vgexport,
"Unregister volume group(s) from the system",
@ -241,11 +241,11 @@ xx(vgrename,
xx(vgs,
"Display information about volume groups",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | CAN_USE_ONE_SCAN | ALLOW_HINTS | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(vgscan,
"Search for all volume groups",
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | ALLOW_EXPORTED | CHECK_DEVS_USED)
PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | LOCKD_VG_SH | ALLOW_EXPORTED | CHECK_DEVS_USED | DEVICE_ID_NOT_FOUND)
xx(vgsplit,
"Move physical volumes into a new or existing volume group",

View File

@ -2475,6 +2475,8 @@ static int _get_current_settings(struct cmd_context *cmd)
cmd->check_devs_used = (cmd->cname->flags & CHECK_DEVS_USED) ? 1 : 0;
cmd->print_device_id_not_found = (cmd->cname->flags & DEVICE_ID_NOT_FOUND) ? 1 : 0;
/*
* enable_hints is set to 1 if any commands are using hints.
* use_hints is set to 1 if this command should use the hints.

View File

@ -1620,6 +1620,8 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
cmd->check_devs_used = 0;
cmd->print_device_id_not_found = 0;
event_activation = find_config_tree_bool(cmd, global_event_activation_CFG, NULL);
if (do_activate && !event_activation) {

View File

@ -141,6 +141,8 @@ struct arg_value_group_list {
#define ALLOW_EXPORTED 0x00008000
/* Command checks and reports warning if devs used by LV are incorrect. */
#define CHECK_DEVS_USED 0x00010000
/* Command prints devices file entries that were not found. */
#define DEVICE_ID_NOT_FOUND 0x00020000
void usage(const char *name);