linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: make queue limits workable in case of 64K PAGE_SIZE
@ 2025-01-02  1:56 Ming Lei
  2025-01-02  2:30 ` Bart Van Assche
  0 siblings, 1 reply; 14+ messages in thread
From: Ming Lei @ 2025-01-02  1:56 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Ming Lei, Yi Zhang, Luis Chamberlain, John Garry

PAGE_SIZE is applied in some block device queue limits, this way is
very fragile and is wrong:

- queue limits are read from hardware, which is often one readonly
hardware property

- PAGE_SIZE is one config option which can be changed during build time.

In RH lab, it has been found that max segment size of some mmc card is
less than 64K, then this kind of card can't work in case of 64K PAGE_SIZE.

Fix this issue by using SZ_4K in related code for dealing with queue
limits.

Cc: Yi Zhang <yi.zhang@redhat.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-settings.c | 6 +++---
 block/blk.h          | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 8f09e33f41f6..3b6918c134b1 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -300,7 +300,7 @@ int blk_validate_limits(struct queue_limits *lim)
 	max_hw_sectors = min_not_zero(lim->max_hw_sectors,
 				lim->max_dev_sectors);
 	if (lim->max_user_sectors) {
-		if (lim->max_user_sectors < PAGE_SIZE / SECTOR_SIZE)
+		if (lim->max_user_sectors < SZ_4K / SECTOR_SIZE)
 			return -EINVAL;
 		lim->max_sectors = min(max_hw_sectors, lim->max_user_sectors);
 	} else if (lim->io_opt > (BLK_DEF_MAX_SECTORS_CAP << SECTOR_SHIFT)) {
@@ -338,7 +338,7 @@ int blk_validate_limits(struct queue_limits *lim)
 	 */
 	if (!lim->seg_boundary_mask)
 		lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
-	if (WARN_ON_ONCE(lim->seg_boundary_mask < PAGE_SIZE - 1))
+	if (WARN_ON_ONCE(lim->seg_boundary_mask < SZ_4K - 1))
 		return -EINVAL;
 
 	/*
@@ -359,7 +359,7 @@ int blk_validate_limits(struct queue_limits *lim)
 		 */
 		if (!lim->max_segment_size)
 			lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
-		if (WARN_ON_ONCE(lim->max_segment_size < PAGE_SIZE))
+		if (WARN_ON_ONCE(lim->max_segment_size < SZ_4K))
 			return -EINVAL;
 	}
 
diff --git a/block/blk.h b/block/blk.h
index 2c26abf505b8..570d66f1e338 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -357,7 +357,7 @@ static inline bool bio_may_need_split(struct bio *bio,
 		const struct queue_limits *lim)
 {
 	return lim->chunk_sectors || bio->bi_vcnt != 1 ||
-		bio->bi_io_vec->bv_len + bio->bi_io_vec->bv_offset > PAGE_SIZE;
+		bio->bi_io_vec->bv_len + bio->bi_io_vec->bv_offset > SZ_4K;
 }
 
 /**
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-01-08 19:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-02  1:56 [PATCH] block: make queue limits workable in case of 64K PAGE_SIZE Ming Lei
2025-01-02  2:30 ` Bart Van Assche
2025-01-02  2:49   ` Ming Lei
2025-01-02  3:46     ` Bart Van Assche
2025-01-03  2:01       ` Ming Lei
2025-01-03 22:12         ` Bart Van Assche
2025-01-04  1:47           ` Luis Chamberlain
2025-01-04  2:15             ` Bart Van Assche
2025-01-04  4:04               ` Luis Chamberlain
2025-01-04 22:30                 ` Bart Van Assche
2025-01-08 19:32                   ` Luis Chamberlain
2025-01-05  0:59                 ` Keith Busch
2025-01-08 19:12                   ` Luis Chamberlain
2025-01-06  1:20           ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).