On Thu, May 22, 2025 at 6:51 AM Ming Lei <ming.lei@xxxxxxxxxx> 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@xxxxxxxxxxxxxxx> > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > --- > 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 >