Skip to contentSkip to conversation

non-root fixes

PATCH Applied Pavel Begunkov 2 participants 4 messages Aug 24, 2021 io_uring

lore
Share & tools
lore
#0 lore raw

cover non-root fixes

1/1 fixes non-root rw tests, and 2/2 makes yet another test case to handle non-root users.

Pavel Begunkov (2):
tests: rw: don't exit ring when init failed
tests: non-root io_uring_register

 test/io_uring_register.c | 8 +++++---
 test/iopoll.c            | 3 +--
 test/read-write.c        | 4 +---
 3 files changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 tests: non-root io_uring_register

Non-previliged users can't register too many buffers, just skip the test in this case.

---
 test/io_uring_register.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
test/io_uring_register.c +5 -3
index 53e3987..9475739 100644
@@ -303,12 +303,14 @@ test_iovec_nr(int fd)
 	printf("io_uring_register(%d, %u, %p, %u)\n",
 	       fd, IORING_REGISTER_BUFFERS, iovs, nr);
 	ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
-	if (ret != 0) {
+	if (ret && (errno == ENOMEM || errno == EPERM) && geteuid()) {
+		printf("can't register large iovec for regular users, skip\n");
+	} else if (ret != 0) {
 		printf("expected success, got %d\n", errno);
 		status = 1;
-	} else
+	} else {
 		__sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
-
+	}
 	free(buf);
 	free(iovs);
 	return status;
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 tests: rw: don't exit ring when init failed

In reply to Pavel Begunkov

Don't do io_uring_queue_exit() after t_create_ring() got skipped.

---
 test/iopoll.c     | 3 +--
 test/read-write.c | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)
test/iopoll.c +1 -2
index 5273279..7037c31 100644
@@ -278,13 +278,12 @@ static int test_io(const char *file, int write, int sqthread, int fixed,
 
 	ret = t_create_ring(64, &ring, ring_flags);
 	if (ret == T_SETUP_SKIP)
-		goto done;
+		return 0;
 	if (ret != T_SETUP_OK) {
 		fprintf(stderr, "ring create failed: %d\n", ret);
 		return 1;
 	}
 	ret = __test_io(file, &ring, write, sqthread, fixed, buf_select);
-done:
 	io_uring_queue_exit(&ring);
 	return ret;
 }
test/read-write.c +1 -3
index 93f6803..1cfa2d5 100644
@@ -242,7 +242,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
 
 	ret = t_create_ring(64, &ring, ring_flags);
 	if (ret == T_SETUP_SKIP)
-		goto done;
+		return 0;
 	if (ret != T_SETUP_OK) {
 		fprintf(stderr, "ring create failed: %d\n", ret);
 		return 1;
@@ -250,8 +250,6 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
 
 	ret = __test_io(file, &ring, write, buffered, sqthread, fixed, nonvec,
 			0, 0, exp_len);
-
-done:
 	io_uring_queue_exit(&ring);
 	return ret;
 }
Signature · 1 line
2.32.0
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 11 lines · Pavel Begunkov

1/1 fixes non-root rw tests, and 2/2 makes yet another test case to handle non-root users.

Pavel Begunkov (2):
tests: rw: don't exit ring when init failed
tests: non-root io_uring_register

 test/io_uring_register.c | 8 +++++---
 test/iopoll.c            | 3 +--
 test/read-write.c        | 4 +---
 3 files changed, 7 insertions(+), 8 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe