ublk: add feature UBLK_F_QUIESCE

Add feature UBLK_F_QUIESCE, which adds control command `UBLK_U_CMD_QUIESCE_DEV`
for quiescing device, then device state can become `UBLK_S_DEV_QUIESCED`
or `UBLK_S_DEV_FAIL_IO` finally from ublk_ch_release() with ublk server
cooperation.

This feature can help to support to upgrade ublk server application by
shutting down ublk server gracefully, meantime keep ublk block device
persistent during the upgrading period.

The feature is only available for UBLK_F_USER_RECOVERY.

Suggested-by: Yoav Cohen <yoav@nvidia.com>
Link: https://lore.kernel.org/linux-block/DM4PR12MB632807AB7CDCE77D1E5AB7D0A9B92@DM4PR12MB6328.namprd12.prod.outlook.com/
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250522163523.406289-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Ming Lei
2025-05-23 00:35:20 +08:00
committed by Jens Axboe
parent f40b1f2670
commit b465ae7b25
2 changed files with 142 additions and 1 deletions

View File

@@ -53,6 +53,8 @@
_IOR('u', 0x14, struct ublksrv_ctrl_cmd)
#define UBLK_U_CMD_UPDATE_SIZE \
_IOWR('u', 0x15, struct ublksrv_ctrl_cmd)
#define UBLK_U_CMD_QUIESCE_DEV \
_IOWR('u', 0x16, struct ublksrv_ctrl_cmd)
/*
* 64bits are enough now, and it should be easy to extend in case of
@@ -253,6 +255,23 @@
*/
#define UBLK_F_AUTO_BUF_REG (1ULL << 11)
/*
* Control command `UBLK_U_CMD_QUIESCE_DEV` is added for quiescing device,
* which state can be transitioned to `UBLK_S_DEV_QUIESCED` or
* `UBLK_S_DEV_FAIL_IO` finally, and it needs ublk server cooperation for
* handling `UBLK_IO_RES_ABORT` correctly.
*
* Typical use case is for supporting to upgrade ublk server application,
* meantime keep ublk block device persistent during the period.
*
* This feature is only available when UBLK_F_USER_RECOVERY is enabled.
*
* Note, this command returns -EBUSY in case that all IO commands are being
* handled by ublk server and not completed in specified time period which
* is passed from the control command parameter.
*/
#define UBLK_F_QUIESCE (1ULL << 12)
/* device state */
#define UBLK_S_DEV_DEAD 0
#define UBLK_S_DEV_LIVE 1