mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Uday Shankar <ushankar@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,
	 Uday Shankar <ushankar@purestorage.com>,
	 Caleb Sander Mateos <csander@purestorage.com>
Subject: [PATCH 2/4] ublk: mark ublk_queue as const for ublk_register_io_buf
Date: Mon, 21 Apr 2025 17:46:41 -0600	[thread overview]
Message-ID: <20250421-ublk_constify-v1-2-3371f9e9f73c@purestorage.com> (raw)
In-Reply-To: <20250421-ublk_constify-v1-0-3371f9e9f73c@purestorage.com>

In the future, we may allow multiple tasks to operate on one ublk_queue
concurrently. Any writes to ublk_queue in ublk_register_io_buf, which
has no synchronization, would then become data races. Try to ensure that
such writes do not exist by marking ublk_queue pointers as const in
ublk_register_io_buf.

Suggested-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/block/ublk_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 57b8625ae64232a750d4f94e76aaf119c28f9450..a617ffde412936d3c37a3ded08a79e3557f4f56f 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -203,7 +203,7 @@ struct ublk_params_header {
 static void ublk_stop_dev_unlocked(struct ublk_device *ub);
 static void ublk_abort_queue(struct ublk_device *ub, struct ublk_queue *ubq);
 static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
-		struct ublk_queue *ubq, int tag, size_t offset);
+		const struct ublk_queue *ubq, int tag, size_t offset);
 static inline unsigned int ublk_req_build_flags(struct request *req);
 static inline struct ublksrv_io_desc *ublk_get_iod(struct ublk_queue *ubq,
 						   int tag);
@@ -1918,7 +1918,7 @@ static void ublk_io_release(void *priv)
 }
 
 static int ublk_register_io_buf(struct io_uring_cmd *cmd,
-				struct ublk_queue *ubq, unsigned int tag,
+				const struct ublk_queue *ubq, unsigned int tag,
 				unsigned int index, unsigned int issue_flags)
 {
 	struct ublk_device *ub = cmd->file->private_data;
@@ -2115,7 +2115,7 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
 }
 
 static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
-		struct ublk_queue *ubq, int tag, size_t offset)
+		const struct ublk_queue *ubq, int tag, size_t offset)
 {
 	struct request *req;
 

-- 
2.34.1


  parent reply	other threads:[~2025-04-21 23:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21 23:46 [PATCH 0/4] ublk: refactor __ublk_ch_uring_cmd Uday Shankar
2025-04-21 23:46 ` [PATCH 1/4] ublk: factor out ublk_commit_and_fetch Uday Shankar
2025-04-22  2:16   ` Ming Lei
2025-04-21 23:46 ` Uday Shankar [this message]
2025-04-21 23:46 ` [PATCH 3/4] ublk: factor out ublk_get_data Uday Shankar
2025-04-22  2:17   ` Ming Lei
2025-04-21 23:46 ` [PATCH 4/4] ublk: factor out error handling in __ublk_ch_uring_cmd Uday Shankar
2025-04-22  2:17   ` Ming Lei
2025-04-24 21:50 ` [PATCH 0/4] ublk: refactor __ublk_ch_uring_cmd Uday Shankar
2025-04-25  2:40   ` 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=20250421-ublk_constify-v1-2-3371f9e9f73c@purestorage.com \
    --to=ushankar@purestorage.com \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --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

all inboxes | Powered by JetHome®