main - vgimportdevices: fix locking when creating devices file
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0eebd9d7802c724ee71...
Commit: 0eebd9d7802c724ee71b6ebb80940ea6007f9c7a
Parent: 3c49a2e43ccfbad720a3134484c7870a14b1135b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Aug 30 14:40:48 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Aug 30 14:52:00 2022 -0500
vgimportdevices: fix locking when creating devices file
Take the devices file lock before creating a new devices file.
(Was missed by the change to preemptively create the devices
file prior to setup_devices(), which was done to improve the
error path.)
---
lib/device/dev-cache.c | 7 +++----
lib/device/device_id.c | 1 +
tools/vgimportdevices.c | 10 ++++++++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 193eb7585..85f9b499a 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1937,10 +1937,9 @@ int setup_devices(struct cmd_context *cmd)
if (!file_exists) {
/*
- * pvcreate/vgcreate/vgimportdevices/lvmdevices-add create
- * a new devices file here if it doesn't exist.
- * They have the create_edit_devices_file flag set.
- * First they create/lock-ex the devices file lockfile.
+ * pvcreate/vgcreate create a new devices file here if it
+ * doesn't exist. They have create_edit_devices_file=1.
+ * First create/lock-ex the devices file lockfile.
* Other commands will not use a devices file if none exists.
*/
lock_mode = LOCK_EX;
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 6c70f110c..a0a626533 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -2468,6 +2468,7 @@ static int _lock_devices_file(struct cmd_context *cmd, int mode, int nonblock, i
if (_devices_file_locked == mode) {
/* can happen when a command holds an ex lock and does an update in device_ids_validate */
+ /* can happen when vgimportdevices calls this directly, followed later by setup_devices */
if (held)
*held = 1;
return 1;
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index 9ade1b9e4..23c2718ff 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -132,8 +132,10 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
/*
- * Prepare devices file preemptively because the error path for this
- * case from process_each is not as clean.
+ * Prepare/create devices file preemptively because the error path for
+ * this case from process_each/setup_devices is not as clean.
+ * This means that when setup_devices is called, it the devices
+ * file steps will be redundant, and need to handle being repeated.
*/
if (!setup_devices_file(cmd)) {
log_error("Failed to set up devices file.");
@@ -143,6 +145,10 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
log_error("Devices file not enabled.");
return ECMD_FAILED;
}
+ if (!lock_devices_file(cmd, LOCK_EX)) {
+ log_error("Failed to lock the devices file.");
+ return ECMD_FAILED;
+ }
if (!devices_file_exists(cmd)) {
if (!devices_file_touch(cmd)) {
log_error("Failed to create devices file.");
1 year, 1 month
main - vgimportdevices: change result when devices are not added
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3c49a2e43ccfbad720a...
Commit: 3c49a2e43ccfbad720a3134484c7870a14b1135b
Parent: b553bf6fa817a38474f48816fc520d178cb48229
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Aug 29 15:17:36 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Aug 30 14:52:00 2022 -0500
vgimportdevices: change result when devices are not added
When using --all, if one VG is skipped, continue adding
other VGs, and do not return an error from the command
if some VGs are added. (A VG is skipped if it's missing PVs.)
If the command fails during devices file setup or device
scanning, then remove the devices file if it has been
newly created by the command, and exit with an error.
If devices from a named VG are not imported (e.g. the
VG is missing devices), then remove the devices file if
it has been newly created by the command, and exit with
an error.
If --all VGs are being imported, and no devices are found
to include in the devices file, then remove the devices
file if it has been newly created by the command, and
exit with an error.
---
test/shell/vgimportdevices.sh | 308 ++++++++++++++++++++++++++++++++++++++++++
tools/vgimportdevices.c | 41 ++++--
2 files changed, 336 insertions(+), 13 deletions(-)
diff --git a/test/shell/vgimportdevices.sh b/test/shell/vgimportdevices.sh
new file mode 100644
index 000000000..47363cec3
--- /dev/null
+++ b/test/shell/vgimportdevices.sh
@@ -0,0 +1,308 @@
+
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+test_description='vgimportdevices'
+
+. lib/inittest
+
+aux prepare_devs 5
+
+DFDIR="$LVM_SYSTEM_DIR/devices"
+mkdir "$DFDIR" || true
+DF="$DFDIR/system.devices"
+
+aux lvmconf 'devices/use_devicesfile = 1'
+
+not ls "$DF"
+pvcreate "$dev1"
+ls "$DF"
+grep "$dev1" "$DF"
+rm -f "$DF"
+dd if=/dev/zero of="$dev1" bs=1M count=1
+
+#
+# vgimportdevices -a with no prev df
+#
+
+# no devs found
+not vgimportdevices -a
+not ls "$DF"
+
+# one orphan pv, no vgs
+pvcreate "$dev1"
+rm -f "$DF"
+not vgimportdevices -a
+not ls "$DF"
+
+# one complete vg
+vgcreate $vg1 "$dev1"
+rm -f "$DF"
+vgimportdevices -a
+ls "$DF"
+grep "$dev1" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+rm -f "$DF"
+
+# two complete vgs
+vgcreate $vg1 "$dev1"
+vgcreate $vg2 "$dev2"
+rm -f "$DF"
+vgimportdevices -a
+ls "$DF"
+grep "$dev1" "$DF"
+grep "$dev2" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+rm -f "$DF"
+
+# one incomplete vg
+vgcreate $vg1 "$dev1" "$dev2"
+lvcreate -l1 -an $vg1
+rm -f "$DF"
+dd if=/dev/zero of="$dev1" bs=1M count=1
+not vgimportdevices -a
+not ls "$DF"
+vgs $vg1
+pvs "$dev2"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+rm -f "$DF"
+
+# three complete, one incomplete vg
+vgcreate $vg1 "$dev1"
+vgcreate $vg2 "$dev2"
+vgcreate $vg3 "$dev3"
+vgcreate $vg4 "$dev4" "$dev5"
+rm -f "$DF"
+dd if=/dev/zero of="$dev5" bs=1M count=1
+vgimportdevices -a
+ls "$DF"
+grep "$dev1" "$DF"
+grep "$dev2" "$DF"
+grep "$dev3" "$DF"
+not grep "$dev4" "$DF"
+not grep "$dev5" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+dd if=/dev/zero of="$dev3" bs=1M count=1
+dd if=/dev/zero of="$dev4" bs=1M count=1
+rm -f "$DF"
+
+
+#
+# vgimportdevices -a with existing df
+#
+
+# no devs found
+vgcreate $vg1 "$dev1"
+grep "$dev1" "$DF"
+dd if=/dev/zero of="$dev1" bs=1M count=1
+not vgimportdevices -a
+ls "$DF"
+
+# one complete vg
+vgcreate $vg1 "$dev1"
+vgimportdevices -a
+grep "$dev1" "$DF"
+vgcreate --devicesfile "" $vg2 "$dev2"
+not grep "$dev2" "$DF"
+vgimportdevices -a
+grep "$dev1" "$DF"
+grep "$dev2" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+rm -f "$DF"
+
+# two complete vgs
+vgcreate --devicesfile "" $vg1 "$dev1"
+vgcreate --devicesfile "" $vg2 "$dev2"
+rm -f "$DF"
+vgimportdevices -a
+ls "$DF"
+grep "$dev1" "$DF"
+grep "$dev2" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+rm -f "$DF"
+
+# one incomplete vg
+vgcreate $vg1 "$dev1"
+vgimportdevices -a
+grep "$dev1" "$DF"
+dd if=/dev/zero of="$dev1" bs=1M count=1
+vgcreate --devicesfile "" $vg2 "$dev2" "$dev3"
+not grep "$dev2" "$DF"
+not grep "$dev3" "$DF"
+dd if=/dev/zero of="$dev2" bs=1M count=1
+not vgimportdevices -a
+ls "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+dd if=/dev/zero of="$dev3" bs=1M count=1
+rm -f "$DF"
+
+# import the same vg again
+vgcreate --devicesfile "" $vg1 "$dev1"
+not ls "$DF"
+vgimportdevices -a
+ls "$DF"
+grep "$dev1" "$DF"
+vgimportdevices -a
+ls "$DF"
+grep "$dev1" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+rm -f "$DF"
+
+# import a series of vgs
+vgcreate --devicesfile "" $vg1 "$dev1"
+vgimportdevices -a
+grep "$dev1" "$DF"
+vgcreate --devicesfile "" $vg2 "$dev2"
+vgimportdevices -a
+grep "$dev1" "$DF"
+grep "$dev2" "$DF"
+vgcreate --devicesfile "" $vg3 "$dev3"
+vgimportdevices -a
+grep "$dev1" "$DF"
+grep "$dev2" "$DF"
+grep "$dev3" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+dd if=/dev/zero of="$dev3" bs=1M count=1
+rm -f "$DF"
+
+#
+# vgimportdevices vg with no prev df
+#
+
+# no devs found
+not vgimportdevices $vg1
+not ls "$DF"
+
+# one complete vg
+vgcreate $vg1 "$dev1"
+rm -f "$DF"
+vgimportdevices $vg1
+ls "$DF"
+grep "$dev1" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+rm -f "$DF"
+
+# two complete vgs
+vgcreate $vg1 "$dev1"
+vgcreate $vg2 "$dev2"
+rm -f "$DF"
+vgimportdevices $vg1
+ls "$DF"
+grep "$dev1" "$DF"
+vgimportdevices $vg2
+ls "$DF"
+grep "$dev2" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+rm -f "$DF"
+
+# one incomplete vg
+vgcreate $vg1 "$dev1" "$dev2"
+lvcreate -l1 -an $vg1
+rm -f "$DF"
+dd if=/dev/zero of="$dev1" bs=1M count=1
+not vgimportdevices $vg1
+not ls "$DF"
+vgs $vg1
+pvs "$dev2"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+rm -f "$DF"
+
+# three complete, one incomplete vg
+vgcreate $vg1 "$dev1"
+vgcreate $vg2 "$dev2"
+vgcreate $vg3 "$dev3"
+vgcreate $vg4 "$dev4" "$dev5"
+rm -f "$DF"
+dd if=/dev/zero of="$dev5" bs=1M count=1
+not vgimportdevices $vg4
+not ls "$DF"
+vgimportdevices $vg3
+ls "$DF"
+grep "$dev3" "$DF"
+not grep "$dev1" "$DF"
+not grep "$dev2" "$DF"
+not grep "$dev4" "$DF"
+not grep "$dev5" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+dd if=/dev/zero of="$dev3" bs=1M count=1
+dd if=/dev/zero of="$dev4" bs=1M count=1
+rm -f "$DF"
+
+#
+# vgimportdevices vg with existing df
+#
+
+# vg not found
+vgcreate $vg1 "$dev1"
+vgimportdevices -a
+grep "$dev1" "$DF"
+not vgimportdevices $vg2
+grep "$dev1" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+rm -f "$DF"
+
+# vg incomplete
+vgcreate $vg1 "$dev1"
+vgimportdevices -a
+grep "$dev1" "$DF"
+vgcreate --devicesfile "" $vg2 "$dev2" "$dev3"
+dd if=/dev/zero of="$dev2" bs=1M count=1
+not vgimportdevices $vg2
+grep "$dev1" "$DF"
+not grep "$dev2" "$DF"
+not grep "$dev3" "$DF"
+
+# reset
+dd if=/dev/zero of="$dev1" bs=1M count=1
+dd if=/dev/zero of="$dev2" bs=1M count=1
+dd if=/dev/zero of="$dev3" bs=1M count=1
+dd if=/dev/zero of="$dev4" bs=1M count=1
+rm -f "$DF"
+
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index ea205d941..9ade1b9e4 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -36,9 +36,9 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
dm_list_iterate_items(pvl, &vg->pvs) {
if (is_missing_pv(pvl->pv) || !pvl->pv->dev) {
memcpy(pvid, &pvl->pv->id.uuid, ID_LEN);
- log_error("Not importing devices for VG %s with missing PV %s.",
- vg->name, pvid);
- goto bad;
+ log_print("Not importing devices for VG %s with missing PV %s.",
+ vg->name, pvid);
+ return ECMD_PROCESSED;
}
}
@@ -71,14 +71,17 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
updated_pvs++;
}
+ /*
+ * Writes the device_id of each PV into the vg metadata.
+ * This is not a critial step and should not influence
+ * the result of the command.
+ */
if (updated_pvs) {
if (!vg_write(vg) || !vg_commit(vg))
- goto_bad;
+ log_print("Failed to write device ids in VG metadata.");
}
return ECMD_PROCESSED;
-bad:
- return ECMD_FAILED;
}
/*
@@ -114,6 +117,7 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
{
struct vgimportdevices_params vp = { 0 };
struct processing_handle *handle;
+ int created_file = 0;
int ret = ECMD_FAILED;
if (arg_is_set(cmd, foreign_ARG))
@@ -139,9 +143,12 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
log_error("Devices file not enabled.");
return ECMD_FAILED;
}
- if (!devices_file_exists(cmd) && !devices_file_touch(cmd)) {
- log_error("Failed to create devices file.");
- return ECMD_FAILED;
+ if (!devices_file_exists(cmd)) {
+ if (!devices_file_touch(cmd)) {
+ log_error("Failed to create devices file.");
+ return ECMD_FAILED;
+ }
+ created_file = 1;
}
/*
@@ -195,22 +202,30 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
*/
ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
0, handle, _vgimportdevices_single);
- if (ret == ECMD_FAILED)
- goto out;
+ if (ret == ECMD_FAILED) {
+ /*
+ * Error from setting up devices file or label_scan,
+ * _vgimportdevices_single does not return an error.
+ */
+ goto_out;
+ }
if (!vp.added_devices) {
- log_print("No devices to add.");
+ log_error("No devices to add.");
+ ret = ECMD_FAILED;
goto out;
}
if (!device_ids_write(cmd)) {
- log_print("Failed to update devices file.");
+ log_error("Failed to write the devices file.");
ret = ECMD_FAILED;
goto out;
}
log_print("Added %u devices to devices file.", vp.added_devices);
out:
+ if ((ret == ECMD_FAILED) && created_file)
+ unlink(cmd->devices_file_path);
destroy_processing_handle(cmd, handle);
return ret;
}
1 year, 1 month
main - mm: use mallinfo2 when available
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b553bf6fa817a38474f...
Commit: b553bf6fa817a38474f48816fc520d178cb48229
Parent: 8370d117d7ef8a472c95315a3cd085696c90b3be
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 30 13:48:18 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 30 13:56:16 2022 +0200
mm: use mallinfo2 when available
Switch to mallinfo2() from a deprecated mallinfo() glibc call
since struct size members where to small for 64b CPUs.
---
WHATS_NEW | 1 +
lib/mm/memlock.c | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9e7cd1f0c..293c034af 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.17 -
===============================
+ Switch to use mallinfo2 and use it only with glibc.
Error out in lvm shell if using a cmd argument not supported in the shell.
Fix lvm shell's lastlog command to report previous pre-command failures.
Extend VDO and VDOPOOL without flushing and locking fs.
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 4a202866a..ad69f6474 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -167,7 +167,8 @@ static void _allocate_memory(void)
*/
void *stack_mem;
struct rlimit limit;
- int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;
+ int i, area = 0, missing = _size_malloc_tmp, max_areas = 32;
+ size_t hblks;
char *areas[max_areas];
/* Check if we could preallocate requested stack */
@@ -180,6 +181,12 @@ static void _allocate_memory(void)
}
/* FIXME else warn user setting got ignored */
+#ifdef HAVE_MALLINFO2
+ /* Prefer mallinfo2 call when avaialble with newer glibc */
+#define MALLINFO mallinfo2
+#else
+#define MALLINFO mallinfo
+#endif
/*
* When a brk() fails due to fragmented address space (which sometimes
* happens when we try to grab 8M or so), glibc will make a new
@@ -191,13 +198,13 @@ static void _allocate_memory(void)
* memory on free(), this is good enough for our purposes.
*/
while (missing > 0) {
- struct mallinfo inf = mallinfo();
+ struct MALLINFO inf = MALLINFO();
hblks = inf.hblks;
if ((areas[area] = malloc(_size_malloc_tmp)))
_touch_memory(areas[area], _size_malloc_tmp);
- inf = mallinfo();
+ inf = MALLINFO();
if (hblks < inf.hblks) {
/* malloc cheated and used mmap, even though we told it
1 year, 1 month
main - mm: preallocate memory only with glibc
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8370d117d7ef8a472c9...
Commit: 8370d117d7ef8a472c95315a3cd085696c90b3be
Parent: 5aa8683e8693f405d560b93a1bd8de809dc985ef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 19 16:15:17 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 30 13:55:52 2022 +0200
mm: preallocate memory only with glibc
Use mallinfo() only with glibc.
---
lib/mm/memlock.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index f43bacdcd..4a202866a 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -159,7 +159,12 @@ static void _touch_memory(void *mem, size_t size)
static void _allocate_memory(void)
{
-#ifndef VALGRIND_POOL
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
+ /* Memory allocation is currently only tested with glibc
+ * for different C libraries, some other mechanisms might be needed
+ * meanwhile let users use lvm2 code without memory preallocation.
+ * Compilation for VALGRIND tracing also goes without preallocation.
+ */
void *stack_mem;
struct rlimit limit;
int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;
1 year, 1 month
main - configure: remove some obsolete or duplicate checks
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5aa8683e8693f405d56...
Commit: 5aa8683e8693f405d560b93a1bd8de809dc985ef
Parent: bda93ed4bcdc1bf7493298f6c90076cc3a033223
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 30 13:36:52 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 30 13:54:19 2022 +0200
configure: remove some obsolete or duplicate checks
As autoupdate suggested, drop unneeded checks.
---
configure | 166 +------------------------------------------------
configure.ac | 10 +--
include/configure.h.in | 7 ---
3 files changed, 5 insertions(+), 178 deletions(-)
diff --git a/configure b/configure
index aa3b83fcb..2dbcf1c40 100755
--- a/configure
+++ b/configure
@@ -3417,10 +3417,10 @@ as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"
as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
-as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
as_fn_append ac_header_c_list " vfork.h vfork_h HAVE_VFORK_H"
as_fn_append ac_func_c_list " fork HAVE_FORK"
as_fn_append ac_func_c_list " vfork HAVE_VFORK"
+as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
as_fn_append ac_func_c_list " alarm HAVE_ALARM"
as_fn_append ac_header_c_list " sys/param.h sys_param_h HAVE_SYS_PARAM_H"
as_fn_append ac_func_c_list " getpagesize HAVE_GETPAGESIZE"
@@ -6872,136 +6872,6 @@ printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
fi
-# Autoupdate added the next two lines to ensure that your configure
-# script's behavior did not change. They are probably safe to remove.
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-printf %s "checking for egrep... " >&6; }
-if test ${ac_cv_path_EGREP+y}
-then :
- printf %s "(cached) " >&6
-else $as_nop
- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
- then ac_cv_path_EGREP="$GREP -E"
- else
- if test -z "$EGREP"; then
- ac_path_EGREP_found=false
- # Loop through the user's path and test for each of PROGNAME-LIST
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- case $as_dir in #(((
- '') as_dir=./ ;;
- */) ;;
- *) as_dir=$as_dir/ ;;
- esac
- for ac_prog in egrep
- do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
- as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
- # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
- ac_count=0
- printf %s 0123456789 >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- printf "%s\n" 'EGREP' >> "conftest.nl"
- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- as_fn_arith $ac_count + 1 && ac_count=$as_val
- if test $ac_count -gt ${ac_path_EGREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_EGREP="$ac_path_EGREP"
- ac_path_EGREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
- $ac_path_EGREP_found && break 3
- done
- done
- done
-IFS=$as_save_IFS
- if test -z "$ac_cv_path_EGREP"; then
- as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
- fi
-else
- ac_cv_path_EGREP=$EGREP
-fi
-
- fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-printf "%s\n" "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
-printf %s "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
-if test ${ac_cv_header_sys_wait_h+y}
-then :
- printf %s "(cached) " >&6
-else $as_nop
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
-#endif
-#ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-
-int
-main (void)
-{
- int s;
- wait (&s);
- s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
- ac_cv_header_sys_wait_h=yes
-else $as_nop
- ac_cv_header_sys_wait_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5
-printf "%s\n" "$ac_cv_header_sys_wait_h" >&6; }
-if test $ac_cv_header_sys_wait_h = yes; then
-
-printf "%s\n" "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
-
-fi
-
-
-
-# Obsolete code to be removed.
-if test $ac_cv_header_sys_time_h = yes; then
-
-printf "%s\n" "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
-# End of obsolete code.
-
for ac_header in assert.h ctype.h dirent.h errno.h fcntl.h float.h getopt.h inttypes.h langinfo.h libgen.h limits.h locale.h paths.h signal.h stdarg.h stddef.h stdio.h stdlib.h string.h sys/file.h sys/ioctl.h syslog.h sys/mman.h sys/param.h sys/resource.h sys/stat.h sys/time.h sys/types.h sys/utsname.h sys/wait.h time.h unistd.h
do :
@@ -7352,39 +7222,6 @@ printf "%s\n" "#define pid_t $ac_pid_type" >>confdefs.h
fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
-printf %s "checking return type of signal handlers... " >&6; }
-if test ${ac_cv_type_signal+y}
-then :
- printf %s "(cached) " >&6
-else $as_nop
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <signal.h>
-
-int
-main (void)
-{
-return *(signal (0, 0)) (0) == 1;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
- ac_cv_type_signal=int
-else $as_nop
- ac_cv_type_signal=void
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
-printf "%s\n" "$ac_cv_type_signal" >&6; }
-
-printf "%s\n" "#define RETSIGTYPE $ac_cv_type_signal" >>confdefs.h
-
-
ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
if test "x$ac_cv_type_size_t" = xyes
then :
@@ -8439,6 +8276,7 @@ esac
+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
printf %s "checking for working mktime... " >&6; }
if test ${ac_cv_func_working_mktime+y}
diff --git a/configure.ac b/configure.ac
index 3148370ad..39bbc4fef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,9 +95,6 @@ dnl -- Check for header files.
AC_HEADER_DIRENT
AC_HEADER_MAJOR
AC_HEADER_STDBOOL
-AC_HEADER_STDC
-AC_HEADER_SYS_WAIT
-AC_HEADER_TIME
AC_CHECK_HEADERS([assert.h ctype.h dirent.h errno.h fcntl.h float.h \
getopt.h inttypes.h langinfo.h libgen.h limits.h locale.h paths.h \
@@ -125,7 +122,6 @@ AC_STRUCT_ST_BLOCKS
AC_STRUCT_TM
AC_TYPE_OFF_T
AC_TYPE_PID_T
-AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_MODE_T
AC_TYPE_INT8_T
@@ -1139,7 +1135,7 @@ AC_CHECK_HEADER([systemd/sd-id128.h],
[APP_MACHINEID_SUPPORT=no])
AC_MSG_CHECKING(whether to support systemd appmachineid)
AC_ARG_ENABLE(app-machineid,
- AC_HELP_STRING([--disable-app-machineid],
+ AS_HELP_STRING([--disable-app-machineid],
[disable LVM system ID using app-specific machine-id]),
AS_IF([test "$enableval" = yes && test "$APP_MACHINEID_SUPPORT" = no],
AC_MSG_ERROR([Enabling app machineid requires systemd/sd-id128.h and systemd >= 234.]))
@@ -1323,8 +1319,8 @@ if test "$BUILD_LVMDBUSD" = yes; then
test "$PYTHON3_BINDINGS" = yes && PYTHON_BINDINGS=yes
# To get this macro, install autoconf-archive package then run autoreconf
- AC_PYTHON_MODULE([pyudev], [Required], python3)
- AC_PYTHON_MODULE([dbus], [Required], python3)
+ AX_PYTHON_MODULE([pyudev], [Required], python3)
+ AX_PYTHON_MODULE([dbus], [Required], python3)
fi
################################################################################
diff --git a/include/configure.h.in b/include/configure.h.in
index 63c296550..230658f7b 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -642,9 +642,6 @@
/* Define to 1 to include the LVM readline shell. */
#undef READLINE_SUPPORT
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
/* Define to 1 to include built-in support for snapshots. */
#undef SNAPSHOT_INTERNAL
@@ -689,10 +686,6 @@
/* The path to 'thin_restore', if available. */
#undef THIN_RESTORE_CMD
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
- macro is obsolete. */
-#undef TIME_WITH_SYS_TIME
-
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
1 year, 1 month
main - configure: check for mallinfo2
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bda93ed4bcdc1bf7493...
Commit: bda93ed4bcdc1bf7493298f6c90076cc3a033223
Parent: 60ca2ce20fef54b3441dda051beebbc1847db50d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 30 13:28:24 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 30 13:54:19 2022 +0200
configure: check for mallinfo2
---
configure | 6 ++++++
configure.ac | 2 +-
include/configure.h.in | 3 +++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 3586dd91c..aa3b83fcb 100755
--- a/configure
+++ b/configure
@@ -7696,6 +7696,12 @@ if test "x$ac_cv_func_ffs" = xyes
then :
printf "%s\n" "#define HAVE_FFS 1" >>confdefs.h
+fi
+ac_fn_c_check_func "$LINENO" "mallinfo2" "ac_cv_func_mallinfo2"
+if test "x$ac_cv_func_mallinfo2" = xyes
+then :
+ printf "%s\n" "#define HAVE_MALLINFO2 1" >>confdefs.h
+
fi
ac_fn_c_check_func "$LINENO" "prlimit" "ac_cv_func_prlimit"
if test "x$ac_cv_func_prlimit" = xyes
diff --git a/configure.ac b/configure.ac
index ba02f1f9b..3148370ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,7 +153,7 @@ AC_CHECK_FUNCS([ftruncate gethostname getpagesize gettimeofday localtime_r \
memchr memset mkdir mkfifo munmap nl_langinfo pselect realpath rmdir setenv \
setlocale strcasecmp strchr strcspn strdup strerror strncasecmp strndup \
strrchr strspn strstr strtol strtoul uname], , [AC_MSG_ERROR(bailing out)])
-AC_CHECK_FUNCS([ffs prlimit versionsort])
+AC_CHECK_FUNCS([ffs mallinfo2 prlimit versionsort])
AC_FUNC_ALLOCA
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_CHOWN
diff --git a/include/configure.h.in b/include/configure.h.in
index 83de33ab4..63c296550 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -267,6 +267,9 @@
/* Define to 1 if you have the <machine/endian.h> header file. */
#undef HAVE_MACHINE_ENDIAN_H
+/* Define to 1 if you have the `mallinfo2' function. */
+#undef HAVE_MALLINFO2
+
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
1 year, 1 month
main - thin: rename internal function
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=60ca2ce20fef54b3441...
Commit: 60ca2ce20fef54b3441dda051beebbc1847db50d
Parent: 8d70cfe6005165e173643954e6cd9eff745e4aa4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Aug 24 15:02:07 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 30 13:54:19 2022 +0200
thin: rename internal function
Names matching internal code layout.
Functionc in thin_manip.c uses thin_pool in its name.
Keep 'pool' only for function working for both cache and thin pools.
No change of functionality.
---
lib/activate/activate.c | 2 +-
lib/locking/lvmlockd.c | 2 +-
lib/metadata/lv_manip.c | 32 ++++++++++++++++----------------
lib/metadata/metadata-exported.h | 7 ++++---
lib/metadata/metadata.h | 39 +++++++++++++++++++++------------------
lib/metadata/pool_manip.c | 6 +++---
lib/metadata/thin_manip.c | 36 ++++++++++++++++++------------------
lib/thin/thin.c | 4 ++--
tools/lvchange.c | 2 +-
tools/lvconvert.c | 6 +++---
10 files changed, 70 insertions(+), 66 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index a92fbb8e1..2f3c231cc 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2764,7 +2764,7 @@ static int _component_cb(struct logical_volume *lv, void *data)
if (lv_is_locked(lv) || lv_is_pvmove(lv) ||/* ignoring */
/* thin-pool is special and it's using layered device */
- (lv_is_thin_pool(lv) && pool_is_active(lv)))
+ (lv_is_thin_pool(lv) && thin_pool_is_active(lv)))
return -1;
/* External origin is activated through thinLV and uses -real suffix.
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 60c80f1b1..f0183db3d 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2555,7 +2555,7 @@ static int _lockd_lv_thin(struct cmd_context *cmd, struct logical_volume *lv,
* Unlock when the pool is no longer active.
*/
- if (def_mode && !strcmp(def_mode, "un") && pool_is_active(pool_lv))
+ if (def_mode && !strcmp(def_mode, "un") && thin_pool_is_active(pool_lv))
return 1;
flags |= LDLV_MODE_NO_SH;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9523e3e66..a9057830d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5125,7 +5125,7 @@ static int _lvresize_adjust_policy(const struct logical_volume *lv,
goto_bad;
/* Resize below the minimal usable value */
- min_threshold = pool_metadata_min_threshold(first_seg(lv)) / DM_PERCENT_1;
+ min_threshold = thin_pool_metadata_min_threshold(first_seg(lv)) / DM_PERCENT_1;
*meta_amount = _adjust_amount(thin_pool_status->metadata_usage,
(min_threshold < policy_threshold) ?
min_threshold : policy_threshold, policy_amount);
@@ -6179,13 +6179,13 @@ int lv_resize(struct logical_volume *lv,
if (lv_is_thin_pool(lock_lv)) {
/* Update lvm pool metadata (drop messages). */
- if (!update_pool_lv(lock_lv, 1))
+ if (!update_thin_pool_lv(lock_lv, 1))
goto_bad;
}
/* Check for over provisioning when extended */
if ((lp->resize == LV_EXTEND) && lv_is_thin_type(lv))
- pool_check_overprovisioning(lv);
+ thin_pool_check_overprovisioning(lv);
out:
log_print_unless_silent("Logical volume %s successfully resized.",
@@ -6742,8 +6742,8 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
/* Clear thin pool stacked messages */
- if (pool_lv && pool_has_message(first_seg(pool_lv), lv, 0) &&
- !update_pool_lv(pool_lv, 1)) {
+ if (pool_lv && thin_pool_has_message(first_seg(pool_lv), lv, 0) &&
+ !update_thin_pool_lv(pool_lv, 1)) {
if (force < DONT_PROMPT_OVERRIDE) {
log_error("Failed to update pool %s.", display_lvname(pool_lv));
return 0;
@@ -6820,9 +6820,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* Release unneeded blocks in thin pool */
/* TODO: defer when multiple LVs relased at once */
- if (pool_lv && !update_pool_lv(pool_lv, 1)) {
+ if (pool_lv && !update_thin_pool_lv(pool_lv, 1)) {
if (force < DONT_PROMPT_OVERRIDE) {
- log_error("Failed to update pool %s.", display_lvname(pool_lv));
+ log_error("Failed to update thin pool %s.", display_lvname(pool_lv));
return 0;
}
log_print_unless_silent("Ignoring update failure of pool %s.",
@@ -8299,7 +8299,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
display_lvname(pool_lv));
return NULL;
}
- if (!pool_below_threshold(first_seg(pool_lv))) {
+ if (!thin_pool_below_threshold(first_seg(pool_lv))) {
log_error("Cannot create new thin volume, free space in "
"thin pool %s reached threshold.",
display_lvname(pool_lv));
@@ -8386,7 +8386,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
* within the same thin pool
*/
if (first_seg(origin_lv)->pool_lv != pool_lv) {
- if (!pool_supports_external_origin(first_seg(pool_lv), origin_lv))
+ if (!thin_pool_supports_external_origin(first_seg(pool_lv), origin_lv))
return_NULL;
if (origin_lv->status & LVM_WRITE) {
log_error("Cannot use writable LV as the external origin.");
@@ -8448,8 +8448,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (pool_lv && segtype_is_thin_volume(create_segtype)) {
/* Ensure all stacked messages are submitted */
- if ((pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
- !update_pool_lv(pool_lv, 1))
+ if ((thin_pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
+ !update_thin_pool_lv(pool_lv, 1))
return_NULL;
}
@@ -8536,7 +8536,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
(seg = first_seg(lv)) &&
seg_is_thin(seg)) { /* going to be a thin volume */
pool_seg = first_seg(pool_lv);
- if (!(seg->device_id = get_free_pool_device_id(pool_seg)))
+ if (!(seg->device_id = get_free_thin_pool_device_id(pool_seg)))
return_NULL;
seg->transaction_id = pool_seg->transaction_id;
if (origin_lv && lv_is_thin_volume(origin_lv) &&
@@ -8555,11 +8555,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
}
- if (!attach_pool_message(pool_seg, DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
+ if (!attach_thin_pool_message(pool_seg, DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
return_NULL;
}
- if (!pool_check_overprovisioning(lv))
+ if (!thin_pool_check_overprovisioning(lv))
return_NULL;
/* FIXME Log allocation and attachment should have happened inside lv_extend. */
@@ -8677,7 +8677,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
goto revert_new_lv;
}
/* At this point remove pool messages, snapshot is active */
- if (!update_pool_lv(pool_lv, 0)) {
+ if (!update_thin_pool_lv(pool_lv, 0)) {
stack;
goto revert_new_lv;
}
@@ -8699,7 +8699,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
}
/* Keep thin pool active until thin volume is activated */
- if (!update_pool_lv(pool_lv, 1)) {
+ if (!update_thin_pool_lv(pool_lv, 1)) {
stack;
goto revert_new_lv;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 6180ac88e..deaf3f30c 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -880,15 +880,16 @@ uint32_t extents_from_percent_size(struct volume_group *vg, const struct dm_list
percent_type_t percent, uint64_t size);
struct logical_volume *find_pool_lv(const struct logical_volume *lv);
-int pool_is_active(const struct logical_volume *lv);
-int pool_supports_external_origin(const struct lv_segment *pool_seg, const struct logical_volume *external_lv);
+int thin_pool_is_active(const struct logical_volume *lv);
+int thin_pool_supports_external_origin(const struct lv_segment *pool_seg, const struct logical_volume *external_lv);
int thin_pool_feature_supported(const struct logical_volume *lv, int feature);
+int update_thin_pool_lv(struct logical_volume *lv, int activate);
+
int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
int chunk_size_calc_policy);
int validate_cache_chunk_size(struct cmd_context *cmd, uint32_t chunk_size);
int validate_thin_pool_chunk_size(struct cmd_context *cmd, uint32_t chunk_size);
int validate_pool_chunk_size(struct cmd_context *cmd, const struct segment_type *segtype, uint32_t chunk_size);
-int update_pool_lv(struct logical_volume *lv, int activate);
int get_default_allocation_thin_pool_chunk_size(struct cmd_context *cmd, struct profile *profile,
uint32_t *chunk_size, int *chunk_size_calc_method);
int update_thin_pool_params(struct cmd_context *cmd,
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 6c39ff845..7f3cf9d29 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -408,7 +408,7 @@ struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le);
struct lv_segment *find_pool_seg(const struct lv_segment *seg);
/* Find some unused device_id for thin pool LV segment. */
-uint32_t get_free_pool_device_id(struct lv_segment *thin_pool_seg);
+uint32_t get_free_thin_pool_device_id(struct lv_segment *thin_pool_seg);
/* Check if the new thin-pool could be used for lvm2 thin volumes */
int check_new_thin_pool(const struct logical_volume *pool_lv);
@@ -490,31 +490,15 @@ struct volume_group *vg_from_config_tree(struct cmd_context *cmd, const struct d
int fixup_imported_mirrors(struct volume_group *vg);
/*
- * From thin_manip.c
+ * From pool_manip.c
*/
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
struct logical_volume *origin,
struct generic_logical_volume *indirect_origin,
struct logical_volume *merge_lv);
int detach_pool_lv(struct lv_segment *seg);
-int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
- struct logical_volume *lv, uint32_t delete_id,
- int no_update);
-int lv_is_merging_thin_snapshot(const struct logical_volume *lv);
-int pool_has_message(const struct lv_segment *seg,
- const struct logical_volume *lv, uint32_t device_id);
-int pool_metadata_min_threshold(const struct lv_segment *pool_seg);
-int pool_below_threshold(const struct lv_segment *pool_seg);
-int pool_check_overprovisioning(const struct logical_volume *lv);
int create_pool(struct logical_volume *pool_lv, const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size);
-uint64_t get_thin_pool_max_metadata_size(struct cmd_context *cmd, struct profile *profile,
- thin_crop_metadata_t *crop);
-thin_crop_metadata_t get_thin_pool_crop_metadata(struct cmd_context *cmd,
- thin_crop_metadata_t crop,
- uint64_t metadata_size);
-uint64_t estimate_thin_pool_metadata_size(uint32_t data_extents, uint32_t extent_size, uint32_t chunk_size);
-
int update_pool_metadata_min_max(struct cmd_context *cmd,
uint32_t extent_size,
uint64_t min_metadata_size, /* required min */
@@ -523,6 +507,25 @@ int update_pool_metadata_min_max(struct cmd_context *cmd,
struct logical_volume *metadata_lv, /* name of converted LV or NULL */
uint32_t *metadata_extents); /* resulting extent count */
+/*
+ * From thin_manip.c
+ */
+int attach_thin_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
+ struct logical_volume *lv, uint32_t delete_id,
+ int no_update);
+int lv_is_merging_thin_snapshot(const struct logical_volume *lv);
+int thin_pool_has_message(const struct lv_segment *seg,
+ const struct logical_volume *lv, uint32_t device_id);
+int thin_pool_metadata_min_threshold(const struct lv_segment *pool_seg);
+int thin_pool_below_threshold(const struct lv_segment *pool_seg);
+int thin_pool_check_overprovisioning(const struct logical_volume *lv);
+uint64_t get_thin_pool_max_metadata_size(struct cmd_context *cmd, struct profile *profile,
+ thin_crop_metadata_t *crop);
+thin_crop_metadata_t get_thin_pool_crop_metadata(struct cmd_context *cmd,
+ thin_crop_metadata_t crop,
+ uint64_t metadata_size);
+uint64_t estimate_thin_pool_metadata_size(uint32_t data_extents, uint32_t extent_size, uint32_t chunk_size);
+
/*
* Begin skeleton for external LVM library
*/
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index e451e92ae..bb4b5f115 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -310,9 +310,9 @@ int detach_pool_lv(struct lv_segment *seg)
return_0;
if (seg->device_id && /* Only thins with device_id > 0 can be deleted */
- !attach_pool_message(first_seg(seg->pool_lv),
- DM_THIN_MESSAGE_DELETE,
- NULL, seg->device_id, no_update))
+ !attach_thin_pool_message(first_seg(seg->pool_lv),
+ DM_THIN_MESSAGE_DELETE,
+ NULL, seg->device_id, no_update))
return_0;
if (!remove_seg_from_segs_using_this_lv(seg->pool_lv, seg))
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 6ce88bd3d..14656ed3f 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -34,9 +34,9 @@ struct logical_volume *data_lv_from_thin_pool(struct logical_volume *pool_lv)
}
/* TODO: drop unused no_update */
-int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
- struct logical_volume *lv, uint32_t delete_id,
- int no_update)
+int attach_thin_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
+ struct logical_volume *lv, uint32_t delete_id,
+ int no_update)
{
struct lv_thin_message *tmsg;
@@ -46,7 +46,7 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
return 0;
}
- if (pool_has_message(pool_seg, lv, delete_id)) {
+ if (thin_pool_has_message(pool_seg, lv, delete_id)) {
if (lv)
log_error("Message referring LV %s already queued in pool %s.",
display_lvname(lv), display_lvname(pool_seg->lv));
@@ -151,13 +151,13 @@ int lv_is_merging_thin_snapshot(const struct logical_volume *lv)
* Check whether pool has some message queued for LV or for device_id
* When LV is NULL and device_id is 0 it just checks for any message.
*/
-int pool_has_message(const struct lv_segment *seg,
- const struct logical_volume *lv, uint32_t device_id)
+int thin_pool_has_message(const struct lv_segment *seg,
+ const struct logical_volume *lv, uint32_t device_id)
{
const struct lv_thin_message *tmsg;
if (!seg_is_thin_pool(seg)) {
- log_error(INTERNAL_ERROR "LV %s is not pool.", display_lvname(seg->lv));
+ log_error(INTERNAL_ERROR "LV %s is not a thin pool.", display_lvname(seg->lv));
return 0;
}
@@ -183,13 +183,13 @@ int pool_has_message(const struct lv_segment *seg,
return 0;
}
-int pool_is_active(const struct logical_volume *lv)
+int thin_pool_is_active(const struct logical_volume *lv)
{
struct lvinfo info;
const struct seg_list *sl;
if (!lv_is_thin_pool(lv)) {
- log_error(INTERNAL_ERROR "pool_is_active called with non-pool volume %s.",
+ log_error(INTERNAL_ERROR "thin_pool_is_active called with non thin pool volume %s.",
display_lvname(lv));
return 0;
}
@@ -233,7 +233,7 @@ int thin_pool_feature_supported(const struct logical_volume *lv, int feature)
return (attr & feature) ? 1 : 0;
}
-int pool_metadata_min_threshold(const struct lv_segment *pool_seg)
+int thin_pool_metadata_min_threshold(const struct lv_segment *pool_seg)
{
/*
* Hardcoded minimal requirement for thin pool target.
@@ -252,11 +252,11 @@ int pool_metadata_min_threshold(const struct lv_segment *pool_seg)
return DM_PERCENT_100 - meta_free;
}
-int pool_below_threshold(const struct lv_segment *pool_seg)
+int thin_pool_below_threshold(const struct lv_segment *pool_seg)
{
struct cmd_context *cmd = pool_seg->lv->vg->cmd;
struct lv_status_thin_pool *thin_pool_status = NULL;
- dm_percent_t min_threshold = pool_metadata_min_threshold(pool_seg);
+ dm_percent_t min_threshold = thin_pool_metadata_min_threshold(pool_seg);
dm_percent_t threshold = DM_PERCENT_1 *
find_config_tree_int(cmd, activation_thin_pool_autoextend_threshold_CFG,
lv_config_profile(pool_seg->lv));
@@ -344,7 +344,7 @@ out:
* Lots of test combined together.
* Test is not detecting status of dmeventd, too complex for now...
*/
-int pool_check_overprovisioning(const struct logical_volume *lv)
+int thin_pool_check_overprovisioning(const struct logical_volume *lv)
{
const struct lv_list *lvl;
const struct seg_list *sl;
@@ -433,7 +433,7 @@ int pool_check_overprovisioning(const struct logical_volume *lv)
/*
* Validate given external origin could be used with thin pool
*/
-int pool_supports_external_origin(const struct lv_segment *pool_seg, const struct logical_volume *external_lv)
+int thin_pool_supports_external_origin(const struct lv_segment *pool_seg, const struct logical_volume *external_lv)
{
uint32_t csize = pool_seg->chunk_size;
@@ -474,7 +474,7 @@ struct logical_volume *find_pool_lv(const struct logical_volume *lv)
* FIXME: Improve naive search and keep the value cached
* and updated during VG lifetime (so no const for lv_segment)
*/
-uint32_t get_free_pool_device_id(struct lv_segment *thin_pool_seg)
+uint32_t get_free_thin_pool_device_id(struct lv_segment *thin_pool_seg)
{
uint32_t max_id = 0;
struct seg_list *sl;
@@ -516,7 +516,7 @@ static int _check_pool_create(const struct logical_volume *lv)
display_lvname(lv));
return 0;
}
- if (!pool_below_threshold(first_seg(lv))) {
+ if (!thin_pool_below_threshold(first_seg(lv))) {
log_error("Free space in pool %s is above threshold, new volumes are not allowed.",
display_lvname(lv));
return 0;
@@ -527,13 +527,13 @@ static int _check_pool_create(const struct logical_volume *lv)
return 1;
}
-int update_pool_lv(struct logical_volume *lv, int activate)
+int update_thin_pool_lv(struct logical_volume *lv, int activate)
{
int monitored;
int ret = 1;
if (!lv_is_thin_pool(lv)) {
- log_error(INTERNAL_ERROR "Updated LV %s is not pool.", display_lvname(lv));
+ log_error(INTERNAL_ERROR "Updated LV %s is not thin pool.", display_lvname(lv));
return 0;
}
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 5f3015026..9ce04438d 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -72,7 +72,7 @@ static int _thin_pool_add_message(struct lv_segment *seg,
else
return SEG_LOG_ERROR("Unknown message in");
- if (!attach_pool_message(seg, type, lv, delete_id, 1))
+ if (!attach_thin_pool_message(seg, type, lv, delete_id, 1))
return_0;
return 1;
@@ -585,7 +585,7 @@ static int _thin_add_target_line(struct dev_manager *dm,
/* Add external origin LV */
if (seg->external_lv) {
- if (!pool_supports_external_origin(first_seg(seg->pool_lv), seg->external_lv))
+ if (!thin_pool_supports_external_origin(first_seg(seg->pool_lv), seg->external_lv))
return_0;
if (seg->external_lv->size < seg->lv->size) {
/* Validate target supports smaller external origin */
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 670a4ec3d..34c9e36fd 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -103,7 +103,7 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
if (discards != first_seg(lv)->discards) {
if (((discards == THIN_DISCARDS_IGNORE) ||
(first_seg(lv)->discards == THIN_DISCARDS_IGNORE)) &&
- pool_is_active(lv))
+ thin_pool_is_active(lv))
log_error("Cannot change support for discards while pool volume %s is active.",
display_lvname(lv));
else {
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 081b344d0..6e5d748cc 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2414,7 +2414,7 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
argv[++args] = pms_path;
argv[++args] = NULL;
- if (pool_is_active(pool_lv)) {
+ if (thin_pool_is_active(pool_lv)) {
log_error("Active pools cannot be repaired. Use lvchange -an first.");
return 0;
}
@@ -2781,7 +2781,7 @@ static int _lvconvert_to_thin_with_external(struct cmd_context *cmd,
dm_list_init(&lvc.tags);
- if (!pool_supports_external_origin(first_seg(thinpool_lv), lv))
+ if (!thin_pool_supports_external_origin(first_seg(thinpool_lv), lv))
return_0;
if (!(lvc.segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_THIN)))
@@ -2906,7 +2906,7 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
}
/* FIXME cache pool */
- if (is_thinpool && pool_is_active(lv)) {
+ if (is_thinpool && thin_pool_is_active(lv)) {
/* If any volume referencing pool active - abort here */
log_error("Cannot convert pool %s with active volumes.",
display_lvname(lv));
1 year, 1 month
main - report: values: add note about self-decriptive values to report
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d70cfe6005165e1736...
Commit: 8d70cfe6005165e173643954e6cd9eff745e4aa4
Parent: e6b6a09f90f53a5cea3a712b2b84af57f4514a02
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 26 14:51:31 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 26 15:08:33 2022 +0200
report: values: add note about self-decriptive values to report
---
lib/report/report.c | 27 +++++++++++++++++++++++++++
lib/report/values.h | 27 +++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/lib/report/report.c b/lib/report/report.c
index 8a5122ff9..f666ca842 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -29,6 +29,33 @@
#include <float.h> /* DBL_MAX */
#include <time.h>
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * IMPORTANT NOTE ABOUT ADDING A NEW VALUE FOR REPORTING
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ *
+ * When adding a new string value to report, try to keep it
+ * self-descriptive so when it's printed even without the header,
+ * we can still deduce what it is actually reporting.
+ *
+ * If you need more than one descriptive string to mean the same value,
+ * please define them as reserved values in values.h.
+ *
+ * The first reserved value is the one that is printed in reports (unless
+ * it's a binary value and we have report/binary_values_as_numeric=1 config
+ * option used OR --binary command line option is used OR we're using an
+ * output format which must always print binary values in numeric way,
+ * like json_std output format.
+ *
+ * All the other (2nd and further) listed reserved names are synonyms which
+ * may be also used in selection (-S|--select).
+ *
+ * Also, always use proper *_disp functions to display each type of value
+ * properly. For example, in case of binary values, you should use
+ * _binary_disp so that we can always switch between numerical (0/1/-1) and
+ * string representation while reporting the value.
+ */
+
struct lvm_report_object {
struct volume_group *vg;
struct lv_with_info_and_seg_status *lvdm;
diff --git a/lib/report/values.h b/lib/report/values.h
index 9b98c229e..71175fa6e 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -45,6 +45,33 @@
/* *INDENT-OFF* */
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * IMPORTANT NOTE ABOUT ADDING A NEW VALUE FOR REPORTING
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ *
+ * When adding a new string value to report, try to keep it
+ * self-descriptive so when it's printed even without the header,
+ * we can still deduce what it is actually reporting.
+ *
+ * If you need more than one descriptive string to mean the same value,
+ * please define them as reserved values in values.h.
+ *
+ * The first reserved value is the one that is printed in reports (unless
+ * it's a binary value and we have report/binary_values_as_numeric=1 config
+ * option used OR --binary command line option is used OR we're using an
+ * output format which must always print binary values in numeric way,
+ * like json_std output format.
+ *
+ * All the other (2nd and further) listed reserved names are synonyms which
+ * may be also used in selection (-S|--select).
+ *
+ * Also, always use proper *_disp functions to display each type of value
+ * properly. For example, in case of binary values, you should use
+ * _binary_disp so that we can always switch between numerical (0/1/-1) and
+ * string representation while reporting the value.
+ */
+
/* Per-type reserved values usable for all fields of certain type. */
TYPE_RESERVED_VALUE(NUM, NOFLAG, num_undef_64, "Reserved value for undefined numeric value.", UINT64_C(-1), "-1", "unknown", "undefined", "undef")
1 year, 1 month
main - args: add ARG_NONINTERACTIVE for cmds not supported in lvm shell
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e6b6a09f90f53a5cea3...
Commit: e6b6a09f90f53a5cea3a712b2b84af57f4514a02
Parent: 800436d2affd4142b9d4b405112c4c30f1d31b5b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 26 12:17:45 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 26 12:17:50 2022 +0200
args: add ARG_NONINTERACTIVE for cmds not supported in lvm shell
Certain args can't be used in lvm shell ("interactive mode") because
they are not supported there. Add ARG_NONINTERACTIVE flag to mark
such args and error out if we're in interactive mode and at the same
time we detect use of such argument.
Currently, this is the case for --reportformat arg - we don't support
changing the format per command in lvm shell. The whole shell is running
under a reportformat chosen at shell's start.
---
WHATS_NEW | 1 +
tools/args.h | 2 +-
tools/command.c | 1 +
tools/lvmcmdline.c | 9 +++++++++
tools/tools.h | 1 +
5 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 90dd417b1..9e7cd1f0c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.17 -
===============================
+ Error out in lvm shell if using a cmd argument not supported in the shell.
Fix lvm shell's lastlog command to report previous pre-command failures.
Extend VDO and VDOPOOL without flushing and locking fs.
Add --valuesonly option to lvmconfig to print only values without keys.
diff --git a/tools/args.h b/tools/args.h
index bdeefca7d..85dd11aeb 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -671,7 +671,7 @@ arg(replace_ARG, '\0', "replace", pv_VAL, ARG_GROUPABLE, 0,
"Multiple PVs can be replaced by repeating this option.\n"
"See \\fBlvmraid\\fP(7) for more information.\n")
-arg(reportformat_ARG, '\0', "reportformat", reportformat_VAL, 0, 0,
+arg(reportformat_ARG, '\0', "reportformat", reportformat_VAL, ARG_NONINTERACTIVE, 0,
"Overrides current output format for reports which is defined globally by\n"
"the report/output_format setting in \\fBlvm.conf\\fP(5).\n"
"\\fBbasic\\fP is the original format with columns and rows.\n"
diff --git a/tools/command.c b/tools/command.c
index 8de8825e4..5da511530 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -78,6 +78,7 @@ static void *dm_pool_alloc(void *p, size_t size)
/* needed to include args.h */
#define ARG_COUNTABLE 0x00000001
#define ARG_GROUPABLE 0x00000002
+#define ARG_NONINTERACTIVE 0x00000004
struct cmd_context;
struct arg_values;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 4fb21074f..ba3ca220b 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2261,6 +2261,15 @@ static int _process_command_line(struct cmd_context *cmd, int *argc, char ***arg
av = &cmd->opt_arg_values[arg_enum];
+ if (a->flags & ARG_NONINTERACTIVE && cmd->is_interactive) {
+ log_error("Argument%s%c%s%s cannot be used in interactive mode.",
+ a->short_opt ? " -" : "",
+ a->short_opt ? : ' ',
+ (a->short_opt && a->long_opt) ?
+ "/" : "", a->long_opt ? : "");
+ return 0;
+ }
+
if (a->flags & ARG_GROUPABLE) {
/*
* Start a new group of arguments:
diff --git a/tools/tools.h b/tools/tools.h
index cd89e1692..2636c22da 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -96,6 +96,7 @@ enum {
#define ARG_COUNTABLE 0x00000001 /* E.g. -vvvv */
#define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */
+#define ARG_NONINTERACTIVE 0x00000004 /* only for use in noninteractive mode */
struct arg_values {
unsigned count;
1 year, 1 month
main - libdm: report: fix escaping of JSON quote char in reported fields
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=800436d2affd4142b9d...
Commit: 800436d2affd4142b9d4b405112c4c30f1d31b5b
Parent: 508782a9135acf13b39b47605e675a5678495c58
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Aug 24 12:08:51 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Aug 24 12:10:10 2022 +0200
libdm: report: fix escaping of JSON quote char in reported fields
Commit 73ec3c954b21522352b6f5cce9a700d6bf30ccf4 added a way to print
only a part of the report string (repstr) to support decoding individual
string list items out of repstr.
The repstr is normally printed through _safe_repstr_output so that any
JSON_QUOTE character ('"') found within the repstr is escaped to not
interfere with value quoting in JSON format.
However, the commit 73ec3c954b21522352b6f5cce9a700d6bf30ccf4 missed
checking the 'len' argument passed to _safe_repstr_output function when
adding the rest of the repstr after all previous JSON_QUOTE characters
were escaped (when calling the last dm_pool_grow_object). When 'len'
is 0, we need to calculate the 'len' ourselves in the function by
simply calling strlen. This is because 'len' is passed to the function
only if we're taking a part of repstr, not as a whole.
---
device_mapper/libdm-report.c | 11 +++--------
libdm/libdm-report.c | 11 +++--------
2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index d4cd06002..2d4c8883b 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -4572,17 +4572,12 @@ bad:
static int _safe_repstr_output(struct dm_report *rh, const char *repstr, size_t len)
{
const char *p_repstr;
- const char *repstr_end = repstr + len;
+ const char *repstr_end = len ? repstr + len : repstr + strlen(repstr);
/* Escape any JSON_QUOTE that may appear in reported string. */
while (1) {
- if (len) {
- if (!(p_repstr = memchr(repstr, JSON_QUOTE[0], repstr_end - repstr)))
- break;
- } else {
- if (!(p_repstr = strstr(repstr, JSON_QUOTE)))
- break;
- }
+ if (!(p_repstr = memchr(repstr, JSON_QUOTE[0], repstr_end - repstr)))
+ break;
if (p_repstr > repstr) {
if (!dm_pool_grow_object(rh->mem, repstr, p_repstr - repstr)) {
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index fc71ca5df..8eaf5896e 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4571,17 +4571,12 @@ bad:
static int _safe_repstr_output(struct dm_report *rh, const char *repstr, size_t len)
{
const char *p_repstr;
- const char *repstr_end = repstr + len;
+ const char *repstr_end = len ? repstr + len : repstr + strlen(repstr);
/* Escape any JSON_QUOTE that may appear in reported string. */
while (1) {
- if (len) {
- if (!(p_repstr = memchr(repstr, JSON_QUOTE[0], repstr_end - repstr)))
- break;
- } else {
- if (!(p_repstr = strstr(repstr, JSON_QUOTE)))
- break;
- }
+ if (!(p_repstr = memchr(repstr, JSON_QUOTE[0], repstr_end - repstr)))
+ break;
if (p_repstr > repstr) {
if (!dm_pool_grow_object(rh->mem, repstr, p_repstr - repstr)) {
1 year, 1 month