Skip to content

Commit 47dd675

Browse files
mcgrofbrauner
authored andcommitted
block/bdev: lift block size restrictions to 64k
We now can support blocksizes larger than PAGE_SIZE, so in theory we should be able to lift the restriction up to the max supported page cache order. However bound ourselves to what we can currently validate and test. Through blktests and fstest we can validate up to 64k today. Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: "Matthew Wilcox (Oracle)" <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 3c20917 commit 47dd675

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

block/bdev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ int sb_set_blocksize(struct super_block *sb, int size)
183183
{
184184
if (set_blocksize(sb->s_bdev_file, size))
185185
return 0;
186-
/* If we get here, we know size is power of two
187-
* and it's value is between 512 and PAGE_SIZE */
186+
/* If we get here, we know size is validated */
188187
sb->s_blocksize = size;
189188
sb->s_blocksize_bits = blksize_bits(size);
190189
return sb->s_blocksize;

include/linux/blkdev.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,16 @@ static inline dev_t disk_devt(struct gendisk *disk)
267267
return MKDEV(disk->major, disk->first_minor);
268268
}
269269

270+
/*
271+
* We should strive for 1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER)
272+
* however we constrain this to what we can validate and test.
273+
*/
274+
#define BLK_MAX_BLOCK_SIZE SZ_64K
275+
270276
/* blk_validate_limits() validates bsize, so drivers don't usually need to */
271277
static inline int blk_validate_block_size(unsigned long bsize)
272278
{
273-
if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
279+
if (bsize < 512 || bsize > BLK_MAX_BLOCK_SIZE || !is_power_of_2(bsize))
274280
return -EINVAL;
275281

276282
return 0;

0 commit comments

Comments
 (0)