Skip to content

Commit 198efa3

Browse files
Coly Liaxboe
authored andcommitted
bcache: move bucket related code into read_super_common()
Setting sb->first_bucket and checking sb->keys indeed are only for cache device, it does not make sense to do them in read_super() for backing device too. This patch moves the related code piece into read_super_common() explicitly for cache device and avoid the confusion. Signed-off-by: Coly Li <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d721a43 commit 198efa3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/md/bcache/super.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ static const char *read_super_common(struct cache_sb *sb, struct block_device *
6666
const char *err;
6767
unsigned int i;
6868

69+
sb->first_bucket= le16_to_cpu(s->first_bucket);
6970
sb->nbuckets = le64_to_cpu(s->nbuckets);
7071
sb->bucket_size = le16_to_cpu(s->bucket_size);
7172

7273
sb->nr_in_set = le16_to_cpu(s->nr_in_set);
7374
sb->nr_this_dev = le16_to_cpu(s->nr_this_dev);
7475

76+
err = "Too many journal buckets";
77+
if (sb->keys > SB_JOURNAL_BUCKETS)
78+
goto err;
79+
7580
err = "Too many buckets";
7681
if (sb->nbuckets > LONG_MAX)
7782
goto err;
@@ -155,7 +160,6 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
155160
sb->flags = le64_to_cpu(s->flags);
156161
sb->seq = le64_to_cpu(s->seq);
157162
sb->last_mount = le32_to_cpu(s->last_mount);
158-
sb->first_bucket = le16_to_cpu(s->first_bucket);
159163
sb->keys = le16_to_cpu(s->keys);
160164

161165
for (i = 0; i < SB_JOURNAL_BUCKETS; i++)
@@ -172,10 +176,6 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
172176
if (memcmp(sb->magic, bcache_magic, 16))
173177
goto err;
174178

175-
err = "Too many journal buckets";
176-
if (sb->keys > SB_JOURNAL_BUCKETS)
177-
goto err;
178-
179179
err = "Bad checksum";
180180
if (s->csum != csum_set(s))
181181
goto err;

0 commit comments

Comments
 (0)