diff options
author | Kent Overstreet <koverstreet@google.com> | 2013-04-24 00:51:48 -0400 |
---|---|---|
committer | Kent Overstreet <koverstreet@google.com> | 2013-04-24 16:07:39 -0400 |
commit | 8abb2a5dbadab91f9cae22270054e9ee3b3a1d2f (patch) | |
tree | ef40e5ed1d1833152ca8b542a688f9664820201f /drivers/md/bcache | |
parent | a09ded8edf9ed4009930713e101249084cbcea5c (diff) |
bcache: Make sure blocksize isn't smaller than device blocksize
Sanity check to make sure we don't end up doing IO the device doesn't
support.
Signed-off-by: Kent Overstreet <koverstreet@google.com>
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r-- | drivers/md/bcache/super.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 6817ea46cf0a..b3601476f7dd 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -139,13 +139,17 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev, | |||
139 | if (bch_is_zero(sb->uuid, 16)) | 139 | if (bch_is_zero(sb->uuid, 16)) |
140 | goto err; | 140 | goto err; |
141 | 141 | ||
142 | sb->block_size = le16_to_cpu(s->block_size); | ||
143 | |||
144 | err = "Superblock block size smaller than device block size"; | ||
145 | if (sb->block_size << 9 < bdev_logical_block_size(bdev)) | ||
146 | goto err; | ||
147 | |||
142 | switch (sb->version) { | 148 | switch (sb->version) { |
143 | case BCACHE_SB_VERSION_BDEV: | 149 | case BCACHE_SB_VERSION_BDEV: |
144 | sb->block_size = le16_to_cpu(s->block_size); | ||
145 | sb->data_offset = BDEV_DATA_START_DEFAULT; | 150 | sb->data_offset = BDEV_DATA_START_DEFAULT; |
146 | break; | 151 | break; |
147 | case BCACHE_SB_VERSION_BDEV_WITH_OFFSET: | 152 | case BCACHE_SB_VERSION_BDEV_WITH_OFFSET: |
148 | sb->block_size = le16_to_cpu(s->block_size); | ||
149 | sb->data_offset = le64_to_cpu(s->data_offset); | 153 | sb->data_offset = le64_to_cpu(s->data_offset); |
150 | 154 | ||
151 | err = "Bad data offset"; | 155 | err = "Bad data offset"; |