From: Josh Triplett <josh@joshtriplett.org>
To: Dylan Yudaken <dylany@meta.com>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
"asml.silence@gmail.com" <asml.silence@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>
Subject: Re: [PATCHv2] io_uring: Support calling io_uring_register with a registered ring fd
Date: Thu, 16 Feb 2023 04:05:47 -0800 [thread overview]
Message-ID: <Y+4cG5yy8U0XGHP6@localhost> (raw)
In-Reply-To: <be9f297f68ee3149f67f781fd291b657cfe4166b.camel@meta.com>
On Thu, Feb 16, 2023 at 09:35:44AM +0000, Dylan Yudaken wrote:
> On Tue, 2023-02-14 at 16:42 -0800, Josh Triplett wrote:
> > @@ -4177,17 +4177,37 @@ SYSCALL_DEFINE4(io_uring_register, unsigned
> > int, fd, unsigned int, opcode,
> > struct io_ring_ctx *ctx;
> > long ret = -EBADF;
> > struct fd f;
> > + bool use_registered_ring;
> > +
> > + use_registered_ring = !!(opcode &
> > IORING_REGISTER_USE_REGISTERED_RING);
> > + opcode &= ~IORING_REGISTER_USE_REGISTERED_RING;
> >
> > if (opcode >= IORING_REGISTER_LAST)
> > return -EINVAL;
> >
> > - f = fdget(fd);
> > - if (!f.file)
> > - return -EBADF;
> > + if (use_registered_ring) {
> > + /*
> > + * Ring fd has been registered via
> > IORING_REGISTER_RING_FDS, we
> > + * need only dereference our task private array to
> > find it.
> > + */
> > + struct io_uring_task *tctx = current->io_uring;
> >
> > - ret = -EOPNOTSUPP;
> > - if (!io_is_uring_fops(f.file))
> > - goto out_fput;
> > + if (unlikely(!tctx || fd >= IO_RINGFD_REG_MAX))
> > + return -EINVAL;
> > + fd = array_index_nospec(fd, IO_RINGFD_REG_MAX);
> > + f.file = tctx->registered_rings[fd];
> > + f.flags = 0;
> > + if (unlikely(!f.file))
> > + return -EBADF;
> > + opcode &= ~IORING_REGISTER_USE_REGISTERED_RING;
>
> ^ this line looks duplicated at the top of the function?
Good catch!
Jens, since you've already applied this, can you remove this line or
would you like a patch doing so?
> Also - is there a liburing regression test for this?
Userspace, including test: https://github.com/axboe/liburing/pull/664
next prev parent reply other threads:[~2023-02-16 12:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 0:42 [PATCHv2] io_uring: Support calling io_uring_register with a registered ring fd Josh Triplett
2023-02-15 17:44 ` Jens Axboe
2023-02-15 20:33 ` Josh Triplett
2023-02-15 21:39 ` Jens Axboe
2023-02-16 3:24 ` Jens Axboe
2023-02-16 9:35 ` Dylan Yudaken
2023-02-16 12:05 ` Josh Triplett [this message]
2023-02-16 13:10 ` 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=Y+4cG5yy8U0XGHP6@localhost \
--to=josh@joshtriplett.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=dylany@meta.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.