diff --git a/lib/label/label.c b/lib/label/label.c index 97e2a0bf9..a9818092a 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -946,7 +946,14 @@ bool dev_write_bytes(struct device *dev, off_t start, size_t len, void *data) } if (!bcache_write_bytes(scan_bcache, dev->bcache_fd, start, len, data)) { - log_error("dev_write_bytes %s at %u failed invalidate fd %d", + log_error("dev_write_bytes %s at %u bcache write failed invalidate fd %d", + dev_name(dev), (uint32_t)start, dev->bcache_fd); + label_scan_invalidate(dev); + return false; + } + + if (!bcache_flush(scan_bcache)) { + log_error("dev_write_bytes %s at %u bcache flush failed invalidate fd %d", dev_name(dev), (uint32_t)start, dev->bcache_fd); label_scan_invalidate(dev); return false; @@ -982,7 +989,14 @@ bool dev_write_zeros(struct device *dev, off_t start, size_t len) } if (!bcache_write_zeros(scan_bcache, dev->bcache_fd, start, len)) { - log_error("dev_write_zeros %s at %u failed invalidate fd %d", + log_error("dev_write_zeros %s at %u bcache write failed invalidate fd %d", + dev_name(dev), (uint32_t)start, dev->bcache_fd); + label_scan_invalidate(dev); + return false; + } + + if (!bcache_flush(scan_bcache)) { + log_error("dev_write_zeros %s at %u bcache flush failed invalidate fd %d", dev_name(dev), (uint32_t)start, dev->bcache_fd); label_scan_invalidate(dev); return false;