|
|
Log in / Subscribe / Register

ublk: introduce UBLK_CMD_TRY_STOP_DEV

From:  Yoav Cohen <yoav-AT-nvidia.com>
To:  Ming Lei <ming.lei-AT-redhat.com>, Jens Axboe <axboe-AT-kernel.dk>, <linux-block-AT-vger.kernel.org>, <csander-AT-purestorage.com>
Subject:  [PATCH v5 0/3] ublk: introduce UBLK_CMD_TRY_STOP_DEV
Date:  Sun, 11 Jan 2026 11:45:01 +0200
Message-ID:  <20260111094504.24701-1-yoav@nvidia.com>
Cc:  <jholzman-AT-nvidia.com>, <omril-AT-nvidia.com>, Yoav Cohen <yoav-AT-example.com>, Yoav Cohen <yoav-AT-nvidia.com>
Archive-link:  Article

Hello,

This patch series introduces a new command for ublk device management.

The first patch changes `ublk_ctrl_stop_dev()` to return void, since it
always returned 0. This simplifies the API.

The second patch introduces `UBLK_CMD_TRY_STOP_DEV`, which stops the
device only if there are no active openers. Unlike the existing stop
command (`UBLK_CMD_STOP_DEV`), this command avoids disrupting active
users by returning -EBUSY if the device is busy.

These patches only introduce the new command and API simplification
without altering existing behavior for active users

Changes since v2:
 - Address Ming Lei’s comments in patch 2:
   - Add a feature flag and some minor comments.
 - Patch 1 unchanged, keeps Reviewed-by

Changes since v3:
 - Address Caleb's comments in patch 2
   - add to kublk.c
   - add to auto features
   - set feature flag to 17

Change since v4:
 - Selftest added by Ming
 - Move kublk.c change to new selftest commit

Ming Lei (1):
  selftests: ublk: add stop command with --safe option

Yoav Cohen (2):
  ublk: make ublk_ctrl_stop_dev return void
  ublk: add UBLK_CMD_TRY_STOP_DEV command

 drivers/block/ublk_drv.c                      | 50 ++++++++++++++--
 include/uapi/linux/ublk_cmd.h                 |  9 ++-
 tools/testing/selftests/ublk/Makefile         |  1 +
 tools/testing/selftests/ublk/kublk.c          | 53 +++++++++++++++++
 tools/testing/selftests/ublk/kublk.h          |  1 +
 .../testing/selftests/ublk/test_generic_16.sh | 57 +++++++++++++++++++
 6 files changed, 165 insertions(+), 6 deletions(-)
 create mode 100755 tools/testing/selftests/ublk/test_generic_16.sh

-- 
2.39.5 (Apple Git-154)




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds