Re: [PATCH for-next 06/12] io_uring: add fixed file peeking function

Dylan Yudaken
2022-10-31T16:47:08Z

On Mon, 2022-10-31 at 10:04 -0600, Jens Axboe wrote:
> On 10/31/22 7:41 AM, Dylan Yudaken wrote:
> > @@ -1849,17 +1866,14 @@ inline struct file
> > *io_file_get_fixed(struct io_kiocb *req, int fd,
> >         unsigned long file_ptr;
> >
> >         io_ring_submit_lock(ctx, issue_flags);
> > -
> > -       if (unlikely((unsigned int)fd >= ctx->nr_user_files))
> > -               goto out;
> > -       fd = array_index_nospec(fd, ctx->nr_user_files);
> > -       file_ptr = io_fixed_file_slot(&ctx->file_table, fd)-
> > >file_ptr;
> > +       file_ptr = __io_file_peek_fixed(req, fd);
> >         file = (struct file *) (file_ptr & FFS_MASK);
> >         file_ptr &= ~FFS_MASK;
> >         /* mask in overlapping REQ_F and FFS bits */
> >         req->flags |= (file_ptr << REQ_F_SUPPORT_NOWAIT_BIT);
> >         io_req_set_rsrc_node(req, ctx, 0);
> > -out:
> > +       WARN_ON_ONCE(file && !test_bit(fd, ctx-
> > >file_table.bitmap));
> > +
> >         io_ring_submit_unlock(ctx, issue_flags);
> >         return file;
> >  }
>
> Is this WARN_ON_ONCE() a leftover from being originally based on a
> tree
> before:
>
> commit 4d5059512d283dab7372d282c2fbd43c7f5a2456
> Author: Pavel Begunkov <asml.silence@gmail.com>
> Date:   Sun Oct 16 21:30:49 2022 +0100
>
>     io_uring: kill hot path fixed file bitmap debug checks
>
> got added? Seems not related to the changes here otherwise.
>

Ah yes. That was a bad merge in that case with the "out:" label.
I'll fix that in v2. I am assuming there will be some more comments.
Thanks for pointing this out.

Dylan