[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADUfDZpmnj8wCjaQcDTTT_rNhsegs0NFk6w393e+JsTg4MN+bQ@mail.gmail.com>
Date: Fri, 28 Feb 2025 17:42:10 -0800
From: Caleb Sander Mateos <csander@...estorage.com>
To: Pavel Begunkov <asml.silence@...il.com>
Cc: Jens Axboe <axboe@...nel.dk>, io-uring@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] io_uring/rsrc: use rq_data_dir() to compute bvec dir
On Fri, Feb 28, 2025 at 5:23 PM Pavel Begunkov <asml.silence@...il.com> wrote:
>
> On 2/28/25 22:30, Caleb Sander Mateos wrote:
> > The macro rq_data_dir() already computes a request's data direction.
> > Use it in place of the if-else to set imu->dir.
> >
> > Signed-off-by: Caleb Sander Mateos <csander@...estorage.com>
> > ---
> > io_uring/rsrc.c | 6 +-----
> > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> > index 45bfb37bca1e..3107a03d56b8 100644
> > --- a/io_uring/rsrc.c
> > +++ b/io_uring/rsrc.c
> > @@ -957,15 +957,11 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq,
> > imu->nr_bvecs = nr_bvecs;
> > refcount_set(&imu->refs, 1);
> > imu->release = release;
> > imu->priv = rq;
> > imu->is_kbuf = true;
> > -
> > - if (op_is_write(req_op(rq)))
> > - imu->dir = IO_IMU_SOURCE;
> > - else
> > - imu->dir = IO_IMU_DEST;
> > + imu->dir = 1 << rq_data_dir(rq);
>
> rq_data_dir returns READ/WRITE, which should be fine, but it'd
> be nicer to be more explicit unless it's already enforced
> somewhere else
>
> BUILD_BUG_ON(WRITE == ITER_SOURCE);
> ditto for READ
The definitions of ITER_SOURCE and ITER_DEST seem pretty clear that
they are aliases for WRITE/READ:
#define ITER_SOURCE 1 // == WRITE
#define ITER_DEST 0 // == READ
So I assume other code is already relying on this equivalence.
Best,
Caleb
Powered by blists - more mailing lists