From: Michael Lyle <mlyle@lyle.org>
To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org
Cc: axboe@kernel.dk, Tang Junhui <tang.junhui@zte.com.cn>,
Michael Lyle <mlyle@lyle.org>
Subject: [PATCH 1/4] bcache: add a comment in journal bucket reading
Date: Fri, 24 Nov 2017 15:14:24 -0800 [thread overview]
Message-ID: <20171124231427.9563-2-mlyle@lyle.org> (raw)
In-Reply-To: <20171124231427.9563-1-mlyle@lyle.org>
From: Tang Junhui <tang.junhui@zte.com.cn>
Journal bucket is a circular buffer, the bucket
can be like YYYNNNYY, which means the first valid journal in
the 7th bucket, and the latest valid journal in third bucket, in
this case, if we do not try we the zero index first, We
may get a valid journal in the 7th bucket, then we call
find_next_bit(bitmap,ca->sb.njournal_buckets, l + 1) to get the
first invalid bucket after the 7th bucket, because all these
buckets is valid, so no bit 1 in bitmap, thus find_next_bit()
function would return with ca->sb.njournal_buckets (8). So, after
that, bcache only read journal in 7th and 8the bucket,
the first to the third buckets are lost.
So, it is important to let developer know that, we need to try
the zero index at first in the hash-search, and avoid any breaks
in future's code modification.
[ML: Fixed whitespace & formatting & file permissions]
Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn>
Signed-off-by: Michael Lyle <mlyle@lyle.org>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
---
drivers/md/bcache/journal.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 02a98ddb592d..5018c56ebb67 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -170,6 +170,11 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
* find a sequence of buckets with valid journal entries
*/
for (i = 0; i < ca->sb.njournal_buckets; i++) {
+ /*
+ * We must try the index l with ZERO first for
+ * correctness due to the scenario that the journal
+ * bucket is circular buffer which might have wrapped
+ */
l = (i * 2654435769U) % ca->sb.njournal_buckets;
if (test_bit(l, bitmap))
--
2.14.1
next prev parent reply other threads:[~2017-11-24 23:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-24 23:14 Commits for 4.15-- bcache Michael Lyle
2017-11-24 23:14 ` Michael Lyle [this message]
2017-11-24 23:14 ` [PATCH 2/4] bcache: Fix building error on MIPS Michael Lyle
2017-11-28 13:42 ` Christoph Hellwig
2017-11-24 23:14 ` [PATCH 3/4] bcache: recover data from backing when data is clean Michael Lyle
2017-11-24 23:14 ` [PATCH 4/4] bcache: check return value of register_shrinker Michael Lyle
2017-11-24 23:23 ` Commits for 4.15-- bcache Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171124231427.9563-2-mlyle@lyle.org \
--to=mlyle@lyle.org \
--cc=axboe@kernel.dk \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=tang.junhui@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox