b74c0695d2
LVM Metadata Error: Error writing device at 4096 length 512 (bsc#1150021) + bug-1150021_01-scanning-open-devs-rw-when-rescanning-for-write.patch + bug-1150021_02-bcache-add-bcache_abort.patch + bug-1150021_03-label-Use-bcache_abort_fd-to-ensure-blocks-are-no-lo.patch + bug-1150021_04-bcache-add-unit-test.patch + bug-1150021_05-bcache-bcache_invalidate_fd-only-remove-prefixes-on.patch + bug-1150021_06-fix-dev_unset_last_byte-after-write-error.patch - Update patch, according to bug-1150021_01-scanning-xxx.patch + bug-1158861_06-fix-segfault-for-invalid-characters-in-vg-name.patch OBS-URL: https://build.opensuse.org/request/show/759060 OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=263
127 lines
4.5 KiB
Diff
127 lines
4.5 KiB
Diff
diff -Nupr a/lib/label/label.c b/lib/label/label.c
|
|
--- a/lib/label/label.c 2019-12-23 16:01:02.144729254 +0800
|
|
+++ b/lib/label/label.c 2019-12-23 16:01:25.752772110 +0800
|
|
@@ -619,6 +619,14 @@ static void _drop_bad_aliases(struct dev
|
|
}
|
|
}
|
|
|
|
+// Like bcache_invalidate, only it throws any dirty data away if the
|
|
+// write fails.
|
|
+static void _invalidate_fd(struct bcache *cache, int fd)
|
|
+{
|
|
+ if (!bcache_invalidate_fd(cache, fd))
|
|
+ bcache_abort_fd(cache, fd);
|
|
+}
|
|
+
|
|
/*
|
|
* Read or reread label/metadata from selected devs.
|
|
*
|
|
@@ -730,7 +738,7 @@ static int _scan_list(struct cmd_context
|
|
* drop it from bcache.
|
|
*/
|
|
if (scan_failed || !is_lvm_device) {
|
|
- bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
_scan_dev_close(devl->dev);
|
|
}
|
|
|
|
@@ -935,7 +943,7 @@ int label_scan(struct cmd_context *cmd)
|
|
* so this will usually not be true.
|
|
*/
|
|
if (_in_bcache(dev)) {
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
}
|
|
|
|
@@ -1111,7 +1119,7 @@ int label_scan_devs(struct cmd_context *
|
|
|
|
dm_list_iterate_items(devl, devs) {
|
|
if (_in_bcache(devl->dev)) {
|
|
- bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
_scan_dev_close(devl->dev);
|
|
}
|
|
}
|
|
@@ -1138,7 +1146,7 @@ int label_scan_devs_rw(struct cmd_contex
|
|
|
|
dm_list_iterate_items(devl, devs) {
|
|
if (_in_bcache(devl->dev)) {
|
|
- bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
_scan_dev_close(devl->dev);
|
|
}
|
|
/*
|
|
@@ -1160,7 +1168,7 @@ int label_scan_devs_excl(struct dm_list
|
|
|
|
dm_list_iterate_items(devl, devs) {
|
|
if (_in_bcache(devl->dev)) {
|
|
- bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, devl->dev->bcache_fd);
|
|
_scan_dev_close(devl->dev);
|
|
}
|
|
/*
|
|
@@ -1180,7 +1188,7 @@ int label_scan_devs_excl(struct dm_list
|
|
void label_scan_invalidate(struct device *dev)
|
|
{
|
|
if (_in_bcache(dev)) {
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
}
|
|
}
|
|
@@ -1262,7 +1270,7 @@ int label_read(struct device *dev)
|
|
dm_list_add(&one_dev, &devl->list);
|
|
|
|
if (_in_bcache(dev)) {
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
}
|
|
|
|
@@ -1304,7 +1312,7 @@ int label_scan_open_excl(struct device *
|
|
if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_EXCL)) {
|
|
/* FIXME: avoid tossing out bcache blocks just to replace fd. */
|
|
log_debug("Close and reopen excl %s", dev_name(dev));
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
}
|
|
dev->flags |= DEV_BCACHE_EXCL;
|
|
@@ -1317,7 +1325,7 @@ int label_scan_open_rw(struct device *de
|
|
if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
|
|
/* FIXME: avoid tossing out bcache blocks just to replace fd. */
|
|
log_debug("Close and reopen rw %s", dev_name(dev));
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
}
|
|
dev->flags |= DEV_BCACHE_WRITE;
|
|
@@ -1365,7 +1373,7 @@ bool dev_write_bytes(struct device *dev,
|
|
if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
|
|
/* FIXME: avoid tossing out bcache blocks just to replace fd. */
|
|
log_debug("Close and reopen to write %s", dev_name(dev));
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
|
|
dev->flags |= DEV_BCACHE_WRITE;
|
|
@@ -1411,7 +1419,7 @@ bool dev_write_zeros(struct device *dev,
|
|
if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
|
|
/* FIXME: avoid tossing out bcache blocks just to replace fd. */
|
|
log_debug("Close and reopen to write %s", dev_name(dev));
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
|
|
dev->flags |= DEV_BCACHE_WRITE;
|
|
@@ -1462,7 +1470,7 @@ bool dev_set_bytes(struct device *dev, u
|
|
if (_in_bcache(dev) && !(dev->flags & DEV_BCACHE_WRITE)) {
|
|
/* FIXME: avoid tossing out bcache blocks just to replace fd. */
|
|
log_debug("Close and reopen to write %s", dev_name(dev));
|
|
- bcache_invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
+ _invalidate_fd(scan_bcache, dev->bcache_fd);
|
|
_scan_dev_close(dev);
|
|
/* goes to label_scan_open() since bcache_fd < 0 */
|
|
}
|