Repository navigation
xen-blkfront: Fix IO race during unplug - #89
Merged
Merged
Conversation
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>
alexandermerritt
approved these changes
Nov 5, 2026
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 beforeblk_mark_disk_dead(), so I/O queued in between is never dispatched and the queue freeze indel_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