From: Jeff Moyer <jmoyer@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCHSET v2] io_uring: support fileset add/remove/modify
Date: Fri, 04 Oct 2019 14:17:03 -0400 [thread overview]
Message-ID: <x49pnjcl6jk.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20191004162222.10390-1-axboe@kernel.dk> (Jens Axboe's message of "Fri, 4 Oct 2019 10:22:20 -0600")
Jens Axboe <axboe@kernel.dk> writes:
> Currently we only support registrering a fixed file set. If changes need
> to be made to that set, the application must unregister the existing set
> first, then register a new one.
>
> This patchset adds support for sparse file sets (patch 1), which means
> the application can register a fileset with room for expansion. This is
> done through having unregistered slots use fd == -1.
>
> On top of that, we can add IORING_REGISTER_FILES_UPDATE. This allows
> modifying the existing file set through:
>
> - Replacing empty slots with valid file descriptors
> - Replacing valid descriptors with an empty slot
> - Modifying an existing slot, replacing a file descriptor with a new one
I don't pretend to understand the socket code you wrote. The io_uring
bits look good to me. I also added a testcase to your file-register.c
program--diff below. The test passes, of course. :)
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Cheers,
Jeff
diff --git a/test/file-register.c b/test/file-register.c
index b25f0f5..322545f 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -358,6 +358,40 @@ err:
return 1;
}
+/*
+ * Register 0 files, but reserve space for 10. Then add one file.
+ */
+static int test_zero(struct io_uring *ring)
+{
+ struct io_uring_files_update up;
+ int *files;
+ int ret;
+
+ files = open_files(0, 10, 0);
+ ret = io_uring_register(ring->ring_fd, IORING_REGISTER_FILES, files, 10);
+ if (ret)
+ goto err;
+
+ up.fds = open_files(1, 0, 1);
+ up.offset = 0;
+ ret = io_uring_register(ring->ring_fd,
+ IORING_REGISTER_FILES_UPDATE, &up, 1);
+ if (ret != 1) {
+ printf("ret=%d, errno=%d\n", ret, errno);
+ goto err;
+ }
+
+ ret = io_uring_register(ring->ring_fd, IORING_UNREGISTER_FILES, NULL, 0);
+ if (ret)
+ goto err;
+
+ close_files(up.fds, 1, 1);
+ return 0;
+err:
+ close_files(up.fds, 1, 1);
+ return 1;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring;
@@ -426,5 +460,11 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_zero(&ring);
+ if (ret) {
+ printf("test_zero failed\n");
+ return ret;
+ }
+
return 0;
}
next prev parent reply other threads:[~2019-10-04 18:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 16:22 [PATCHSET v2] io_uring: support fileset add/remove/modify Jens Axboe
2019-10-04 16:22 ` [PATCH 1/2] io_uring: allow sparse fixed file sets Jens Axboe
2019-10-04 16:22 ` [PATCH 2/2] io_uring: add support for IORING_REGISTER_FILES_UPDATE Jens Axboe
2019-10-04 18:17 ` Jeff Moyer [this message]
2019-10-04 18:52 ` [PATCHSET v2] io_uring: support fileset add/remove/modify Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=x49pnjcl6jk.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).