VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   57 Tags
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:
Revert "block: simplify set_init_blocksize" to regain lost performance
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)