fd msg-ring slot allocation tests
cover fd msg-ring slot allocation tests
Add a helper for fd msg-ring passing a file and auto allocating the target index, and test it.
Pavel Begunkov (2):
Add io_uring_prep_msg_ring_fd_alloc() helper
test: test fd msg-ring allocating indexes
src/include/liburing.h | 9 +++++++++ test/fd-pass.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.1
PATCH 1/2 Add io_uring_prep_msg_ring_fd_alloc() helper
Add a helper initialising msg-ring requests transferring files and allocating a target file index.
--- src/include/liburing.h | 9 +++++++++ 1 file changed, 9 insertions(+)
src/include/liburing.h +9 -0
@@ -1015,6 +1015,15 @@ IOURINGINLINE void io_uring_prep_msg_ring_fd(struct io_uring_sqe *sqe, int fd, sqe->msg_ring_flags = flags; } +IOURINGINLINE void io_uring_prep_msg_ring_fd_alloc(struct io_uring_sqe *sqe, +int fd,int source_fd, +__u64 data,unsigned int flags) +{ +io_uring_prep_msg_ring_fd (sqe, fd, source_fd, +IORING_FILE_INDEX_ALLOC -1 , + data, flags); +} + IOURINGINLINE void io_uring_prep_getxattr(struct io_uring_sqe *sqe,const char *name,char *value,const char *path,unsigned int len)
Signature · 1 line
2.39.1
Jens Axboe
maintainerRe: [PATCH liburing 1/2] Add io_uring_prep_msg_ring_fd_alloc() helper
Quoted 2 lines · Pavel Begunkov
Add a helper initialising msg-ring requests transferring files and allocating a target file index.
This needs an ffi map entry too, I added it.
Signature · 1 line
Jens Axboe
PATCH 2/2 test: test fd msg-ring allocating indexes
In reply to Pavel Begunkovfd msg-ring requests supports IORING_FILE_INDEX_ALLOC, add a test for that.
--- test/fd-pass.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)
test/fd-pass.c +34 -3
@@ -80,6 +80,14 @@ static int test(const char *filename, int source_fd, int target_fd)fprintf (stderr,"register files failed %d\n" , ret);return T_EXIT_FAIL ; } +if (target_fd ==IORING_FILE_INDEX_ALLOC ) { +/* we want to test installing into a non-zero slot */ + ret =io_uring_register_file_alloc_range (&dring,1 ,1 ); +if (ret) { +fprintf (stderr,"io_uring_register_file_alloc_range %d\n" , ret); +return T_EXIT_FAIL ; + } + }/* open direct descriptor */ sqe =io_uring_get_sqe (&sring);
@@ -102,8 +110,14 @@ static int test(const char *filename, int source_fd, int target_fd)/* send direct descriptor to destination ring */ sqe =io_uring_get_sqe (&sring); -io_uring_prep_msg_ring_fd (sqe, dring.ring_fd, source_fd, target_fd, -USER_DATA ,0 ); +if (target_fd ==IORING_FILE_INDEX_ALLOC ) { +io_uring_prep_msg_ring_fd_alloc (sqe, dring.ring_fd, source_fd, +USER_DATA ,0 ); + }else { + +io_uring_prep_msg_ring_fd (sqe, dring.ring_fd, source_fd, + target_fd,USER_DATA ,0 ); + }io_uring_submit (&sring); ret =io_uring_wait_cqe (&sring, &cqe);
@@ -111,7 +125,7 @@ static int test(const char *filename, int source_fd, int target_fd)fprintf (stderr,"wait cqe failed %d\n" , ret);return T_EXIT_FAIL ; } -if (cqe->res) { +if (cqe->res <0 ) {if (cqe->res == -EINVAL && !no_fd_pass) { no_fd_pass =1 ;return T_EXIT_SKIP ;
@@ -131,6 +145,17 @@ static int test(const char *filename, int source_fd, int target_fd)fprintf (stderr,"bad user_data %ld\n" , (long ) cqe->res);return T_EXIT_FAIL ; } +if (cqe->res <0 ) { +fprintf (stderr,"bad result %i\n" , cqe->res); +return T_EXIT_FAIL ; + } +if (target_fd ==IORING_FILE_INDEX_ALLOC ) { +if (cqe->res !=1 ) { +fprintf (stderr,"invalid allocated index %i\n" , cqe->res); +return T_EXIT_FAIL ; + } + target_fd = cqe->res; + }io_uring_cqe_seen (&dring, cqe);/* now verify we can read the sane data from the destination ring */
@@ -201,6 +226,12 @@ int main(int argc, char *argv[]) ret =T_EXIT_FAIL ; } + ret =test (fname,1 ,IORING_FILE_INDEX_ALLOC ); +if (ret ==T_EXIT_FAIL ) { +fprintf (stderr,"test failed 1 ALLOC\n" ); + ret =T_EXIT_FAIL ; + } +unlink (fname);return ret; }
Signature · 1 line
2.39.1
Quoted 8 lines · Pavel Begunkov
Add a helper for fd msg-ring passing a file and auto allocating the target index, and test it.
Pavel Begunkov (2):
Addio_uring_prep_msg_ring_fd_alloc()helper
test: test fd msg-ring allocating indexes[...]
Applied, thanks!
[1/2] Add io_uring_prep_msg_ring_fd_alloc() helper
commit: ab9113c58b43c33f305822739abd6084e02c8a63
[2/2] test: test fd msg-ring allocating indexes
commit: ab9113c58b43c33f305822739abd6084e02c8a63Best regards,
Signature · 1 line
Jens Axboe