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: