All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Nikanth Karthikesan <knikanth@suse.de>
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Subject: Re: [PATCH] BUG: ll_merge_requests_fn() updates req->nr_phys_segments wrongly
Date: Thu, 25 Sep 2008 15:55:26 +0200	[thread overview]
Message-ID: <20080925135526.GO2677@kernel.dk> (raw)
In-Reply-To: <200809232358.02810.knikanth@suse.de>

On Tue, Sep 23 2008, Nikanth Karthikesan wrote:
> 
> From: Nikanth Karthikesan <knikanth@suse.de>
> 
> ll_merge_requests_fn() decreases the req->nr_phys_segments if 
> blk_phys_contig_segment() returns true, but it is perfectly possible that 
> blk_hw_contig_segment() is false. A new hw_segment implies a new phys_segment. 
> So decrementing nr_phys_segments wrongly here triggers the BUG_ON() in 
> scsi_init_sgtable(), as blk_rq_map_sg() would map 1 phys_segment more than  
> req->nr_phys_segment. This is easily reproducible. Other callers of 
> blk_rq_map_sg() should also be affected by this bug.
> 
> Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
> ---
> 
>  block/blk-merge.c |   10 ++++------
>  1 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-merge.c b/block/blk-merge.c
> index 5efc9e7..6e6d04b 100644
> --- a/block/blk-merge.c
> +++ b/block/blk-merge.c
> @@ -392,11 +392,6 @@ static int ll_merge_requests_fn(struct request_queue *q, 
> struct request *req,
>  		return 0;
>  
>  	total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
> -	if (blk_phys_contig_segment(q, req->biotail, next->bio))
> -		total_phys_segments--;

This is totally broken, I gather you are thinking the bug is fixed since
the counts always match up. Well that's mainly because you know don't do
ANY merging.

> -	if (total_phys_segments > q->max_phys_segments)
> -		return 0;

Hmm?

I think you should try and describe the problem you are seeing instead,
then we can perhaps find the real issue.

-- 
Jens Axboe

      parent reply	other threads:[~2008-09-25 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-23 18:28 [PATCH] BUG: ll_merge_requests_fn() updates req->nr_phys_segments wrongly Nikanth Karthikesan
2008-09-25  7:35 ` FUJITA Tomonori
2008-09-25 13:55 ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080925135526.GO2677@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=knikanth@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.