diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-08-05 17:04:06 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-01-08 16:05:06 -0500 |
commit | b3fa7e77e67e647db3db2166b65083a427d84ed3 (patch) | |
tree | 287ba3124137234e1518208b57717d60aa9eb44b /drivers/md | |
parent | ef71ec00002d92a08eb27e9d036e3d48835b6597 (diff) |
bcache: Minor journal fix
The real fix is where we check the bytes we need against how much is
remaining - we also need to check for a journal entry bigger than our
buffer, we'll never write those and it would be bad if we tried to read
one.
Also improve the diagnostic messages.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/journal.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 7eafdf09a0ae..29cccc510eb6 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c | |||
@@ -44,11 +44,11 @@ static int journal_read_bucket(struct cache *ca, struct list_head *list, | |||
44 | 44 | ||
45 | closure_init_stack(&cl); | 45 | closure_init_stack(&cl); |
46 | 46 | ||
47 | pr_debug("reading %llu", (uint64_t) bucket); | 47 | pr_debug("reading %u", bucket_index); |
48 | 48 | ||
49 | while (offset < ca->sb.bucket_size) { | 49 | while (offset < ca->sb.bucket_size) { |
50 | reread: left = ca->sb.bucket_size - offset; | 50 | reread: left = ca->sb.bucket_size - offset; |
51 | len = min_t(unsigned, left, PAGE_SECTORS * 8); | 51 | len = min_t(unsigned, left, PAGE_SECTORS << JSET_BITS); |
52 | 52 | ||
53 | bio_reset(bio); | 53 | bio_reset(bio); |
54 | bio->bi_iter.bi_sector = bucket + offset; | 54 | bio->bi_iter.bi_sector = bucket + offset; |
@@ -74,17 +74,26 @@ reread: left = ca->sb.bucket_size - offset; | |||
74 | struct list_head *where; | 74 | struct list_head *where; |
75 | size_t blocks, bytes = set_bytes(j); | 75 | size_t blocks, bytes = set_bytes(j); |
76 | 76 | ||
77 | if (j->magic != jset_magic(&ca->sb)) | 77 | if (j->magic != jset_magic(&ca->sb)) { |
78 | pr_debug("%u: bad magic", bucket_index); | ||
78 | return ret; | 79 | return ret; |
80 | } | ||
79 | 81 | ||
80 | if (bytes > left << 9) | 82 | if (bytes > left << 9 || |
83 | bytes > PAGE_SIZE << JSET_BITS) { | ||
84 | pr_info("%u: too big, %zu bytes, offset %u", | ||
85 | bucket_index, bytes, offset); | ||
81 | return ret; | 86 | return ret; |
87 | } | ||
82 | 88 | ||
83 | if (bytes > len << 9) | 89 | if (bytes > len << 9) |
84 | goto reread; | 90 | goto reread; |
85 | 91 | ||
86 | if (j->csum != csum_set(j)) | 92 | if (j->csum != csum_set(j)) { |
93 | pr_info("%u: bad csum, %zu bytes, offset %u", | ||
94 | bucket_index, bytes, offset); | ||
87 | return ret; | 95 | return ret; |
96 | } | ||
88 | 97 | ||
89 | blocks = set_blocks(j, ca->set); | 98 | blocks = set_blocks(j, ca->set); |
90 | 99 | ||