> +/** > + * bio_full - check if the bio is full > + * @bio: bio to check > + * @len: length of one segment to be added > + * > + * Return true if @bio is full and one segment with @len bytes can't be > + * added to the bio, otherwise return false > + */ > +bool bio_full(struct bio *bio, unsigned len) > +{ > + if (bio->bi_vcnt >= bio->bi_max_vecs) > + return true; > + > + if (bio->bi_iter.bi_size > UINT_MAX - len) > + return true; > + > + if (bio_op(bio) == REQ_OP_ZONE_APPEND) > + return bio_can_zone_append(bio, len); > + > + return false; > +} If you need to move bio_full out of line that should be a separate prep patch. But I'd rather unshare a little more code rather than spreading zone append conditionals over lots of fast path functions. > +static bool bio_try_merge_zone_append_page(struct bio *bio, struct page *page, > + unsigned int len, unsigned int off) > +{ > + struct request_queue *q = bio->bi_disk->queue; > + struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; > + unsigned long mask = queue_segment_boundary(q); > + phys_addr_t addr1 = page_to_phys(bv->bv_page) + bv->bv_offset; > + phys_addr_t addr2 = page_to_phys(page) + off + len - 1; > + > + if ((addr1 | mask) != (addr2 | mask)) > + return false; > + if (bv->bv_len + len > queue_max_segment_size(q)) > + return false; > + return true; > +} This seems to be identical to bio_try_merge_pc_page, except for not passing an explicit queue argument, and for not calling __bio_try_merge_page. I'd rather factor out a new __bio_can_merge_pc_page or similar helper in a prep patch and use that in both functions. > /** > * __bio_try_merge_page - try appending data to an existing bvec. > * @bio: destination bio > @@ -856,6 +911,12 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page, > if (bio->bi_vcnt > 0) { > struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; > > + if (bio_op(bio) == REQ_OP_ZONE_APPEND) { > + if (!bio_try_merge_zone_append_page(bio, page, len, > + off)) > + return false; > + } > + > if (page_is_mergeable(bv, page, len, off, same_page)) { > if (bio->bi_iter.bi_size > UINT_MAX - len) > return false; I'd rather have a separare __bio_try_merge_append_page helper to avoid the conditional in __bio_try_merge_page. > @@ -916,6 +977,7 @@ int bio_add_page(struct bio *bio, struct page *page, > if (!__bio_try_merge_page(bio, page, len, offset, &same_page)) { > if (bio_full(bio, len)) > return 0; > + > __bio_add_page(bio, page, len, offset); > } > return len; > @@ -948,7 +1010,7 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter) > > len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count); > size = bio_add_page(bio, bv->bv_page, len, > - bv->bv_offset + iter->iov_offset); > + bv->bv_offset + iter->iov_offset); Spurious whitespace changes. > if (unlikely(size != len)) > return -EINVAL; > iov_iter_advance(iter, size); > @@ -1448,7 +1510,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q, > */ > struct bio *bio_map_user_iov(struct request_queue *q, > struct iov_iter *iter, > - gfp_t gfp_mask) > + gfp_t gfp_mask, unsigned int op) Why do we need to pass the op here? bio_map_user_iov is only used for SG_IO passthrough. > if (!__bio_add_pc_page(q, bio, page, n, offs, > - &same_page)) { > + &same_page)) { Spurious whitespace change. > extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, > unsigned int, unsigned int); > + Spurious whitespace change. > +static inline unsigned int queue_max_zone_append_sectors(const struct request_queue *q) This adds an overly long line.