io_uring/rsrc: use rq_data_dir() to compute bvec dir
PATCH 1/1 io_uring/rsrc: use rq_data_dir() to compute bvec dir
The macro rq_data_dir() already computes a request's data direction. Use it in place of the if-else to set imu->dir.
--- io_uring/rsrc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
io_uring/rsrc.c +1 -5
@@ -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); bvec = imu->bvec;rq_for_each_bvec (bv, rq, rq_iter) *bvec++ = bv;
Signature · 1 line
2.45.2
Quoted 14 lines · Caleb Sander Mateos
The macro
rq_data_dir()already computes a request's data direction. Use it in place of the if-else to setimu->dir.Signed-off-by Caleb Sander Mateos <[email protected]>--- io_uring/rsrc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)io_uring/rsrc.c +0
-0@@ -957,15 +957,11 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, imu->nr_bvecs = nr_bvecs;
io_uring/rsrc.c int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, · line 962
Quoted 10 lines
io_uring/rsrc.c +1
-5refcount_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
Quoted 5 lines
io_uring/rsrc.c +0
-0bvec = imu->bvec;rq_for_each_bvec (bv, rq, rq_iter) *bvec++ = bv;
Signature · 1 line
Pavel Begunkov
Quoted 31 lines · Pavel Begunkov
Quoted 14 lines · Caleb Sander Mateos
The macro
rq_data_dir()already computes a request's data direction. Use it in place of the if-else to setimu->dir.Signed-off-by Caleb Sander Mateos <[email protected]>--- io_uring/rsrc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)io_uring/rsrc.c +0
-0@@ -957,15 +957,11 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, imu->nr_bvecs = nr_bvecs;io_uring/rsrc.c int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, · line 962
Quoted 10 lines
io_uring/rsrc.c +1
-5refcount_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_dirreturns READ/WRITE, which should be fine, but it'd be nicer to be more explicit unless it's already enforced somewhere else
Quoted 2 lines
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
Quoted 35 lines · Caleb Sander Mateos
Quoted 31 lines · Pavel Begunkov
Quoted 14 lines · Caleb Sander Mateos
The macro
rq_data_dir()already computes a request's data direction. Use it in place of the if-else to setimu->dir.Signed-off-by Caleb Sander Mateos <[email protected]>--- io_uring/rsrc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)io_uring/rsrc.c +0
-0@@ -957,15 +957,11 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, imu->nr_bvecs = nr_bvecs;io_uring/rsrc.c int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, · line 962
Quoted 10 lines
io_uring/rsrc.c +1
-5refcount_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_dirreturns READ/WRITE, which should be fine, but it'd be nicer to be more explicit unless it's already enforced somewhere elseQuoted 2 lines
BUILD_BUG_ON(WRITE == ITER_SOURCE);
ditto for READ
Quoted 6 lines
The definitions of
ITER_SOURCEandITER_DESTseem pretty clear that they are aliases for WRITE/READ:
#defineITER_SOURCE1 // == WRITE
#defineITER_DEST0 // == READSo I assume other code is already relying on this equivalence.
And it'll be left a mystery they weren't defined through WRITE/READ in the first place. but the patch should be fine then.
Signature · 1 line
Pavel Begunkov
Quoted 4 lines · Caleb Sander Mateos
The macro
rq_data_dir()already computes a request's data direction. Use it in place of the if-else to setimu->dir.
Applied, thanks!
[1/1] io_uring/rsrc: use rq_data_dir() to compute bvec dir
commit: 2fced37638a897be4e0ac724d93a23a4e38633a6
Best regards,
Signature · 1 line
Jens Axboe