Re: [PATCH V2] block: make segment size limit workable for > 4K PAGE_SIZE
From: Christoph Hellwig <hch@infradead.org>
Date: 2025-02-13 08:33:20
On Mon, Feb 10, 2025 at 05:03:19PM +0800, Ming Lei wrote:
PAGE_SIZE is applied in some block device queue limits, this way is very fragile and is wrong:
Can you rephrase this? what is "some block device queue limits"?
quoted hunk ↗ jump to hunk
}diff --git a/block/blk.h b/block/blk.h index 90fa5f28ccab..cbfa8a3d4e42 100644 --- a/block/blk.h +++ b/block/blk.h@@ -359,7 +359,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 > BLK_MIN_SEGMENT_SIZE;
please avoid the overly long line here. And maybe split up the condition to actually be readable? I.e. if (lim->chunk_sectors) return true; if (bio->bi_vcnt != 1) return true; if (bio->bi_io_vec->bv_len + bio->bi_io_vec->bv_offset > BLK_MIN_SEGMENT_SIZE) return true; return false;
+ BLK_MIN_SEGMENT_SIZE = 4096, /* min(PAGE_SIZE) */
That's a very sparse and cryptic comment. Please write down an actual explanation.