From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Wang Shanker <shankerwangmiao@gmail.com>
Subject: Re: [PATCH 1/2] block: fix discard request merge
Date: Tue, 22 Jun 2021 15:51:38 +0800 [thread overview]
Message-ID: <YNGWioq53qoPlBMi@T590> (raw)
In-Reply-To: <20210622065309.GA29691@lst.de>
On Tue, Jun 22, 2021 at 08:53:09AM +0200, Christoph Hellwig wrote:
> On Wed, Jun 09, 2021 at 08:45:55AM +0800, Ming Lei wrote:
> > index 4d97fb6dd226..bcdff1879c34 100644
> > --- a/block/blk-merge.c
> > +++ b/block/blk-merge.c
> > @@ -559,10 +559,14 @@ static inline unsigned int blk_rq_get_max_segments(struct request *rq)
> > static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
> > unsigned int nr_phys_segs)
> > {
> > - if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
> > + if (blk_integrity_merge_bio(req->q, req, bio) == false)
> > goto no_merge;
> >
> > - if (blk_integrity_merge_bio(req->q, req, bio) == false)
> > + /* discard request merge won't add new segment */
> > + if (req_op(req) == REQ_OP_DISCARD)
> > + return 1;
> > +
> > + if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
>
> I'd rather handle this by returning UINT_MAX for discard requests from
> blk_rq_get_max_segments given that bio_attempt_discard_merge is only used
> for the !DISCARD_MERGE case anyway.
This way makes very big req->nr_phys_segments or overflows it, and may break
drivers.
At least it breaks blk_rq_nr_discard_segments(), which looks easy to fix. But we
need to audit every driver to use req->nr_phys_segments directly in case of
discard request.
Thanks,
Ming
next prev parent reply other threads:[~2021-06-22 7:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 0:45 [PATCH 0/2] block: discard merge fix & improvement Ming Lei
2021-06-09 0:45 ` [PATCH 1/2] block: fix discard request merge Ming Lei
2021-06-22 6:53 ` Christoph Hellwig
2021-06-22 7:51 ` Ming Lei [this message]
2021-06-09 0:45 ` [PATCH 2/2] block: support bio merge for multi-range discard Ming Lei
2021-06-09 3:05 ` Wang Shanker
2021-06-09 6:12 ` Ming Lei
2021-06-09 6:57 ` Wang Shanker
2021-06-22 6:55 ` Christoph Hellwig
2021-06-22 8:35 ` Miao Wang
2021-06-14 22:00 ` [PATCH 0/2] block: discard merge fix & improvement Ming Lei
2021-06-22 3:53 ` Ming Lei
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=YNGWioq53qoPlBMi@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=shankerwangmiao@gmail.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