]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: add UBLK_CMD_TRY_STOP_DEV command
authorYoav Cohen <yoav@nvidia.com>
Mon, 12 Jan 2026 22:05:01 +0000 (00:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 12 Jan 2026 22:07:31 +0000 (15:07 -0700)
commit93ada1b3da398b492c45429cef1a1c9651d5c7ba
treefd6a4acfbb0bb27ecf1a4453cb480d409e9ff469
parent9e386f49fa269298490b303c423c6af4645f184e
ublk: add UBLK_CMD_TRY_STOP_DEV command

Add a best-effort stop command, UBLK_CMD_TRY_STOP_DEV, which only stops a
ublk device when it has no active openers.

Unlike UBLK_CMD_STOP_DEV, this command does not disrupt existing users.
New opens are blocked only after disk_openers has reached zero; if the
device is busy, the command returns -EBUSY and leaves it running.

The ub->block_open flag is used only to close a race with an in-progress
open and does not otherwise change open behavior.

Advertise support via the UBLK_F_SAFE_STOP_DEV feature flag.

Signed-off-by: Yoav Cohen <yoav@nvidia.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c
include/uapi/linux/ublk_cmd.h