Thread (16 messages) 16 messages, 3 authors, 2025-07-31

Re: [PATCHv3 1/7] blk-mq: introduce blk_map_iter

From: Keith Busch <kbusch@kernel.org>
Date: 2025-07-30 15:18:23
Also in: linux-nvme

On Wed, Jul 30, 2025 at 01:48:42PM +0530, Kanchan Joshi wrote:
On 7/29/2025 8:04 PM, Keith Busch wrote:
quoted
@@ -39,12 +33,11 @@ static bool blk_map_iter_next(struct request *req, struct req_iterator *iter,
  	 * one could be merged into it.  This typically happens when moving to
  	 * the next bio, but some callers also don't pack bvecs tight.
  	 */
-	while (!iter->iter.bi_size || !iter->iter.bi_bvec_done) {
+	while (!iter->iter.bi_size ||
+	       (!iter->iter.bi_bvec_done && iter->bio->bi_next)) {
  		struct bio_vec next;
  
  		if (!iter->iter.bi_size) {
-			if (!iter->bio->bi_next)
-				break;
  			iter->bio = iter->bio->bi_next;
  			iter->iter = iter->bio->bi_iter;
This can crash here if we come inside the loop because 
iter->iter.bi_size is 0
and if this is the last bio i.e., iter->bio->bi_next is NULL?
Nah, I changed the while loop condition to ensure bio->bi_next isn't
NULL if the current bi_size is 0. But I don't recall why I moved the
condition check to there in the first place either.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help