Linux block layer
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Gui-Dong Han <hanguidong02@gmail.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	konrad.wilk@oracle.com, linux-kernel@vger.kernel.org,
	baijiaju1990@gmail.com, roger@xenproject.org,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen/blkback: Prevent missed completion when draining I/O
Date: Thu, 30 Jul 2026 10:43:43 +0200	[thread overview]
Message-ID: <66fc571d-4e6e-4d2e-973c-2de4789df432@suse.com> (raw)
In-Reply-To: <20260730084000.3305702-1-hanguidong02@gmail.com>

On 30.07.2026 10:40, Gui-Dong Han wrote:
> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -1021,6 +1021,13 @@ static void xen_blk_drain_io(struct xen_blkif_ring *ring)
>  	struct xen_blkif *blkif = ring->blkif;
>  
>  	atomic_set(&blkif->drain, 1);
> +	/*
> +	 * Publish drain before checking inflight. Otherwise,
> +	 * xen_blkbk_unmap_and_respond_callback() can decrement inflight with
> +	 * atomic_dec_and_test() and still see drain == 0 after this path saw
> +	 * inflight > 0, missing the completion.
> +	 */
> +	smp_mb();
>  	do {
>  		if (atomic_read(&ring->inflight) == 0)
>  			break;

Yet then don't we also need a barrier in xen_blkbk_unmap_and_respond_callback()'s
check? Barriers almost always come in pairs, after all.

Jan

  reply	other threads:[~2026-07-30  8:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  8:40 [PATCH] xen/blkback: Prevent missed completion when draining I/O Gui-Dong Han
2026-07-30  8:43 ` Jan Beulich [this message]
2026-07-30  9:25   ` Gui-Dong Han

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=66fc571d-4e6e-4d2e-973c-2de4789df432@suse.com \
    --to=jbeulich@suse.com \
    --cc=axboe@kernel.dk \
    --cc=baijiaju1990@gmail.com \
    --cc=hanguidong02@gmail.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger@xenproject.org \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox