From: jianchao.w.wang@oracle.com (jianchao.wang)
Subject: WARNING: CPU: 2 PID: 207 at drivers/nvme/host/core.c:527 nvme_setup_cmd+0x3d3
Date: Thu, 1 Feb 2018 11:03:01 +0800 [thread overview]
Message-ID: <7459ffed-c63c-38a9-84f5-456c2a5c4fe0@oracle.com> (raw)
In-Reply-To: <0b7686b3-f716-49ba-c7c4-929d84905569@kernel.dk>
Hi Jens
On 01/31/2018 11:29 PM, Jens Axboe wrote:
> How about something like the below?
>
>
> diff --git a/block/blk-merge.c b/block/blk-merge.c
> index 8452fc7164cc..cee102fb060e 100644
> --- a/block/blk-merge.c
> +++ b/block/blk-merge.c
> @@ -574,8 +574,13 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
> blk_rq_get_max_sectors(req, blk_rq_pos(req)))
> return 0;
>
> + /*
> + * For DISCARDs, the segment count isn't interesting since
> + * the requests have no data attached.
> + */
> total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
> - if (blk_phys_contig_segment(q, req->biotail, next->bio)) {
> + if (total_phys_segments &&
> + blk_phys_contig_segment(q, req->biotail, next->bio)) {
> if (req->nr_phys_segments == 1)
> req->bio->bi_seg_front_size = seg_size;
> if (next->nr_phys_segments == 1)
This patch will avoid the nr_phys_segments to be set to 0xffff,
but the merged req will have two bios but zero nr_phys_segments.
We have to align with the DISCARD merging strategy.
Please refer to:
/*
* Number of discard segments (or ranges) the driver needs to fill in.
* Each discard bio merged into a request is counted as one segment.
*/
static inline unsigned short blk_rq_nr_discard_segments(struct request *rq)
{
return max_t(unsigned short, rq->nr_phys_segments, 1);
}
bool bio_attempt_discard_merge(struct request_queue *q, struct request *req,
struct bio *bio)
{
unsigned short segments = blk_rq_nr_discard_segments(req);
if (segments >= queue_max_discard_segments(q))
goto no_merge;
if (blk_rq_sectors(req) + bio_sectors(bio) >
blk_rq_get_max_sectors(req, blk_rq_pos(req)))
goto no_merge;
req->biotail->bi_next = bio;
req->biotail = bio;
req->__data_len += bio->bi_iter.bi_size;
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
req->nr_phys_segments = segments + 1;
blk_account_io_start(req, false);
return true;
no_merge:
req_set_nomerge(q, req);
return false;
}
blk_rq_nr_discard_segments will get a wrong value finally.
Maybe we could change blk_rq_nr_discard_segments to iterate and count the bios in one request
to decide the DISCARD request nr_phy_segment. And discard the nr_phys_segments operations in
the DISCARD merging path, plus your patch here.
Thanks
Jianchao
next prev parent reply other threads:[~2018-02-01 3:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-30 15:41 WARNING: CPU: 2 PID: 207 at drivers/nvme/host/core.c:527 nvme_setup_cmd+0x3d3 Jens Axboe
2018-01-30 15:57 ` Jens Axboe
2018-01-30 20:30 ` Keith Busch
2018-01-30 20:32 ` Jens Axboe
2018-01-30 20:49 ` Keith Busch
2018-01-30 20:55 ` Jens Axboe
2018-01-31 4:25 ` jianchao.wang
2018-01-31 15:29 ` Jens Axboe
2018-01-31 23:33 ` Keith Busch
2018-02-01 3:03 ` Jens Axboe
2018-02-01 3:03 ` jianchao.wang [this message]
2018-02-01 3:07 ` Jens Axboe
2018-02-01 3:33 ` jianchao.wang
2018-02-01 3:35 ` Jens Axboe
2018-02-01 4:56 ` Keith Busch
2018-02-01 15:26 ` Jens Axboe
2018-02-01 17:58 ` Jens Axboe
2018-02-01 18:12 ` Keith Busch
2018-02-01 19:52 ` Keith Busch
2018-02-01 20:55 ` Jens Axboe
2018-02-01 18:01 ` Keith Busch
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=7459ffed-c63c-38a9-84f5-456c2a5c4fe0@oracle.com \
--to=jianchao.w.wang@oracle.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox