1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Add --trustcache option to reporting commands in preparation for supporting

event-driven model.  Without changes to the way the cache gets updated, the
option is currently unreliable without a global lock to prevent any lvm2
commands from running concurrently.
This commit is contained in:
Alasdair Kergon 2006-08-01 14:56:33 +00:00
parent f7c55da7d0
commit df0a5561a1
9 changed files with 35 additions and 7 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.08 -
================================
Add unreliable --trustcache option to reporting commands.
Fix locking for mimage removal.
Fix clvmd_init_rhel4 'status' exit code.

View File

@ -241,7 +241,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan)
goto out;
}
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1: 0))) {
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1 : 0))) {
log_error("dev_iter creation failed");
goto out;
}

View File

@ -645,8 +645,7 @@ struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan)
return NULL;
}
if (dev_scan) {
if (dev_scan && !trust_cache()) {
/* Flag gets reset between each command */
if (!full_scan_done())
persistent_filter_wipe(f); /* Calls _full_scan(1) */

View File

@ -458,7 +458,7 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
/*
* Build a list of pv_d's structures, allocated from mem.
* We keep track of the first object allocated form the pool
* We keep track of the first object allocated from the pool
* so we can free off all the memory if something goes wrong.
*/
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,

View File

@ -32,6 +32,7 @@ static int _partial = 0;
static int _md_filtering = 0;
static int _pvmove = 0;
static int _full_scan_done = 0; /* Restrict to one full scan during each cmd */
static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
static int _debug_level = 0;
static int _syslog = 0;
static int _log_to_file = 0;
@ -163,6 +164,11 @@ void init_full_scan_done(int level)
_full_scan_done = level;
}
void init_trust_cache(int trustcache)
{
_trust_cache = trustcache;
}
void init_ignorelockingfailure(int level)
{
_ignorelockingfailure = level;
@ -237,6 +243,11 @@ int full_scan_done()
return _full_scan_done;
}
int trust_cache()
{
return _trust_cache;
}
int lockingfailed()
{
return _lockingfailed;

View File

@ -66,6 +66,7 @@ void init_partial(int level);
void init_md_filtering(int level);
void init_pvmove(int level);
void init_full_scan_done(int level);
void init_trust_cache(int trustcache);
void init_debug(int level);
void init_cmd_name(int status);
void init_msg_prefix(const char *prefix);
@ -83,6 +84,7 @@ int partial_mode(void);
int md_filtering(void);
int pvmove_mode(void);
int full_scan_done(void);
int trust_cache(void);
int debug_level(void);
int ignorelockingfailure(void);
int lockingfailed(void);

View File

@ -49,6 +49,7 @@ arg(nosync_ARG, '\0', "nosync", NULL)
arg(corelog_ARG, '\0', "corelog", NULL)
arg(monitor_ARG, '\0', "monitor", yes_no_arg)
arg(config_ARG, '\0', "config", string_arg)
arg(trustcache_ARG, '\0', "trustcache", NULL)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg)

View File

@ -343,6 +343,7 @@ xx(lvs,
"\t[-P|--partial] " "\n"
"\t[--segments]\n"
"\t[--separator Separator]\n"
"\t[--trustcache]\n"
"\t[--unbuffered]\n"
"\t[--units hsbkmgtHKMGT]\n"
"\t[-v|--verbose]\n"
@ -351,7 +352,7 @@ xx(lvs,
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
xx(lvscan,
"List all logical volumes in all volume groups",
@ -527,6 +528,7 @@ xx(pvs,
"\t[-P|--partial] " "\n"
"\t[--segments]\n"
"\t[--separator Separator]\n"
"\t[--trustcache]\n"
"\t[--unbuffered]\n"
"\t[--units hsbkmgtHKMGT]\n"
"\t[-v|--verbose]\n"
@ -535,7 +537,7 @@ xx(pvs,
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
xx(pvscan,
"List all physical volumes",
@ -819,6 +821,7 @@ xx(vgs,
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
"\t[-P|--partial] " "\n"
"\t[--separator Separator]\n"
"\t[--trustcache]\n"
"\t[--unbuffered]\n"
"\t[--units hsbkmgtHKMGT]\n"
"\t[-v|--verbose]\n"
@ -827,7 +830,7 @@ xx(vgs,
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG,
sort_ARG, unbuffered_ARG, units_ARG)
sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
xx(vgscan,
"Search for all volume groups",

View File

@ -707,6 +707,17 @@ static int _get_settings(struct cmd_context *cmd)
return EINVALID_CMD_LINE;
}
if (arg_count(cmd, trustcache_ARG)) {
if (arg_count(cmd, all_ARG)) {
log_error("--trustcache is incompatible with --all");
return EINVALID_CMD_LINE;
}
init_trust_cache(1);
log_print("WARNING: Cache file of PVs will be trusted. "
"New devices holding PVs may get ignored.");
} else
init_trust_cache(0);
/* Handle synonyms */
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||