On Thu, Feb 13, 2025 at 11:12:07AM +0000, John Garry wrote: > On 13/02/2025 10:35, Ming Lei wrote: > > > > BLK_MIN_SEGMENT_SIZE is just one hint which can be used to check if one > > > > bvec can fit in single segment quickly, otherwise the normal split code > > > > path is run into. > > > So consider we have PAGE_SIZE > 4k and max_segment_size=4k, if an iovec has > > > PAGE_SIZE then a bvec can also have PAGE_SIZE but then we need to split into > > > multiple segments, right? > > Yes, hardware limit needs to be respected. > > > > Looks one write atomic application trouble in case of 64K page size, > > and it can't work w/wo this patchset. > > I think that we need to take max_segment_size into account in > blk_queue_max_guaranteed_bio(), like: > > static unsigned int blk_queue_max_guaranteed_bio(struct queue_limits *lim) > { > unsigned int max_segments = min(BIO_MAX_VECS, lim->max_segments); > unsigned int length; > > length = min(max_segments, 2) * lim->logical_block_size; > if (max_segments > 2) > length += (max_segments - 2) * min(PAGE_SIZE, lim->max_segment_size); > > return length; > } > > Note that blk_queue_max_guaranteed_bio() is only really relevant to dio, so > assumes that the iov_iter follows the bdev dio rules It can't work because ITER_UBUF from pwritev2(iovcnt=1) is virtually-contiguous, and the middle segment size has to be PAGE_SIZE. Thanks, Ming