block: two fixes on avoiding bio splitting
cover block: two fixes on avoiding bio splitting
Hi,
The 1st patch fixes kernel panic issue which is caused by not splitting bio.
The 2nd patch requets to change the limit as SZ_4K instead of PAGE_SIZE which can be big enough to break some devies.
Thanks,
Ming Lei (2):
block: still try to split bio if the bvec crosses pages
block: split bio if the only bvec's length is > SZ_4K
block/blk-merge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
PATCH 1/2 block: still try to split bio if the bvec crosses pages
Some device may set segment boundary as PAGE_SIZE - 1. If the bvec crosses pages, and meantime its length is <= PAGE_SIZE, we still need to split the bvec into 2 segments.
Fixes this issue by still splitting bio if the single bvec crosses pages.
--- block/blk-merge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-merge.c +2 -1
@@ -319,7 +319,8 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,*/ if (!q->limits.chunk_sectors && (*bio)->bi_vcnt ==1 && - (*bio)->bi_io_vec[0 ].bv_len <=PAGE_SIZE ) { + ((*bio)->bi_io_vec[0 ].bv_len + + (*bio)->bi_io_vec[0 ].bv_offset) <=PAGE_SIZE ) { *nr_segs =1 ;break ; }
Signature · 1 line
2.20.1
RFC PATCH 2/2 block: split bio if the only bvec's length is > SZ_4K
In reply to Ming Lei64K PAGE_SIZE is popular on ARM64 or other ARCHs, and 64K has been big enough to break some devices probably, so change the logic to split bio if the only bvec's length is > SZ_4K instead of PAGE_SIZE.
--- block/blk-merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-merge.c +1 -1
@@ -320,7 +320,7 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,if (!q->limits.chunk_sectors && (*bio)->bi_vcnt ==1 && ((*bio)->bi_io_vec[0 ].bv_len + - (*bio)->bi_io_vec[0 ].bv_offset) <=PAGE_SIZE ) { + (*bio)->bi_io_vec[0 ].bv_offset) <=SZ_4K ) { *nr_segs =1 ;break ; }
Signature · 1 line
2.20.1
Re: [RFC PATCH 2/2] block: split bio if the only bvec's length is > SZ_4K
Quoted 3 lines · Ming Lei
64K
PAGE_SIZEis popular on ARM64 or other ARCHs, and 64K has been big enough to break some devices probably, so change the logic to split bio if the only bvec's length is >SZ_4Kinstead ofPAGE_SIZE.
I don't think this makes sense as-is given that blk_queue_max_hw_sectors, blk_queue_max_segment_size and co all check for a minimum of PAGE_SIZE and warn otherwise, and blk_bio_segment_split uses PAGE_SIZE for its short cut as well. So I don't think this has been a problem in practice, and if it was this patch is not enough.
So either we leave things as is, or we need to do a real audit for code using PAGE_SIZE as the minimum I/O granularity and replace it everywhere a well as updating the documentation. Which might be a good thing given that variable sized limits are weird.
Jens Axboe
maintainerQuoted 7 lines · Ming Lei
Hi,
The 1st patch fixes kernel panic issue which is caused by not splitting bio.
The 2nd patch requets to change the limit as
SZ_4Kinstead ofPAGE_SIZEwhich can be big enough to break some devies.
Both changes make sense to me, applied, thanks.
Signature · 1 line
Jens Axboe