[PATCH v2] fs/buffer: use min folio order to calculate upper limit in __getblk_slow()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The maximum IO size that a block device can read as a single block is
based on the min folio order and not the PAGE_SIZE as we have bs > ps
support for block devices[1].

Calculate the upper limit based on the on min folio order.

[1] https://lore.kernel.org/linux-block/20250221223823.1680616-1-mcgrof@xxxxxxxxxx/

Reviewed-by: Jan Kara <jack@xxxxxxx>
Signed-off-by: Pankaj Raghav <p.raghav@xxxxxxxxxxx>
---
Changes since v1:
- Rebased on top of vfs/vfs-6.17.misc as it has a merge conflict.
- Added RVB tag from Jan Kara.

 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index a14d281c6a74..445df839a0f0 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1121,9 +1121,10 @@ __getblk_slow(struct block_device *bdev, sector_t block,
 	     unsigned size, gfp_t gfp)
 {
 	bool blocking = gfpflags_allow_blocking(gfp);
+	int blocklog = PAGE_SHIFT + mapping_min_folio_order(bdev->bd_mapping);
 
 	if (unlikely(size & (bdev_logical_block_size(bdev) - 1) ||
-		     (size < 512 || size > PAGE_SIZE))) {
+		     (size < 512 || size > (1U << blocklog)))) {
 		printk(KERN_ERR "getblk(): invalid block size %d requested\n",
 					size);
 		printk(KERN_ERR "logical block size: %d\n",

base-commit: 6ae58121126dcf8efcc2611f216a36a5e50b8ad9
-- 
2.49.0





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux