main - pvscan: add options listlvs listvg checkcomplete
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0b6782fa0139e412f82...
Commit: 0b6782fa0139e412f827cc9d1f0cd96ea38e27b0
Parent: 3e1316bb09b087ec79c9661ead14d8556c36fa8d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Dec 9 10:59:40 2020 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 7 12:06:49 2021 -0500
pvscan: add options listlvs listvg checkcomplete
pvscan --cache <dev>
. read only dev
. create online file for dev
pvscan --listvg <dev>
. read only dev
. list VG using dev
pvscan --listlvs <dev>
. read only dev
. list VG using dev
. list LVs using dev
pvscan --cache --listvg [--checkcomplete] <dev>
. read only dev
. create online file for dev
. list VG using dev
. [check online files and report if VG is complete]
pvscan --cache --listlvs [--checkcomplete] <dev>
. read only dev
. create online file for dev
. list VG using dev
. list LVs using dev
. [check online files and report if VG is complete]
. [check online files and report if LVs are complete]
[--vgonline]
can be used with --checkcomplete, to enable use of a vg online
file. This results in only the first pvscan command to see
the complete VG to report 'VG complete', and others will report
'VG finished'. This allows the caller to easily run a single
activation of the VG.
[--udevoutput]
can be used with --cache --listvg --checkcomplete, to enable
an output mode that prints LVM_VG_NAME_COMPLETE='vgname' that
a udev rule can import, and prevents other output from the
command (other output causes udev to ignore the command.)
The list of complete LVs is meant to be passed to lvchange -aay,
or the complete VG used with vgchange -aay.
When --checkcomplete is used, lvm assumes that that the output
will be used to trigger event-based autoactivation, so the pvscan
does nothing if event_activation=0 and --checkcomplete is used.
Example of listlvs
------------------
$ lvs -a vg -olvname,devices
LV Devices
lv_a /dev/loop0(0)
lv_ab /dev/loop0(1),/dev/loop1(1)
lv_abc /dev/loop0(3),/dev/loop1(3),/dev/loop2(1)
lv_b /dev/loop1(0)
lv_c /dev/loop2(0)
$ pvscan --cache --listlvs --checkcomplete /dev/loop0
pvscan[35680] PV /dev/loop0 online, VG vg incomplete (need 2).
VG vg incomplete
LV vg/lv_a complete
LV vg/lv_ab incomplete
LV vg/lv_abc incomplete
$ pvscan --cache --listlvs --checkcomplete /dev/loop1
pvscan[35681] PV /dev/loop1 online, VG vg incomplete (need 1).
VG vg incomplete
LV vg/lv_b complete
LV vg/lv_ab complete
LV vg/lv_abc incomplete
$ pvscan --cache --listlvs --checkcomplete /dev/loop2
pvscan[35682] PV /dev/loop2 online, VG vg is complete.
VG vg complete
LV vg/lv_c complete
LV vg/lv_abc complete
Example of listvg
-----------------
$ pvscan --cache --listvg --checkcomplete /dev/loop0
pvscan[35684] PV /dev/loop0 online, VG vg incomplete (need 2).
VG vg incomplete
$ pvscan --cache --listvg --checkcomplete /dev/loop1
pvscan[35685] PV /dev/loop1 online, VG vg incomplete (need 1).
VG vg incomplete
$ pvscan --cache --listvg --checkcomplete /dev/loop2
pvscan[35686] PV /dev/loop2 online, VG vg is complete.
VG vg complete
---
lib/commands/toolcontext.h | 1 +
lib/metadata/metadata.c | 33 ++++
lib/metadata/metadata.h | 4 +
tools/args.h | 20 +++
tools/command-lines.in | 30 +++-
tools/lvmcmdline.c | 4 +
tools/pvscan.c | 418 ++++++++++++++++++++++++++++++++++-----------
tools/toollib.c | 18 ++
tools/tools.h | 2 +
9 files changed, 431 insertions(+), 99 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 8f11a7714..731cc7ee0 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -29,6 +29,7 @@ struct config_info {
int debug_classes;
int verbose;
int silent;
+ int suppress;
int test;
int yes;
int syslog;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5fa623ec9..c4f65366b 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5279,3 +5279,36 @@ struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_
return vg;
}
+
+int get_visible_lvs_using_pv(struct cmd_context *cmd, struct volume_group *vg, struct device *dev,
+ struct dm_list *lvs_list)
+{
+ struct pv_list *pvl;
+ struct lv_list *lvl, *lvl2;
+ struct physical_volume *pv = NULL;
+
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (pvl->pv->dev == dev) {
+ pv = pvl->pv;
+ break;
+ }
+ }
+
+ if (!pv)
+ return_0;
+
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if (!lv_is_visible(lvl->lv))
+ continue;
+ if (!lv_is_on_pv(lvl->lv, pv))
+ continue;
+
+ if (!(lvl2 = dm_pool_zalloc(cmd->mem, sizeof(*lvl2))))
+ return_0;
+ lvl2->lv = lvl->lv;
+ dm_list_add(lvs_list, &lvl2->list);
+ }
+
+ return 1;
+}
+
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 95ca320e6..6c39ff845 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -535,4 +535,8 @@ char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tagsl);
void set_pv_devices(struct format_instance *fid, struct volume_group *vg);
+int get_visible_lvs_using_pv(struct cmd_context *cmd, struct volume_group *vg, struct device *dev,
+ struct dm_list *lvs_list);
+
+
#endif
diff --git a/tools/args.h b/tools/args.h
index 05c16d94a..8ce176739 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -329,6 +329,19 @@ arg(labelsector_ARG, '\0', "labelsector", number_VAL, 0, 0,
"start of the disk (between 0 and 3 inclusive - see LABEL_SCAN_SECTORS\n"
"in the source). Use with care.\n")
+arg(listlvs_ARG, '\0', "listlvs", 0, 0, 0,
+ "Print a list of LVs that use the device.\n")
+
+arg(listvg_ARG, '\0', "listvg", 0, 0, 0,
+ "Print the VG that uses the device.\n")
+
+arg(checkcomplete_ARG, '\0', "checkcomplete", 0, 0, 0,
+ "Check if all the devices used by a VG or LV are present,\n"
+ "and print \"complete\" or \"incomplete\" for each listed\n"
+ "VG or LV. This option is used as a part of event-based\n"
+ "autoactivation, so pvscan will do nothing if this option\n"
+ "is set and event_activation=0 in the config settings.\n")
+
arg(lockopt_ARG, '\0', "lockopt", string_VAL, 0, 0,
"Used to pass options for special cases to lvmlockd.\n"
"See \\fBlvmlockd\\fP(8) for more information.\n")
@@ -816,6 +829,9 @@ arg(type_ARG, '\0', "type", segtype_VAL, 0, 0,
"(e.g. --stripes, --mirrors, --snapshot, --virtualsize, --thin, --cache, --vdo).\n"
"Use inferred types with care because it can lead to unexpected results.\n")
+arg(udevoutput_ARG, '\0', "udevoutput", 0, 0, 0,
+ "Command output is modified to be imported from a udev rule.\n")
+
arg(unbuffered_ARG, '\0', "unbuffered", 0, 0, 0,
"Produce output immediately without sorting or aligning the columns properly.\n")
@@ -892,6 +908,10 @@ arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", vgmetadatacopies_VAL, 0, 0,
"\\fBall\\fP causes LVM to first clear the metadataignore flags on\n"
"all PVs, and then to become unmanaged.\n")
+arg(vgonline_ARG, '\0', "vgonline", 0, 0, 0,
+ "The first command to see a complete VG will report it uniquely.\n"
+ "Other commands to see the complete VG will report it differently.\n")
+
arg(withsummary_ARG, '\0', "withsummary", 0, 0, 0,
"Display a one line comment for each configuration node.\n")
diff --git a/tools/command-lines.in b/tools/command-lines.in
index e63b2bcc3..332ad8a3b 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1634,11 +1634,37 @@ DESC: Display PV information.
pvscan --cache_long
OO: --ignorelockingfailure, --reportformat ReportFmt,
---activate ay, --major Number, --minor Number, --noudevsync
+--major Number, --minor Number, --noudevsync
OP: PV|String ...
IO: --background
ID: pvscan_cache
-DESC: Autoactivate a VG when all PVs are online.
+DESC: Record that a PV is online or offline.
+
+pvscan --cache_long --activate ay
+OO: --ignorelockingfailure, --reportformat ReportFmt,
+--major Number, --minor Number, --noudevsync
+OP: PV|String ...
+IO: --background
+ID: pvscan_cache
+DESC: Record that a PV is online and autoactivate the VG if complete.
+
+pvscan --cache_long --listvg PV
+OO: --ignorelockingfailure, --checkcomplete, --vgonline, --udevoutput
+ID: pvscan_cache
+DESC: Record that a PV is online and list the VG using the PV.
+
+pvscan --cache_long --listlvs PV
+OO: --ignorelockingfailure, --checkcomplete, --vgonline
+ID: pvscan_cache
+DESC: Record that a PV is online and list LVs using the PV.
+
+pvscan --listlvs PV
+ID: pvscan_cache
+DESC: List LVs using the PV.
+
+pvscan --listvg PV
+ID: pvscan_cache
+DESC: List the VG using the PV.
---
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 1fc2dc3bb..d82c374c6 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2391,6 +2391,9 @@ static void _reset_current_settings_to_default(struct cmd_context *cmd)
static void _get_current_output_settings_from_args(struct cmd_context *cmd)
{
+ if (arg_is_set(cmd, udevoutput_ARG))
+ cmd->current_settings.suppress = 1;
+
if (arg_is_set(cmd, debug_ARG))
cmd->current_settings.debug = _LOG_FATAL + (arg_count(cmd, debug_ARG) - 1);
@@ -2406,6 +2409,7 @@ static void _get_current_output_settings_from_args(struct cmd_context *cmd)
static void _apply_current_output_settings(struct cmd_context *cmd)
{
+ log_suppress(cmd->current_settings.suppress);
init_debug(cmd->current_settings.debug);
init_debug_classes_logged(cmd->default_settings.debug_classes);
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
diff --git a/tools/pvscan.c b/tools/pvscan.c
index a0be17e8e..75a08d325 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -179,6 +179,27 @@ out:
return ret;
}
+/*
+ * Avoid a duplicate pvscan[%d] prefix when logging to the journal.
+ * FIXME: this should probably replace if (udevoutput) with
+ * if (log_journal & LOG_JOURNAL_OUTPUT)
+ */
+#define log_print_pvscan(cmd, fmt, args...) \
+do \
+ if (arg_is_set(cmd, udevoutput_ARG)) \
+ log_print(fmt, ##args); \
+ else \
+ log_print("pvscan[%d] " fmt, getpid(), ##args); \
+while (0)
+
+#define log_error_pvscan(cmd, fmt, args...) \
+do \
+ if (arg_is_set(cmd, udevoutput_ARG)) \
+ log_error(fmt, ##args); \
+ else \
+ log_error("pvscan[%d] " fmt, getpid(), ##args); \
+while (0)
+
static char *_vgname_in_pvid_file_buf(char *buf)
{
char *p, *n;
@@ -260,7 +281,7 @@ static void _lookup_file_remove(char *vgname)
* that the vg will be activated again when it becomes complete.
*/
-static void _online_vg_file_remove(const char *vgname)
+void online_vg_file_remove(const char *vgname)
{
char path[PATH_MAX];
@@ -315,7 +336,7 @@ static void _online_pvid_file_remove_devno(int major, int minor)
log_sys_debug("unlink", path);
if (file_vgname[0]) {
- _online_vg_file_remove(file_vgname);
+ online_vg_file_remove(file_vgname);
_lookup_file_remove(file_vgname);
}
}
@@ -346,7 +367,7 @@ static void _online_files_remove(const char *dirpath)
log_sys_debug("closedir", dirpath);
}
-static int _online_pvid_file_create(struct device *dev, const char *vgname)
+static int _online_pvid_file_create(struct cmd_context *cmd, struct device *dev, const char *vgname)
{
char path[PATH_MAX];
char buf[MAX_PVID_FILE_SIZE] = { 0 };
@@ -363,18 +384,18 @@ static int _online_pvid_file_create(struct device *dev, const char *vgname)
minor = (int)MINOR(dev->dev);
if (dm_snprintf(path, sizeof(path), "%s/%s", _pvs_online_dir, dev->pvid) < 0) {
- log_error("Path %s/%s is too long.", _pvs_online_dir, dev->pvid);
+ log_error_pvscan(cmd, "Path %s/%s is too long.", _pvs_online_dir, dev->pvid);
return 0;
}
if ((len1 = dm_snprintf(buf, sizeof(buf), "%d:%d\n", major, minor)) < 0) {
- log_error("Cannot create online file path for %s %d:%d.", dev_name(dev), major, minor);
+ log_error_pvscan(cmd, "Cannot create online file path for %s %d:%d.", dev_name(dev), major, minor);
return 0;
}
if (vgname) {
if ((len2 = dm_snprintf(buf + len1, sizeof(buf) - len1, "vg:%s\n", vgname)) < 0) {
- log_warn("Incomplete online file for %s %d:%d vg %s.", dev_name(dev), major, minor, vgname);
+ log_print_pvscan(cmd, "Incomplete online file for %s %d:%d vg %s.", dev_name(dev), major, minor, vgname);
/* can still continue without vgname */
len2 = 0;
}
@@ -388,7 +409,7 @@ static int _online_pvid_file_create(struct device *dev, const char *vgname)
if (fd < 0) {
if (errno == EEXIST)
goto check_duplicate;
- log_error("Failed to create online file for %s path %s error %d", dev_name(dev), path, errno);
+ log_error_pvscan(cmd, "Failed to create online file for %s path %s error %d", dev_name(dev), path, errno);
return 0;
}
@@ -436,12 +457,12 @@ check_duplicate:
/* Don't know how vgname might not match, but it's not good so fail. */
if ((file_major != major) || (file_minor != minor))
- log_error("pvscan[%d] PV %s is duplicate for PVID %s on %d:%d and %d:%d.",
- getpid(), dev_name(dev), dev->pvid, major, minor, file_major, file_minor);
+ log_error_pvscan(cmd, "PV %s is duplicate for PVID %s on %d:%d and %d:%d.",
+ dev_name(dev), dev->pvid, major, minor, file_major, file_minor);
if (file_vgname[0] && vgname && strcmp(file_vgname, vgname))
- log_error("pvscan[%d] PV %s has unexpected VG %s vs %s.",
- getpid(), dev_name(dev), vgname, file_vgname);
+ log_error_pvscan(cmd, "PV %s has unexpected VG %s vs %s.",
+ dev_name(dev), vgname, file_vgname);
return 0;
}
@@ -476,7 +497,7 @@ static int _write_lookup_file(struct cmd_context *cmd, struct volume_group *vg)
int fd;
if (dm_snprintf(path, sizeof(path), "%s/%s", _pvs_lookup_dir, vg->name) < 0) {
- log_error("Path %s/%s is too long.", _pvs_lookup_dir, vg->name);
+ log_error_pvscan(cmd, "Path %s/%s is too long.", _pvs_lookup_dir, vg->name);
return 0;
}
@@ -639,7 +660,7 @@ static int _count_pvid_files_from_lookup_file(struct cmd_context *cmd, struct de
return (vgname) ? 1 : 0;
}
-static void _online_dir_setup(void)
+static void _online_dir_setup(struct cmd_context *cmd)
{
struct stat st;
int rv;
@@ -653,7 +674,7 @@ static void _online_dir_setup(void)
dm_prepare_selinux_context(NULL, 0);
if ((rv < 0) && stat(DEFAULT_RUN_DIR, &st))
- log_error("Failed to create %s %d", DEFAULT_RUN_DIR, errno);
+ log_error_pvscan(cmd, "Failed to create %s %d", DEFAULT_RUN_DIR, errno);
do_pvs:
if (!stat(_pvs_online_dir, &st))
@@ -665,7 +686,7 @@ do_pvs:
dm_prepare_selinux_context(NULL, 0);
if ((rv < 0) && stat(_pvs_online_dir, &st))
- log_error("Failed to create %s %d", _pvs_online_dir, errno);
+ log_error_pvscan(cmd, "Failed to create %s %d", _pvs_online_dir, errno);
do_vgs:
if (!stat(_vgs_online_dir, &st))
@@ -677,7 +698,7 @@ do_vgs:
dm_prepare_selinux_context(NULL, 0);
if ((rv < 0) && stat(_vgs_online_dir, &st))
- log_error("Failed to create %s %d", _vgs_online_dir, errno);
+ log_error_pvscan(cmd, "Failed to create %s %d", _vgs_online_dir, errno);
do_lookup:
if (!stat(_pvs_lookup_dir, &st))
@@ -689,7 +710,7 @@ do_lookup:
dm_prepare_selinux_context(NULL, 0);
if ((rv < 0) && stat(_pvs_lookup_dir, &st))
- log_error("Failed to create %s %d", _pvs_lookup_dir, errno);
+ log_error_pvscan(cmd, "Failed to create %s %d", _pvs_lookup_dir, errno);
}
@@ -728,7 +749,7 @@ static int _pvscan_aa_single(struct cmd_context *cmd, const char *vg_name,
log_debug("pvscan autoactivating VG %s.", vg_name);
if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
- log_error("%s: autoactivation failed.", vg->name);
+ log_error_pvscan(cmd, "%s: autoactivation failed.", vg->name);
pp->activate_errors++;
}
@@ -741,7 +762,7 @@ static int _online_vg_file_create(struct cmd_context *cmd, const char *vgname)
int fd;
if (dm_snprintf(path, sizeof(path), "%s/%s", _vgs_online_dir, vgname) < 0) {
- log_error("Path %s/%s is too long.", _vgs_online_dir, vgname);
+ log_error_pvscan(cmd, "Path %s/%s is too long.", _vgs_online_dir, vgname);
return 0;
}
@@ -829,15 +850,15 @@ static int _get_devs_from_saved_vg(struct cmd_context *cmd, const char *vgname,
_online_pvid_file_read(path, &file_major, &file_minor, file_vgname);
if (file_vgname[0] && strcmp(vgname, file_vgname)) {
- log_error("Wrong VG found for %d:%d PVID %s: %s vs %s",
- file_major, file_minor, pvid, vgname, file_vgname);
+ log_error_pvscan(cmd, "Wrong VG found for %d:%d PVID %s: %s vs %s",
+ file_major, file_minor, pvid, vgname, file_vgname);
goto bad;
}
devno = MKDEV(file_major, file_minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, NULL, NULL))) {
- log_error("No device found for %d:%d PVID %s", file_major, file_minor, pvid);
+ log_error_pvscan(cmd, "No device found for %d:%d PVID %s", file_major, file_minor, pvid);
goto bad;
}
@@ -847,7 +868,7 @@ static int _get_devs_from_saved_vg(struct cmd_context *cmd, const char *vgname,
if (strcmp(name1, name2)) {
if (!id_write_format((const struct id *)pvid, uuidstr, sizeof(uuidstr)))
uuidstr[0] = '\0';
- log_print("PVID %s read from %s last written to %s.", uuidstr, name1, name2);
+ log_print_pvscan(cmd, "PVID %s read from %s last written to %s.", uuidstr, name1, name2);
goto bad;
}
@@ -924,7 +945,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
* The dev_cache gives us struct devices from the devnums.
*/
if (!_get_devs_from_saved_vg(cmd, vgname, &devs)) {
- log_print("pvscan[%d] VG %s not using quick activation.", getpid(), vgname);
+ log_print_pvscan(cmd, "VG %s not using quick activation.", vgname);
*no_quick = 1;
return ECMD_FAILED;
}
@@ -943,7 +964,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
* label rescan are then disabled in vg_read.)
*/
if (!lock_vol(cmd, vgname, LCK_VG_WRITE, NULL)) {
- log_error("pvscan activation for VG %s failed to lock VG.", vgname);
+ log_error_pvscan(cmd, "activation for VG %s failed to lock VG.", vgname);
return ECMD_FAILED;
}
@@ -956,7 +977,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
label_scan_devs(cmd, NULL, &devs);
if (!(vgid = lvmcache_vgid_from_vgname(cmd, vgname))) {
- log_error("pvscan activation for VG %s failed to find vgid.", vgname);
+ log_error_pvscan(cmd, "activation for VG %s failed to find vgid.", vgname);
return ECMD_FAILED;
}
@@ -976,7 +997,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
* original device arg scan. There will be very few and unusual
* cases that would be caught here.
*/
- log_error("pvscan activation for VG %s cannot read (%x).", vgname, error_flags);
+ log_error_pvscan(cmd, "activation for VG %s cannot read (%x).", vgname, error_flags);
return ECMD_FAILED;
}
@@ -998,7 +1019,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
dm_list_iterate_items(pvl, &vg->pvs) {
if (dev_in_device_list(pvl->pv->dev, &devs))
continue;
- log_error("pvscan activation for VG %s found different devices.", vgname);
+ log_error_pvscan(cmd, "activation for VG %s found different devices.", vgname);
ret = ECMD_FAILED;
goto out;
}
@@ -1006,7 +1027,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
log_debug("pvscan autoactivating VG %s.", vgname);
if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
- log_error("%s: autoactivation failed.", vg->name);
+ log_error_pvscan(cmd, "%s: autoactivation failed.", vg->name);
pp->activate_errors++;
}
@@ -1025,7 +1046,7 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
int ret = ECMD_FAILED;
if (!(handle = init_processing_handle(cmd, NULL))) {
- log_error("Failed to initialize processing handle.");
+ log_error_pvscan(cmd, "Failed to initialize processing handle.");
goto out;
}
@@ -1040,11 +1061,11 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
*/
dm_list_iterate_items_safe(sl, sl2, vgnames) {
if (!_online_vg_file_create(cmd, sl->str)) {
- log_print("pvscan[%d] VG %s skip autoactivation.", getpid(), sl->str);
+ log_print_pvscan(cmd, "VG %s skip autoactivation.", sl->str);
str_list_del(vgnames, sl->str);
continue;
}
- log_print("pvscan[%d] VG %s run autoactivation.", getpid(), sl->str);
+ log_print_pvscan(cmd, "VG %s run autoactivation.", sl->str);
}
if (dm_list_empty(vgnames)) {
@@ -1192,6 +1213,64 @@ static int _get_args_devs(struct cmd_context *cmd, struct dm_list *pvscan_args,
return 1;
}
+static void _set_pv_devices_online(struct cmd_context *cmd, struct volume_group *vg)
+{
+ char path[PATH_MAX];
+ char file_vgname[NAME_LEN];
+ char pvid[ID_LEN+1] = { 0 };
+ struct pv_list *pvl;
+ struct device *dev;
+ int major, minor;
+ dev_t devno;
+
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ memcpy(&pvid, &pvl->pv->id.uuid, ID_LEN);
+
+ if (pvl->pv->status & MISSING_PV) {
+ log_debug("set_pv_devices_online vg %s pv %s missing flag already set",
+ vg->name, pvid);
+ continue;
+ }
+
+ if (!_online_pvid_file_exists(pvid)) {
+ log_debug("set_pv_devices_online vg %s pv %s no online file",
+ vg->name, pvid);
+ pvl->pv->status |= MISSING_PV;
+ continue;
+ }
+
+ memset(path, 0, sizeof(path));
+ snprintf(path, sizeof(path), "%s/%s", _pvs_online_dir, pvid);
+
+ major = 0;
+ minor = 0;
+ file_vgname[0] = '\0';
+
+ _online_pvid_file_read(path, &major, &minor, file_vgname);
+
+ if (file_vgname[0] && strcmp(vg->name, file_vgname)) {
+ log_warn("WARNING: VG %s PV %s wrong vgname in online file %s",
+ vg->name, pvid, file_vgname);
+ pvl->pv->status |= MISSING_PV;
+ continue;
+ }
+
+ devno = MKDEV(major, minor);
+
+ if (!(dev = dev_cache_get_by_devt(cmd, devno, NULL, NULL))) {
+ log_print_pvscan(cmd, "VG %s PV %s no device found for %d:%d",
+ vg->name, pvid, major, minor);
+ pvl->pv->status |= MISSING_PV;
+ continue;
+ }
+
+ log_debug("set_pv_devices_online vg %s pv %s is online %s",
+ vg->name, pvid, dev_name(dev));
+
+ pvl->pv->dev = dev;
+ }
+}
+
static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvscan_devs,
int *pv_count, struct dm_list *complete_vgnames)
{
@@ -1204,15 +1283,20 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
struct metadata_area *mda1, *mda2;
struct volume_group *vg;
struct physical_volume *pv;
- const char *vgname;
- uint32_t ext_version, ext_flags;
+ const char *vgname = NULL;
uint64_t devsize;
+ uint32_t ext_version, ext_flags;
+ int do_cache = arg_is_set(cmd, cache_long_ARG);
int do_activate = arg_is_set(cmd, activate_ARG);
- int do_full_check;
+ int do_list_lvs = arg_is_set(cmd, listlvs_ARG);
+ int do_list_vg = arg_is_set(cmd, listvg_ARG);
+ int do_check_complete = arg_is_set(cmd, checkcomplete_ARG);
+ int do_vgonline = arg_is_set(cmd, vgonline_ARG);
int pvs_online;
int pvs_offline;
int pvs_unknown;
int vg_complete;
+ int do_full_check;
int ret = 1;
dm_list_iterate_items_safe(devl, devl2, pvscan_devs) {
@@ -1222,14 +1306,14 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
if (!(info = lvmcache_info_from_pvid(dev->pvid, dev, 0))) {
if (!do_all)
- log_print("pvscan[%d] ignore %s with no lvm info.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "ignore %s with no lvm info.", dev_name(dev));
continue;
}
ext_version = lvmcache_ext_version(info);
ext_flags = lvmcache_ext_flags(info);
if ((ext_version >= 2) && !(ext_flags & PV_EXT_USED)) {
- log_print("pvscan[%d] PV %s not used.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "PV %s not used.", dev_name(dev));
(*pv_count)++;
continue;
}
@@ -1253,7 +1337,7 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
vg = mda2->ops->vg_read(cmd, fid, "", mda2, NULL, NULL);
if (!vg) {
- log_print("pvscan[%d] PV %s has no VG metadata.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "PV %s has no VG metadata.", dev_name(dev));
if (fid)
fmt->ops->destroy_instance(fid);
goto online;
@@ -1262,7 +1346,7 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
set_pv_devices(fid, vg);
if (!(pv = find_pv(vg, dev))) {
- log_print("pvscan[%d] PV %s not found in VG %s.", getpid(), dev_name(dev), vg->name);
+ log_print_pvscan(cmd, "PV %s not found in VG %s.", dev_name(dev), vg->name);
release_vg(vg);
continue;
}
@@ -1283,14 +1367,15 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
if (pv->device_hint && !strncmp(pv->device_hint, "/dev/md", 7))
do_full_check = 1;
}
+
if (do_full_check && dev_is_md_component(cmd, dev, NULL, 1)) {
- log_print("pvscan[%d] ignore md component %s.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "ignore md component %s.", dev_name(dev));
release_vg(vg);
continue;
}
if (vg_is_shared(vg)) {
- log_print("pvscan[%d] PV %s ignore shared VG.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "PV %s ignore shared VG.", dev_name(dev));
release_vg(vg);
continue;
}
@@ -1300,7 +1385,13 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
vg_is_foreign(vg)) {
log_verbose("Ignore PV %s with VG system id %s with our system id %s",
dev_name(dev), vg->system_id, cmd->system_id);
- log_print("pvscan[%d] PV %s ignore foreign VG.", getpid(), dev_name(dev));
+ log_print_pvscan(cmd, "PV %s ignore foreign VG.", dev_name(dev));
+ release_vg(vg);
+ continue;
+ }
+
+ if (vg_is_exported(vg)) {
+ log_print_pvscan(cmd, "PV %s ignore exported VG.", dev_name(dev));
release_vg(vg);
continue;
}
@@ -1319,19 +1410,20 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
/*
* Create file named for pvid to record this PV is online.
+ * The command creates/checks online files only when --cache is used.
*/
- if (!_online_pvid_file_create(dev, vg ? vg->name : NULL)) {
- log_error("pvscan[%d] PV %s failed to create online file.", getpid(), dev_name(dev));
+ if (do_cache && !_online_pvid_file_create(cmd, dev, vg ? vg->name : NULL)) {
+ log_error_pvscan(cmd, "PV %s failed to create online file.", dev_name(dev));
release_vg(vg);
ret = 0;
continue;
}
/*
- * When not activating we don't need to know about vg completeness.
+ * A plain pvscan --cache <dev> just creates the online file.
*/
- if (!do_activate) {
- log_print("pvscan[%d] PV %s online.", getpid(), dev_name(dev));
+ if (!do_activate && !do_list_lvs && !do_list_vg) {
+ log_print_pvscan(cmd, "PV %s online.", dev_name(dev));
release_vg(vg);
continue;
}
@@ -1339,58 +1431,159 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
/*
* Check if all the PVs for this VG are online. If the arrival
* of this dev completes the VG, then save the vgname in
- * complete_vgnames so it will be activated.
+ * complete_vgnames (activation phase will want to know which
+ * VGs to activate.)
*/
- pvs_online = 0;
- pvs_offline = 0;
- pvs_unknown = 0;
- vg_complete = 0;
-
- if (vg) {
- /*
- * Use the VG metadata from this PV for a list of all
- * PVIDs. Write a lookup file of PVIDs in case another
- * pvscan needs it. After writing lookup file, recheck
- * pvid files to resolve a possible race with another
- * pvscan reading the lookup file that missed it.
- */
- log_debug("checking all pvid files from vg %s", vg->name);
- _count_pvid_files(vg, &pvs_online, &pvs_offline);
+ if (do_activate || do_check_complete) {
+ pvs_online = 0;
+ pvs_offline = 0;
+ pvs_unknown = 0;
+ vg_complete = 0;
- if (pvs_offline && _write_lookup_file(cmd, vg)) {
- log_debug("rechecking all pvid files from vg %s", vg->name);
+ if (vg) {
+ /*
+ * Use the VG metadata from this PV for a list of all
+ * PVIDs. Write a lookup file of PVIDs in case another
+ * pvscan needs it. After writing lookup file, recheck
+ * pvid files to resolve a possible race with another
+ * pvscan reading the lookup file that missed it.
+ */
+ log_debug("checking all pvid files from vg %s", vg->name);
_count_pvid_files(vg, &pvs_online, &pvs_offline);
- if (!pvs_offline)
- log_print("pvscan[%d] VG %s complete after recheck.", getpid(), vg->name);
+
+ if (pvs_offline && _write_lookup_file(cmd, vg)) {
+ log_debug("rechecking all pvid files from vg %s", vg->name);
+ _count_pvid_files(vg, &pvs_online, &pvs_offline);
+ if (!pvs_offline)
+ log_print_pvscan(cmd, "VG %s complete after recheck.", vg->name);
+ }
+
+ vgname = vg->name;
+ } else {
+ /*
+ * No VG metadata on this PV, so try to use a lookup
+ * file written by a prior pvscan for a list of all
+ * PVIDs. A lookup file may not exist for this PV if
+ * it's the first to appear from the VG.
+ */
+ log_debug("checking all pvid files from lookup file");
+ if (!_count_pvid_files_from_lookup_file(cmd, dev, &pvs_online, &pvs_offline, &vgname))
+ pvs_unknown = 1;
+ }
+
+ if (pvs_unknown) {
+ log_print_pvscan(cmd, "PV %s online, VG unknown.", dev_name(dev));
+ vg_complete = 0;
+
+ } else if (pvs_offline) {
+ log_print_pvscan(cmd, "PV %s online, VG %s incomplete (need %d).",
+ dev_name(dev), vgname, pvs_offline);
+ vg_complete = 0;
+
+ } else {
+ log_print_pvscan(cmd, "PV %s online, VG %s is complete.", dev_name(dev), vgname);
+ if (!str_list_add(cmd->mem, complete_vgnames, dm_pool_strdup(cmd->mem, vgname)))
+ stack;
+ vg_complete = 1;
}
+ }
+ if (!vgname && vg)
vgname = vg->name;
- } else {
+
+ if (do_list_vg || do_list_lvs) {
+ if (!vgname) {
+ log_print("VG unknown");
+ } else if (!do_check_complete) {
+ log_print("VG %s", vgname);
+ } else if (vg_complete) {
+ if (do_vgonline && !_online_vg_file_create(cmd, vgname)) {
+ log_print("VG %s finished", vgname);
+ } else {
+ /*
+ * A udev rule imports KEY=val from a program's stdout.
+ * Other output causes udev to ignore everything.
+ * Run pvscan from udev rule using --udevoutput to
+ * enable this printf, and suppress all log output
+ */
+ if (arg_is_set(cmd, udevoutput_ARG))
+ printf("LVM_VG_NAME_COMPLETE='%s'\n", vgname);
+ else
+ log_print("VG %s complete", vgname);
+ }
+ } else {
+ if (arg_is_set(cmd, udevoutput_ARG))
+ printf("LVM_VG_NAME_INCOMPLETE='%s'\n", vgname);
+ else
+ log_print("VG %s incomplete", vgname);
+ }
+
/*
- * No VG metadata on this PV, so try to use a lookup
- * file written by a prior pvscan for a list of all
- * PVIDs. A lookup file may not exist for this PV if
- * it's the first to appear from the VG.
+ * When the VG is complete|finished, we could print
+ * a list of devices in the VG, by reading the pvid files
+ * that were counted, which provides major:minor of each
+ * device and using that to get the struct dev and dev_name.
+ * The user could pass this list of devices to --devices
+ * to optimize a subsequent command (activation) on the VG.
+ * Just call set_pv_devices_online (if not done othewise)
+ * since that finds the devs.
*/
- log_debug("checking all pvid files from lookup file");
- if (!_count_pvid_files_from_lookup_file(cmd, dev, &pvs_online, &pvs_offline, &vgname))
- pvs_unknown = 1;
}
- if (pvs_unknown) {
- log_print("pvscan[%d] PV %s online, VG unknown.",
- getpid(), dev_name(dev));
- } else if (pvs_offline) {
- log_print("pvscan[%d] PV %s online, VG %s incomplete (need %d).",
- getpid(), dev_name(dev), vgname, pvs_offline);
- } else {
- log_print("pvscan[%d] PV %s online, VG %s is complete.", getpid(), dev_name(dev), vgname);
- if (!str_list_add(cmd->mem, complete_vgnames, dm_pool_strdup(cmd->mem, vgname)))
- stack;
- vg_complete = 1;
+ if (do_list_lvs && !vg) {
+ /* require all PVs used for booting have metadata */
+ log_print_pvscan(cmd, "Cannot list LVs from device without metadata.");
+ }
+
+ if (do_list_lvs && vg) {
+ struct dm_list lvs_list;
+ struct lv_list *lvl;
+
+ dm_list_init(&lvs_list);
+
+ /*
+ * For each vg->pvs entry, get the dev based on the online file
+ * for the pvid and set pv->dev or pv->status MISSING_PV.
+ */
+ _set_pv_devices_online(cmd, vg);
+
+ /*
+ * lvs_list are LVs that use dev.
+ */
+ if (!get_visible_lvs_using_pv(cmd, vg, dev, &lvs_list))
+ log_print_pvscan(cmd, "Failed to find LVs using %s.", dev_name(dev));
+
+ if (!do_check_complete) {
+ dm_list_iterate_items(lvl, &lvs_list)
+ log_print("LV %s", display_lvname(lvl->lv));
+ } else if (vg_complete) {
+ /*
+ * A shortcut; the vg complete implies all lvs are complete.
+ */
+ dm_list_iterate_items(lvl, &lvs_list)
+ log_print("LV %s complete", display_lvname(lvl->lv));
+ } else {
+ /*
+ * For each LV in VG, check if all devs are present.
+ * Sets the PARTIAL flag on LVs that are not complete.
+ */
+ if (!vg_mark_partial_lvs(vg, 1))
+ log_print_pvscan(cmd, "Failed to check partial lvs.");
+
+ dm_list_iterate_items(lvl, &lvs_list) {
+ if (!lv_is_partial(lvl->lv))
+ log_print("LV %s complete", display_lvname(lvl->lv));
+ else
+ log_print("LV %s incomplete", display_lvname(lvl->lv));
+ }
+ }
}
- if (!saved_vg && vg && vg_complete && !do_all && (dm_list_size(pvscan_devs) == 1))
+ /*
+ * When "pvscan --cache -aay <dev>" completes the vg, save the
+ * struct vg to use for quick activation function.
+ */
+ if (do_activate && !saved_vg && vg && vg_complete && !do_all && (dm_list_size(pvscan_devs) == 1))
saved_vg = vg;
else
release_vg(vg);
@@ -1484,7 +1677,7 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
* Specific devs must be matched later with device_ids_match_dev().
*/
if (!setup_devices_no_file_match(cmd)) {
- log_error("Failed to set up devices.");
+ log_error_pvscan(cmd, "Failed to set up devices.");
return 0;
}
@@ -1563,8 +1756,8 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
dm_list_iterate_items_safe(devl, devl2, &pvscan_devs) {
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, NULL)) {
- log_print("pvscan[%d] %s excluded by filters: %s.", getpid(),
- dev_name(devl->dev), dev_filtered_reason(devl->dev));
+ log_print_pvscan(cmd, "%s excluded by filters: %s.",
+ dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
}
}
@@ -1600,7 +1793,7 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
if (!has_pvid) {
/* Not an lvm device */
- log_print("pvscan[%d] %s not an lvm device.", getpid(), dev_name(devl->dev));
+ log_print_pvscan(cmd, "%s not an lvm device.", dev_name(devl->dev));
dm_list_del(&devl->list);
continue;
}
@@ -1611,8 +1804,8 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
*/
if (relax_deviceid_filter) {
if (!get_du_for_pvid(cmd, devl->dev->pvid)) {
- log_print("pvscan[%d] %s excluded by devices file (checking PVID).",
- getpid(), dev_name(devl->dev));
+ log_print_pvscan(cmd, "%s excluded by devices file (checking PVID).",
+ dev_name(devl->dev));
dm_list_del(&devl->list);
continue;
}
@@ -1620,8 +1813,8 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
/* Applies all filters, including those that need data from dev. */
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, NULL)) {
- log_print("pvscan[%d] %s excluded by filters: %s.", getpid(),
- dev_name(devl->dev), dev_filtered_reason(devl->dev));
+ log_print_pvscan(cmd, "%s excluded by filters: %s.",
+ dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
}
}
@@ -1685,6 +1878,37 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
return ECMD_PROCESSED;
}
+ /*
+ * lvm udev rules call:
+ * pvscan --cache --listvg|--listlvs --checkcomplete PV
+ * when PVs appear, even if event_activation=0 in lvm.conf.
+ *
+ * The udev rules will do autoactivation if they see complete
+ * VGs/LVs reported from the pvscan.
+ *
+ * When event_activation=0 we do not want to do autoactivation
+ * from udev events, so we need the pvscan to not report any
+ * complete VGs/LVs when event_activation=0 so that the udev
+ * rules do not attempt to autoactivate.
+ */
+
+ if (arg_is_set(cmd, checkcomplete_ARG) && !event_activation) {
+ if (arg_is_set(cmd, udevoutput_ARG))
+ printf("LVM_EVENT_ACTIVATION=0\n");
+ else
+ log_print_pvscan(cmd, "Ignoring pvscan with --checkcomplete because event_activation is disabled.");
+ return ECMD_PROCESSED;
+ }
+
+ /*
+ * If obtain_device_list_from_udev was set to 1, force it to 0.
+ * Don't ask udev for info since pvscan is running from udev.
+ * If a pvscan attempts to get dev info from udev, udev can
+ * repeatedly return errors about the dev not being initialized
+ * which will stall the pvscan.
+ */
+ init_obtain_device_list_from_udev(0);
+
if (arg_is_set(cmd, major_ARG) + arg_is_set(cmd, minor_ARG))
devno_args = 1;
@@ -1695,13 +1919,13 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
do_all = !argc && !devno_args;
- _online_dir_setup();
+ _online_dir_setup(cmd);
if (do_all) {
if (!_pvscan_cache_all(cmd, argc, argv, &complete_vgnames))
return ECMD_FAILED;
} else {
- if (!event_activation) {
+ if (!arg_is_set(cmd, checkcomplete_ARG) && !event_activation) {
/* Avoid doing anything for device removal: pvscan --cache <devno> */
log_verbose("Ignoring pvscan --cache because event_activation is disabled.");
return ECMD_PROCESSED;
diff --git a/tools/toollib.c b/tools/toollib.c
index 357c9f8b8..3682dfa0a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -813,6 +813,24 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
lv_clear_integrity_recalculate_metadata(lv);
}
+ /*
+ * When LVs are deactivated, then autoactivation of the VG is
+ * "re-armed" by removing the vg online file. So, after deactivation
+ * of LVs, if PVs are disconnected and reconnected again, event
+ * activation will trigger autoactivation again. This secondary
+ * autoactivation is somewhat different from, and not as important as
+ * the initial autoactivation during system startup. The secondary
+ * autoactivation will happen to a VG on a running system and may be
+ * mixing with user commands, so the end result is unpredictable.
+ *
+ * It's possible that we might want a config setting for usersto
+ * disable secondary autoactivations. Once a system is up, the
+ * user may want to take charge of activation changes to the VG
+ * and not have the system autoactivation interfere.
+ */
+ if (!is_change_activating(activate) && find_config_tree_bool(cmd, global_event_activation_CFG, NULL))
+ online_vg_file_remove(lv->vg->name);
+
set_lv_notify(lv->vg->cmd);
return r;
diff --git a/tools/tools.h b/tools/tools.h
index 708a78d1c..bc98fcb09 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -295,4 +295,6 @@ int lvconvert_cachevol_attach_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle);
+void online_vg_file_remove(const char *vgname);
+
#endif
2 years, 6 months
main - system_id: new appmachineid option
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3e1316bb09b087ec79c...
Commit: 3e1316bb09b087ec79c9661ead14d8556c36fa8d
Parent: 6c22392a3f903d6c086f7cc94978bdf8b072da6e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 20 10:59:38 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 7 12:06:49 2021 -0500
system_id: new appmachineid option
The new system_id_source="appmachineid" will cause
lvm to use an lvm-specific derivation of the machine-id,
instead of the machine-id directly. This is now
recommended in place of using machineid.
---
configure.ac | 20 ++++++++++++++++++++
lib/commands/toolcontext.c | 26 +++++++++++++++++++++++---
lib/config/config_settings.h | 8 +++++---
man/lvmsystemid.7_main | 17 +++++++++++++++++
test/shell/system_id.sh | 11 +++++++++++
5 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6b1ea9854..31196d96c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1105,6 +1105,26 @@ if test "$NOTIFYDBUS_SUPPORT" = yes; then
PKG_CHECK_MODULES(NOTIFY_DBUS, systemd >= 221, [HAVE_NOTIFY_DBUS=yes], $bailout)
fi
+################################################################################
+dnl -- Build appmachineid
+AC_MSG_CHECKING(whether to build appmachineid)
+AC_ARG_ENABLE(app-machineid,
+ AC_HELP_STRING([--enable-app-machineid],
+ [enable LVM system ID using app-specific machine-id]),
+ APP_MACHINEID_SUPPORT=$enableval, APP_MACHINEID_SUPPORT=no)
+AC_MSG_RESULT($APP_MACHINEID_SUPPORT)
+
+if test "$APP_MACHINEID_SUPPORT" = yes; then
+ AC_DEFINE([APP_MACHINEID_SUPPORT], 1, [Define to 1 to include code that uses libsystemd machine-id apis.])
+ SYSTEMD_LIBS="-lsystemd"
+fi
+
+################################################################################
+dnl -- Look for libsystemd libraries
+if test "$APP_MACHINEID_SUPPORT" = yes; then
+ PKG_CHECK_MODULES(APP_MACHINEID, systemd >= 234, [HAVE_APP_MACHINEID=yes], $bailout)
+fi
+
################################################################################
dnl -- Enable blkid wiping functionality
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index ecd50dbf7..8991aebcf 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -41,6 +41,10 @@
#include <syslog.h>
#include <time.h>
+#ifdef APP_MACHINEID_SUPPORT
+#include <systemd/sd-id128.h>
+#endif
+
#ifdef __linux__
# include <malloc.h>
#endif
@@ -129,9 +133,12 @@ static const char *_read_system_id_from_file(struct cmd_context *cmd, const char
return system_id;
}
+/* systemd-id128 new produced: f64406832c2140e8ac5422d1089aae03 */
+#define LVM_APPLICATION_ID SD_ID128_MAKE(f6,44,06,83,2c,21,40,e8,ac,54,22,d1,08,9a,ae,03)
+
static const char *_system_id_from_source(struct cmd_context *cmd, const char *source)
{
- char filebuf[PATH_MAX];
+ char buf[PATH_MAX];
const char *file;
const char *etc_str;
const char *str;
@@ -150,10 +157,23 @@ static const char *_system_id_from_source(struct cmd_context *cmd, const char *s
goto out;
}
+#ifdef APP_MACHINEID_SUPPORT
+ if (!strcasecmp(source, "appmachineid")) {
+ sd_id128_t id;
+
+ sd_id128_get_machine_app_specific(LVM_APPLICATION_ID, &id);
+
+ if (dm_snprintf(buf, PATH_MAX, SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(id)) < 0)
+ stack;
+ system_id = system_id_from_string(cmd, buf);
+ goto out;
+ }
+#endif
+
if (!strcasecmp(source, "machineid") || !strcasecmp(source, "machine-id")) {
etc_str = find_config_tree_str(cmd, global_etc_CFG, NULL);
- if (dm_snprintf(filebuf, sizeof(filebuf), "%s/machine-id", etc_str) != -1)
- system_id = _read_system_id_from_file(cmd, filebuf);
+ if (dm_snprintf(buf, sizeof(buf), "%s/machine-id", etc_str) != -1)
+ system_id = _read_system_id_from_file(cmd, buf);
goto out;
}
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index b2270bee9..aad0d5989 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1275,10 +1275,12 @@ cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, CFG_DEF
" uname\n"
" Set the system ID from the hostname (uname) of the system.\n"
" System IDs beginning localhost are not permitted.\n"
+ " appmachineid\n"
+ " Use an LVM-specific derivation of the local machine-id as the\n"
+ " system ID. See 'man machine-id'.\n"
" machineid\n"
- " Use the contents of the machine-id file to set the system ID.\n"
- " Some systems create this file at installation time.\n"
- " See 'man machine-id' and global/etc.\n"
+ " Use the contents of the machine-id file to set the system ID\n"
+ " (appmachineid is recommended.)\n"
" file\n"
" Use the contents of another file (system_id_file) to set the\n"
" system ID.\n"
diff --git a/man/lvmsystemid.7_main b/man/lvmsystemid.7_main
index eac4f7bc1..06e7f3454 100644
--- a/man/lvmsystemid.7_main
+++ b/man/lvmsystemid.7_main
@@ -172,6 +172,22 @@ global {
}
.fi
.
+.TP
+.B appmachineid
+.br
+
+An LVM-specific derivation of /etc/machine-id is used as the system ID.
+See
+.BR machine-id (5)
+to check if machine-id is available on the host.
+
+.I lvm.conf
+.nf
+global {
+ system_id_source = "appmachineid"
+}
+.fi
+
.TP
.B machineid
.br
@@ -181,6 +197,7 @@ See
and
.BR systemd-machine-id-setup (1)
to check if machine-id is available on the host.
+(appmachineid is recommended in place of machineid.)
.sp
.I lvm.conf
.nf
diff --git a/test/shell/system_id.sh b/test/shell/system_id.sh
index ee51ca179..756c95add 100644
--- a/test/shell/system_id.sh
+++ b/test/shell/system_id.sh
@@ -64,6 +64,17 @@ check vg_field $vg1 systemid "$SID"
vgremove $vg1
fi
+## appmachineid
+lvm version > lvmver
+if grep app-machineid lvmver; then
+aux lvmconf "global/system_id_source = appmachineid"
+lvm systemid | awk '{ print $3 }' > sid_lvm
+vgcreate $vg1 "$dev1"
+vgs -o systemid --noheadings $vg1 | awk '{print $1}' > sid_vg
+diff sid_lvm sid_vg
+vgremove $vg1
+fi
+
## uname
SID1=$(uname -n)
2 years, 6 months
main - config: change default use_devicesfile to 1
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6c22392a3f903d6c086...
Commit: 6c22392a3f903d6c086f7cc94978bdf8b072da6e
Parent: 02626cbd33b58144eff5e4582f07560e37f212b5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 16 09:52:13 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 7 12:06:49 2021 -0500
config: change default use_devicesfile to 1
---
lib/config/defaults.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 66eece53a..a7a2a06df 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -322,7 +322,7 @@
#define DEFAULT_MD_COMPONENT_CHECKS "auto"
-#define DEFAULT_USE_DEVICES_FILE 0
+#define DEFAULT_USE_DEVICES_FILE 1
#define DEFAULT_DEVICES_FILE "system.devices"
#define DEFAULT_SEARCH_FOR_DEVNAMES "auto"
2 years, 6 months
main - config: comment all default settings
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=02626cbd33b58144eff...
Commit: 02626cbd33b58144eff5e4582f07560e37f212b5
Parent: 3cf97a737bb5eb4cd456b894b1e675291f459129
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 16 09:51:41 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 7 12:06:49 2021 -0500
config: comment all default settings
---
lib/config/config_settings.h | 174 +++++++++++++++++++++----------------------
1 file changed, 87 insertions(+), 87 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index c0e491cad..b2270bee9 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -205,7 +205,7 @@ cfg_section(local_CFG_SECTION, "local", root_CFG_SECTION, 0, vsn(2, 2, 117), 0,
"# Please take care that each setting only appears once if uncommenting\n" \
"# example settings in this file and never copy this file between hosts.\n\n"
-cfg(config_checks_CFG, "checks", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 99), NULL, 0, NULL,
+cfg(config_checks_CFG, "checks", config_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 2, 99), NULL, 0, NULL,
"If enabled, any LVM configuration mismatch is reported.\n"
"This implies checking that the configuration key is understood by\n"
"LVM and that the value of the key is the proper type. If disabled,\n"
@@ -213,22 +213,22 @@ cfg(config_checks_CFG, "checks", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2,
"without any warning (a message about the configuration key not being\n"
"found is issued in verbose mode only).\n")
-cfg(config_abort_on_errors_CFG, "abort_on_errors", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2,2,99), NULL, 0, NULL,
+cfg(config_abort_on_errors_CFG, "abort_on_errors", config_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(2,2,99), NULL, 0, NULL,
"Abort the LVM process if a configuration mismatch is found.\n")
-cfg_runtime(config_profile_dir_CFG, "profile_dir", config_CFG_SECTION, CFG_DISALLOW_INTERACTIVE, CFG_TYPE_STRING, vsn(2, 2, 99), 0, NULL,
+cfg_runtime(config_profile_dir_CFG, "profile_dir", config_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_DISALLOW_INTERACTIVE, CFG_TYPE_STRING, vsn(2, 2, 99), 0, NULL,
"Directory where LVM looks for configuration profiles.\n")
-cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_DEV_DIR, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_DEV_DIR, vsn(1, 0, 0), NULL, 0, NULL,
"Directory in which to create volume group device nodes.\n"
"Commands also accept this as a prefix on volume group names.\n")
-cfg_array(devices_scan_CFG, "scan", devices_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, "#S/dev", vsn(1, 0, 0), NULL, 0, NULL,
+cfg_array(devices_scan_CFG, "scan", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, "#S/dev", vsn(1, 0, 0), NULL, 0, NULL,
"Directories containing device nodes to use with LVM.\n")
cfg_array(devices_loopfiles_CFG, "loopfiles", devices_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 2, 0), NULL, vsn(2, 3, 0), NULL, NULL)
-cfg(devices_obtain_device_list_from_udev_CFG, "obtain_device_list_from_udev", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV, vsn(2, 2, 85), NULL, 0, NULL,
+cfg(devices_obtain_device_list_from_udev_CFG, "obtain_device_list_from_udev", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV, vsn(2, 2, 85), NULL, 0, NULL,
"Obtain the list of available devices from udev.\n"
"This avoids opening or using any inapplicable non-block devices or\n"
"subdirectories found in the udev directory. Any device node or\n"
@@ -237,7 +237,7 @@ cfg(devices_obtain_device_list_from_udev_CFG, "obtain_device_list_from_udev", de
"directories will be scanned fully. LVM needs to be compiled with\n"
"udev support for this setting to apply.\n")
-cfg(devices_external_device_info_source_CFG, "external_device_info_source", devices_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_EXTERNAL_DEVICE_INFO_SOURCE, vsn(2, 2, 116), NULL, 0, NULL,
+cfg(devices_external_device_info_source_CFG, "external_device_info_source", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_EXTERNAL_DEVICE_INFO_SOURCE, vsn(2, 2, 116), NULL, 0, NULL,
"Enable device information from udev.\n"
"If set to \"udev\", lvm will supplement its own native device information\n"
"with information from libudev. This can potentially improve the detection\n"
@@ -360,12 +360,12 @@ cfg_array(devices_types_CFG, "types", devices_CFG_SECTION, CFG_DEFAULT_UNDEFINED
"types = [ \"fd\", 16 ]\n"
"#\n")
-cfg(devices_sysfs_scan_CFG, "sysfs_scan", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SYSFS_SCAN, vsn(1, 0, 8), NULL, 0, NULL,
+cfg(devices_sysfs_scan_CFG, "sysfs_scan", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_SYSFS_SCAN, vsn(1, 0, 8), NULL, 0, NULL,
"Restrict device scanning to block devices appearing in sysfs.\n"
"This is a quick way of filtering out block devices that are not\n"
"present on the system. sysfs must be part of the kernel and mounted.)\n")
-cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SCAN_LVS, vsn(2, 2, 182), NULL, 0, NULL,
+cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_SCAN_LVS, vsn(2, 2, 182), NULL, 0, NULL,
"Scan LVM LVs for layered PVs, allowing LVs to be used as PVs.\n"
"When 1, LVM will detect PVs layered on LVs, and caution must be\n"
"taken to avoid a host accessing a layered VG that may not belong\n"
@@ -378,14 +378,14 @@ cfg(devices_scan_lvs_CFG, "scan_lvs", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEF
"an LV. The LVs are ignored using a built in device filter that\n"
"identifies and excludes LVs.\n")
-cfg(devices_multipath_component_detection_CFG, "multipath_component_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MULTIPATH_COMPONENT_DETECTION, vsn(2, 2, 89), NULL, 0, NULL,
+cfg(devices_multipath_component_detection_CFG, "multipath_component_detection", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_MULTIPATH_COMPONENT_DETECTION, vsn(2, 2, 89), NULL, 0, NULL,
"Ignore devices that are components of DM multipath devices.\n")
cfg(devices_multipath_wwids_file_CFG, "multipath_wwids_file", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ALLOW_EMPTY, CFG_TYPE_STRING, DEFAULT_WWIDS_FILE, vsn(2, 3, 13), NULL, 0, NULL,
"The path to the multipath wwids file used for multipath component detection.\n"
"Set this to an empty string to disable the use of the multipath wwids file.\n")
-cfg(devices_md_component_detection_CFG, "md_component_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MD_COMPONENT_DETECTION, vsn(1, 0, 18), NULL, 0, NULL,
+cfg(devices_md_component_detection_CFG, "md_component_detection", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_MD_COMPONENT_DETECTION, vsn(1, 0, 18), NULL, 0, NULL,
"Enable detection and exclusion of MD component devices.\n"
"An MD component device is a block device that MD uses as part\n"
"of a software RAID virtual device. When an LVM PV is created\n"
@@ -411,12 +411,12 @@ cfg(devices_md_component_checks_CFG, "md_component_checks", devices_CFG_SECTION,
" This requires an extra read at the end of devices.\n"
"#\n")
-cfg(devices_fw_raid_component_detection_CFG, "fw_raid_component_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_FW_RAID_COMPONENT_DETECTION, vsn(2, 2, 112), NULL, 0, NULL,
+cfg(devices_fw_raid_component_detection_CFG, "fw_raid_component_detection", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_FW_RAID_COMPONENT_DETECTION, vsn(2, 2, 112), NULL, 0, NULL,
"Ignore devices that are components of firmware RAID devices.\n"
"LVM must use an external_device_info_source other than none for this\n"
"detection to execute.\n")
-cfg(devices_md_chunk_alignment_CFG, "md_chunk_alignment", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MD_CHUNK_ALIGNMENT, vsn(2, 2, 48), NULL, 0, NULL,
+cfg(devices_md_chunk_alignment_CFG, "md_chunk_alignment", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_MD_CHUNK_ALIGNMENT, vsn(2, 2, 48), NULL, 0, NULL,
"Align the start of a PV data area with md device's stripe-width.\n"
"This applies if a PV is placed directly on an md device.\n"
"default_data_alignment will be overridden if it is not aligned\n"
@@ -430,7 +430,7 @@ cfg(devices_default_data_alignment_CFG, "default_data_alignment", devices_CFG_SE
"This setting is overridden by data_alignment and the --dataalignment\n"
"option.\n")
-cfg(devices_data_alignment_detection_CFG, "data_alignment_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_DATA_ALIGNMENT_DETECTION, vsn(2, 2, 51), NULL, 0, NULL,
+cfg(devices_data_alignment_detection_CFG, "data_alignment_detection", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_DATA_ALIGNMENT_DETECTION, vsn(2, 2, 51), NULL, 0, NULL,
"Align the start of a PV data area with sysfs io properties.\n"
"The start of a PV data area will be a multiple of minimum_io_size or\n"
"optimal_io_size exposed in sysfs. minimum_io_size is the smallest\n"
@@ -444,14 +444,14 @@ cfg(devices_data_alignment_detection_CFG, "data_alignment_detection", devices_CF
"This setting is overridden by data_alignment and the --dataalignment\n"
"option.\n")
-cfg(devices_data_alignment_CFG, "data_alignment", devices_CFG_SECTION, 0, CFG_TYPE_INT, 0, vsn(2, 2, 45), NULL, 0, NULL,
+cfg(devices_data_alignment_CFG, "data_alignment", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(2, 2, 45), NULL, 0, NULL,
"Align the start of a PV data area with this number of KiB.\n"
"When non-zero, this setting overrides default_data_alignment.\n"
"Set to 0 to disable, in which case default_data_alignment\n"
"is used to align the first PE in units of MiB.\n"
"This setting is overridden by the --dataalignment option.\n")
-cfg(devices_data_alignment_offset_detection_CFG, "data_alignment_offset_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION, vsn(2, 2, 50), NULL, 0, NULL,
+cfg(devices_data_alignment_offset_detection_CFG, "data_alignment_offset_detection", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION, vsn(2, 2, 50), NULL, 0, NULL,
"Shift the start of an aligned PV data area based on sysfs information.\n"
"After a PV data area is aligned, it will be shifted by the\n"
"alignment_offset exposed in sysfs. This offset is often 0, but may\n"
@@ -461,12 +461,12 @@ cfg(devices_data_alignment_offset_detection_CFG, "data_alignment_offset_detectio
"LBA -1, and consequently sector 63 is aligned on a 4KiB boundary).\n"
"This setting is overridden by the --dataalignmentoffset option.\n")
-cfg(devices_ignore_suspended_devices_CFG, "ignore_suspended_devices", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_IGNORE_SUSPENDED_DEVICES, vsn(1, 2, 19), NULL, 0, NULL,
+cfg(devices_ignore_suspended_devices_CFG, "ignore_suspended_devices", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_IGNORE_SUSPENDED_DEVICES, vsn(1, 2, 19), NULL, 0, NULL,
"Ignore DM devices that have I/O suspended while scanning devices.\n"
"Otherwise, LVM waits for a suspended device to become accessible.\n"
"This should only be needed in recovery situations.\n")
-cfg(devices_ignore_lvm_mirrors_CFG, "ignore_lvm_mirrors", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_IGNORE_LVM_MIRRORS, vsn(2, 2, 104), NULL, 0, NULL,
+cfg(devices_ignore_lvm_mirrors_CFG, "ignore_lvm_mirrors", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_IGNORE_LVM_MIRRORS, vsn(2, 2, 104), NULL, 0, NULL,
"Do not scan 'mirror' LVs to avoid possible deadlocks.\n"
"This avoids possible deadlocks when using the 'mirror' segment type.\n"
"This setting determines whether LVs using the 'mirror' segment type\n"
@@ -484,19 +484,19 @@ cfg(devices_ignore_lvm_mirrors_CFG, "ignore_lvm_mirrors", devices_CFG_SECTION, 0
"apply to LVM RAID types like 'raid1' which handle failures in a\n"
"different way, making them a better choice for VG stacking.\n")
-cfg(devices_disable_after_error_count_CFG, "disable_after_error_count", devices_CFG_SECTION, 0, CFG_TYPE_INT, 0, vsn(2, 2, 75), NULL, vsn(2, 3, 0), NULL,
+cfg(devices_disable_after_error_count_CFG, "disable_after_error_count", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(2, 2, 75), NULL, vsn(2, 3, 0), NULL,
NULL)
-cfg(devices_require_restorefile_with_uuid_CFG, "require_restorefile_with_uuid", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID, vsn(2, 2, 73), NULL, 0, NULL,
+cfg(devices_require_restorefile_with_uuid_CFG, "require_restorefile_with_uuid", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID, vsn(2, 2, 73), NULL, 0, NULL,
"Allow use of pvcreate --uuid without requiring --restorefile.\n")
-cfg(devices_pv_min_size_CFG, "pv_min_size", devices_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_PV_MIN_SIZE_KB, vsn(2, 2, 85), NULL, 0, NULL,
+cfg(devices_pv_min_size_CFG, "pv_min_size", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_PV_MIN_SIZE_KB, vsn(2, 2, 85), NULL, 0, NULL,
"Minimum size in KiB of block devices which can be used as PVs.\n"
"In a clustered environment all nodes must use the same value.\n"
"Any value smaller than 512KiB is ignored. The previous built-in\n"
"value was 512.\n")
-cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ISSUE_DISCARDS, vsn(2, 2, 85), NULL, 0, NULL,
+cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ISSUE_DISCARDS, vsn(2, 2, 85), NULL, 0, NULL,
"Issue discards to PVs that are no longer used by an LV.\n"
"Discards are sent to an LV's underlying physical volumes when the LV\n"
"is no longer using the physical volumes' space, e.g. lvremove,\n"
@@ -508,7 +508,7 @@ cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, 0, CFG_TY
"generally do. If enabled, discards will only be issued if both the\n"
"storage and kernel provide support.\n")
-cfg(devices_allow_changes_with_duplicate_pvs_CFG, "allow_changes_with_duplicate_pvs", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ALLOW_CHANGES_WITH_DUPLICATE_PVS, vsn(2, 2, 153), NULL, 0, NULL,
+cfg(devices_allow_changes_with_duplicate_pvs_CFG, "allow_changes_with_duplicate_pvs", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ALLOW_CHANGES_WITH_DUPLICATE_PVS, vsn(2, 2, 153), NULL, 0, NULL,
"Allow VG modification while a PV appears on multiple devices.\n"
"When a PV appears on multiple devices, LVM attempts to choose the\n"
"best device to use for the PV. If the devices represent the same\n"
@@ -520,7 +520,7 @@ cfg(devices_allow_changes_with_duplicate_pvs_CFG, "allow_changes_with_duplicate_
"Enabling this setting allows the VG to be used as usual even with\n"
"uncertain devices.\n")
-cfg(devices_allow_mixed_block_sizes_CFG, "allow_mixed_block_sizes", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 3, 6), NULL, 0, NULL,
+cfg(devices_allow_mixed_block_sizes_CFG, "allow_mixed_block_sizes", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(2, 3, 6), NULL, 0, NULL,
"Allow PVs in the same VG with different logical block sizes.\n"
"When allowed, the user is responsible to ensure that an LV is\n"
"using PVs with matching block sizes when necessary.\n")
@@ -543,14 +543,14 @@ cfg_array(allocation_cling_tag_list_CFG, "cling_tag_list", allocation_CFG_SECTIO
"cling_tag_list = [ \"@site1\", \"@site2\" ]\n"
"#\n")
-cfg(allocation_maximise_cling_CFG, "maximise_cling", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MAXIMISE_CLING, vsn(2, 2, 85), NULL, 0, NULL,
+cfg(allocation_maximise_cling_CFG, "maximise_cling", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_MAXIMISE_CLING, vsn(2, 2, 85), NULL, 0, NULL,
"Use a previous allocation algorithm.\n"
"Changes made in version 2.02.85 extended the reach of the 'cling'\n"
"policies to detect more situations where data can be grouped onto\n"
"the same disks. This setting can be used to disable the changes\n"
"and revert to the previous algorithm.\n")
-cfg(allocation_use_blkid_wiping_CFG, "use_blkid_wiping", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_USE_BLKID_WIPING, vsn(2, 2, 105), "@DEFAULT_USE_BLKID_WIPING@", 0, NULL,
+cfg(allocation_use_blkid_wiping_CFG, "use_blkid_wiping", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_USE_BLKID_WIPING, vsn(2, 2, 105), "@DEFAULT_USE_BLKID_WIPING@", 0, NULL,
"Use blkid to detect and erase existing signatures on new PVs and LVs.\n"
"The blkid library can detect more signatures than the native LVM\n"
"detection code, but may take longer. LVM needs to be compiled with\n"
@@ -559,7 +559,7 @@ cfg(allocation_use_blkid_wiping_CFG, "use_blkid_wiping", allocation_CFG_SECTION,
"swap signature, and LUKS signatures. To see the list of signatures\n"
"recognized by blkid, check the output of the 'blkid -k' command.\n")
-cfg(allocation_wipe_signatures_when_zeroing_new_lvs_CFG, "wipe_signatures_when_zeroing_new_lvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 105), NULL, 0, NULL,
+cfg(allocation_wipe_signatures_when_zeroing_new_lvs_CFG, "wipe_signatures_when_zeroing_new_lvs", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 2, 105), NULL, 0, NULL,
"Look for and erase any signatures while zeroing a new LV.\n"
"The --wipesignatures option overrides this setting.\n"
"Zeroing is controlled by the -Z/--zero option, and if not specified,\n"
@@ -575,7 +575,7 @@ cfg(allocation_wipe_signatures_when_zeroing_new_lvs_CFG, "wipe_signatures_when_z
"When this setting is disabled, signatures on new LVs are not detected\n"
"or erased unless the --wipesignatures option is used directly.\n")
-cfg(allocation_mirror_logs_require_separate_pvs_CFG, "mirror_logs_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_MIRROR_LOGS_REQUIRE_SEPARATE_PVS, vsn(2, 2, 85), NULL, 0, NULL,
+cfg(allocation_mirror_logs_require_separate_pvs_CFG, "mirror_logs_require_separate_pvs", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_MIRROR_LOGS_REQUIRE_SEPARATE_PVS, vsn(2, 2, 85), NULL, 0, NULL,
"Mirror logs and images will always use different PVs.\n"
"The default setting changed in version 2.02.85.\n")
@@ -854,10 +854,10 @@ cfg(log_command_log_selection_CFG, "command_log_selection", log_CFG_SECTION, CFG
"For more information about selection criteria in general, see\n"
"lvm(8) man page.\n")
-cfg(log_verbose_CFG, "verbose", log_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_VERBOSE, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_verbose_CFG, "verbose", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VERBOSE, vsn(1, 0, 0), NULL, 0, NULL,
"Controls the messages sent to stdout or stderr.\n")
-cfg(log_silent_CFG, "silent", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SILENT, vsn(2, 2, 98), NULL, 0, NULL,
+cfg(log_silent_CFG, "silent", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_SILENT, vsn(2, 2, 98), NULL, 0, NULL,
"Suppress all non-essential messages from stdout.\n"
"This has the same effect as -qq. When enabled, the following commands\n"
"still produce output: dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck,\n"
@@ -867,16 +867,16 @@ cfg(log_silent_CFG, "silent", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SILENT,
"Any 'yes' or 'no' questions not overridden by other arguments are\n"
"suppressed and default to 'no'.\n")
-cfg(log_syslog_CFG, "syslog", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SYSLOG, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_syslog_CFG, "syslog", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_SYSLOG, vsn(1, 0, 0), NULL, 0, NULL,
"Send log messages through syslog.\n")
cfg(log_file_CFG, "file", log_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL,
"Write error and debug log messages to a file specified here.\n")
-cfg(log_overwrite_CFG, "overwrite", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_OVERWRITE, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_overwrite_CFG, "overwrite", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_OVERWRITE, vsn(1, 0, 0), NULL, 0, NULL,
"Overwrite the log file each time the program is run.\n")
-cfg(log_level_CFG, "level", log_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_LOGLEVEL, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_level_CFG, "level", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_LOGLEVEL, vsn(1, 0, 0), NULL, 0, NULL,
"The level of log messages that are sent to the log file or syslog.\n"
"There are 6 syslog-like log levels currently in use: 2 to 7 inclusive.\n"
"7 is the most verbose (LOG_DEBUG).\n")
@@ -884,23 +884,23 @@ cfg(log_level_CFG, "level", log_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_LOGLEVEL,
cfg(log_indent_CFG, "indent", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_INDENT, vsn(1, 0, 0), NULL, 0, NULL,
"Indent messages according to their severity.\n")
-cfg(log_command_names_CFG, "command_names", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_CMD_NAME, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_command_names_CFG, "command_names", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_CMD_NAME, vsn(1, 0, 0), NULL, 0, NULL,
"Display the command name on each line of output.\n")
-cfg(log_prefix_CFG, "prefix", log_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, DEFAULT_MSG_PREFIX, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_prefix_CFG, "prefix", log_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ALLOW_EMPTY, CFG_TYPE_STRING, DEFAULT_MSG_PREFIX, vsn(1, 0, 0), NULL, 0, NULL,
"A prefix to use before the log message text.\n"
"(After the command name, if selected).\n"
"Two spaces allows you to see/grep the severity of each message.\n"
"To make the messages look similar to the original LVM tools use:\n"
"indent = 0, command_names = 1, prefix = \" -- \"\n")
-cfg(log_activation_CFG, "activation", log_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(log_activation_CFG, "activation", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(1, 0, 0), NULL, 0, NULL,
"Log messages during activation.\n"
"Don't use this in low memory situations (can deadlock).\n")
cfg(log_activate_file_CFG, "activate_file", log_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL, NULL)
-cfg_array(log_debug_classes_CFG, "debug_classes", log_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, "#Smemory#Sdevices#Sio#Sactivation#Sallocation#Smetadata#Scache#Slocking#Slvmpolld#Sdbus", vsn(2, 2, 99), NULL, 0, NULL,
+cfg_array(log_debug_classes_CFG, "debug_classes", log_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ALLOW_EMPTY, CFG_TYPE_STRING, "#Smemory#Sdevices#Sio#Sactivation#Sallocation#Smetadata#Scache#Slocking#Slvmpolld#Sdbus", vsn(2, 2, 99), NULL, 0, NULL,
"Select log messages by class.\n"
"Some debugging messages are assigned to a class and only appear in\n"
"debug output if the class is listed here. Classes currently\n"
@@ -915,55 +915,55 @@ cfg_array(log_debug_output_fields_CFG, "debug_output_fields", log_CFG_SECTION, C
"The fields included in debug output written to stderr.\n"
"Use \"all\" to include everything (the default).\n")
-cfg(backup_backup_CFG, "backup", backup_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_BACKUP_ENABLED, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(backup_backup_CFG, "backup", backup_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_BACKUP_ENABLED, vsn(1, 0, 0), NULL, 0, NULL,
"Maintain a backup of the current metadata configuration.\n"
"Think very hard before turning this off!\n")
-cfg_runtime(backup_backup_dir_CFG, "backup_dir", backup_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), 0, NULL,
+cfg_runtime(backup_backup_dir_CFG, "backup_dir", backup_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, vsn(1, 0, 0), 0, NULL,
"Location of the metadata backup files.\n"
"Remember to back up this directory regularly!\n")
-cfg(backup_archive_CFG, "archive", backup_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ARCHIVE_ENABLED, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(backup_archive_CFG, "archive", backup_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ARCHIVE_ENABLED, vsn(1, 0, 0), NULL, 0, NULL,
"Maintain an archive of old metadata configurations.\n"
"Think very hard before turning this off.\n")
-cfg_runtime(backup_archive_dir_CFG, "archive_dir", backup_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(1, 0, 0), 0, NULL,
+cfg_runtime(backup_archive_dir_CFG, "archive_dir", backup_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, vsn(1, 0, 0), 0, NULL,
"Location of the metdata archive files.\n"
"Remember to back up this directory regularly!\n")
-cfg(backup_retain_min_CFG, "retain_min", backup_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_ARCHIVE_NUMBER, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(backup_retain_min_CFG, "retain_min", backup_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_ARCHIVE_NUMBER, vsn(1, 0, 0), NULL, 0, NULL,
"Minimum number of archives to keep.\n")
-cfg(backup_retain_days_CFG, "retain_days", backup_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_ARCHIVE_DAYS, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(backup_retain_days_CFG, "retain_days", backup_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_ARCHIVE_DAYS, vsn(1, 0, 0), NULL, 0, NULL,
"Minimum number of days to keep archive files.\n")
-cfg(shell_history_size_CFG, "history_size", shell_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_MAX_HISTORY, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(shell_history_size_CFG, "history_size", shell_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_MAX_HISTORY, vsn(1, 0, 0), NULL, 0, NULL,
"Number of lines of history to store in ~/.lvm_history.\n")
-cfg(global_umask_CFG, "umask", global_CFG_SECTION, CFG_FORMAT_INT_OCTAL, CFG_TYPE_INT, DEFAULT_UMASK, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(global_umask_CFG, "umask", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_FORMAT_INT_OCTAL, CFG_TYPE_INT, DEFAULT_UMASK, vsn(1, 0, 0), NULL, 0, NULL,
"The file creation mask for any files and directories created.\n"
"Interpreted as octal if the first digit is zero.\n")
-cfg(global_test_CFG, "test", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(global_test_CFG, "test", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(1, 0, 0), NULL, 0, NULL,
"No on-disk metadata changes will be made in test mode.\n"
"Equivalent to having the -t option on every command.\n")
-cfg(global_units_CFG, "units", global_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_STRING, DEFAULT_UNITS, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(global_units_CFG, "units", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_PROFILABLE, CFG_TYPE_STRING, DEFAULT_UNITS, vsn(1, 0, 0), NULL, 0, NULL,
"Default value for --units argument.\n")
-cfg(global_si_unit_consistency_CFG, "si_unit_consistency", global_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_SI_UNIT_CONSISTENCY, vsn(2, 2, 54), NULL, 0, NULL,
+cfg(global_si_unit_consistency_CFG, "si_unit_consistency", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_SI_UNIT_CONSISTENCY, vsn(2, 2, 54), NULL, 0, NULL,
"Distinguish between powers of 1024 and 1000 bytes.\n"
"The LVM commands distinguish between powers of 1024 bytes,\n"
"e.g. KiB, MiB, GiB, and powers of 1000 bytes, e.g. KB, MB, GB.\n"
"If scripts depend on the old behaviour, disable this setting\n"
"temporarily until they are updated.\n")
-cfg(global_suffix_CFG, "suffix", global_CFG_SECTION, CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_SUFFIX, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(global_suffix_CFG, "suffix", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_PROFILABLE, CFG_TYPE_BOOL, DEFAULT_SUFFIX, vsn(1, 0, 0), NULL, 0, NULL,
"Display unit suffix for sizes.\n"
"This setting has no effect if the units are in human-readable form\n"
"(global/units = \"h\") in which case the suffix is always displayed.\n")
-cfg(global_activation_CFG, "activation", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ACTIVATION, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(global_activation_CFG, "activation", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ACTIVATION, vsn(1, 0, 0), NULL, 0, NULL,
"Enable/disable communication with the kernel device-mapper.\n"
"Disable to use the tools to manipulate LVM metadata without\n"
"activating any logical volumes. If the device-mapper driver\n"
@@ -981,30 +981,30 @@ cfg_array(global_format_libraries_CFG, "format_libraries", global_CFG_SECTION, C
cfg_array(global_segment_libraries_CFG, "segment_libraries", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 18), NULL, vsn(2, 3, 3), NULL, NULL)
-cfg(global_proc_CFG, "proc", global_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_PROC_DIR, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(global_proc_CFG, "proc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_PROC_DIR, vsn(1, 0, 0), NULL, 0, NULL,
"Location of proc filesystem.\n")
-cfg(global_etc_CFG, "etc", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_ETC_DIR, vsn(2, 2, 117), "@CONFDIR@", 0, NULL,
+cfg(global_etc_CFG, "etc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_ETC_DIR, vsn(2, 2, 117), "@CONFDIR@", 0, NULL,
"Location of /etc system configuration directory.\n")
-cfg(global_locking_type_CFG, "locking_type", global_CFG_SECTION, 0, CFG_TYPE_INT, 1, vsn(1, 0, 0), NULL, vsn(2, 3, 0), NULL,
+cfg(global_locking_type_CFG, "locking_type", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 1, vsn(1, 0, 0), NULL, vsn(2, 3, 0), NULL,
NULL)
-cfg(global_wait_for_locks_CFG, "wait_for_locks", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_WAIT_FOR_LOCKS, vsn(2, 2, 50), NULL, 0, NULL,
+cfg(global_wait_for_locks_CFG, "wait_for_locks", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_WAIT_FOR_LOCKS, vsn(2, 2, 50), NULL, 0, NULL,
"When disabled, fail if a lock request would block.\n")
-cfg(global_fallback_to_clustered_locking_CFG, "fallback_to_clustered_locking", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING, vsn(2, 2, 42), NULL, vsn(2, 3, 0), NULL,
+cfg(global_fallback_to_clustered_locking_CFG, "fallback_to_clustered_locking", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING, vsn(2, 2, 42), NULL, vsn(2, 3, 0), NULL,
NULL)
-cfg(global_fallback_to_local_locking_CFG, "fallback_to_local_locking", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_FALLBACK_TO_LOCAL_LOCKING, vsn(2, 2, 42), NULL, vsn(2, 3, 0), NULL,
+cfg(global_fallback_to_local_locking_CFG, "fallback_to_local_locking", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_FALLBACK_TO_LOCAL_LOCKING, vsn(2, 2, 42), NULL, vsn(2, 3, 0), NULL,
NULL)
-cfg(global_locking_dir_CFG, "locking_dir", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_LOCK_DIR, vsn(1, 0, 0), "@DEFAULT_LOCK_DIR@", 0, NULL,
+cfg(global_locking_dir_CFG, "locking_dir", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_LOCK_DIR, vsn(1, 0, 0), "@DEFAULT_LOCK_DIR@", 0, NULL,
"Directory to use for LVM command file locks.\n"
"Local non-LV directory that holds file-based locks while commands are\n"
"in progress. A directory like /tmp that may get wiped on reboot is OK.\n")
-cfg(global_prioritise_write_locks_CFG, "prioritise_write_locks", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_PRIORITISE_WRITE_LOCKS, vsn(2, 2, 52), NULL, 0, NULL,
+cfg(global_prioritise_write_locks_CFG, "prioritise_write_locks", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_PRIORITISE_WRITE_LOCKS, vsn(2, 2, 52), NULL, 0, NULL,
"Allow quicker VG write access during high volume read access.\n"
"When there are competing read-only and read-write access requests for\n"
"a volume group's metadata, instead of always granting the read-only\n"
@@ -1018,22 +1018,22 @@ cfg(global_library_dir_CFG, "library_dir", global_CFG_SECTION, CFG_DEFAULT_UNDEF
cfg(global_locking_library_CFG, "locking_library", global_CFG_SECTION, CFG_ALLOW_EMPTY | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_LOCKING_LIB, vsn(1, 0, 0), NULL, vsn(2, 3, 0), NULL,
NULL)
-cfg(global_abort_on_internal_errors_CFG, "abort_on_internal_errors", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ABORT_ON_INTERNAL_ERRORS, vsn(2, 2, 57), NULL, 0, NULL,
+cfg(global_abort_on_internal_errors_CFG, "abort_on_internal_errors", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ABORT_ON_INTERNAL_ERRORS, vsn(2, 2, 57), NULL, 0, NULL,
"Abort a command that encounters an internal error.\n"
"Treat any internal errors as fatal errors, aborting the process that\n"
"encountered the internal error. Please only enable for debugging.\n")
-cfg(global_detect_internal_vg_cache_corruption_CFG, "detect_internal_vg_cache_corruption", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 96), NULL, vsn(2, 2, 174), NULL,
+cfg(global_detect_internal_vg_cache_corruption_CFG, "detect_internal_vg_cache_corruption", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(2, 2, 96), NULL, vsn(2, 2, 174), NULL,
NULL)
-cfg(global_metadata_read_only_CFG, "metadata_read_only", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_METADATA_READ_ONLY, vsn(2, 2, 75), NULL, 0, NULL,
+cfg(global_metadata_read_only_CFG, "metadata_read_only", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_METADATA_READ_ONLY, vsn(2, 2, 75), NULL, 0, NULL,
"No operations that change on-disk metadata are permitted.\n"
"Additionally, read-only commands that encounter metadata in need of\n"
"repair will still be allowed to proceed exactly as if the repair had\n"
"been performed (except for the unchanged vg_seqno). Inappropriate\n"
"use could mess up your system, so seek advice first!\n")
-cfg(global_mirror_segtype_default_CFG, "mirror_segtype_default", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_MIRROR_SEGTYPE, vsn(2, 2, 87), "@DEFAULT_MIRROR_SEGTYPE@", 0, NULL,
+cfg(global_mirror_segtype_default_CFG, "mirror_segtype_default", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_MIRROR_SEGTYPE, vsn(2, 2, 87), "@DEFAULT_MIRROR_SEGTYPE@", 0, NULL,
"The segment type used by the short mirroring option -m.\n"
"The --type mirror|raid1 option overrides this setting.\n"
"#\n"
@@ -1068,7 +1068,7 @@ cfg(global_support_mirrored_mirror_log_CFG, "support_mirrored_mirror_log", globa
"Not supported for regular operation!\n"
"\n")
-cfg(global_raid10_segtype_default_CFG, "raid10_segtype_default", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_RAID10_SEGTYPE, vsn(2, 2, 99), "@DEFAULT_RAID10_SEGTYPE@", 0, NULL,
+cfg(global_raid10_segtype_default_CFG, "raid10_segtype_default", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_RAID10_SEGTYPE, vsn(2, 2, 99), "@DEFAULT_RAID10_SEGTYPE@", 0, NULL,
"The segment type used by the -i -m combination.\n"
"The --type raid10|mirror option overrides this setting.\n"
"The --stripes/-i and --mirrors/-m options can both be specified\n"
@@ -1086,7 +1086,7 @@ cfg(global_raid10_segtype_default_CFG, "raid10_segtype_default", global_CFG_SECT
" in terms of providing redundancy and performance.\n"
"#\n")
-cfg(global_sparse_segtype_default_CFG, "sparse_segtype_default", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_SPARSE_SEGTYPE, vsn(2, 2, 112), "@DEFAULT_SPARSE_SEGTYPE@", 0, NULL,
+cfg(global_sparse_segtype_default_CFG, "sparse_segtype_default", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_SPARSE_SEGTYPE, vsn(2, 2, 112), "@DEFAULT_SPARSE_SEGTYPE@", 0, NULL,
"The segment type used by the -V -L combination.\n"
"The --type snapshot|thin option overrides this setting.\n"
"The combination of -V and -L options creates a sparse LV. There are\n"
@@ -1124,7 +1124,7 @@ cfg(global_event_activation_CFG, "event_activation", global_CFG_SECTION, CFG_DEF
"See the --setautoactivation option or the auto_activation_volume_list\n"
"setting to configure autoactivation for specific VGs or LVs.\n")
-cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 93), 0, vsn(2, 3, 0), NULL,
+cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(2, 2, 93), 0, vsn(2, 3, 0), NULL,
NULL)
cfg(global_lvmetad_update_wait_time_CFG, "lvmetad_update_wait_time", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(2, 2, 151), NULL, vsn(2, 3, 0), NULL,
@@ -1133,7 +1133,7 @@ cfg(global_lvmetad_update_wait_time_CFG, "lvmetad_update_wait_time", global_CFG_
cfg(global_use_aio_CFG, "use_aio", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_USE_AIO, vsn(2, 2, 183), NULL, 0, NULL,
"Use async I/O when reading and writing devices.\n")
-cfg(global_use_lvmlockd_CFG, "use_lvmlockd", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 124), NULL, 0, NULL,
+cfg(global_use_lvmlockd_CFG, "use_lvmlockd", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 0, vsn(2, 2, 124), NULL, 0, NULL,
"Use lvmlockd for locking among hosts using LVM on shared storage.\n"
"Applicable only if LVM is compiled with lockd support in which\n"
"case there is also lvmlockd(8) man page available for more\n"
@@ -1259,7 +1259,7 @@ cfg(global_fsadm_executable_CFG, "fsadm_executable", global_CFG_SECTION, CFG_DEF
"The full path to the fsadm command.\n"
"LVM uses this command to help with lvresize -r operations.\n")
-cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL, 0, NULL,
+cfg(global_system_id_source_CFG, "system_id_source", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_SYSTEM_ID_SOURCE, vsn(2, 2, 117), NULL, 0, NULL,
"The method LVM uses to set the local system ID.\n"
"Volume Groups can also be given a system ID (by vgcreate, vgchange,\n"
"or vgimport.) A VG on shared storage devices is accessible only to\n"
@@ -1289,13 +1289,13 @@ cfg(global_system_id_file_CFG, "system_id_file", global_CFG_SECTION, CFG_DEFAULT
"This is used when system_id_source is set to 'file'.\n"
"Comments starting with the character # are ignored.\n")
-cfg(activation_checks_CFG, "checks", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ACTIVATION_CHECKS, vsn(2, 2, 86), NULL, 0, NULL,
+cfg(activation_checks_CFG, "checks", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ACTIVATION_CHECKS, vsn(2, 2, 86), NULL, 0, NULL,
"Perform internal checks of libdevmapper operations.\n"
"Useful for debugging problems with activation. Some of the checks may\n"
"be expensive, so it's best to use this only when there seems to be a\n"
"problem.\n")
-cfg(global_use_lvmpolld_CFG, "use_lvmpolld", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_USE_LVMPOLLD, vsn(2, 2, 120), "@DEFAULT_USE_LVMPOLLD@", 0, NULL,
+cfg(global_use_lvmpolld_CFG, "use_lvmpolld", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_USE_LVMPOLLD, vsn(2, 2, 120), "@DEFAULT_USE_LVMPOLLD@", 0, NULL,
"Use lvmpolld to supervise long running LVM commands.\n"
"When enabled, control of long running LVM commands is transferred\n"
"from the original LVM command to the lvmpolld daemon. This allows\n"
@@ -1308,7 +1308,7 @@ cfg(global_use_lvmpolld_CFG, "use_lvmpolld", global_CFG_SECTION, 0, CFG_TYPE_BOO
"commands will supervise long running operations by forking themselves.\n"
"Applicable only if LVM is compiled with lvmpolld support.\n")
-cfg(global_notify_dbus_CFG, "notify_dbus", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_NOTIFY_DBUS, vsn(2, 2, 145), NULL, 0, NULL,
+cfg(global_notify_dbus_CFG, "notify_dbus", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_NOTIFY_DBUS, vsn(2, 2, 145), NULL, 0, NULL,
"Enable D-Bus notification from LVM commands.\n"
"When enabled, an LVM command that changes PVs, changes VG metadata,\n"
"or changes the activation state of an LV will send a notification.\n")
@@ -1321,7 +1321,7 @@ cfg(global_io_memory_size_CFG, "io_memory_size", global_CFG_SECTION, CFG_DEFAULT
"This value should usually not be decreased from the default; setting\n"
"it too low can result in lvm failing to read VGs.\n")
-cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL, 0, NULL,
+cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL, 0, NULL,
"Use udev notifications to synchronize udev and LVM.\n"
"The --noudevsync option overrides this setting.\n"
"When disabled, LVM commands will not wait for notifications from\n"
@@ -1331,7 +1331,7 @@ cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_B
"running, and LVM processes are waiting for udev, run the command\n"
"'dmsetup udevcomplete_all' to wake them up.\n")
-cfg(activation_udev_rules_CFG, "udev_rules", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_RULES, vsn(2, 2, 57), NULL, 0, NULL,
+cfg(activation_udev_rules_CFG, "udev_rules", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_UDEV_RULES, vsn(2, 2, 57), NULL, 0, NULL,
"Use udev rules to manage LV device nodes and symlinks.\n"
"When disabled, LVM will manage the device nodes and symlinks for\n"
"active LVs itself. Manual intervention may be required if this\n"
@@ -1343,13 +1343,13 @@ cfg(activation_verify_udev_operations_CFG, "verify_udev_operations", activation_
"in the device directory after udev has completed processing its\n"
"events. Useful for diagnosing problems with LVM/udev interactions.\n")
-cfg(activation_retry_deactivation_CFG, "retry_deactivation", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_RETRY_DEACTIVATION, vsn(2, 2, 89), NULL, 0, NULL,
+cfg(activation_retry_deactivation_CFG, "retry_deactivation", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_RETRY_DEACTIVATION, vsn(2, 2, 89), NULL, 0, NULL,
"Retry failed LV deactivation.\n"
"If LV deactivation fails, LVM will retry for a few seconds before\n"
"failing. This may happen because a process run from a quick udev rule\n"
"temporarily opened the device.\n")
-cfg(activation_missing_stripe_filler_CFG, "missing_stripe_filler", activation_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_STRIPE_FILLER, vsn(1, 0, 0), NULL, 0, NULL,
+cfg(activation_missing_stripe_filler_CFG, "missing_stripe_filler", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_STRIPE_FILLER, vsn(1, 0, 0), NULL, 0, NULL,
"Method to fill missing stripes when activating an incomplete LV.\n"
"Using 'error' will make inaccessible parts of the device return I/O\n"
"errors on access. Using 'zero' will return success (and zero) on I/O\n"
@@ -1462,11 +1462,11 @@ cfg_array(activation_read_only_volume_list_CFG, "read_only_volume_list", activat
"read_only_volume_list = [ \"vg1\", \"vg2/lvol1\", \"@tag1\", \"@*\" ]\n"
"#\n")
- cfg(activation_mirror_region_size_CFG, "mirror_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(1, 0, 0), NULL, vsn(2, 2, 99),
+ cfg(activation_mirror_region_size_CFG, "mirror_region_size", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(1, 0, 0), NULL, vsn(2, 2, 99),
"This has been replaced by the activation/raid_region_size setting.\n",
"Size in KiB of each raid or mirror synchronization region.\n")
-cfg(activation_raid_region_size_CFG, "raid_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(2, 2, 99), NULL, 0, NULL,
+cfg(activation_raid_region_size_CFG, "raid_region_size", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(2, 2, 99), NULL, 0, NULL,
"Size in KiB of each raid or mirror synchronization region.\n"
"The clean/dirty state of data is tracked for each region.\n"
"The value is rounded down to a power of two if necessary, and\n"
@@ -1491,7 +1491,7 @@ cfg(activation_readahead_CFG, "readahead", activation_CFG_SECTION, CFG_DEFAULT_C
" Use default value chosen by kernel.\n"
"#\n")
-cfg(activation_raid_fault_policy_CFG, "raid_fault_policy", activation_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_RAID_FAULT_POLICY, vsn(2, 2, 89), NULL, 0, NULL,
+cfg(activation_raid_fault_policy_CFG, "raid_fault_policy", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_RAID_FAULT_POLICY, vsn(2, 2, 89), NULL, 0, NULL,
"Defines how a device failure in a RAID LV is handled.\n"
"This includes LVs that have the following segment types:\n"
"raid1, raid4, raid5*, and raid6*.\n"
@@ -1512,7 +1512,7 @@ cfg(activation_raid_fault_policy_CFG, "raid_fault_policy", activation_CFG_SECTIO
" replace faulty devices.\n"
"#\n")
-cfg_runtime(activation_mirror_image_fault_policy_CFG, "mirror_image_fault_policy", activation_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(2, 2, 57), 0, NULL,
+cfg_runtime(activation_mirror_image_fault_policy_CFG, "mirror_image_fault_policy", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, vsn(2, 2, 57), 0, NULL,
"Defines how a device failure in a 'mirror' LV is handled.\n"
"An LV with the 'mirror' segment type is composed of mirror images\n"
"(copies) and a mirror log. A disk log ensures that a mirror LV does\n"
@@ -1548,16 +1548,16 @@ cfg_runtime(activation_mirror_image_fault_policy_CFG, "mirror_image_fault_policy
" replacement.\n"
"#\n")
-cfg(activation_mirror_log_fault_policy_CFG, "mirror_log_fault_policy", activation_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_MIRROR_LOG_FAULT_POLICY, vsn(1, 2, 18), NULL, 0, NULL,
+cfg(activation_mirror_log_fault_policy_CFG, "mirror_log_fault_policy", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_MIRROR_LOG_FAULT_POLICY, vsn(1, 2, 18), NULL, 0, NULL,
"Defines how a device failure in a 'mirror' log LV is handled.\n"
"The mirror_image_fault_policy description for mirrored LVs also\n"
"applies to mirrored log LVs.\n")
-cfg(activation_mirror_device_fault_policy_CFG, "mirror_device_fault_policy", activation_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_MIRROR_DEVICE_FAULT_POLICY, vsn(1, 2, 10), NULL, vsn(2, 2, 57),
+cfg(activation_mirror_device_fault_policy_CFG, "mirror_device_fault_policy", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_MIRROR_DEVICE_FAULT_POLICY, vsn(1, 2, 10), NULL, vsn(2, 2, 57),
"This has been replaced by the activation/mirror_image_fault_policy setting.\n",
"Define how a device failure affecting a mirror is handled.\n")
-cfg(activation_snapshot_autoextend_threshold_CFG, "snapshot_autoextend_threshold", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_SNAPSHOT_AUTOEXTEND_THRESHOLD, vsn(2, 2, 75), NULL, 0, NULL,
+cfg(activation_snapshot_autoextend_threshold_CFG, "snapshot_autoextend_threshold", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_SNAPSHOT_AUTOEXTEND_THRESHOLD, vsn(2, 2, 75), NULL, 0, NULL,
"Auto-extend a snapshot when its usage exceeds this percent.\n"
"Setting this to 100 disables automatic extension.\n"
"The minimum value is 50 (a smaller value is treated as 50.)\n"
@@ -1571,7 +1571,7 @@ cfg(activation_snapshot_autoextend_threshold_CFG, "snapshot_autoextend_threshold
"snapshot_autoextend_threshold = 70\n"
"#\n")
-cfg(activation_snapshot_autoextend_percent_CFG, "snapshot_autoextend_percent", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_SNAPSHOT_AUTOEXTEND_PERCENT, vsn(2, 2, 75), NULL, 0, NULL,
+cfg(activation_snapshot_autoextend_percent_CFG, "snapshot_autoextend_percent", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_SNAPSHOT_AUTOEXTEND_PERCENT, vsn(2, 2, 75), NULL, 0, NULL,
"Auto-extending a snapshot adds this percent extra space.\n"
"The amount of additional space added to a snapshot is this\n"
"percent of its current size.\n"
@@ -1583,7 +1583,7 @@ cfg(activation_snapshot_autoextend_percent_CFG, "snapshot_autoextend_percent", a
"snapshot_autoextend_percent = 20\n"
"#\n")
-cfg(activation_thin_pool_autoextend_threshold_CFG, "thin_pool_autoextend_threshold", activation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_INT, DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD, vsn(2, 2, 89), NULL, 0, NULL,
+cfg(activation_thin_pool_autoextend_threshold_CFG, "thin_pool_autoextend_threshold", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_INT, DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD, vsn(2, 2, 89), NULL, 0, NULL,
"Auto-extend a thin pool when its usage exceeds this percent.\n"
"Setting this to 100 disables automatic extension.\n"
"The minimum value is 50 (a smaller value is treated as 50.)\n"
@@ -1597,7 +1597,7 @@ cfg(activation_thin_pool_autoextend_threshold_CFG, "thin_pool_autoextend_thresho
"thin_pool_autoextend_threshold = 70\n"
"#\n")
-cfg(activation_thin_pool_autoextend_percent_CFG, "thin_pool_autoextend_percent", activation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_INT, DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT, vsn(2, 2, 89), NULL, 0, NULL,
+cfg(activation_thin_pool_autoextend_percent_CFG, "thin_pool_autoextend_percent", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_INT, DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT, vsn(2, 2, 89), NULL, 0, NULL,
"Auto-extending a thin pool adds this percent extra space.\n"
"The amount of additional space added to a thin pool is this\n"
"percent of its current size.\n"
@@ -1654,7 +1654,7 @@ cfg(activation_use_mlockall_CFG, "use_mlockall", activation_CFG_SECTION, CFG_DEF
"Prior to version 2.02.62, LVM used mlockall() to pin the whole\n"
"process's memory while activating devices.\n")
-cfg(activation_monitoring_CFG, "monitoring", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_DMEVENTD_MONITOR, vsn(2, 2, 63), NULL, 0, NULL,
+cfg(activation_monitoring_CFG, "monitoring", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_DMEVENTD_MONITOR, vsn(2, 2, 63), NULL, 0, NULL,
"Monitor LVs that are activated.\n"
"The --ignoremonitoring option overrides this setting.\n"
"When enabled, LVM will ask dmeventd to monitor activated LVs.\n")
@@ -1676,7 +1676,7 @@ cfg(activation_auto_set_activation_skip_CFG, "auto_set_activation_skip", activat
"flag set. When this setting is enabled, the activation skip flag is\n"
"set on new thin snapshot LVs.\n")
-cfg(activation_mode_CFG, "activation_mode", activation_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_ACTIVATION_MODE, vsn(2,2,108), NULL, 0, NULL,
+cfg(activation_mode_CFG, "activation_mode", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_ACTIVATION_MODE, vsn(2,2,108), NULL, 0, NULL,
"How LVs with missing devices are activated.\n"
"The --activationmode option overrides this setting.\n"
"#\n"
@@ -2199,4 +2199,4 @@ cfg(local_host_id_CFG, "host_id", local_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_
"This must be unique among all hosts, and must be between 1 and 2000.\n"
"Applicable only if LVM is compiled with lockd support\n")
-cfg(CFG_COUNT, NULL, root_CFG_SECTION, 0, CFG_TYPE_INT, 0, vsn(0, 0, 0), NULL, 0, NULL, NULL)
+cfg(CFG_COUNT, NULL, root_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(0, 0, 0), NULL, 0, NULL, NULL)
2 years, 6 months
main - cleanup: use dm_list_empty
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3cf97a737bb5eb4cd45...
Commit: 3cf97a737bb5eb4cd456b894b1e675291f459129
Parent: 197f6aaad71b6da801ba02b53c65f99b98a15991
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 1 14:30:49 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 6 15:43:31 2021 +0200
cleanup: use dm_list_empty
Instant check for 'dm_list_size() == 0' without any size calc.
---
lib/metadata/metadata.c | 2 +-
lib/metadata/raid_manip.c | 2 +-
tools/reporter.c | 2 +-
tools/toollib.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 8dcdd919c..5fa623ec9 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2739,7 +2739,7 @@ int vg_validate(struct volume_group *vg)
continue;
}
- if (!hlv->indirect_origin && !dm_list_size(&hlv->indirect_glvs)) {
+ if (!hlv->indirect_origin && dm_list_empty(&hlv->indirect_glvs)) {
log_error(INTERNAL_ERROR "Historical LV %s is not part of any LV chain in VG %s", hlv->name, vg->name);
r = 0;
continue;
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 60a10332e..0e6a77bac 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -6963,7 +6963,7 @@ try_again:
*/
if (!_raid_extract_images(lv, force,
raid_seg->area_count - match_count,
- (partial_segment_removed || !dm_list_size(remove_pvs)) ?
+ (partial_segment_removed || dm_list_empty(remove_pvs)) ?
&lv->vg->pvs : remove_pvs, 0,
&old_lvs, &old_lvs)) {
log_error("Failed to remove the specified images from %s.",
diff --git a/tools/reporter.c b/tools/reporter.c
index 54a538d04..eafba4fec 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -1203,7 +1203,7 @@ static int _full_report_single(struct cmd_context *cmd,
int orphan = is_orphan_vg(vg->name);
int r = ECMD_FAILED;
- if (orphan && !dm_list_size(&vg->pvs))
+ if (orphan && dm_list_empty(&vg->pvs))
return ECMD_PROCESSED;
args->full_report_vg = vg;
diff --git a/tools/toollib.c b/tools/toollib.c
index 7e35f6f22..357c9f8b8 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3172,7 +3172,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
log_set_report_object_name_and_id(NULL, NULL);
if (handle->include_historical_lvs && !tags_supplied) {
- if (!dm_list_size(&_historical_lv.segments))
+ if (dm_list_empty(&_historical_lv.segments))
dm_list_add(&_historical_lv.segments, &_historical_lv_segment.list);
_historical_lv.vg = vg;
2 years, 6 months
main - cleanup: skip zeroing buffer overwritten by memcpy
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=197f6aaad71b6da801b...
Commit: 197f6aaad71b6da801ba02b53c65f99b98a15991
Parent: 79e65a3596dc4fef1d7ac74fe727e9c24a539afb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 1 14:25:59 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 6 15:43:31 2021 +0200
cleanup: skip zeroing buffer overwritten by memcpy
Since the buffer is going to be overwritten by memcpy, reset only last
char to 0.
Also more use of DM_LIST_INIT list.h macro.
---
lib/format_text/format-text.c | 7 ++++---
lib/metadata/metadata.c | 33 ++++++++++++++++-----------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 6a4cc98d8..654c387bf 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1988,7 +1988,7 @@ static int _text_pv_setup(const struct format_type *fmt,
struct physical_volume *pv,
struct volume_group *vg)
{
- char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char pvid[ID_LEN + 1] __attribute__((aligned(8)));
struct format_instance *fid = pv->fid;
struct lvmcache_info *info;
unsigned mda_index;
@@ -1997,6 +1997,7 @@ static int _text_pv_setup(const struct format_type *fmt,
uint64_t pe_count;
uint64_t size_reduction = 0;
+ pvid[ID_LEN] = 0;
if (*pv->old_id.uuid)
memcpy(pvid, &pv->old_id.uuid, ID_LEN);
else
@@ -2167,7 +2168,7 @@ static int _add_metadata_area_to_pv(struct physical_volume *pv,
uint64_t mda_size,
unsigned mda_ignored)
{
- char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char pvid[ID_LEN + 1] __attribute__((aligned(8)));
struct metadata_area *mda;
struct mda_context *mdac;
struct mda_lists *mda_lists = (struct mda_lists *) pv->fmt->private;
@@ -2202,6 +2203,7 @@ static int _add_metadata_area_to_pv(struct physical_volume *pv,
memset(&mdac->rlocn, 0, sizeof(mdac->rlocn));
mda_set_ignored(mda, mda_ignored);
+ pvid[ID_LEN] = 0;
memcpy(pvid, &pv->id.uuid, ID_LEN);
fid_add_mda(pv->fid, mda, pvid, ID_LEN, mda_index);
@@ -2675,4 +2677,3 @@ int text_wipe_outdated_pv_mda(struct cmd_context *cmd, struct device *dev,
return 1;
}
-
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index ad908634a..8dcdd919c 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -275,12 +275,13 @@ void add_pvl_to_vgs(struct volume_group *vg, struct pv_list *pvl)
void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
{
- char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char pvid[ID_LEN + 1] __attribute__((aligned(8)));
struct lvmcache_info *info;
vg->pv_count--;
dm_list_del(&pvl->list);
+ pvid[ID_LEN] = 0;
memcpy(pvid, &pvl->pv->id.uuid, ID_LEN);
pvl->pv->vg = vg->fid->fmt->orphan_vg; /* orphan */
@@ -2840,8 +2841,8 @@ static int _handle_historical_lvs(struct volume_group *vg)
static void _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg)
{
- char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
- struct dm_list devs;
+ char vgid[ID_LEN + 1] __attribute__((aligned(8)));
+ DM_LIST_INIT(devs);
struct dm_list *mdas = NULL;
struct device_list *devl;
struct device *dev;
@@ -2850,8 +2851,6 @@ static void _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg)
struct lvmcache_info *info;
uint32_t ext_flags;
- dm_list_init(&devs);
-
/*
* When vg_read selected a good copy of the metadata, it used it to
* update the lvmcache representation of the VG (lvmcache_update_vg).
@@ -2859,6 +2858,7 @@ static void _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg)
* vginfo->outdated_infos list. Here we clear the PVs on that list.
*/
+ vgid[ID_LEN] = 0;
memcpy(vgid, &vg->id.uuid, ID_LEN);
lvmcache_get_outdated_devs(cmd, vg->name, vgid, &devs);
@@ -2910,7 +2910,7 @@ static void _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg)
*/
int vg_write(struct volume_group *vg)
{
- char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char vgid[ID_LEN + 1] __attribute__((aligned(8)));
struct dm_list *mdah;
struct pv_list *pvl, *pvl_safe, *new_pvl;
struct metadata_area *mda;
@@ -2918,6 +2918,7 @@ int vg_write(struct volume_group *vg)
struct device *mda_dev;
int revert = 0, wrote = 0;
+ vgid[ID_LEN] = 0;
memcpy(vgid, &vg->id.uuid, ID_LEN);
if (vg_is_shared(vg)) {
@@ -3098,13 +3099,12 @@ int vg_write(struct volume_group *vg)
static int _vg_commit_mdas(struct volume_group *vg)
{
struct metadata_area *mda, *tmda;
- struct dm_list ignored;
+ DM_LIST_INIT(ignored);
int failed = 0;
int good = 0;
int cache_updated = 0;
/* Rearrange the metadata_areas_in_use so ignored mdas come first. */
- dm_list_init(&ignored);
dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_in_use)
if (mda_is_ignored(mda))
dm_list_move(&ignored, &mda->list);
@@ -3437,13 +3437,14 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
static int _check_devs_used_correspond_with_vg(struct volume_group *vg)
{
struct dm_pool *mem;
- char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char vgid[ID_LEN + 1] __attribute__((aligned(8)));
struct pv_list *pvl;
struct lv_list *lvl;
struct dm_list *list;
struct device_list *dl;
int found_inconsistent = 0;
+ vgid[ID_LEN] = 0;
memcpy(vgid, &vg->id.uuid, ID_LEN);
/* Mark all PVs in VG as used. */
@@ -3503,7 +3504,7 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
struct volume_group *vg,
struct lvmcache_info *info)
{
- char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char pvid[ID_LEN + 1] __attribute__((aligned(8)));
struct physical_volume *pv;
struct device *dev = lvmcache_device(info);
@@ -3527,6 +3528,7 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
if (!alloc_pv_segment_whole_pv(vg->vgmem, pv))
goto_bad;
+ pvid[ID_LEN] = 0;
memcpy(pvid, &pv->id.uuid, ID_LEN);
lvmcache_fid_add_mdas(info, vg->fid, pvid, ID_LEN);
@@ -4448,14 +4450,13 @@ int vg_is_foreign(struct volume_group *vg)
void vg_write_commit_bad_mdas(struct cmd_context *cmd, struct volume_group *vg)
{
- char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
- struct dm_list bad_mda_list;
+ char vgid[ID_LEN + 1] __attribute__((aligned(8)));
+ DM_LIST_INIT(bad_mda_list);
struct mda_list *mdal;
struct metadata_area *mda;
struct device *dev;
- dm_list_init(&bad_mda_list);
-
+ vgid[ID_LEN] = 0;
memcpy(vgid, &vg->id.uuid, ID_LEN);
lvmcache_get_bad_mdas(cmd, vg->name, vgid, &bad_mda_list);
@@ -4544,7 +4545,7 @@ void vg_write_commit_bad_mdas(struct cmd_context *cmd, struct volume_group *vg)
static bool _scan_text_mismatch(struct cmd_context *cmd, const char *vgname, const char *vgid)
{
- struct dm_list mda_list;
+ DM_LIST_INIT(mda_list);
struct mda_list *mdal, *safe;
struct metadata_area *mda;
struct mda_context *mdac;
@@ -4560,8 +4561,6 @@ static bool _scan_text_mismatch(struct cmd_context *cmd, const char *vgname, con
* else check that all mda_headers are unchanged.
*/
- dm_list_init(&mda_list);
-
lvmcache_get_mdas(cmd, vgname, vgid, &mda_list);
dm_list_iterate_items(mdal, &mda_list) {
2 years, 6 months
main - cleanup: all lvmcache_add users pass char with 0
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=79e65a3596dc4fef1d7...
Commit: 79e65a3596dc4fef1d7ac74fe727e9c24a539afb
Parent: 5ccb373d869ca23afc10416c2319331eb108e16b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 1 14:10:39 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 6 15:43:31 2021 +0200
cleanup: all lvmcache_add users pass char with 0
No local copy needed, both users submit zero-end string as pv/vgid.
---
lib/cache/lvmcache.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 7a7634074..e04f00f2d 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -2166,8 +2166,8 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
const char *vgname, const char *vgid_arg, uint32_t vgstatus,
int *is_duplicate)
{
- char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
- char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ const char *pvid = pvid_arg;
+ const char *vgid = vgid_arg;
char pvid_dashed[64] __attribute__((aligned(8)));
struct lvmcache_vgsummary vgsummary = { 0 };
struct lvmcache_info *info;
@@ -2175,12 +2175,6 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
struct device_list *devl;
int created = 0;
- /* pvid_arg and vgid_arg may not be null terminated */
- memcpy(pvid, pvid_arg, ID_LEN);
-
- if (vgid_arg)
- memcpy(vgid, vgid_arg, ID_LEN);
-
if (!id_write_format((const struct id *)&pvid, pvid_dashed, sizeof(pvid_dashed)))
stack;
@@ -2282,7 +2276,7 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
update_vginfo:
vgsummary.vgstatus = vgstatus;
vgsummary.vgname = vgname;
- if (vgid[0])
+ if (vgid && vgid[0])
memcpy(vgsummary.vgid, vgid, ID_LEN);
if (!lvmcache_update_vgname_and_id(cmd, info, &vgsummary)) {
2 years, 6 months
main - cleanup: always initialize historical ptr
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5ccb373d869ca23afc1...
Commit: 5ccb373d869ca23afc10416c2319331eb108e16b
Parent: a841babaf7f0108797ef18af0777721742c8656c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 1 13:53:28 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 6 15:43:31 2021 +0200
cleanup: always initialize historical ptr
Set ptr for all paths.
---
lib/metadata/metadata.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index d5ef7f7cb..ad908634a 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1701,17 +1701,19 @@ struct generic_logical_volume *find_historical_glv(const struct volume_group *vg
int lv_name_is_used_in_vg(const struct volume_group *vg, const char *name, int *historical)
{
- int found = 0;
+ int found;
- if (find_lv(vg, name)) {
+ if (historical)
+ *historical = 0;
+
+ if (find_lv(vg, name))
found = 1;
- if (historical)
- *historical = 0;
- } else if (find_historical_glv(vg, name, 0, NULL)) {
+ else if (find_historical_glv(vg, name, 0, NULL)) {
found = 1;
if (historical)
*historical = 1;
- }
+ } else
+ found = 0;
return found;
}
2 years, 6 months
main - cleanup: remove unused code
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a841babaf7f0108797e...
Commit: a841babaf7f0108797ef18af0777721742c8656c
Parent: 5ea426e65628218569ede461312d80ba5d1c50fb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 1 13:47:43 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 6 15:43:31 2021 +0200
cleanup: remove unused code
---
lib/metadata/metadata.c | 12 ------------
lib/metadata/metadata.h | 3 ---
2 files changed, 15 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 146ce476d..d5ef7f7cb 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1648,18 +1648,6 @@ struct lv_list *find_lv_in_vg(const struct volume_group *vg,
return NULL;
}
-struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
- const struct logical_volume *lv)
-{
- struct lv_list *lvl;
-
- dm_list_iterate_items(lvl, ll)
- if (lvl->lv == lv)
- return lvl;
-
- return NULL;
-}
-
struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg,
const union lvid *lvid)
{
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 3b3145d2c..95ca320e6 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -395,9 +395,6 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg,
const union lvid *lvid);
-struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
- const struct logical_volume *lv);
-
/* FIXME Merge these functions with ones above */
struct physical_volume *find_pv(struct volume_group *vg, struct device *dev);
2 years, 6 months
main - archiving: refactor code to allocate less memory
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5ea426e65628218569e...
Commit: 5ea426e65628218569ede461312d80ba5d1c50fb
Parent: 98c57f7ce44788f22499f10f8d6c3f320869aa16
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 1 16:19:53 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 6 15:42:53 2021 +0200
archiving: refactor code to allocate less memory
Do not store full path with each archived name reduces memory usage if
the directory has thousands of entries and just add 'dir' path when
needed.
Also emit info print message to a user if the total size of archived
files for a VG is more then 128MiB or 8192 files.
TODO: Consider wheather adding a new 'lvm.conf archive{option}' to support
trimming these wild archive sizes can make situation better.
We already support retain_min && retain_days - but if user is
generating too many and too large archives with minutes - maybe archiving
should be disabled by a user - as it's not producing anything largely usable
and just slows-down command ??
If we add 'retain_max & retain_max_size' the condition will go against
each other and we need to chose priorities.
mm
---
WHATS_NEW | 1 +
lib/format_text/archive.c | 104 ++++++++++++++++++++++++++++------------------
2 files changed, 64 insertions(+), 41 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0cae2642e..d87cb7e37 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.14 -
==================================
+ Print info message with too many or too large archived files.
Reduce metadata readings during scanning phase.
Optimize computation of crc32 check sum with multiple PVs.
Enhance recover path on cache creation failure.
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index 103b0608d..740129df0 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -49,7 +49,7 @@
struct archive_file {
struct dm_list list;
- const char *path;
+ const char *name;
uint32_t index;
};
@@ -105,18 +105,6 @@ static void _insert_archive_file(struct dm_list *head, struct archive_file *b)
dm_list_add_h(&bf->list, &b->list);
}
-static char *_join_file_to_dir(struct dm_pool *mem, const char *dir, const char *name)
-{
- if (!dm_pool_begin_object(mem, 32) ||
- !dm_pool_grow_object(mem, dir, strlen(dir)) ||
- !dm_pool_grow_object(mem, "/", 1) ||
- !dm_pool_grow_object(mem, name, strlen(name)) ||
- !dm_pool_grow_object(mem, "\0", 1))
- return_NULL;
-
- return dm_pool_end_object(mem);
-}
-
/*
* Returns a list of archive_files.
*/
@@ -125,7 +113,7 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
{
int i, count;
uint32_t ix;
- char vgname_found[64], *path;
+ char vgname_found[64], *name;
struct dirent **dirent = NULL;
struct archive_file *af;
struct dm_list *results;
@@ -159,7 +147,7 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
if (strcmp(vgname, vgname_found))
continue;
- if (!(path = _join_file_to_dir(mem, dir, dirent[i]->d_name)))
+ if (!(name = dm_pool_strdup(mem, dirent[i]->d_name)))
goto_out;
/*
@@ -172,7 +160,7 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
}
af->index = ix;
- af->path = path;
+ af->name = name;
/*
* Insert it to the correct part of the list.
@@ -188,12 +176,15 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
return results;
}
-static void _remove_expired(struct dm_list *archives, uint32_t archives_size,
+static void _remove_expired(const char *dir, const char *vgname,
+ struct dm_list *archives, uint32_t archives_size,
uint32_t retain_days, uint32_t min_archive)
{
struct archive_file *bf;
struct stat sb;
time_t retain_time;
+ uint64_t sum = 0;
+ char path[PATH_MAX];
/* Make sure there are enough archives to even bother looking for
* expired ones... */
@@ -205,23 +196,32 @@ static void _remove_expired(struct dm_list *archives, uint32_t archives_size,
/* Assume list is ordered newest first (by index) */
dm_list_iterate_back_items(bf, archives) {
+ if (dm_snprintf(path, sizeof(path), "%s/%s", dir, bf->name) < 0)
+ continue;
+
/* Get the mtime of the file and unlink if too old */
- if (stat(bf->path, &sb)) {
- log_sys_error("stat", bf->path);
+ if (stat(path, &sb)) {
+ log_sys_debug("stat", path);
continue;
}
+ sum += sb.st_size;
if (sb.st_mtime > retain_time)
- return;
+ continue;
- log_very_verbose("Expiring archive %s", bf->path);
- if (unlink(bf->path))
- log_sys_error("unlink", bf->path);
+ log_very_verbose("Expiring archive %s", path);
+ if (unlink(path))
+ log_sys_debug("unlink", path);
/* Don't delete any more if we've reached the minimum */
if (--archives_size <= min_archive)
- return;
+ break;
}
+
+ sum /= 1024 * 1024;
+ if (sum > 128 || archives_size > 8192)
+ log_print_unless_silent("Consider prunning %s VG archive with more then %u MiB in %u files (check archiving is needed in lvm.conf).",
+ vgname, (unsigned)sum, archives_size);
}
int archive_vg(struct volume_group *vg,
@@ -292,25 +292,30 @@ int archive_vg(struct volume_group *vg,
if (!renamed)
log_error("Archive rename failed for %s", temp_file);
- _remove_expired(archives, dm_list_size(archives) + renamed, retain_days,
+ _remove_expired(dir, vg->name, archives, dm_list_size(archives) + renamed, retain_days,
min_archive);
return 1;
}
-static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
+static void _display_archive(struct cmd_context *cmd, const char *dir, struct archive_file *af)
{
struct volume_group *vg = NULL;
struct format_instance *tf;
struct format_instance_ctx fic;
- struct text_context tc = {.path_live = af->path,
- .path_edit = NULL,
- .desc = NULL};
+ struct text_context tc = { NULL };
+ char path[PATH_MAX];
time_t when;
char *desc;
+ if (dm_snprintf(path, sizeof(path), "%s/%s", dir, af->name) < 0) {
+ log_debug("Created path %s/%s is too long.", dir, af->name);
+ return;
+ }
+
log_print(" ");
- log_print("File:\t\t%s", af->path);
+ log_print("File:\t\t%s/%s", path, af->name);
+ tc.path_live = path;
fic.type = FMT_INSTANCE_PRIVATE_MDAS;
fic.context.private = &tc;
@@ -324,7 +329,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
* retrieve the archive time and description.
*/
/* FIXME Use variation on _vg_read */
- if (!(vg = text_read_metadata_file(tf, af->path, &when, &desc))) {
+ if (!(vg = text_read_metadata_file(tf, path, &when, &desc))) {
log_error("Unable to read archive file.");
tf->fmt->ops->destroy_instance(tf);
return;
@@ -349,7 +354,7 @@ int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
log_print("No archives found in %s.", dir);
dm_list_iterate_back_items(af, archives)
- _display_archive(cmd, af);
+ _display_archive(cmd, dir, af);
dm_pool_free(cmd->mem, archives);
@@ -358,29 +363,46 @@ int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
int archive_list_file(struct cmd_context *cmd, const char *file)
{
- struct archive_file af;
+ struct archive_file af = { 0 };
+ char path[PATH_MAX];
+ size_t len;
- af.path = file;
+ if (!path_exists(file)) {
+ log_error("Archive file %s not found.", file);
+ return 0;
+ }
- if (!path_exists(af.path)) {
- log_error("Archive file %s not found.", af.path);
+ if (!(af.name = strrchr(file, '/'))) {
+ log_error("No '/' in file path %s found.", file);
return 0;
}
- _display_archive(cmd, &af);
+ len = (size_t)(af.name - file);
+
+ if (len >= sizeof(path)) {
+ log_error(INTERNAL_ERROR "Passed file path name %s is too long.", file);
+ return 0;
+ }
+
+ memcpy(path, file, len);
+ path[len] = 0;
+ af.name++; /* jump over '/' */
+
+ _display_archive(cmd, path, &af);
return 1;
}
int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname)
{
- struct archive_file af;
+ struct archive_file af = { .name = vgname };
+ char path[PATH_MAX];
- if (!(af.path = _join_file_to_dir(cmd->mem, dir, vgname)))
+ if (dm_snprintf(path, sizeof(path), "%s/%s", dir, vgname) < 0)
return_0;
- if (path_exists(af.path))
- _display_archive(cmd, &af);
+ if (path_exists(path))
+ _display_archive(cmd, dir, &af);
return 1;
}
2 years, 6 months