[PATCH v2 0/2] ublk: speed up ublk server exit handling

From: Uday Shankar
Date: Fri Jul 04 2025 - 01:41:46 EST


Recently, we've observed a few cases where a ublk server is able to
complete restart more quickly than the driver can process the exit of
the previous ublk server. The new ublk server comes up, attempts
recovery of the preexisting ublk devices, and observes them still in
state UBLK_S_DEV_LIVE. While this is possible due to the asynchronous
nature of io_uring cleanup and should therefore be handled properly in
the ublk server, it is still preferable to make ublk server exit
handling faster if possible, as we should strive for it to not be a
limiting factor in how fast a ublk server can restart and provide
service again.

The first patch contains the functional change that speeds up the exit
handling, and the second factors out a repeating and error-prone pattern
into a helper.

Signed-off-by: Uday Shankar <ushankar@xxxxxxxxxxxxxxx>
---
Changes in v2:
- Added back ublk_queue::canceling to minimize number of cache lines
accessed by hot path (Ming Lei)
- Added a ublk_set_canceling helper
- Link to v1: https://lore.kernel.org/r/20250627-ublk_too_many_quiesce-v1-1-55ef9d80a6af@xxxxxxxxxxxxxxx

---
Uday Shankar (2):
ublk: speed up ublk server exit handling
ublk: introduce and use ublk_set_canceling helper

drivers/block/ublk_drv.c | 76 ++++++++++++++++++++++++++++++------------------
1 file changed, 48 insertions(+), 28 deletions(-)
---
base-commit: e74a1c6a8e8af2422fce125c29b14f1d3fab5b5c
change-id: 20250627-ublk_too_many_quiesce-937d6c36ce46

Best regards,
--
Uday Shankar <ushankar@xxxxxxxxxxxxxxx>