mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
label: cleanup set_byte error exit
This commit is contained in:
parent
37bcd7ce84
commit
491eb25832
@ -1519,6 +1519,8 @@ bool dev_write_zeros(struct device *dev, uint64_t start, size_t len)
|
||||
|
||||
bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
|
||||
{
|
||||
bool rv;
|
||||
|
||||
if (test_mode())
|
||||
return true;
|
||||
|
||||
@ -1547,25 +1549,30 @@ bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
|
||||
|
||||
dev_set_last_byte(dev, start + len);
|
||||
|
||||
if ((!val && !bcache_zero_bytes(scan_bcache, dev->bcache_fd, start, len)) ||
|
||||
!bcache_set_bytes(scan_bcache, dev->bcache_fd, start, len, val)) {
|
||||
log_error("Error writing device %s at %llu length %u.",
|
||||
if (!val)
|
||||
rv = bcache_zero_bytes(scan_bcache, dev->bcache_fd, start, len);
|
||||
else
|
||||
rv = bcache_set_bytes(scan_bcache, dev->bcache_fd, start, len, val);
|
||||
|
||||
if (!rv) {
|
||||
log_error("Error writing device value %s at %llu length %u.",
|
||||
dev_name(dev), (unsigned long long)start, (uint32_t)len);
|
||||
dev_unset_last_byte(dev);
|
||||
label_scan_invalidate(dev);
|
||||
return false;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!bcache_flush(scan_bcache)) {
|
||||
log_error("Error writing device %s at %llu length %u.",
|
||||
dev_name(dev), (unsigned long long)start, (uint32_t)len);
|
||||
dev_unset_last_byte(dev);
|
||||
label_scan_invalidate(dev);
|
||||
return false;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dev_unset_last_byte(dev);
|
||||
return true;
|
||||
|
||||
fail:
|
||||
dev_unset_last_byte(dev);
|
||||
label_scan_invalidate(dev);
|
||||
return false;
|
||||
}
|
||||
|
||||
void dev_set_last_byte(struct device *dev, uint64_t offset)
|
||||
|
Loading…
Reference in New Issue
Block a user