bsg: setting rq->bio to NULL [Linux 2.6.30]

This Linux kernel change "bsg: setting rq->bio to NULL" is included in the Linux 2.6.30 release. This change is authored by FUJITA Tomonori <fujita.tomonori [at]> on Tue Jun 9 15:17:37 2009 +0200. The commit for this change in Linux stable tree is c1d4c41 (patch).

bsg: setting rq->bio to NULL

Due to commit 1cd96c242a829d52f7a5ae98f554ca9775429685 ("block: WARN
in __blk_put_request() for potential bio leak"), BSG SMP requests get
the false warnings:

WARNING: at block/blk-core.c:1068 __blk_put_request+0x52/0xc0()

This sets rq->bio to NULL to avoid that false warnings.

Signed-off-by: FUJITA Tomonori <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 block/bsg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/bsg.c b/block/bsg.c
index 206060e..dd81be4 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -315,6 +315,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
    if (next_rq) {
+       next_rq->bio = NULL;
    return ERR_PTR(ret);
@@ -448,6 +449,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
        hdr->dout_resid = rq->data_len;
        hdr->din_resid = rq->next_rq->data_len;
+       rq->next_rq->bio = NULL;
    } else if (rq_data_dir(rq) == READ)
        hdr->din_resid = rq->data_len;
@@ -466,6 +468,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
    if (rq->cmd != rq->__cmd)
+   rq->bio = NULL;

    return ret;

Leave a Reply

Your email address will not be published. Required fields are marked *