public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Caleb Sander Mateos <csander@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Caleb Sander Mateos <csander@purestorage.com>
Subject: [PATCH 04/17] ublk: add helpers to check ublk_device flags
Date: Wed, 17 Sep 2025 19:49:40 -0600	[thread overview]
Message-ID: <20250918014953.297897-5-csander@purestorage.com> (raw)
In-Reply-To: <20250918014953.297897-1-csander@purestorage.com>

Introduce ublk_device analogues of the ublk_queue flag helpers:
- ublk_support_zero_copy() -> ublk_dev_support_user_copy()
- ublk_support_auto_buf_reg() -> ublk_dev_support_auto_buf_reg()
- ublk_support_user_copy() -> ublk_dev_support_user_copy()
- ublk_need_map_io() -> ublk_dev_need_map_io()
- ublk_need_req_ref() -> ublk_dev_need_req_ref()
- ublk_need_get_data() -> ublk_dev_need_get_data()

These will be used in subsequent changes to avoid accessing the
ublk_queue just for the flags, and instead use the ublk_device.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/block/ublk_drv.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 4cb023d26593..04b8613ce623 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -660,26 +660,48 @@ static void ublk_apply_params(struct ublk_device *ub)
 static inline bool ublk_support_zero_copy(const struct ublk_queue *ubq)
 {
 	return ubq->flags & UBLK_F_SUPPORT_ZERO_COPY;
 }
 
+static inline bool ublk_dev_support_zero_copy(const struct ublk_device *ub)
+{
+	return ub->dev_info.flags & UBLK_F_SUPPORT_ZERO_COPY;
+}
+
 static inline bool ublk_support_auto_buf_reg(const struct ublk_queue *ubq)
 {
 	return ubq->flags & UBLK_F_AUTO_BUF_REG;
 }
 
+static inline bool ublk_dev_support_auto_buf_reg(const struct ublk_device *ub)
+{
+	return ub->dev_info.flags & UBLK_F_AUTO_BUF_REG;
+}
+
 static inline bool ublk_support_user_copy(const struct ublk_queue *ubq)
 {
 	return ubq->flags & UBLK_F_USER_COPY;
 }
 
+static inline bool ublk_dev_support_user_copy(const struct ublk_device *ub)
+{
+	return ub->dev_info.flags & UBLK_F_USER_COPY;
+}
+
 static inline bool ublk_need_map_io(const struct ublk_queue *ubq)
 {
 	return !ublk_support_user_copy(ubq) && !ublk_support_zero_copy(ubq) &&
 		!ublk_support_auto_buf_reg(ubq);
 }
 
+static inline bool ublk_dev_need_map_io(const struct ublk_device *ub)
+{
+	return !ublk_dev_support_user_copy(ub) &&
+	       !ublk_dev_support_zero_copy(ub) &&
+	       !ublk_dev_support_auto_buf_reg(ub);
+}
+
 static inline bool ublk_need_req_ref(const struct ublk_queue *ubq)
 {
 	/*
 	 * read()/write() is involved in user copy, so request reference
 	 * has to be grabbed
@@ -693,10 +715,17 @@ static inline bool ublk_need_req_ref(const struct ublk_queue *ubq)
 	 */
 	return ublk_support_user_copy(ubq) || ublk_support_zero_copy(ubq) ||
 		ublk_support_auto_buf_reg(ubq);
 }
 
+static inline bool ublk_dev_need_req_ref(const struct ublk_device *ub)
+{
+	return ublk_dev_support_user_copy(ub) ||
+	       ublk_dev_support_zero_copy(ub) ||
+	       ublk_dev_support_auto_buf_reg(ub);
+}
+
 static inline void ublk_init_req_ref(const struct ublk_queue *ubq,
 		struct ublk_io *io)
 {
 	if (ublk_need_req_ref(ubq))
 		refcount_set(&io->ref, UBLK_REFCOUNT_INIT);
@@ -724,10 +753,15 @@ static inline bool ublk_sub_req_ref(struct ublk_io *io)
 static inline bool ublk_need_get_data(const struct ublk_queue *ubq)
 {
 	return ubq->flags & UBLK_F_NEED_GET_DATA;
 }
 
+static inline bool ublk_dev_need_get_data(const struct ublk_device *ub)
+{
+	return ub->dev_info.flags & UBLK_F_NEED_GET_DATA;
+}
+
 /* Called in slow path only, keep it noinline for trace purpose */
 static noinline struct ublk_device *ublk_get_device(struct ublk_device *ub)
 {
 	if (kobject_get_unless_zero(&ub->cdev_dev.kobj))
 		return ub;
-- 
2.45.2


  parent reply	other threads:[~2025-09-18  1:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  1:49 [PATCH 00/17] ublk: avoid accessing ublk_queue to handle ublksrv_io_cmd Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 01/17] ublk: remove ubq check in ublk_check_and_get_req() Caleb Sander Mateos
2025-09-19  3:53   ` Ming Lei
2025-09-18  1:49 ` [PATCH 02/17] ublk: don't pass q_id to ublk_queue_cmd_buf_size() Caleb Sander Mateos
2025-09-19  4:04   ` Ming Lei
2025-09-18  1:49 ` [PATCH 03/17] ublk: don't pass ublk_queue to __ublk_fail_req() Caleb Sander Mateos
2025-09-20  8:52   ` Ming Lei
2025-09-18  1:49 ` Caleb Sander Mateos [this message]
2025-09-20  8:54   ` [PATCH 04/17] ublk: add helpers to check ublk_device flags Ming Lei
2025-09-18  1:49 ` [PATCH 05/17] ublk: don't dereference ublk_queue in ublk_ch_uring_cmd_local() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 06/17] ublk: don't dereference ublk_queue in ublk_check_and_get_req() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 07/17] ublk: pass ublk_device to ublk_register_io_buf() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 08/17] ublk: don't access ublk_queue in ublk_register_io_buf() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 09/17] ublk: don't access ublk_queue in ublk_daemon_register_io_buf() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 10/17] ublk: pass q_id and tag to __ublk_check_and_get_req() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 11/17] ublk: don't access ublk_queue in ublk_check_fetch_buf() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 12/17] ublk: don't access ublk_queue in ublk_config_io_buf() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 13/17] ublk: don't pass ublk_queue to ublk_fetch() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 14/17] ublk: don't access ublk_queue in ublk_check_commit_and_fetch() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 15/17] ublk: don't access ublk_queue in ublk_need_complete_req() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 16/17] ublk: pass ublk_io to __ublk_complete_rq() Caleb Sander Mateos
2025-09-18  1:49 ` [PATCH 17/17] ublk: don't access ublk_queue in ublk_unmap_io() Caleb Sander Mateos
2025-09-20  9:32 ` [PATCH 00/17] ublk: avoid accessing ublk_queue to handle ublksrv_io_cmd Ming Lei
2025-09-20 12:39 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250918014953.297897-5-csander@purestorage.com \
    --to=csander@purestorage.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox