public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Caleb Sander Mateos <csander@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, io-uring@vger.kernel.org,
	 Uday Shankar <ushankar@purestorage.com>
Subject: Re: [PATCH 1/2] io_uring: add helper io_uring_cmd_ctx_handle()
Date: Thu, 22 May 2025 07:34:12 -0700	[thread overview]
Message-ID: <CADUfDZq5V=7ah8bHgPosjWk=Pshgw2S5jKuX7LhX8HVGRSH5dQ@mail.gmail.com> (raw)
In-Reply-To: <20250522135045.389102-2-ming.lei@redhat.com>

On Thu, May 22, 2025 at 6:51 AM Ming Lei <ming.lei@redhat.com> wrote:
>
> Add helper io_uring_cmd_ctx_handle() for driver to track per-context
> resource, such as registered kernel io buffer.
>
> Suggested-by: Caleb Sander Mateos <csander@purestorage.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  include/linux/io_uring/cmd.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h
> index 0634a3de1782..92d523865df8 100644
> --- a/include/linux/io_uring/cmd.h
> +++ b/include/linux/io_uring/cmd.h
> @@ -140,6 +140,15 @@ static inline struct io_uring_cmd_data *io_uring_cmd_get_async_data(struct io_ur
>         return cmd_to_io_kiocb(cmd)->async_data;
>  }
>
> +/*
> + * Return uring_cmd's context reference as its context handle for driver to
> + * track per-context resource, such as registered kernel IO buffer
> + */
> +static inline unsigned long io_uring_cmd_ctx_handle(struct io_uring_cmd *cmd)
> +{
> +       return (unsigned long)cmd_to_io_kiocb(cmd)->ctx;

I would still prefer to return const void *. That would avoid the need
for a cast.
Other than that, this looks good.

Best,
Caleb

> +}
> +
>  int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq,
>                             void (*release)(void *), unsigned int index,
>                             unsigned int issue_flags);
> --
> 2.47.0
>

  reply	other threads:[~2025-05-22 14:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22 13:50 [PATCH 0/2] ublk: run auto buf unregister on same io_ring_ctx with register Ming Lei
2025-05-22 13:50 ` [PATCH 1/2] io_uring: add helper io_uring_cmd_ctx_handle() Ming Lei
2025-05-22 14:34   ` Caleb Sander Mateos [this message]
2025-05-22 13:50 ` [PATCH 2/2] ublk: run auto buf unregister on same io_ring_ctx with register Ming Lei
2025-05-22 14:40   ` Caleb Sander Mateos

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='CADUfDZq5V=7ah8bHgPosjWk=Pshgw2S5jKuX7LhX8HVGRSH5dQ@mail.gmail.com' \
    --to=csander@purestorage.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=ushankar@purestorage.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