Skip to content

Commit 35c820e

Browse files
committed
Revert "bio: limit bio max size"
This reverts commit cd2c754. Alex reports that the commit causes corruption with LUKS on ext4. Revert it for now so that this can be investigated properly. Link: https://lore.kernel.org/linux-block/1620493841.bxdq8r5haw.none@localhost/ Reported-by: Alex Xu (Hello71) <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent cf7b39a commit 35c820e

File tree

4 files changed

+3
-21
lines changed

4 files changed

+3
-21
lines changed

block/bio.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ void bio_init(struct bio *bio, struct bio_vec *table,
255255
}
256256
EXPORT_SYMBOL(bio_init);
257257

258-
unsigned int bio_max_size(struct bio *bio)
259-
{
260-
struct block_device *bdev = bio->bi_bdev;
261-
262-
return bdev ? bdev->bd_disk->queue->limits.bio_max_bytes : UINT_MAX;
263-
}
264-
265258
/**
266259
* bio_reset - reinitialize a bio
267260
* @bio: bio to reset
@@ -873,7 +866,7 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
873866
struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
874867

875868
if (page_is_mergeable(bv, page, len, off, same_page)) {
876-
if (bio->bi_iter.bi_size > bio_max_size(bio) - len) {
869+
if (bio->bi_iter.bi_size > UINT_MAX - len) {
877870
*same_page = false;
878871
return false;
879872
}
@@ -1002,7 +995,6 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
1002995
{
1003996
unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt;
1004997
unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt;
1005-
unsigned int bytes_left = bio_max_size(bio) - bio->bi_iter.bi_size;
1006998
struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt;
1007999
struct page **pages = (struct page **)bv;
10081000
bool same_page = false;
@@ -1018,8 +1010,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
10181010
BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2);
10191011
pages += entries_left * (PAGE_PTRS_PER_BVEC - 1);
10201012

1021-
size = iov_iter_get_pages(iter, pages, bytes_left, nr_pages,
1022-
&offset);
1013+
size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset);
10231014
if (unlikely(size <= 0))
10241015
return size ? size : -EFAULT;
10251016

block/blk-settings.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ EXPORT_SYMBOL_GPL(blk_queue_rq_timeout);
3131
*/
3232
void blk_set_default_limits(struct queue_limits *lim)
3333
{
34-
lim->bio_max_bytes = UINT_MAX;
3534
lim->max_segments = BLK_MAX_SEGMENTS;
3635
lim->max_discard_segments = 1;
3736
lim->max_integrity_segments = 0;
@@ -140,10 +139,6 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto
140139
limits->logical_block_size >> SECTOR_SHIFT);
141140
limits->max_sectors = max_sectors;
142141

143-
if (check_shl_overflow(max_sectors, SECTOR_SHIFT,
144-
&limits->bio_max_bytes))
145-
limits->bio_max_bytes = UINT_MAX;
146-
147142
q->backing_dev_info->io_pages = max_sectors >> (PAGE_SHIFT - 9);
148143
}
149144
EXPORT_SYMBOL(blk_queue_max_hw_sectors);

include/linux/bio.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ static inline void *bio_data(struct bio *bio)
106106
return NULL;
107107
}
108108

109-
extern unsigned int bio_max_size(struct bio *bio);
110-
111109
/**
112110
* bio_full - check if the bio is full
113111
* @bio: bio to check
@@ -121,7 +119,7 @@ static inline bool bio_full(struct bio *bio, unsigned len)
121119
if (bio->bi_vcnt >= bio->bi_max_vecs)
122120
return true;
123121

124-
if (bio->bi_iter.bi_size > bio_max_size(bio) - len)
122+
if (bio->bi_iter.bi_size > UINT_MAX - len)
125123
return true;
126124

127125
return false;

include/linux/blkdev.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ enum blk_bounce {
327327
};
328328

329329
struct queue_limits {
330-
unsigned int bio_max_bytes;
331-
332330
enum blk_bounce bounce;
333331
unsigned long seg_boundary_mask;
334332
unsigned long virt_boundary_mask;

0 commit comments

Comments
 (0)