diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2012-03-27 11:04:46 +0000 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2012-03-27 11:04:46 +0000 |
commit | 3be9089cd3827637c0c18a4ea44a6d8858d971c6 (patch) | |
tree | 1f63231e3063e55c3906b5cdf45db114e152da69 /tools | |
parent | 4007e0d139e47fb25ea7828f9062d55919b37cb9 (diff) | |
download | lvm2-3be9089cd3827637c0c18a4ea44a6d8858d971c6.tar.gz lvm2-3be9089cd3827637c0c18a4ea44a6d8858d971c6.tar.xz lvm2-3be9089cd3827637c0c18a4ea44a6d8858d971c6.zip |
Add 'vgscan --cache' functionality for consistency with 'pvscan --cache'.
Calling vgscan alone should reuse information from the lvmetad (if running).
The --cache option should initiate direct device scan and update lvmetad
appropriately (if running).
This is mainly for vgscan to behave consistently compared to pvscan.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/commands.h | 3 | ||||
-rw-r--r-- | tools/vgscan.c | 23 |
2 files changed, 20 insertions, 6 deletions
diff --git a/tools/commands.h b/tools/commands.h index bad0618c..7101ef0f 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -1004,6 +1004,7 @@ xx(vgscan, "Search for all volume groups", PERMITTED_READ_ONLY, "vgscan " + "\t[--cache]\n" "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" @@ -1012,7 +1013,7 @@ xx(vgscan, "\t[-v|--verbose]\n" "\t[--version]" "\n", - ignorelockingfailure_ARG, mknodes_ARG, partial_ARG) + cache_ARG, ignorelockingfailure_ARG, mknodes_ARG, partial_ARG) xx(vgsplit, "Move physical volumes into a new or existing volume group", diff --git a/tools/vgscan.c b/tools/vgscan.c index a353c432..f82c71f8 100644 --- a/tools/vgscan.c +++ b/tools/vgscan.c @@ -15,6 +15,8 @@ #include "tools.h" +static int _lvmetad; + static int vgscan_single(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, void *handle __attribute__((unused))) @@ -25,16 +27,18 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name, check_current_backup(vg); - /* keep lvmetad up to date */ + /* keep lvmetad up to date, restore the "active" state temporarily */ + lvmetad_set_active(_lvmetad); if (!lvmetad_vg_update(vg)) stack; + lvmetad_set_active(0); return ECMD_PROCESSED; } int vgscan(struct cmd_context *cmd, int argc, char **argv) { - int maxret, ret, lvmetad; + int maxret, ret; if (argc) { log_error("Too many parameters on command line"); @@ -48,8 +52,17 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv) persistent_filter_wipe(cmd->filter); lvmcache_destroy(cmd, 1); - lvmetad = lvmetad_active(); - lvmetad_set_active(0); /* do not rely on lvmetad info */ + + _lvmetad = lvmetad_active(); + if (arg_count(cmd, cache_ARG)) { + if (_lvmetad) + lvmetad_set_active(0); /* do not rely on lvmetad info */ + else { + log_error("Cannot proceed since lvmetad is not active."); + unlock_vg(cmd, VG_GLOBAL); + return ECMD_FAILED; + } + } log_print("Reading all physical volumes. This may take a while..."); @@ -62,7 +75,7 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv) maxret = ret; } - lvmetad_set_active(lvmetad); /* restore */ + lvmetad_set_active(_lvmetad); /* restore */ unlock_vg(cmd, VG_GLOBAL); return maxret; } |