1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

wipe: dev_set_bytes resolves zeroing

Since dev_write_zeros() is just subset of dev_set_bytes()
use it directly and simplify code.
This commit is contained in:
Zdenek Kabelac 2020-09-15 20:35:48 +02:00
parent d588de77aa
commit 2b36542f41

View File

@ -7641,6 +7641,7 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
log_debug("Metadata logical volume %s will be fully zeroed.", log_debug("Metadata logical volume %s will be fully zeroed.",
display_lvname(lv)); display_lvname(lv));
zero_sectors = lv->size; zero_sectors = lv->size;
wp.zero_value = 0;
} else { } else {
if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */ if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */
log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.", log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.",
@ -7657,11 +7658,7 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_size(lv->vg->cmd, zero_sectors), display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value); display_lvname(lv), wp.zero_value);
if ((!wp.is_metadata && if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
wp.zero_value && !dev_set_bytes(dev, UINT64_C(0),
(size_t) zero_sectors << SECTOR_SHIFT,
(uint8_t)wp.zero_value)) ||
!dev_write_zeros(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT)) {
label_scan_invalidate(dev); label_scan_invalidate(dev);
log_error("Failed to initialize %s of logical volume %s with value %d.", log_error("Failed to initialize %s of logical volume %s with value %d.",
display_size(lv->vg->cmd, zero_sectors), display_size(lv->vg->cmd, zero_sectors),