aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2019-05-22 22:21:37 +0800
committerColy Li <colyli@suse.de>2019-05-22 22:21:37 +0800
commit6a5ea9440648aac00d5d1d04a8b5563695c60e51 (patch)
tree5412c9cf4725f11d661376e18c4186b12eb8992b
parent9ef6bfa4f850aebe006ae92f945fbbdae6d011fd (diff)
downloadbcache-patches-6a5ea9440648aac00d5d1d04a8b5563695c60e51.tar.gz
for-test: remove tested or out-of-date patches
for-next: add new patches
-rw-r--r--for-next/0001-bcache-ignore-read-ahead-request-failure-on-backing-.patch2
-rw-r--r--for-next/0002-bcache-add-io-error-counting-in-write_bdev_super_end.patch2
-rw-r--r--for-next/0003-bcache-remove-XXX-comment-line-from-run_cache_set.patch2
-rw-r--r--for-next/0004-bcache-remove-unnecessary-prefetch-in-bset_search_tr.patch2
-rw-r--r--for-next/0005-bcache-make-bset_search_tree-be-more-understandable.patch2
-rw-r--r--for-next/0006-bcache-use-sysfs_match_string-instead-of-__sysfs_mat.patch2
-rw-r--r--for-next/0007-bcache-add-return-value-check-to-bch_cached_dev_run.patch2
-rw-r--r--for-next/0008-bcache-wake-up-allocator-thread-before-waiting-for-a.patch2
-rw-r--r--for-next/0009-bcache-remove-unncessary-code-in-bch_btree_keys_init.patch2
-rw-r--r--for-next/0010-bcache-avoid-a-deadlock-in-bcache_reboot.patch31
-rw-r--r--for-next/0011-bcache-check-CACHE_SET_IO_DISABLE-in-allocator-code.patch52
-rw-r--r--for-next/0012-bcache-check-CACHE_SET_IO_DISABLE-bit-in-bch_journal.patch39
-rw-r--r--for-test/0001-bcache-add-return-value-check-for-bch_uuid_write.patch254
-rw-r--r--for-test/0001-bcache-add-return-value-check-more.patch301
-rw-r--r--for-test/0001-more-return-value-check.patch234
15 files changed, 120 insertions, 809 deletions
diff --git a/for-next/0001-bcache-ignore-read-ahead-request-failure-on-backing-.patch b/for-next/0001-bcache-ignore-read-ahead-request-failure-on-backing-.patch
index e901d2d..addd86d 100644
--- a/for-next/0001-bcache-ignore-read-ahead-request-failure-on-backing-.patch
+++ b/for-next/0001-bcache-ignore-read-ahead-request-failure-on-backing-.patch
@@ -1,7 +1,7 @@
From 31dc685d78b6f77ddd3d4ffa97478431a6602ed9 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 13 May 2019 22:48:09 +0800
-Subject: [PATCH 01/10] bcache: ignore read-ahead request failure on backing
+Subject: [PATCH 01/12] bcache: ignore read-ahead request failure on backing
device
When md raid device (e.g. raid456) is used as backing device, read-ahead
diff --git a/for-next/0002-bcache-add-io-error-counting-in-write_bdev_super_end.patch b/for-next/0002-bcache-add-io-error-counting-in-write_bdev_super_end.patch
index 5b2576b..6fc12db 100644
--- a/for-next/0002-bcache-add-io-error-counting-in-write_bdev_super_end.patch
+++ b/for-next/0002-bcache-add-io-error-counting-in-write_bdev_super_end.patch
@@ -1,7 +1,7 @@
From 1ccada2ebb2f37fbe2b0a3705a3166e4f3f8d2fb Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 13 May 2019 23:42:39 +0800
-Subject: [PATCH 02/10] bcache: add io error counting in
+Subject: [PATCH 02/12] bcache: add io error counting in
write_bdev_super_endio()
When backing device super block is written by bch_write_bdev_super(),
diff --git a/for-next/0003-bcache-remove-XXX-comment-line-from-run_cache_set.patch b/for-next/0003-bcache-remove-XXX-comment-line-from-run_cache_set.patch
index 876ff77..f8ace2a 100644
--- a/for-next/0003-bcache-remove-XXX-comment-line-from-run_cache_set.patch
+++ b/for-next/0003-bcache-remove-XXX-comment-line-from-run_cache_set.patch
@@ -1,7 +1,7 @@
From 5e92305f8838785b2c42ed2cb8c5f2bc03103e94 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 13 May 2019 23:47:38 +0800
-Subject: [PATCH 03/10] bcache: remove "XXX:" comment line from run_cache_set()
+Subject: [PATCH 03/12] bcache: remove "XXX:" comment line from run_cache_set()
In previous bcache patches for Linux v5.2, the failure code path of
run_cache_set() is tested and fixed. So now the following comment
diff --git a/for-next/0004-bcache-remove-unnecessary-prefetch-in-bset_search_tr.patch b/for-next/0004-bcache-remove-unnecessary-prefetch-in-bset_search_tr.patch
index 7098e06..f3abd0e 100644
--- a/for-next/0004-bcache-remove-unnecessary-prefetch-in-bset_search_tr.patch
+++ b/for-next/0004-bcache-remove-unnecessary-prefetch-in-bset_search_tr.patch
@@ -1,7 +1,7 @@
From 77980a54c7e90525e8cada5b75bc44daa214d9e5 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Tue, 14 May 2019 22:23:35 +0800
-Subject: [PATCH 04/10] bcache: remove unnecessary prefetch() in
+Subject: [PATCH 04/12] bcache: remove unnecessary prefetch() in
bset_search_tree()
In function bset_search_tree(), when p >= t->size, t->tree[0] will be
diff --git a/for-next/0005-bcache-make-bset_search_tree-be-more-understandable.patch b/for-next/0005-bcache-make-bset_search_tree-be-more-understandable.patch
index 31ee755..7534bb6 100644
--- a/for-next/0005-bcache-make-bset_search_tree-be-more-understandable.patch
+++ b/for-next/0005-bcache-make-bset_search_tree-be-more-understandable.patch
@@ -1,7 +1,7 @@
From 5e31e419f54eb8db7f4e95bf9328523e801c1dfb Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Tue, 14 May 2019 22:51:40 +0800
-Subject: [PATCH 05/10] bcache: make bset_search_tree() be more understandable
+Subject: [PATCH 05/12] bcache: make bset_search_tree() be more understandable
The purpose of following code in bset_search_tree() is to avoid a branch
instruction,
diff --git a/for-next/0006-bcache-use-sysfs_match_string-instead-of-__sysfs_mat.patch b/for-next/0006-bcache-use-sysfs_match_string-instead-of-__sysfs_mat.patch
index ade16af..242ad1c 100644
--- a/for-next/0006-bcache-use-sysfs_match_string-instead-of-__sysfs_mat.patch
+++ b/for-next/0006-bcache-use-sysfs_match_string-instead-of-__sysfs_mat.patch
@@ -1,7 +1,7 @@
From a6bdbacfd6a798edcceaaae5fe48fd2403a4c93a Mon Sep 17 00:00:00 2001
From: Alexandru Ardelean <alexandru.ardelean@analog.com>
Date: Tue, 7 May 2019 12:43:12 +0300
-Subject: [PATCH 06/10] bcache: use sysfs_match_string() instead of
+Subject: [PATCH 06/12] bcache: use sysfs_match_string() instead of
__sysfs_match_string()
The arrays (of strings) that are passed to __sysfs_match_string() are
diff --git a/for-next/0007-bcache-add-return-value-check-to-bch_cached_dev_run.patch b/for-next/0007-bcache-add-return-value-check-to-bch_cached_dev_run.patch
index dcb6ded..010ae78 100644
--- a/for-next/0007-bcache-add-return-value-check-to-bch_cached_dev_run.patch
+++ b/for-next/0007-bcache-add-return-value-check-to-bch_cached_dev_run.patch
@@ -1,7 +1,7 @@
From 8e29cf9a5dc6f5c7e06f7c9bc516a1e03a998f85 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Tue, 21 May 2019 22:16:38 +0800
-Subject: [PATCH 07/10] bcache: add return value check to bch_cached_dev_run()
+Subject: [PATCH 07/12] bcache: add return value check to bch_cached_dev_run()
This patch adds return value check to bch_cached_dev_run(), now if there
is error happens inside bch_cached_dev_run(), it can be catched.
diff --git a/for-next/0008-bcache-wake-up-allocator-thread-before-waiting-for-a.patch b/for-next/0008-bcache-wake-up-allocator-thread-before-waiting-for-a.patch
index c94b68f..ea7e06b 100644
--- a/for-next/0008-bcache-wake-up-allocator-thread-before-waiting-for-a.patch
+++ b/for-next/0008-bcache-wake-up-allocator-thread-before-waiting-for-a.patch
@@ -1,7 +1,7 @@
From bc49a3f47899f6f24a9eb555cf94d5d72f724ed8 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 19 Mar 2018 23:39:32 +0800
-Subject: [PATCH 08/10] bcache: wake up allocator thread before waiting for
+Subject: [PATCH 08/12] bcache: wake up allocator thread before waiting for
available buckets
Currently alloc.c:bch_bucket_alloc() wakes up allocator thread after
diff --git a/for-next/0009-bcache-remove-unncessary-code-in-bch_btree_keys_init.patch b/for-next/0009-bcache-remove-unncessary-code-in-bch_btree_keys_init.patch
index 58c8468..ed3773b 100644
--- a/for-next/0009-bcache-remove-unncessary-code-in-bch_btree_keys_init.patch
+++ b/for-next/0009-bcache-remove-unncessary-code-in-bch_btree_keys_init.patch
@@ -1,7 +1,7 @@
From b2dbb2ca3139d14e63cf70604ac057025e9488df Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Tue, 21 May 2019 22:36:35 +0800
-Subject: [PATCH 09/10] bcache: remove unncessary code in bch_btree_keys_init()
+Subject: [PATCH 09/12] bcache: remove unncessary code in bch_btree_keys_init()
Function bch_btree_keys_init() initializes b->set[].size and
b->set[].data to zero. As the code comments indicates, these code indeed
diff --git a/for-next/0010-bcache-avoid-a-deadlock-in-bcache_reboot.patch b/for-next/0010-bcache-avoid-a-deadlock-in-bcache_reboot.patch
index 0adcce9..874a17d 100644
--- a/for-next/0010-bcache-avoid-a-deadlock-in-bcache_reboot.patch
+++ b/for-next/0010-bcache-avoid-a-deadlock-in-bcache_reboot.patch
@@ -1,7 +1,7 @@
-From b7f3bc63bb2d5bba048eacb1aa8618651d091ea9 Mon Sep 17 00:00:00 2001
+From a2182231368fdba0c9b2d990fc910065290fdda4 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Tue, 21 May 2019 23:19:55 +0800
-Subject: [PATCH 10/10] bcache: avoid a deadlock in bcache_reboot()
+Subject: [PATCH 10/12] bcache: avoid a deadlock in bcache_reboot()
It is quite frequently to observe deadlock in bcache_reboot() happens
and hang the system reboot process. The reason is, in bcache_reboot()
@@ -41,8 +41,8 @@ acceptable as cost for the simple fix.
Signed-off-by: Coly Li <colyli@suse.de>
---
drivers/md/bcache/super.c | 35 ++++++++++++++++++++++++++++++++++-
- drivers/md/bcache/sysfs.c | 24 ++++++++++++++++++++++++
- 2 files changed, 58 insertions(+), 1 deletion(-)
+ drivers/md/bcache/sysfs.c | 26 ++++++++++++++++++++++++++
+ 2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 34653cdcdd4a..bf177cbc3cff 100644
@@ -133,10 +133,19 @@ index 34653cdcdd4a..bf177cbc3cff 100644
err:
bcache_exit();
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index 129031663cc8..f42d4b7effd4 100644
+index 129031663cc8..961a13a223ee 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
-@@ -267,6 +267,10 @@ STORE(__cached_dev)
+@@ -16,6 +16,8 @@
+ #include <linux/sort.h>
+ #include <linux/sched/clock.h>
+
++extern bool bcache_is_reboot;
++
+ /* Default is 0 ("writethrough") */
+ static const char * const bch_cache_modes[] = {
+ "writethrough",
+@@ -267,6 +269,10 @@ STORE(__cached_dev)
struct cache_set *c;
struct kobj_uevent_env *env;
@@ -147,7 +156,7 @@ index 129031663cc8..f42d4b7effd4 100644
#define d_strtoul(var) sysfs_strtoul(var, dc->var)
#define d_strtoul_nonzero(var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX)
#define d_strtoi_h(var) sysfs_hatoi(var, dc->var)
-@@ -407,6 +411,10 @@ STORE(bch_cached_dev)
+@@ -407,6 +413,10 @@ STORE(bch_cached_dev)
struct cached_dev *dc = container_of(kobj, struct cached_dev,
disk.kobj);
@@ -158,7 +167,7 @@ index 129031663cc8..f42d4b7effd4 100644
mutex_lock(&bch_register_lock);
size = __cached_dev_store(kobj, attr, buf, size);
-@@ -505,6 +513,10 @@ STORE(__bch_flash_dev)
+@@ -505,6 +515,10 @@ STORE(__bch_flash_dev)
kobj);
struct uuid_entry *u = &d->c->uuids[d->id];
@@ -169,7 +178,7 @@ index 129031663cc8..f42d4b7effd4 100644
sysfs_strtoul(data_csum, d->data_csum);
if (attr == &sysfs_size) {
-@@ -740,6 +752,10 @@ STORE(__bch_cache_set)
+@@ -740,6 +754,10 @@ STORE(__bch_cache_set)
struct cache_set *c = container_of(kobj, struct cache_set, kobj);
ssize_t v;
@@ -180,7 +189,7 @@ index 129031663cc8..f42d4b7effd4 100644
if (attr == &sysfs_unregister)
bch_cache_set_unregister(c);
-@@ -859,6 +875,10 @@ STORE(bch_cache_set_internal)
+@@ -859,6 +877,10 @@ STORE(bch_cache_set_internal)
{
struct cache_set *c = container_of(kobj, struct cache_set, internal);
@@ -191,7 +200,7 @@ index 129031663cc8..f42d4b7effd4 100644
return bch_cache_set_store(&c->kobj, attr, buf, size);
}
-@@ -1044,6 +1064,10 @@ STORE(__bch_cache)
+@@ -1044,6 +1066,10 @@ STORE(__bch_cache)
struct cache *ca = container_of(kobj, struct cache, kobj);
ssize_t v;
diff --git a/for-next/0011-bcache-check-CACHE_SET_IO_DISABLE-in-allocator-code.patch b/for-next/0011-bcache-check-CACHE_SET_IO_DISABLE-in-allocator-code.patch
new file mode 100644
index 0000000..0cab5d9
--- /dev/null
+++ b/for-next/0011-bcache-check-CACHE_SET_IO_DISABLE-in-allocator-code.patch
@@ -0,0 +1,52 @@
+From 332399ce57135a13f6aba7f837ef7e1e80b66ec0 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Wed, 22 May 2019 21:55:09 +0800
+Subject: [PATCH 11/12] bcache: check CACHE_SET_IO_DISABLE in allocator code
+
+If CACHE_SET_IO_DISABLE of a cache set flag is set by too many I/O
+errors, currently allocator routines can still continue allocate
+space which may introduce inconsistent metadata state.
+
+This patch checkes CACHE_SET_IO_DISABLE bit in following allocator
+routines,
+- bch_bucket_alloc()
+- __bch_bucket_alloc_set()
+Once CACHE_SET_IO_DISABLE is set on cache set, the allocator routines
+may reject allocation request earlier to avoid potential inconsistent
+metadata.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/md/bcache/alloc.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
+index c543f378abb4..a0a8d459e25a 100644
+--- a/drivers/md/bcache/alloc.c
++++ b/drivers/md/bcache/alloc.c
+@@ -393,6 +393,11 @@ long bch_bucket_alloc(struct cache *ca, unsigned int reserve, bool wait)
+ struct bucket *b;
+ long r;
+
++
++ /* No allocation if CACHE_SET_IO_DISABLE set */
++ if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &ca->set->flags)))
++ return -1;
++
+ /* fastpath */
+ if (fifo_pop(&ca->free[RESERVE_NONE], r) ||
+ fifo_pop(&ca->free[reserve], r))
+@@ -489,6 +494,10 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,
+ {
+ int i;
+
++ /* No allocation if CACHE_SET_IO_DISABLE set */
++ if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &c->flags)))
++ return -1;
++
+ lockdep_assert_held(&c->bucket_lock);
+ BUG_ON(!n || n > c->caches_loaded || n > MAX_CACHES_PER_SET);
+
+--
+2.16.4
+
diff --git a/for-next/0012-bcache-check-CACHE_SET_IO_DISABLE-bit-in-bch_journal.patch b/for-next/0012-bcache-check-CACHE_SET_IO_DISABLE-bit-in-bch_journal.patch
new file mode 100644
index 0000000..c6a8756
--- /dev/null
+++ b/for-next/0012-bcache-check-CACHE_SET_IO_DISABLE-bit-in-bch_journal.patch
@@ -0,0 +1,39 @@
+From 33aedb5752649cff8b804a5b567c851e10f3905b Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Wed, 22 May 2019 22:06:21 +0800
+Subject: [PATCH 12/12] bcache: check CACHE_SET_IO_DISABLE bit in bch_journal()
+
+When too many I/O errors happen on cache set and CACHE_SET_IO_DISABLE
+bit is set, bch_journal() may continue to work because the journaling
+bkey might be still in write set yet. The caller of bch_journal() may
+believe the journal still work but the truth is in-memory journal write
+set won't be written into cache device any more. This behavior may
+introduce potential inconsistent metadata status.
+
+This patch checks CACHE_SET_IO_DISABLE bit at the head of bch_journal(),
+if the bit is set, bch_journal() returns NULL immediately to notice
+caller to know journal does not work.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/md/bcache/journal.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
+index 12dae9348147..d4b9817f2237 100644
+--- a/drivers/md/bcache/journal.c
++++ b/drivers/md/bcache/journal.c
+@@ -811,6 +811,10 @@ atomic_t *bch_journal(struct cache_set *c,
+ struct journal_write *w;
+ atomic_t *ret;
+
++ /* No journaling if CACHE_SET_IO_DISABLE set already */
++ if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &c->flags)))
++ return NULL;
++
+ if (!CACHE_SYNC(&c->sb))
+ return NULL;
+
+--
+2.16.4
+
diff --git a/for-test/0001-bcache-add-return-value-check-for-bch_uuid_write.patch b/for-test/0001-bcache-add-return-value-check-for-bch_uuid_write.patch
deleted file mode 100644
index 106dafe..0000000
--- a/for-test/0001-bcache-add-return-value-check-for-bch_uuid_write.patch
+++ /dev/null
@@ -1,254 +0,0 @@
-From 80cdc02dc1ed2c9cb2e62066493f331374eaa8f6 Mon Sep 17 00:00:00 2001
-From: Coly Li <colyli@suse.de>
-Date: Tue, 21 Nov 2017 02:05:18 +0800
-Subject: [PATCH] bcache: add return value check for bch_uuid_write()
-
----
- drivers/md/bcache/super.c | 61 +++++++++++++++++++++++++++++++++++------------
- drivers/md/bcache/sysfs.c | 23 ++++++++++++++----
- drivers/md/bcache/util.h | 11 +++++++++
- 3 files changed, 75 insertions(+), 20 deletions(-)
-
-diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index 8e74382cd2c2..e5851f456225 100644
---- a/drivers/md/bcache/super.c
-+++ b/drivers/md/bcache/super.c
-@@ -427,7 +427,7 @@ static int __uuid_write(struct cache_set *c)
- lockdep_assert_held(&bch_register_lock);
-
- if (bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, true))
-- return 1;
-+ return -ENOSPC;
-
- SET_KEY_SIZE(&k.key, c->sb.bucket_size);
- uuid_io(c, REQ_OP_WRITE, 0, &k.key, &cl);
-@@ -440,11 +440,18 @@ static int __uuid_write(struct cache_set *c)
-
- int bch_uuid_write(struct cache_set *c)
- {
-- int ret = __uuid_write(c);
-+ int ret = -EIO;
-
-- if (!ret)
-- bch_journal_meta(c, NULL);
-+ if (atomic_read(&c->io_disabled))
-+ goto out;
-+
-+ ret =__uuid_write(c);
-+ if (ret)
-+ goto out;
-
-+ ret = bch_journal_meta(c, NULL);
-+
-+out:
- return ret;
- }
-
-@@ -696,6 +703,8 @@ static void bcache_device_link(struct bcache_device *d, struct cache_set *c,
-
- static void bcache_device_detach(struct bcache_device *d)
- {
-+ int err = 0;
-+
- lockdep_assert_held(&bch_register_lock);
-
- if (test_bit(BCACHE_DEV_DETACHING, &d->flags)) {
-@@ -704,7 +713,9 @@ static void bcache_device_detach(struct bcache_device *d)
- SET_UUID_FLASH_ONLY(u, 0);
- memcpy(u->uuid, invalid_uuid, 16);
- u->invalidated = cpu_to_le32(get_seconds());
-- bch_uuid_write(d->c);
-+ err = bch_uuid_write(d->c);
-+ if (err)
-+ uuid_write_pr_err(err);
- }
-
- bcache_device_unlink(d);
-@@ -951,27 +962,31 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- uint32_t rtime = cpu_to_le32(get_seconds());
- struct uuid_entry *u;
- char buf[BDEVNAME_SIZE];
-+ int ret = -ENOENT;
-
- bdevname(dc->bdev, buf);
-
- if (memcmp(dc->sb.set_uuid, c->sb.set_uuid, 16))
-- return -ENOENT;
-+ goto out;
-
- if (dc->disk.c) {
- pr_err("Can't attach %s: already attached", buf);
-- return -EINVAL;
-+ ret = -EINVAL;
-+ goto out;
- }
-
- if (test_bit(CACHE_SET_STOPPING, &c->flags)) {
- pr_err("Can't attach %s: shutting down", buf);
-- return -EINVAL;
-+ ret = -EINVAL;
-+ goto out;
- }
-
- if (dc->sb.block_size < c->sb.block_size) {
- /* Will die */
- pr_err("Couldn't attach %s: block size less than set's block size",
- buf);
-- return -EINVAL;
-+ ret = -EINVAL;
-+ goto out;
- }
-
- u = uuid_find(c, dc->sb.uuid);
-@@ -987,13 +1002,15 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- if (!u) {
- if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
- pr_err("Couldn't find uuid for %s in set", buf);
-- return -ENOENT;
-+ ret = -ENOENT;
-+ goto out;
- }
-
- u = uuid_find_empty(c);
- if (!u) {
- pr_err("Not caching %s, no room for UUID", buf);
-- return -EINVAL;
-+ ret = -EINVAL;
-+ goto out;
- }
- }
-
-@@ -1008,7 +1025,11 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- memcpy(u->uuid, dc->sb.uuid, 16);
- memcpy(u->label, dc->sb.label, SB_LABEL_SIZE);
- u->first_reg = u->last_reg = rtime;
-- bch_uuid_write(c);
-+ ret = bch_uuid_write(c);
-+ if (ret) {
-+ uuid_write_pr_err(ret);
-+ goto out;
-+ }
-
- memcpy(dc->sb.set_uuid, c->sb.set_uuid, 16);
- SET_BDEV_STATE(&dc->sb, BDEV_STATE_CLEAN);
-@@ -1017,7 +1038,11 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- closure_sync(&cl);
- } else {
- u->last_reg = rtime;
-- bch_uuid_write(c);
-+ ret = bch_uuid_write(c);
-+ if (ret) {
-+ uuid_write_pr_err(ret);
-+ goto out;
-+ }
- }
-
- bcache_device_attach(&dc->disk, c, u - c->uuids);
-@@ -1054,7 +1079,9 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- pr_info("Caching %s as %s on set %pU",
- bdevname(dc->bdev, buf), dc->disk.disk->disk_name,
- dc->disk.c->sb.set_uuid);
-- return 0;
-+ ret = 0;
-+out:
-+ return ret;
- }
-
- void bch_cached_dev_release(struct kobject *kobj)
-@@ -1293,7 +1320,11 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
- SET_UUID_FLASH_ONLY(u, 1);
- u->sectors = size >> 9;
-
-- bch_uuid_write(c);
-+ ret = bch_uuid_write(c);
-+ if (ret) {
-+ uuid_write_pr_err(ret);
-+ return ret;
-+ }
-
- return flash_dev_run(c, u);
- }
-diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index b4184092c727..f8e22212853e 100644
---- a/drivers/md/bcache/sysfs.c
-+++ b/drivers/md/bcache/sysfs.c
-@@ -253,7 +253,11 @@ STORE(__cached_dev)
- if (dc->disk.c) {
- memcpy(dc->disk.c->uuids[dc->disk.id].label,
- buf, SB_LABEL_SIZE);
-- bch_uuid_write(dc->disk.c);
-+ ret = bch_uuid_write(dc->disk.c);
-+ if (ret) {
-+ uuid_write_pr_err(ret);
-+ return ret;
-+ }
- }
- env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
- if (!env)
-@@ -366,6 +370,7 @@ STORE(__bch_flash_dev)
- struct bcache_device *d = container_of(kobj, struct bcache_device,
- kobj);
- struct uuid_entry *u = &d->c->uuids[d->id];
-+ int ret = size;
-
- sysfs_strtoul(data_csum, d->data_csum);
-
-@@ -374,21 +379,29 @@ STORE(__bch_flash_dev)
- strtoi_h_or_return(buf, v);
-
- u->sectors = v >> 9;
-- bch_uuid_write(d->c);
-+ ret = bch_uuid_write(d->c);
-+ if (ret) {
-+ uuid_write_pr_err(ret);
-+ goto out;
-+ }
- set_capacity(d->disk, u->sectors);
- }
-
- if (attr == &sysfs_label) {
- memcpy(u->label, buf, SB_LABEL_SIZE);
-- bch_uuid_write(d->c);
-+ ret = bch_uuid_write(d->c);
-+ if (ret) {
-+ uuid_write_pr_err(ret);
-+ goto out;
-+ }
- }
-
- if (attr == &sysfs_unregister) {
- set_bit(BCACHE_DEV_DETACHING, &d->flags);
- bcache_device_stop(d);
- }
--
-- return size;
-+out:
-+ return ret;
- }
- STORE_LOCKED(bch_flash_dev)
-
-diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
-index ed5e8a412eb8..9e4e54660729 100644
---- a/drivers/md/bcache/util.h
-+++ b/drivers/md/bcache/util.h
-@@ -564,6 +564,17 @@ static inline sector_t bdev_sectors(struct block_device *bdev)
- return bdev->bd_inode->i_size >> 9;
- }
-
-+static inline void uuid_write_pr_err(int err)
-+{
-+ pr_err("Can't write uuid %s");
-+ if (ret == -EIO)
-+ pr_err(", I/O error.");
-+ else if(ret == -ENOSPC)
-+ pr_err(", no space.");
-+ else
-+ pr_err(".");
-+}
-+
- #define closure_bio_submit(bio, cl) \
- do { \
- closure_get(cl); \
---
-2.13.6
-
diff --git a/for-test/0001-bcache-add-return-value-check-more.patch b/for-test/0001-bcache-add-return-value-check-more.patch
deleted file mode 100644
index 18bb3f0..0000000
--- a/for-test/0001-bcache-add-return-value-check-more.patch
+++ /dev/null
@@ -1,301 +0,0 @@
-From 7f711b556001b72e4af455266ca6126adfca0fb0 Mon Sep 17 00:00:00 2001
-From: Coly Li <colyli@suse.de>
-Date: Tue, 28 Nov 2017 01:12:02 +0800
-Subject: [PATCH] bcache: add return value check, more
-
----
- drivers/md/bcache/bcache.h | 2 +-
- drivers/md/bcache/journal.c | 9 ++++++++-
- drivers/md/bcache/journal.h | 2 +-
- drivers/md/bcache/super.c | 31 ++++++++++++++++++++-----------
- drivers/md/bcache/sysfs.c | 8 ++++----
- drivers/md/bcache/util.h | 14 ++++++++------
- drivers/md/bcache/writeback.c | 10 +++++++---
- drivers/md/bcache/writeback.h | 2 +-
- 8 files changed, 50 insertions(+), 28 deletions(-)
-
-diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index 35410171798c..82e2bb39f8ed 100644
---- a/drivers/md/bcache/bcache.h
-+++ b/drivers/md/bcache/bcache.h
-@@ -904,7 +904,7 @@ void bch_flash_dev_release(struct kobject *);
- void bch_cache_set_release(struct kobject *);
- void bch_cache_release(struct kobject *);
-
--int bch_uuid_write(struct cache_set *);
-+int bch_uuid_write(struct cache_set *, struct cached_dev *);
- void bcache_write_super(struct cache_set *);
-
- int bch_flash_dev_create(struct cache_set *c, uint64_t size);
-diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
-index 02a98ddb592d..c9abfbed667b 100644
---- a/drivers/md/bcache/journal.c
-+++ b/drivers/md/bcache/journal.c
-@@ -783,16 +783,23 @@ atomic_t *bch_journal(struct cache_set *c,
- return ret;
- }
-
--void bch_journal_meta(struct cache_set *c, struct closure *cl)
-+int bch_journal_meta(struct cache_set *c, struct closure *cl)
- {
- struct keylist keys;
- atomic_t *ref;
-+ struct cached_dev *dc;
-+
-+ dc = container_of(cl, struct cached_dev, disk.cl);
-+ if (dc && atomic_read(&dc->io_disabled))
-+ return -EIO;
-
- bch_keylist_init(&keys);
-
- ref = bch_journal(c, &keys, cl);
- if (ref)
- atomic_dec_bug(ref);
-+
-+ return 0;
- }
-
- void bch_journal_free(struct cache_set *c)
-diff --git a/drivers/md/bcache/journal.h b/drivers/md/bcache/journal.h
-index b5788199188f..23434d8313d5 100644
---- a/drivers/md/bcache/journal.h
-+++ b/drivers/md/bcache/journal.h
-@@ -170,7 +170,7 @@ struct keylist;
- atomic_t *bch_journal(struct cache_set *, struct keylist *, struct closure *);
- void bch_journal_next(struct journal *);
- void bch_journal_mark(struct cache_set *, struct list_head *);
--void bch_journal_meta(struct cache_set *, struct closure *);
-+int bch_journal_meta(struct cache_set *, struct closure *);
- int bch_journal_read(struct cache_set *, struct list_head *);
- int bch_journal_replay(struct cache_set *, struct list_head *);
-
-diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index e5851f456225..27c0317f5b6b 100644
---- a/drivers/md/bcache/super.c
-+++ b/drivers/md/bcache/super.c
-@@ -438,11 +438,11 @@ static int __uuid_write(struct cache_set *c)
- return 0;
- }
-
--int bch_uuid_write(struct cache_set *c)
-+int bch_uuid_write(struct cache_set *c, struct cached_dev *dc)
- {
- int ret = -EIO;
-
-- if (atomic_read(&c->io_disabled))
-+ if (dc && atomic_read(&dc->io_disabled))
- goto out;
-
- ret =__uuid_write(c);
-@@ -704,6 +704,7 @@ static void bcache_device_link(struct bcache_device *d, struct cache_set *c,
- static void bcache_device_detach(struct bcache_device *d)
- {
- int err = 0;
-+ struct cached_dev *dc = container_of(d, struct cached_dev, disk);
-
- lockdep_assert_held(&bch_register_lock);
-
-@@ -713,7 +714,7 @@ static void bcache_device_detach(struct bcache_device *d)
- SET_UUID_FLASH_ONLY(u, 0);
- memcpy(u->uuid, invalid_uuid, 16);
- u->invalidated = cpu_to_le32(get_seconds());
-- err = bch_uuid_write(d->c);
-+ err = bch_uuid_write(d->c, dc);
- if (err)
- uuid_write_pr_err(err);
- }
-@@ -1025,7 +1026,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- memcpy(u->uuid, dc->sb.uuid, 16);
- memcpy(u->label, dc->sb.label, SB_LABEL_SIZE);
- u->first_reg = u->last_reg = rtime;
-- ret = bch_uuid_write(c);
-+ ret = bch_uuid_write(c, dc);
- if (ret) {
- uuid_write_pr_err(ret);
- goto out;
-@@ -1038,7 +1039,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- closure_sync(&cl);
- } else {
- u->last_reg = rtime;
-- ret = bch_uuid_write(c);
-+ ret = bch_uuid_write(c, dc);
- if (ret) {
- uuid_write_pr_err(ret);
- goto out;
-@@ -1064,7 +1065,9 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
- }
-
- if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
-- bch_sectors_dirty_init(&dc->disk);
-+ ret = bch_sectors_dirty_init(&dc->disk);
-+ if (ret)
-+ goto out;
- atomic_set(&dc->has_dirty, 1);
- refcount_inc(&dc->count);
- bch_writeback_queue(dc);
-@@ -1254,6 +1257,7 @@ static void flash_dev_flush(struct closure *cl)
-
- static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
- {
-+ int ret = -ENOMEM;
- struct bcache_device *d = kzalloc(sizeof(struct bcache_device),
- GFP_KERNEL);
- if (!d)
-@@ -1264,15 +1268,19 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
-
- kobject_init(&d->kobj, &bch_flash_dev_ktype);
-
-- if (bcache_device_init(d, block_bytes(c), u->sectors))
-+ ret = bcache_device_init(d, block_bytes(c), u->sectors);
-+ if (ret)
- goto err;
-
- bcache_device_attach(d, c, u - c->uuids);
-- bch_sectors_dirty_init(d);
-+ ret = bch_sectors_dirty_init(d);
-+ if (ret)
-+ goto err;
- bch_flash_dev_request_init(d);
- add_disk(d->disk);
-
-- if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache"))
-+ ret = kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache");
-+ if (ret)
- goto err;
-
- bcache_device_link(d, c, "volume");
-@@ -1280,7 +1288,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
- return 0;
- err:
- kobject_put(&d->kobj);
-- return -ENOMEM;
-+ return ret;
- }
-
- static int flash_devs_run(struct cache_set *c)
-@@ -1300,6 +1308,7 @@ static int flash_devs_run(struct cache_set *c)
- int bch_flash_dev_create(struct cache_set *c, uint64_t size)
- {
- struct uuid_entry *u;
-+ int ret;
-
- if (test_bit(CACHE_SET_STOPPING, &c->flags))
- return -EINTR;
-@@ -1320,7 +1329,7 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
- SET_UUID_FLASH_ONLY(u, 1);
- u->sectors = size >> 9;
-
-- ret = bch_uuid_write(c);
-+ ret = bch_uuid_write(c, NULL);
- if (ret) {
- uuid_write_pr_err(ret);
- return ret;
-diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index f8e22212853e..ddba4be1329a 100644
---- a/drivers/md/bcache/sysfs.c
-+++ b/drivers/md/bcache/sysfs.c
-@@ -198,7 +198,7 @@ STORE(__cached_dev)
- ssize_t v = size;
- struct cache_set *c;
- struct kobj_uevent_env *env;
--
-+ int ret;
- #define d_strtoul(var) sysfs_strtoul(var, dc->var)
- #define d_strtoul_nonzero(var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX)
- #define d_strtoi_h(var) sysfs_hatoi(var, dc->var)
-@@ -253,7 +253,7 @@ STORE(__cached_dev)
- if (dc->disk.c) {
- memcpy(dc->disk.c->uuids[dc->disk.id].label,
- buf, SB_LABEL_SIZE);
-- ret = bch_uuid_write(dc->disk.c);
-+ ret = bch_uuid_write(dc->disk.c, dc);
- if (ret) {
- uuid_write_pr_err(ret);
- return ret;
-@@ -379,7 +379,7 @@ STORE(__bch_flash_dev)
- strtoi_h_or_return(buf, v);
-
- u->sectors = v >> 9;
-- ret = bch_uuid_write(d->c);
-+ ret = bch_uuid_write(d->c, NULL);
- if (ret) {
- uuid_write_pr_err(ret);
- goto out;
-@@ -389,7 +389,7 @@ STORE(__bch_flash_dev)
-
- if (attr == &sysfs_label) {
- memcpy(u->label, buf, SB_LABEL_SIZE);
-- ret = bch_uuid_write(d->c);
-+ ret = bch_uuid_write(d->c, NULL);
- if (ret) {
- uuid_write_pr_err(ret);
- goto out;
-diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
-index 9e4e54660729..3ce66880c9fb 100644
---- a/drivers/md/bcache/util.h
-+++ b/drivers/md/bcache/util.h
-@@ -566,13 +566,15 @@ static inline sector_t bdev_sectors(struct block_device *bdev)
-
- static inline void uuid_write_pr_err(int err)
- {
-- pr_err("Can't write uuid %s");
-- if (ret == -EIO)
-- pr_err(", I/O error.");
-- else if(ret == -ENOSPC)
-- pr_err(", no space.");
-+ char *str;
-+ if (err == -EIO)
-+ str = ", I/O error.";
-+ else if (err == -ENOSPC)
-+ str = ", no space.";
- else
-- pr_err(".");
-+ str = ".";
-+
-+ pr_err("Can't write uuid, %s", str);
- }
-
- #define closure_bio_submit(bio, cl) \
-diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
-index cec10e6345af..07dcec8d6bab 100644
---- a/drivers/md/bcache/writeback.c
-+++ b/drivers/md/bcache/writeback.c
-@@ -505,15 +505,19 @@ static int sectors_dirty_init_fn(struct btree_op *_op, struct btree *b,
- return MAP_CONTINUE;
- }
-
--void bch_sectors_dirty_init(struct bcache_device *d)
-+int bch_sectors_dirty_init(struct bcache_device *d)
- {
- struct sectors_dirty_init op;
-+ struct cached_dev *dc = container_of(d, struct cached_dev, disk);
-+
-+ if (dc && atomic_read(&dc->io_disabled))
-+ return -EIO;
-
- bch_btree_op_init(&op.op, -1);
- op.inode = d->id;
-
-- bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0),
-- sectors_dirty_init_fn, 0);
-+ return bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0),
-+ sectors_dirty_init_fn, 0);
- }
-
- void bch_cached_dev_writeback_init(struct cached_dev *dc)
-diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h
-index a9e3ffb4b03c..f8cdc2ac5241 100644
---- a/drivers/md/bcache/writeback.h
-+++ b/drivers/md/bcache/writeback.h
-@@ -106,7 +106,7 @@ static inline void bch_writeback_add(struct cached_dev *dc)
-
- void bcache_dev_sectors_dirty_add(struct cache_set *, unsigned, uint64_t, int);
-
--void bch_sectors_dirty_init(struct bcache_device *);
-+int bch_sectors_dirty_init(struct bcache_device *);
- void bch_cached_dev_writeback_init(struct cached_dev *);
- int bch_cached_dev_writeback_start(struct cached_dev *);
-
---
-2.13.6
-
diff --git a/for-test/0001-more-return-value-check.patch b/for-test/0001-more-return-value-check.patch
deleted file mode 100644
index bfde3d4..0000000
--- a/for-test/0001-more-return-value-check.patch
+++ /dev/null
@@ -1,234 +0,0 @@
-From ef5989671b61969d5d6e11fa7413fecffc52e2f9 Mon Sep 17 00:00:00 2001
-From: Coly Li <colyli@suse.de>
-Date: Thu, 30 Nov 2017 21:42:17 +0800
-Subject: [PATCH] more return value check
-
----
- drivers/md/bcache/bcache.h | 1 +
- drivers/md/bcache/super.c | 81 +++++++++++++++++++++++++++++++++++-----------
- 2 files changed, 63 insertions(+), 19 deletions(-)
-
-diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index fbf0bbb88e5b..188393f468c3 100644
---- a/drivers/md/bcache/bcache.h
-+++ b/drivers/md/bcache/bcache.h
-@@ -667,6 +667,7 @@ struct cache_set {
-
- #define BUCKET_HASH_BITS 12
- struct hlist_head bucket_hash[1 << BUCKET_HASH_BITS];
-+ atomic_t io_disabled;
- };
-
- struct bbio {
-diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index a932302c33dc..c02d0b7945ae 100644
---- a/drivers/md/bcache/super.c
-+++ b/drivers/md/bcache/super.c
-@@ -285,11 +285,12 @@ static void bcache_write_super_unlock(struct closure *cl)
- up(&c->sb_write_mutex);
- }
-
--void bcache_write_super(struct cache_set *c)
-+int bcache_write_super(struct cache_set *c)
- {
- struct closure *cl = &c->sb_write;
- struct cache *ca;
- unsigned i;
-+ int ret = 0;
-
- down(&c->sb_write_mutex);
- closure_init(cl, &c->cl);
-@@ -311,10 +312,14 @@ void bcache_write_super(struct cache_set *c)
- bio->bi_private = ca;
-
- closure_get(cl);
-- __write_super(&ca->sb, bio);
-+ ret = __write_super(&ca->sb, bio);
-+ if (ret)
-+ break;
- }
-
- closure_return_with_destructor(cl, bcache_write_super_unlock);
-+
-+ return ret;
- }
-
- /* UUID io */
-@@ -509,7 +514,7 @@ static void prio_endio(struct bio *bio)
- closure_put(&ca->prio);
- }
-
--static void prio_io(struct cache *ca, uint64_t bucket, int op,
-+static int prio_io(struct cache *ca, uint64_t bucket, int op,
- unsigned long op_flags)
- {
- struct closure *cl = &ca->prio;
-@@ -528,14 +533,20 @@ static void prio_io(struct cache *ca, uint64_t bucket, int op,
-
- closure_bio_submit(bio, &ca->prio);
- closure_sync(cl);
-+ if (atomic_read(&cache->io_disabled))
-+ return -EIO;
-+ return 0;
- }
-
--void bch_prio_write(struct cache *ca)
-+int bch_prio_write(struct cache *ca)
- {
-- int i;
-+ int i, ret = -EIO;
- struct bucket *b;
- struct closure cl;
-
-+ if (atomic_read(&ca->io_disabled)
-+ goto out;
-+
- closure_init_stack(&cl);
-
- lockdep_assert_held(&ca->set->bucket_lock);
-@@ -566,20 +577,28 @@ void bch_prio_write(struct cache *ca)
- p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8);
-
- bucket = bch_bucket_alloc(ca, RESERVE_PRIO, true);
-- BUG_ON(bucket == -1);
--
- mutex_unlock(&ca->set->bucket_lock);
-- prio_io(ca, bucket, REQ_OP_WRITE, 0);
-- mutex_lock(&ca->set->bucket_lock);
-
-- ca->prio_buckets[i] = bucket;
-+ if (bucket < 0) {
-+ ret = -ENOSPC;
-+ goto out;
-+ }
-+
-+ ret = prio_io(ca, bucket, REQ_OP_WRITE, 0);
- atomic_dec_bug(&ca->buckets[bucket].pin);
-+ if (ret)
-+ goto out;
-+
-+ mutex_lock(&ca->set->bucket_lock);
-+ ca->prio_buckets[i] = bucket;
- }
-
- mutex_unlock(&ca->set->bucket_lock);
-
-- bch_journal_meta(ca->set, &cl);
-+ ret = bch_journal_meta(ca->set, &cl);
- closure_sync(&cl);
-+ if (ret)
-+ goto out;
-
- mutex_lock(&ca->set->bucket_lock);
-
-@@ -594,6 +613,9 @@ void bch_prio_write(struct cache *ca)
-
- ca->prio_last_buckets[i] = ca->prio_buckets[i];
- }
-+
-+out:
-+ return ret;
- }
-
- static void prio_read(struct cache *ca, uint64_t bucket)
-@@ -1357,6 +1379,9 @@ bool bch_cache_set_error(struct cache_set *c, const char *fmt, ...)
- {
- va_list args;
-
-+ atomic_set(&c->io_disabled, 1);
-+ smp_mb__after_atomic();
-+
- if (c->on_error != ON_ERROR_PANIC &&
- test_bit(CACHE_SET_STOPPING, &c->flags))
- return false;
-@@ -1603,7 +1628,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
- return NULL;
- }
-
--static void run_cache_set(struct cache_set *c)
-+static int run_cache_set(struct cache_set *c)
- {
- const char *err = "cannot allocate memory";
- struct cached_dev *dc, *t;
-@@ -1636,7 +1661,9 @@ static void run_cache_set(struct cache_set *c)
-
- err = "IO error reading priorities";
- for_each_cache(ca, c, i)
-- prio_read(ca, j->prio_bucket[ca->sb.nr_this_dev]);
-+ if (prio_read(ca,
-+ j->prio_bucket[ca->sb.nr_this_dev]))
-+ goto err;
-
- /*
- * If prio_read() fails it'll call cache_set_error and we'll
-@@ -1717,8 +1744,14 @@ static void run_cache_set(struct cache_set *c)
- goto err;
-
- mutex_lock(&c->bucket_lock);
-+
-+ err = "error writing prio";
- for_each_cache(ca, c, i)
-- bch_prio_write(ca);
-+ if (bch_prio_write(ca)) {
-+ mutex_unlock(&c->bucket_lock);
-+ goto err;
-+ }
-+
- mutex_unlock(&c->bucket_lock);
-
- err = "cannot allocate new UUID bucket";
-@@ -1732,7 +1765,11 @@ static void run_cache_set(struct cache_set *c)
-
- mutex_lock(&c->root->write_lock);
- bkey_copy_key(&c->root->key, &MAX_KEY);
-- bch_btree_node_write(c->root, &cl);
-+ err = "cannot write btree node";
-+ if (bch_btree_node_write(c->root, &cl)) {
-+ mutex_unlock(&c->root->write_lock);
-+ goto err;
-+ }
- mutex_unlock(&c->root->write_lock);
-
- bch_btree_set_root(c->root);
-@@ -1746,7 +1783,9 @@ static void run_cache_set(struct cache_set *c)
- SET_CACHE_SYNC(&c->sb, true);
-
- bch_journal_next(&c->journal);
-- bch_journal_meta(c, &cl);
-+ err = "cannot journal bch meta";
-+ if (bch_journal_meta(c, &cl))
-+ goto err;
- }
-
- err = "error starting gc thread";
-@@ -1763,11 +1802,12 @@ static void run_cache_set(struct cache_set *c)
- flash_devs_run(c);
-
- set_bit(CACHE_SET_RUNNING, &c->flags);
-- return;
-+ return 0;
- err:
- closure_sync(&cl);
- /* XXX: test this, it's broken */
- bch_cache_set_error(c, "%s", err);
-+ return -EIO;
- }
-
- static bool can_attach_cache(struct cache *ca, struct cache_set *c)
-@@ -1831,8 +1871,11 @@ static const char *register_cache_set(struct cache *ca)
- ca->set->cache[ca->sb.nr_this_dev] = ca;
- c->cache_by_alloc[c->caches_loaded++] = ca;
-
-- if (c->caches_loaded == c->sb.nr_in_set)
-- run_cache_set(c);
-+ if (c->caches_loaded == c->sb.nr_in_set) {
-+ err = "failed to run cache set";
-+ if (run_cache_set(c))
-+ goto err;
-+ }
-
- return NULL;
- err:
---
-2.13.6
-