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

add --nohints option

The command will not use the hints file to locate devices for PVs.
It will still do standard hint file invalidation where appropriate.
This commit is contained in:
David Teigland 2021-09-10 15:57:19 -05:00
parent b36ab8a063
commit 9857b5a3dc
4 changed files with 67 additions and 1 deletions

View File

@ -37,6 +37,57 @@ aux prepare_devs 6
pvs
not grep scan: $HINTS
#
# test --nohints option
#
pvcreate "$dev1"
pvcreate "$dev2"
# pvs --nohints does not create hints
pvs --nohints |tee out
grep "$dev1" out
grep "$dev2" out
not grep "$dev1" $HINTS
not grep "$dev2" $HINTS
# pvs creates hints
pvs
grep "$dev1" $HINTS
grep "$dev2" $HINTS
# save hints with dev1 and dev2 before dev3 is created
cp $HINTS $PREV
# pvcreate --nohints invalidates hints
pvcreate --nohints "$dev3"
ls $NEWHINTS
# pvs --nohints does not update hints
pvs --nohints |tee out
grep "$dev1" out
grep "$dev2" out
grep "$dev3" out
not grep "$dev3" $HINTS
# restore old hint file without dev3
cp $PREV $HINTS
# pvs --nohints does not update hints
pvs --nohints |tee out
grep "$dev1" out
grep "$dev2" out
grep "$dev3" out
grep "$dev1" $HINTS
grep "$dev2" $HINTS
not grep "$dev3" $HINTS
# pvs updates hints
pvs |tee out
grep "$dev1" out
grep "$dev2" out
grep "$dev3" out
grep "$dev1" $HINTS
grep "$dev2" $HINTS
grep "$dev3" $HINTS
aux wipefs_a "$dev1"
aux wipefs_a "$dev2"
aux wipefs_a "$dev3"
#
# vg1 uses dev1,dev2
#
@ -44,6 +95,8 @@ not grep scan: $HINTS
# and that only PVs are scanned when using hints.
#
rm $HINTS
vgcreate $vg1 "$dev1" "$dev2"
lvcreate -n $lv1 -l 4 $vg1

View File

@ -460,6 +460,11 @@ arg(noheadings_ARG, '\0', "noheadings", 0, 0, 0,
"Suppress the headings line that is normally the first line of output.\n"
"Useful if grepping the output.\n")
arg(nohints_ARG, '\0', "nohints", 0, 0, 0,
"Do not use the hints file to locate devices for PVs. A command may read\n"
"more devices to find PVs when hints are not used. The command will still\n"
"perform standard hint file invalidation where appropriate.\n")
arg(nohistory_ARG, '\0', "nohistory", 0, 0, 0,
"Do not record history of LVs being removed.\n"
"This has no effect unless the configuration setting\n"

View File

@ -204,7 +204,7 @@
#
OO_ALL: --commandprofile String, --config String, --debug,
--driverloaded Bool, --help, --nolocking, --lockopt String, --longhelp, --profile String, --quiet,
--verbose, --version, --yes, --test, --devicesfile String, --devices PV
--verbose, --version, --yes, --test, --devicesfile String, --devices PV, --nohints
#
# options for pvs, lvs, vgs, fullreport

View File

@ -2512,6 +2512,14 @@ static int _get_current_settings(struct cmd_context *cmd)
if (arg_is_set(cmd, sysinit_ARG))
cmd->use_hints = 0;
/*
* Don't use hints from this command, but enable_hints will
* remain set unless hints=none in the config. See above re
* the meaning of use_hints=0 && enable_hints=1.
*/
if (arg_is_set(cmd, nohints_ARG))
cmd->use_hints = 0;
if ((hint_mode = find_config_tree_str(cmd, devices_hints_CFG, NULL))) {
if (!strcmp(hint_mode, "none")) {
cmd->enable_hints = 0;