In order to support large block devices where block size > page size we must be able to support an aops which does support blocks > ps and the block layer needs this on its address space operations. We have to sets of aops and only one which does support bs > ps right now and that is when we use iomap on the aops for the block device cache. If the min order has not yet been set and the target filesystem does require bs > ps allow for the inode for the block device cache to use the iomap aops. Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx> --- block/bdev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index 6e62d8a992e6..63b4d7dd8075 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -126,6 +126,7 @@ static void set_init_blocksize(struct block_device *bdev) { unsigned int bsize = bdev_logical_block_size(bdev); loff_t size = i_size_read(bdev->bd_inode); + int order, folio_order; while (bsize < PAGE_SIZE) { if (size & bsize) @@ -133,6 +134,13 @@ static void set_init_blocksize(struct block_device *bdev) bsize <<= 1; } bdev->bd_inode->i_blkbits = blksize_bits(bsize); + order = bdev->bd_inode->i_blkbits - PAGE_SHIFT; + folio_order = mapping_min_folio_order(bdev->bd_inode->i_mapping); + if (order > 0 && folio_order == 0) { + mapping_set_folio_orders(bdev->bd_inode->i_mapping, order, + MAX_PAGECACHE_ORDER); + bdev->bd_inode->i_data.a_ops = &def_blk_aops_iomap; + } } int set_blocksize(struct block_device *bdev, int size) -- 2.39.2