]>
Commit | Line | Data |
---|---|---|
1143c684 SL |
1 | From b38b56db8e1df58924a756901f269627ac9521b0 Mon Sep 17 00:00:00 2001 |
2 | From: Tang Junhui <tang.junhui.linux@gmail.com> | |
3 | Date: Thu, 25 Apr 2019 00:48:41 +0800 | |
4 | Subject: bcache: fix failure in journal relplay | |
5 | ||
6 | [ Upstream commit 631207314d88e9091be02fbdd1fdadb1ae2ed79a ] | |
7 | ||
8 | journal replay failed with messages: | |
9 | Sep 10 19:10:43 ceph kernel: bcache: error on | |
10 | bb379a64-e44e-4812-b91d-a5599871a3b1: bcache: journal entries | |
11 | 2057493-2057567 missing! (replaying 2057493-2076601), disabling | |
12 | caching | |
13 | ||
14 | The reason is in journal_reclaim(), when discard is enabled, we send | |
15 | discard command and reclaim those journal buckets whose seq is old | |
16 | than the last_seq_now, but before we write a journal with last_seq_now, | |
17 | the machine is restarted, so the journal with the last_seq_now is not | |
18 | written to the journal bucket, and the last_seq_wrote in the newest | |
19 | journal is old than last_seq_now which we expect to be, so when we doing | |
20 | replay, journals from last_seq_wrote to last_seq_now are missing. | |
21 | ||
22 | It's hard to write a journal immediately after journal_reclaim(), | |
23 | and it harmless if those missed journal are caused by discarding | |
24 | since those journals are already wrote to btree node. So, if miss | |
25 | seqs are started from the beginning journal, we treat it as normal, | |
26 | and only print a message to show the miss journal, and point out | |
27 | it maybe caused by discarding. | |
28 | ||
29 | Patch v2 add a judgement condition to ignore the missed journal | |
30 | only when discard enabled as Coly suggested. | |
31 | ||
32 | (Coly Li: rebase the patch with other changes in bch_journal_replay()) | |
33 | ||
34 | Signed-off-by: Tang Junhui <tang.junhui.linux@gmail.com> | |
35 | Tested-by: Dennis Schridde <devurandom@gmx.net> | |
36 | Signed-off-by: Coly Li <colyli@suse.de> | |
37 | Signed-off-by: Jens Axboe <axboe@kernel.dk> | |
38 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
39 | --- | |
40 | drivers/md/bcache/journal.c | 25 +++++++++++++++++++++---- | |
41 | 1 file changed, 21 insertions(+), 4 deletions(-) | |
42 | ||
43 | diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c | |
44 | index 3a102f88eb326..6f9db98f2dfd7 100644 | |
45 | --- a/drivers/md/bcache/journal.c | |
46 | +++ b/drivers/md/bcache/journal.c | |
47 | @@ -309,6 +309,18 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list) | |
48 | } | |
49 | } | |
50 | ||
51 | +bool is_discard_enabled(struct cache_set *s) | |
52 | +{ | |
53 | + struct cache *ca; | |
54 | + unsigned int i; | |
55 | + | |
56 | + for_each_cache(ca, s, i) | |
57 | + if (ca->discard) | |
58 | + return true; | |
59 | + | |
60 | + return false; | |
61 | +} | |
62 | + | |
63 | int bch_journal_replay(struct cache_set *s, struct list_head *list) | |
64 | { | |
65 | int ret = 0, keys = 0, entries = 0; | |
66 | @@ -323,10 +335,15 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list) | |
67 | BUG_ON(i->pin && atomic_read(i->pin) != 1); | |
68 | ||
69 | if (n != i->j.seq) { | |
70 | - pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)", | |
71 | - n, i->j.seq - 1, start, end); | |
72 | - ret = -EIO; | |
73 | - goto err; | |
74 | + if (n == start && is_discard_enabled(s)) | |
75 | + pr_info("bcache: journal entries %llu-%llu may be discarded! (replaying %llu-%llu)", | |
76 | + n, i->j.seq - 1, start, end); | |
77 | + else { | |
78 | + pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)", | |
79 | + n, i->j.seq - 1, start, end); | |
80 | + ret = -EIO; | |
81 | + goto err; | |
82 | + } | |
83 | } | |
84 | ||
85 | for (k = i->j.start; | |
86 | -- | |
87 | 2.20.1 | |
88 |