]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/bcache-return-error-immediately-in-bch_journal_repla.patch
Linux 4.14.123
[thirdparty/kernel/stable-queue.git] / queue-4.9 / bcache-return-error-immediately-in-bch_journal_repla.patch
1 From 710f114c592af6ae54704b15d545fb02b0b784a3 Mon Sep 17 00:00:00 2001
2 From: Coly Li <colyli@suse.de>
3 Date: Thu, 25 Apr 2019 00:48:36 +0800
4 Subject: bcache: return error immediately in bch_journal_replay()
5
6 [ Upstream commit 68d10e6979a3b59e3cd2e90bfcafed79c4cf180a ]
7
8 When failure happens inside bch_journal_replay(), calling
9 cache_set_err_on() and handling the failure in async way is not a good
10 idea. Because after bch_journal_replay() returns, registering code will
11 continue to execute following steps, and unregistering code triggered
12 by cache_set_err_on() is running in same time. First it is unnecessary
13 to handle failure and unregister cache set in an async way, second there
14 might be potential race condition to run register and unregister code
15 for same cache set.
16
17 So in this patch, if failure happens in bch_journal_replay(), we don't
18 call cache_set_err_on(), and just print out the same error message to
19 kernel message buffer, then return -EIO immediately caller. Then caller
20 can detect such failure and handle it in synchrnozied way.
21
22 Signed-off-by: Coly Li <colyli@suse.de>
23 Reviewed-by: Hannes Reinecke <hare@suse.com>
24 Signed-off-by: Jens Axboe <axboe@kernel.dk>
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
26 ---
27 drivers/md/bcache/journal.c | 9 ++++++---
28 1 file changed, 6 insertions(+), 3 deletions(-)
29
30 diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
31 index c76a0176b5c68..f8ae7ce29809d 100644
32 --- a/drivers/md/bcache/journal.c
33 +++ b/drivers/md/bcache/journal.c
34 @@ -322,9 +322,12 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
35 list_for_each_entry(i, list, list) {
36 BUG_ON(i->pin && atomic_read(i->pin) != 1);
37
38 - cache_set_err_on(n != i->j.seq, s,
39 -"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
40 - n, i->j.seq - 1, start, end);
41 + if (n != i->j.seq) {
42 + pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
43 + n, i->j.seq - 1, start, end);
44 + ret = -EIO;
45 + goto err;
46 + }
47
48 for (k = i->j.start;
49 k < bset_bkey_last(&i->j);
50 --
51 2.20.1
52