From: Damien Le Moal <dlemoal@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
Christoph Hellwig <hch@lst.de>, Ming Lei <ming.lei@redhat.com>,
Mike Snitzer <snitzer@kernel.org>
Subject: Re: [PATCH v2 11/12] block: mq-deadline: Fix a race condition related to zoned writes
Date: Mon, 10 Apr 2023 17:16:29 +0900 [thread overview]
Message-ID: <daabaf7e-6672-689c-ecd1-efea0407b6a1@kernel.org> (raw)
In-Reply-To: <20230407235822.1672286-12-bvanassche@acm.org>
On 4/8/23 08:58, Bart Van Assche wrote:
> Let deadline_next_request() only consider the first zoned write per
> zone. This patch fixes a race condition between deadline_next_request()
> and completion of zoned writes.
>
> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Mike Snitzer <snitzer@kernel.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> block/mq-deadline.c | 24 +++++++++++++++++++++---
> include/linux/blk-mq.h | 5 +++++
> 2 files changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/block/mq-deadline.c b/block/mq-deadline.c
> index 8c2bc9fdcf8c..d49e20d3011d 100644
> --- a/block/mq-deadline.c
> +++ b/block/mq-deadline.c
> @@ -389,12 +389,30 @@ deadline_next_request(struct deadline_data *dd, struct dd_per_prio *per_prio,
> */
> spin_lock_irqsave(&dd->zone_lock, flags);
> while (rq) {
> + unsigned int zno = blk_rq_zone_no(rq);
> +
> if (blk_req_can_dispatch_to_zone(rq))
> break;
> - if (blk_queue_nonrot(q))
> - rq = deadline_latter_request(rq);
> - else
> +
> + WARN_ON_ONCE(!blk_queue_is_zoned(q));
I do not think this WARN is useful as blk_req_can_dispatch_to_zone() will always
return true for regular block devices.
> +
> + if (!blk_queue_nonrot(q)) {
> rq = deadline_skip_seq_writes(dd, rq);
> + if (!rq)
> + break;
> + rq = deadline_earlier_request(rq);
> + if (WARN_ON_ONCE(!rq))
> + break;
I do not understand why this is needed.
> + }
> +
> + /*
> + * Skip all other write requests for the zone with zone number
> + * 'zno'. This prevents that this function selects a zoned write
> + * that is not the first write for a given zone.
> + */
> + while ((rq = deadline_latter_request(rq)) &&
> + blk_rq_zone_no(rq) == zno)
> + ;
> }
> spin_unlock_irqrestore(&dd->zone_lock, flags);
>
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index e62feb17af96..515dfd04d736 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -1193,6 +1193,11 @@ static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
> return !blk_req_zone_is_write_locked(rq);
> }
> #else /* CONFIG_BLK_DEV_ZONED */
> +static inline unsigned int blk_rq_zone_no(struct request *rq)
> +{
> + return 0;
> +}
> +
> static inline bool blk_req_needs_zone_write_lock(struct request *rq)
> {
> return false;
next prev parent reply other threads:[~2023-04-10 8:16 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-07 23:58 [PATCH v2 00/12] Submit zoned writes in order Bart Van Assche
2023-04-07 23:58 ` [PATCH v2 01/12] block: Send zoned writes to the I/O scheduler Bart Van Assche
2023-04-10 7:42 ` Damien Le Moal
2023-04-10 16:35 ` Bart Van Assche
2023-04-07 23:58 ` [PATCH v2 02/12] block: Send flush requests " Bart Van Assche
2023-04-10 7:46 ` Damien Le Moal
2023-04-11 0:15 ` Bart Van Assche
2023-04-11 6:38 ` Christoph Hellwig
2023-04-11 17:13 ` Bart Van Assche
2023-04-07 23:58 ` [PATCH v2 03/12] block: Send requeued " Bart Van Assche
2023-04-10 7:53 ` Damien Le Moal
2023-04-10 16:59 ` Bart Van Assche
2023-04-11 12:38 ` Christoph Hellwig
2023-04-11 17:17 ` Bart Van Assche
2023-04-11 13:14 ` Christoph Hellwig
2023-04-07 23:58 ` [PATCH v2 04/12] block: Requeue requests if a CPU is unplugged Bart Van Assche
2023-04-10 7:54 ` Damien Le Moal
2023-04-11 12:40 ` Christoph Hellwig
2023-04-11 17:18 ` Bart Van Assche
2023-04-07 23:58 ` [PATCH v2 05/12] block: One requeue list per hctx Bart Van Assche
2023-04-10 7:58 ` Damien Le Moal
2023-04-10 17:04 ` Bart Van Assche
2023-04-07 23:58 ` [PATCH v2 06/12] block: Preserve the order of requeued requests Bart Van Assche
2023-04-10 8:01 ` Damien Le Moal
2023-04-11 12:43 ` Christoph Hellwig
2023-04-07 23:58 ` [PATCH v2 07/12] block: Make it easier to debug zoned write reordering Bart Van Assche
2023-04-10 8:06 ` Damien Le Moal
2023-04-07 23:58 ` [PATCH v2 08/12] block: mq-deadline: Simplify deadline_skip_seq_writes() Bart Van Assche
2023-04-10 8:07 ` Damien Le Moal
2023-04-07 23:58 ` [PATCH v2 09/12] block: mq-deadline: Disable head insertion for zoned writes Bart Van Assche
2023-04-10 8:10 ` Damien Le Moal
2023-04-10 17:09 ` Bart Van Assche
2023-04-11 6:44 ` Christoph Hellwig
2023-04-07 23:58 ` [PATCH v2 10/12] block: mq-deadline: Introduce a local variable Bart Van Assche
2023-04-10 8:11 ` Damien Le Moal
2023-04-07 23:58 ` [PATCH v2 11/12] block: mq-deadline: Fix a race condition related to zoned writes Bart Van Assche
2023-04-10 8:16 ` Damien Le Moal [this message]
2023-04-10 17:23 ` Bart Van Assche
2023-04-07 23:58 ` [PATCH v2 12/12] block: mq-deadline: Handle requeued requests correctly Bart Van Assche
2023-04-10 8:32 ` Damien Le Moal
2023-04-10 17:31 ` Bart Van Assche
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=daabaf7e-6672-689c-ecd1-efea0407b6a1@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=snitzer@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.