author: Maxim Mikityanskiy <maxtram95@gmail.com> 2021-01-26 21:59:07 +0200
committer: Jens Axboe <axboe@kernel.dk> 2021-01-27 09:14:12 -0700
commit: 8dc932d3e8afb65e12eba7495f046c83884c49bf
parent: b98e762e3d71e893b221f871825dc64694cfb258
Commit Summary:
Diffstat:
1 file changed, 8 insertions, 1 deletion
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 3b8963e228a1..235b5042672e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -130,7 +130,15 @@ EXPORT_SYMBOL(truncate_bdev_range);
static void set_init_blocksize(struct block_device *bdev)
{
- bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev));
+ unsigned int bsize = bdev_logical_block_size(bdev);
+ loff_t size = i_size_read(bdev->bd_inode);
+
+ while (bsize < PAGE_SIZE) {
+ if (size & bsize)
+ break;
+ bsize <<= 1;
+ }
+ bdev->bd_inode->i_blkbits = blksize_bits(bsize);
}
int set_blocksize(struct block_device *bdev, int size)