master - tests: rename shown debug trace
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d9b4c624f5738035ef...
Commit: 8d9b4c624f5738035ef9a7af19cb85b6960ca080
Parent: 73a3a0d3476bd55358348bb95ddcdfe9ff1e809e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 19:17:36 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 22:27:00 2020 +0200
tests: rename shown debug trace
As there could be few invokes of stacktrace, avoid
repeatedly display logs from commands.
So after first display rename debug.log* -> debug_log
so the file still can remain for reading in test dir.
---
test/lib/utils.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 3bf73bb4c..88de1a0e2 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -171,6 +171,7 @@ STACKTRACE() {
test "$name" = "DEBUG" && { name="$name$idx" ; idx=$(( idx + 1 )) ; }
echo "<======== Debug log $i ========>"
sed -e "s,^,## $name: ," "$i"
+ mv -f "$i" "debug_${i#debug.}"
done
if test -e strace.log ; then
echo "<======== Strace debug log ========>"
2 years, 5 months
master - debug: drop vgid from debug
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=73a3a0d3476bd553583...
Commit: 73a3a0d3476bd55358348bb95ddcdfe9ff1e809e
Parent: 117fc64e6ef0905e6474d2bf67a890e97d6da450
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 22:22:25 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 22:27:00 2020 +0200
debug: drop vgid from debug
>From the code can be seen the VGID will be always NULL here
as vgid != NULL is already handled before.
Thus drop from being displayed.
---
lib/cache/lvmcache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index a2fa0e3fb..ef0f4c391 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -326,7 +326,7 @@ static struct lvmcache_vginfo *_vginfo_lookup(const char *vgname, const char *vg
if ((vginfo = dm_hash_lookup(_vgname_hash, vgname))) {
if (vginfo->has_duplicate_local_vgname) {
/* should never happen, found_duplicate_vgnames should be set */
- log_error(INTERNAL_ERROR "vginfo_lookup %s %s has_duplicate_local_vgname", vgname, vgid);
+ log_error(INTERNAL_ERROR "vginfo_lookup %s has_duplicate_local_vgname.", vgname);
return NULL;
}
return vginfo;
@@ -336,7 +336,7 @@ static struct lvmcache_vginfo *_vginfo_lookup(const char *vgname, const char *vg
if (vgname && _found_duplicate_vgnames) {
if ((vginfo = _search_vginfos_list(vgname, vgid))) {
if (vginfo->has_duplicate_local_vgname) {
- log_debug("vginfo_lookup %s %s has_duplicate_local_vgname return none", vgname, vgid);
+ log_debug("vginfo_lookup %s has_duplicate_local_vgname return none.", vgname);
return NULL;
}
return vginfo;
2 years, 5 months
master - debug: no backtrace
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=117fc64e6ef0905e647...
Commit: 117fc64e6ef0905e6474d2bf67a890e97d6da450
Parent: 1b8c6f09bcba1996892a231bc6c25be6ac40d808
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 11:14:18 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:04:16 2020 +0200
debug: no backtrace
As the path already printed verbose message drop backtrace.
---
lib/label/label.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index de01e4532..ec774dc6e 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -417,7 +417,7 @@ static int _process_block(struct cmd_context *cmd, struct dev_filter *f,
lvmcache_del_dev(dev); /* FIXME: if this is needed, fix it. */
*is_lvm_device = 0;
- goto_out;
+ goto out;
}
dev->flags |= DEV_SCAN_FOUND_LABEL;
2 years, 5 months
master - debug: show actually reason for taking this code path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1b8c6f09bcba1996892...
Commit: 1b8c6f09bcba1996892a231bc6c25be6ac40d808
Parent: e1af80c81c2c196ccc2e2a3f45e56cd1abc0dd45
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 11:12:49 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:04:16 2020 +0200
debug: show actually reason for taking this code path
Instead of not so useful backtrace, report what was the reason.
---
lib/format_text/format-text.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 0de881b67..e1142c07e 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2216,8 +2216,10 @@ static int _create_vg_text_instance(struct format_instance *fid,
}
if (type & FMT_INSTANCE_MDAS) {
- if (!(vginfo = lvmcache_vginfo_from_vgname(vg_name, vg_id)))
- goto_out;
+ if (!(vginfo = lvmcache_vginfo_from_vgname(vg_name, vg_id))) {
+ log_debug("No cached vginfo for VG %s and ID %s.", vg_name, vg_id);
+ goto out;
+ }
if (!lvmcache_fid_add_mdas_vg(vginfo, fid))
goto_out;
}
2 years, 5 months
master - debug: drop FD from error message
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e1af80c81c2c196ccc2...
Commit: e1af80c81c2c196ccc2e2a3f45e56cd1abc0dd45
Parent: dd8212365df356e561fe72e73be804f7313148c8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 11:10:44 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:04:16 2020 +0200
debug: drop FD from error message
Since now the error path already has device close and set -1,
there is not much in printing this info - actually shouldn't be
there at all..
---
lib/format_text/format-text.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index e44871226..0de881b67 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -277,7 +277,7 @@ static int _raw_write_mda_header(const struct format_type *fmt,
dev_set_last_byte(dev, start_byte + MDA_HEADER_SIZE);
if (!dev_write_bytes(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
- log_error("Failed to write mda header to %s fd %d", dev_name(dev), dev->bcache_fd);
+ log_error("Failed to write mda header to %s.", dev_name(dev));
return 0;
}
dev_unset_last_byte(dev);
@@ -972,7 +972,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
(unsigned long long)write2_size);
if (!dev_write_bytes(mdac->area.dev, write1_start, (size_t)write1_size, write_buf)) {
- log_error("Failed to write metadata to %s fd %d", devname, mdac->area.dev->bcache_fd);
+ log_error("Failed to write metadata to %s.", devname);
goto out;
}
@@ -984,7 +984,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if (!dev_write_bytes(mdac->area.dev, write2_start, write2_size,
write_buf + new_size - new_wrap)) {
- log_error("Failed to write metadata wrap to %s fd %d", devname, mdac->area.dev->bcache_fd);
+ log_error("Failed to write metadata wrap to %s", devname);
goto out;
}
}
2 years, 5 months
master - debug: update messages
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dd8212365df356e561f...
Commit: dd8212365df356e561fe72e73be804f7313148c8
Parent: e7fff97b8dc4c0a9170bed84388f9ccf55b09169
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 29 23:48:45 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:04:16 2020 +0200
debug: update messages
---
lib/device/dev-io.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 33b9345ee..4f52954fd 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -106,7 +106,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
log_sys_error("ioctl BLKGETSIZE64", name);
if (do_close && !dev_close_immediate(dev))
- log_sys_error("close", name);
+ stack;
return 0;
}
@@ -117,7 +117,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
log_very_verbose("%s: size is %" PRIu64 " sectors", name, *size);
if (do_close && !dev_close_immediate(dev))
- log_sys_error("close", name);
+ stack;
return 1;
}
@@ -133,7 +133,7 @@ static int _dev_read_ahead_dev(struct device *dev, uint32_t *read_ahead)
if (!dev_open_readonly_quiet(dev)) {
log_error("Failed to open to get readahead %s", dev_name(dev));
- return_0;
+ return 0;
}
if (ioctl(dev->fd, BLKRAGET, &read_ahead_long) < 0) {
@@ -449,7 +449,7 @@ int dev_open_readonly_quiet(struct device *dev)
static void _close(struct device *dev)
{
if (close(dev->fd))
- log_sys_error("close", dev_name(dev));
+ log_sys_debug("close", dev_name(dev));
dev->fd = -1;
log_debug_devs("Closed %s", dev_name(dev));
2 years, 5 months
master - wipe_lv: use BLKZEROOUT when possible
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e7fff97b8dc4c0a9170...
Commit: e7fff97b8dc4c0a9170bed84388f9ccf55b09169
Parent: c65d3a6b8a79b7ba68f56194a12d66b9c5f41547
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 19:32:28 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:04:16 2020 +0200
wipe_lv: use BLKZEROOUT when possible
Since BLKZEROOUT ioctl should be supposedly fastest
way how to clear block device start using this ioctl
for zeroing a device. Commonly we do zero typically
small portion of a device (8KiB) - however since we now
also started to zero metadata devices, in the case
of i.e. thin-pool metadata this can go upto ~16GiB
and here the performance starts to be noticable.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 270b9d0f8..16a8baf34 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.11 -
==================================
+ Support using BLKZEROOUT for clearing devices.
Support interruption when wipping LVs.
Support interruption for bcache waiting.
Fix bcache when device has too many failing writes.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b72e08060..4f59900d1 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -33,6 +33,11 @@
#include "lib/label/label.h"
#include "lib/misc/lvm-signal.h"
+#ifdef HAVE_BLKZEROOUT
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#endif
+
typedef enum {
PREFERRED,
USE_AREA,
@@ -7713,6 +7718,33 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
+#ifdef HAVE_BLKZEROOUT
+ if (!test_mode() && !wp.zero_value) {
+ /* TODO: maybe integrate with bcache_zero_set() */
+ const uint64_t end = zero_sectors << SECTOR_SHIFT;
+ uint64_t range[2] = { 0, 1024 * 1024 }; /* zeroing with 1M steps (for better ^C support) */
+ for (/* empty */ ; range[0] < end; range[0] += range[1]) {
+ if ((range[0] + range[1]) > end)
+ range[1] = end - range[0];
+
+ if (ioctl(dev->bcache_fd, BLKZEROOUT, &range)) {
+ if (errno == EINVAL)
+ goto retry_with_dev_set; /* Kernel without support for BLKZEROOUT */
+ log_sys_debug("ioctl", "BLKZEROOUT");
+ sigint_restore();
+ label_scan_invalidate(dev);
+ if (sigint_caught())
+ log_error("Interrupted initialization logical volume %s.",
+ display_lvname(lv));
+ else
+ log_error("Failed to initialize logical volume %s at position " FMTu64 " and size " FMTu64 ".",
+ display_lvname(lv), range[0], range[1]);
+ return 0;
+ }
+ }
+ } else
+retry_with_dev_set:
+#endif
if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
sigint_restore();
if (sigint_caught()) {
2 years, 5 months
master - wipe_lv: interruptible wiping
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c65d3a6b8a79b7ba68f...
Commit: c65d3a6b8a79b7ba68f56194a12d66b9c5f41547
Parent: 7396f1cfee0399237aee1ed41f5930746ee31716
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 19:31:05 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:03:19 2020 +0200
wipe_lv: interruptible wiping
Since we now block signals and wiping may take unexpectedly long
time - support breaking command while wipe is in progress.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index d4cf61d71..270b9d0f8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.11 -
==================================
+ Support interruption when wipping LVs.
Support interruption for bcache waiting.
Fix bcache when device has too many failing writes.
Fix bcache waiting for IO completion with failing disks.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f61705909..b72e08060 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -31,6 +31,7 @@
#include "lib/mm/memlock.h"
#include "lib/locking/lvmlockd.h"
#include "lib/label/label.h"
+#include "lib/misc/lvm-signal.h"
typedef enum {
PREFERRED,
@@ -7668,12 +7669,19 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
return 0;
}
+ sigint_allow();
if (wp.do_wipe_signatures) {
log_verbose("Wiping known signatures on logical volume %s.",
display_lvname(lv));
if (!wipe_known_signatures(lv->vg->cmd, dev, name, 0,
TYPE_DM_SNAPSHOT_COW,
wp.yes, wp.force, NULL)) {
+ sigint_restore();
+ if (sigint_caught()) {
+ log_error("Interrupted initialization logical volume %s.",
+ display_lvname(lv));
+ return 0;
+ }
label_scan_invalidate(dev);
log_error("Filed to wipe signatures of logical volume %s.",
display_lvname(lv));
@@ -7706,12 +7714,19 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_lvname(lv), wp.zero_value);
if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
+ sigint_restore();
+ if (sigint_caught()) {
+ log_error("Interrupted initialization logical volume %s.",
+ display_lvname(lv));
+ return 0;
+ }
log_error("Failed to initialize %s of logical volume %s with value %d.",
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
return 0;
}
}
+ sigint_restore();
label_scan_invalidate(dev);
2 years, 5 months
master - wipe_lv: drop label_scan_invalidate on error path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7396f1cfee0399237ae...
Commit: 7396f1cfee0399237aee1ed41f5930746ee31716
Parent: b44db5d1a7ecc2e8e3cef0852c4397b64ddf0a09
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 19:26:58 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:02:04 2020 +0200
wipe_lv: drop label_scan_invalidate on error path
Since dev_set_bytes() now closes dev on error path itself,
remove this unneeded call now (introduced few commits back
in history thus removing comment from WHATS_NEW)
---
WHATS_NEW | 1 -
lib/metadata/lv_manip.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a93a61b32..d4cf61d71 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -20,7 +20,6 @@ Version 2.03.11 -
Fix 64bit math when calculation cachevol size.
Preserve uint32_t for seqno handling.
Switch from mmap to plain read when loading regular files.
- Fix missing device closing on wiping error path.
Update lvmvdo man page and better explain DISCARD usage.
Version 2.03.10 - 09th August 2020
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a907130ff..f61705909 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7706,7 +7706,6 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_lvname(lv), wp.zero_value);
if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
- label_scan_invalidate(dev);
log_error("Failed to initialize %s of logical volume %s with value %d.",
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
2 years, 5 months
master - bcache: use flexible arrays
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b44db5d1a7ecc2e8e3c...
Commit: b44db5d1a7ecc2e8e3cef0852c4397b64ddf0a09
Parent: b3c7a2b3f0bc761a14cfe1c8fc768e265a183204
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 30 23:28:44 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 21:00:26 2020 +0200
bcache: use flexible arrays
Cleanup, allocate whole struct with a single malloc call.
---
lib/device/bcache.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index d1749d9ab..2451eda2b 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -66,23 +66,17 @@ struct control_block {
struct cb_set {
struct dm_list free;
struct dm_list allocated;
- struct control_block *vec;
+ struct control_block vec[];
} control_block_set;
static struct cb_set *_cb_set_create(unsigned nr)
{
unsigned i;
- struct cb_set *cbs = malloc(sizeof(*cbs));
+ struct cb_set *cbs = malloc(sizeof(*cbs) + nr * sizeof(*cbs->vec));
- if (!cbs)
+ if (!cbs->vec)
return NULL;
- cbs->vec = malloc(nr * sizeof(*cbs->vec));
- if (!cbs->vec) {
- free(cbs);
- return NULL;
- }
-
dm_list_init(&cbs->free);
dm_list_init(&cbs->allocated);
@@ -102,7 +96,6 @@ static void _cb_set_destroy(struct cb_set *cbs)
return;
}
- free(cbs->vec);
free(cbs);
}
2 years, 5 months