Created
February 28, 2025 16:50
-
-
Save mcgrof/459a1132d38e225bdc593d9a7cd73a81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/block/blk-map.c b/block/blk-map.c | |
| index d2f22744b3d1..dbaae6b10050 100644 | |
| --- a/block/blk-map.c | |
| +++ b/block/blk-map.c | |
| @@ -138,6 +138,9 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data, | |
| int nr_pages; | |
| unsigned int len = iter->count; | |
| unsigned int offset = map_data ? offset_in_page(map_data->offset) : 0; | |
| + struct request_queue *q = rq->q; | |
| + const struct queue_limits *lim = &q->limits; | |
| + unsigned bv_seg_lim = max(PAGE_SIZE, lim->max_segment_size); | |
| bmd = bio_alloc_map_data(iter, gfp_mask); | |
| if (!bmd) | |
| @@ -151,7 +154,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data, | |
| bmd->is_our_pages = !map_data; | |
| bmd->is_null_mapped = (map_data && map_data->null_mapped); | |
| - nr_pages = bio_max_segs(DIV_ROUND_UP(offset + len, PAGE_SIZE)); | |
| + nr_pages = bio_max_segs(DIV_ROUND_UP(offset + len, bv_seg_lim)); | |
| ret = -ENOMEM; | |
| bio = bio_kmalloc(nr_pages, gfp_mask); | |
| @@ -161,7 +164,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data, | |
| if (map_data) { | |
| nr_pages = 1U << map_data->page_order; | |
| - i = map_data->offset / PAGE_SIZE; | |
| + i = map_data->offset / bv_seg_lim; | |
| } | |
| while (len) { | |
| unsigned int bytes = PAGE_SIZE; | |
| diff --git a/block/blk-merge.c b/block/blk-merge.c | |
| index c7c85e10cf9c..02b1bab8456b 100644 | |
| --- a/block/blk-merge.c | |
| +++ b/block/blk-merge.c | |
| @@ -318,6 +318,7 @@ int bio_split_rw_at(struct bio *bio, const struct queue_limits *lim, | |
| struct bio_vec bv, bvprv, *bvprvp = NULL; | |
| struct bvec_iter iter; | |
| unsigned nsegs = 0, bytes = 0; | |
| + unsigned bv_seg_lim = max(PAGE_SIZE, lim->max_segment_size); | |
| bio_for_each_bvec(bv, bio, iter) { | |
| /* | |
| @@ -329,7 +330,7 @@ int bio_split_rw_at(struct bio *bio, const struct queue_limits *lim, | |
| if (nsegs < lim->max_segments && | |
| bytes + bv.bv_len <= max_bytes && | |
| - bv.bv_offset + bv.bv_len <= PAGE_SIZE) { | |
| + bv.bv_offset + bv.bv_len <= bv_seg_lim) { | |
| nsegs++; | |
| bytes += bv.bv_len; | |
| } else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment