diff --git a/WHATS_NEW b/WHATS_NEW index 5542d973e..2a50ddfd4 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -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. diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 3361a93ba..36d7a125a 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -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; } diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 1bb52080a..bc8f82262 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -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) */ diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c index 40d17a165..b414b2359 100644 --- a/lib/format1/disk-rep.c +++ b/lib/format1/disk-rep.c @@ -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, diff --git a/lib/log/log.c b/lib/log/log.c index db1796152..9d70b32dc 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -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; diff --git a/lib/log/log.h b/lib/log/log.h index 8d983d08c..9b6861623 100644 --- a/lib/log/log.h +++ b/lib/log/log.h @@ -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); diff --git a/tools/args.h b/tools/args.h index 1b22d4c51..360b15bfb 100644 --- a/tools/args.h +++ b/tools/args.h @@ -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) diff --git a/tools/commands.h b/tools/commands.h index f81b49f8b..52d7f14a1 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -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", diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 2ea28a954..568f0e2d5 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -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) ||