From e96d6b74427990cf9d91bc764e80a8fe79cd3e2d Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Fri, 18 Oct 2024 10:43:08 +0200 Subject: [PATCH] lv_manip: fall back to direct zeroing on any BLKZEROOUT ioctl failure When BLKZEROOUT ioctl fails, it should not stop us from trying the direct zeroing as a fallback action, since this is an optimization only. We should be able to continue with new LV creation if we succeed with that direct fallback then. Related report: https://issues.redhat.com/browse/RHEL-58737 --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index ef08b9f88..7b0c0a4bb 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.03.28 - ================== + Fall back to direct zeroing if BLKZEROOUT fails during new LV initialization. Version 2.03.27 - 02nd October 2024 =================================== diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index b53fc52e6..0ec82bb31 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -8829,16 +8829,17 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp) 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); - log_error("%s logical volume %s at position " FMTu64 " and size " FMTu64 ".", - sigint_caught() ? "Interrupted initialization of" : "Failed to initialize", - display_lvname(lv), range[0], range[1]); - return 0; - } + /* + * If errno == EINVAL, then the kernel is without support for BLKZEROOUT. + * Fall back to dev_set_bytes silently in that case. Otherwise, also log + * the errno message. + */ + if (errno != EINVAL) { + log_sys_debug("ioctl", "BLKZEROOUT"); + log_debug("Falling back to direct zeroing."); + } + + goto retry_with_dev_set; } } } else retry_with_dev_set: