summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-01-26 15:39:39 -0700
committerJens Axboe <axboe@kernel.dk>2021-01-26 15:39:39 -0700
commit5bbf215a81656a0f7cbef059eec80478d6af55f3 (patch)
treece1fc1c65cb110363247f92751ae9b160480773b
parent7b2437c4d45bd2cf501b3fbc3bdffab57f25c5b5 (diff)
parent5821b03c901498a0d21988bd09dc597ebb7b5073 (diff)
downloadliburing-5bbf215a81656a0f7cbef059eec80478d6af55f3.tar.gz
liburing-5bbf215a81656a0f7cbef059eec80478d6af55f3.tar.bz2
Merge branch 'master' of https://github.com/goldsteinn/liburing
* 'master' of https://github.com/goldsteinn/liburing: man/io_uring_register.2: Add documentation on IORING_REGISTER_FILES_SKIP test/file-register.c: Add tests for skipping file
-rw-r--r--man/io_uring_register.27
-rw-r--r--test/file-register.c47
2 files changed, 54 insertions, 0 deletions
diff --git a/man/io_uring_register.2 b/man/io_uring_register.2
index 225e461..6636b6e 100644
--- a/man/io_uring_register.2
+++ b/man/io_uring_register.2
@@ -144,6 +144,7 @@ This operation replaces existing files in the registered file set with new
ones, either turning a sparse entry (one where fd is equal to -1) into a
real one, removing an existing entry (new one is set to -1), or replacing
an existing entry with a new existing entry.
+
.I arg
must contain a pointer to a struct io_uring_files_update, which contains
an offset on which to start the update, and an array of file descriptors to
@@ -152,6 +153,12 @@ use for the update.
must contain the number of descriptors in the passed in array. Available
since 5.5.
+File descriptors can be skipped if they are set to
+.B IORING_REGISTER_FILES_SKIP.
+Skipping an fd will not touch the file assosiated with the previous
+fd at that index. Available since 5.12.
+
+
.TP
.B IORING_UNREGISTER_FILES
This operation requires no argument, and
diff --git a/test/file-register.c b/test/file-register.c
index fc8b887..effa021 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -550,6 +550,44 @@ err:
return 1;
}
+static int test_skip(struct io_uring *ring)
+{
+ int *files;
+ int ret;
+
+ files = open_files(100, 0, 0);
+ ret = io_uring_register_files(ring, files, 100);
+ if (ret) {
+ fprintf(stderr, "%s: register ret=%d\n", __FUNCTION__, ret);
+ goto err;
+ }
+
+ /* -2 to skip */
+ files[90] = -2;
+ ret = io_uring_register_files_update(ring, 90, &files[90], 1);
+ if (ret != 1) {
+ fprintf(stderr, "%s: update ret=%d\n", __FUNCTION__, ret);
+ goto err;
+ }
+
+ /* verify can still use file index 90 */
+ if (test_fixed_read_write(ring, 90))
+ goto err;
+
+ ret = io_uring_unregister_files(ring);
+ if (ret) {
+ fprintf(stderr, "%s: unregister ret=%d\n", __FUNCTION__, ret);
+ goto err;
+ }
+
+ close_files(files, 100, 0);
+ return 0;
+err:
+ close_files(files, 100, 0);
+ return 1;
+}
+
+
static int test_sparse_updates(void)
{
struct io_uring ring;
@@ -687,6 +725,8 @@ static int test_fixed_removal_ordering(void)
return 0;
}
+
+
int main(int argc, char *argv[])
{
struct io_uring ring;
@@ -776,6 +816,12 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_skip(&ring);
+ if (ret) {
+ printf("test_skip failed\n");
+ return 1;
+ }
+
ret = test_sparse_updates();
if (ret) {
printf("test_sparse_updates failed\n");
@@ -790,3 +836,4 @@ int main(int argc, char *argv[])
return 0;
}
+