Skip to content

xen-blkfront: Fix IO race during unplug - #89

Merged
kdaula merged 1 commit into
edera/6.18-ltsfrom
kavi/cor-209-blkfront-unplug-backport
Nov 5, 2026
Merged

kdaula merged 1 commit into
edera/6.18-ltsfrom
kavi/cor-209-blkfront-unplug-backport

Conversation

@kdaula

@kdaula kdaula commented Nov 5, 2026

Copy link
Copy Markdown

Detaching a disk from a zone while the zone has I/O on it can hang the zone's xenwatch forever in del_gendisk(), and after that no device can be attached to or detached from the zone. blkfront_closing() stops the hardware queues before blk_mark_disk_dead(), so I/O queued in between is never dispatched and the queue freeze in del_gendisk() waits on it.

This is a clean backport of upstream 61b6d1d ("xen-blkfront: Fix IO race during unplug"), which is tagged for stable. edera/mainline already has it.

Found by the Linux QA bot's blk-io case, which detaches a disk while fio writes to it.

COR-209

commit 61b6d1d upstream.

During unplug, blkfront stops the hw queues and marks the disk as dead,
then later during removal calls del_gendisk(). However, IO issued after
the hw queues are stopped but before the call to del_gendisk() will be
queued but never handled. This causes del_gendisk() to hang forever
waiting for the queue refcount to drop to zero.

This can be reproduced by issuing IO during an artificial delay after
stopping the hw queues.

Fix this by simply not stopping the hw queues directly. Marking the disk
as dead already freezes the queue which prevents new requests being
added and it synchronously runs the hw queues to clear anything pending.
If the hw queues are stopped when calling blk_mark_disk_dead(), running
the hw queues is a no-op and can leave queued requests unprocessed.

Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Roger Pau Monné <roger@xenproject.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20261006163411.2583538-1-ross.lagerwall@citrix.com>
Signed-off-by: Kavi <kavi@edera.dev>
@kdaula
kdaula merged commit 492d0ef into edera/6.18-lts Nov 5, 2026
2 checks passed
@kdaula

kdaula commented Nov 5, 2026

Copy link
Copy Markdown
Author

Ran the QA bot's blk-io case twice on 6.18-lts with this applied. Both runs detached the disk while fio was writing to it, reattached it and verified data on it, with no xenwatch hang. Without the fix the same case hung in one of its last two runs, so this shows the path works rather than ruling the race out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants