public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v2 0/4] liburing: support xattr functions
@ 2022-03-23 15:44 Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 1/4] liburing: Update io_uring in liburing Stefan Roesch
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Stefan Roesch @ 2022-03-23 15:44 UTC (permalink / raw)
  To: io-uring, kernel-team; +Cc: shr

Add xattr support and testing to liburing

Patch 1: liburing: update io_uring
  Update io_uring.h with io_uring kernel changes.

Patch 2: liburing: add fsetxattr and setxattr
  Add new helper functions for fsetxattr and setxattr support
  in liburing.

Patch 3: liburing: add fgetxattr and getxattr
  Add new helper functions for fgetxattr and getxattr support
  in liburing.

Patch 4: liburing: add new tests for xattr
  Adds a  new test program to test the xattr support.

There are also patches for io_uring and xfstests:
- Adds xattr support for io_uring
- Add xattr support to fsstress

Changes:
- V2: Refreshed source

Stefan Roesch (4):
  liburing: Update io_uring in liburing
  liburing: add helper functions for setxattr and fsetxattr
  liburing: Add helper functions for fgetxattr and getxattr
  liburing: Add new test program to verify xattr support

 src/include/liburing.h          |  47 +++-
 src/include/liburing/io_uring.h |  10 +-
 test/Makefile                   |   1 +
 test/xattr.c                    | 425 ++++++++++++++++++++++++++++++++
 4 files changed, 480 insertions(+), 3 deletions(-)
 create mode 100644 test/xattr.c


base-commit: 56066e7a41fdc6a0d0c537c94b2e746554449943
-- 
2.30.2



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] liburing: Update io_uring in liburing
  2022-03-23 15:44 [PATCH v2 0/4] liburing: support xattr functions Stefan Roesch
@ 2022-03-23 15:44 ` Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 2/4] liburing: add helper functions for setxattr and fsetxattr Stefan Roesch
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Roesch @ 2022-03-23 15:44 UTC (permalink / raw)
  To: io-uring, kernel-team; +Cc: shr

Summary:

Update liburing with the kernel changes in io_uring.

Signed-off-by: Stefan Roesch <[email protected]>
---
 src/include/liburing.h          |  3 ++-
 src/include/liburing/io_uring.h | 10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 5c03061..949a351 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -293,7 +293,8 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
 	sqe->buf_index = 0;
 	sqe->personality = 0;
 	sqe->file_index = 0;
-	sqe->__pad2[0] = sqe->__pad2[1] = 0;
+	sqe->addr3 = 0;
+	sqe->__pad2[0] = 0;
 }
 
 /**
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 15516b7..57ad631 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -49,6 +49,7 @@ struct io_uring_sqe {
 		__u32		rename_flags;
 		__u32		unlink_flags;
 		__u32		hardlink_flags;
+		__u32		xattr_flags;
 	};
 	__u64	user_data;	/* data to be passed back at completion time */
 	/* pack this to avoid bogus arm OABI complaints */
@@ -64,7 +65,8 @@ struct io_uring_sqe {
 		__s32	splice_fd_in;
 		__u32	file_index;
 	};
-	__u64	__pad2[2];
+	__u64	addr3;
+	__u64	__pad2[1];
 };
 
 enum {
@@ -149,6 +151,10 @@ enum {
 	IORING_OP_SYMLINKAT,
 	IORING_OP_LINKAT,
 	IORING_OP_MSG_RING,
+	IORING_OP_FSETXATTR,
+	IORING_OP_SETXATTR,
+	IORING_OP_FGETXATTR,
+	IORING_OP_GETXATTR,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
@@ -395,7 +401,7 @@ struct io_uring_probe {
 	__u8 ops_len;	/* length of ops[] array below */
 	__u16 resv;
 	__u32 resv2[3];
-	struct io_uring_probe_op ops[];
+	struct io_uring_probe_op ops[0];
 };
 
 struct io_uring_restriction {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] liburing: add helper functions for setxattr and fsetxattr
  2022-03-23 15:44 [PATCH v2 0/4] liburing: support xattr functions Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 1/4] liburing: Update io_uring in liburing Stefan Roesch
@ 2022-03-23 15:44 ` Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 3/4] liburing: Add helper functions for fgetxattr and getxattr Stefan Roesch
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Roesch @ 2022-03-23 15:44 UTC (permalink / raw)
  To: io-uring, kernel-team; +Cc: shr

Summary:

This adds the helper functions for:
- fsetxattr
- setxattr

Signed-off-by: Stefan Roesch <[email protected]>
---
 src/include/liburing.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 949a351..0b5dfab 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -729,6 +729,29 @@ static inline void io_uring_prep_msg_ring(struct io_uring_sqe *sqe, int fd,
 	sqe->rw_flags = flags;
 }
 
+static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
+					  const char *name,
+					  const char *value,
+					  const char *path,
+					  int flags,
+					  size_t len)
+{
+	io_uring_prep_rw(IORING_OP_SETXATTR, sqe, 0, name, len, (__u64) value);
+	sqe->addr3 = (__u64) path;
+	sqe->xattr_flags = flags;
+}
+
+static inline void io_uring_prep_fsetxattr(struct io_uring_sqe *sqe,
+					   int         fd,
+					   const char *name,
+					   const char *value,
+					   int         flags,
+					   size_t      len)
+{
+	io_uring_prep_rw(IORING_OP_FSETXATTR, sqe, fd, name, len, (__u64) value);
+	sqe->xattr_flags = flags;
+}
+
 /*
  * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in
  * the SQ ring
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] liburing: Add helper functions for fgetxattr and getxattr
  2022-03-23 15:44 [PATCH v2 0/4] liburing: support xattr functions Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 1/4] liburing: Update io_uring in liburing Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 2/4] liburing: add helper functions for setxattr and fsetxattr Stefan Roesch
@ 2022-03-23 15:44 ` Stefan Roesch
  2022-03-23 15:44 ` [PATCH v2 4/4] liburing: Add new test program to verify xattr support Stefan Roesch
  2022-03-30 20:47 ` [PATCH v2 0/4] liburing: support xattr functions Jens Axboe
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Roesch @ 2022-03-23 15:44 UTC (permalink / raw)
  To: io-uring, kernel-team; +Cc: shr

Summary:

This adds the helper functions for:
- fgetxattr
- getxattr

Signed-off-by: Stefan Roesch <[email protected]>
---
 src/include/liburing.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 0b5dfab..105f5dc 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -729,6 +729,17 @@ static inline void io_uring_prep_msg_ring(struct io_uring_sqe *sqe, int fd,
 	sqe->rw_flags = flags;
 }
 
+static inline void io_uring_prep_getxattr(struct io_uring_sqe *sqe,
+					  const char *name,
+					  const char *value,
+					  const char *path,
+					  size_t len)
+{
+	io_uring_prep_rw(IORING_OP_GETXATTR, sqe, 0, name, len, (__u64) value);
+	sqe->addr3 = (__u64) path;
+	sqe->xattr_flags = 0;
+}
+
 static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
 					  const char *name,
 					  const char *value,
@@ -741,6 +752,16 @@ static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
 	sqe->xattr_flags = flags;
 }
 
+static inline void io_uring_prep_fgetxattr(struct io_uring_sqe *sqe,
+		                           int         fd,
+					   const char *name,
+					   const char *value,
+					   size_t      len)
+{
+	io_uring_prep_rw(IORING_OP_FGETXATTR, sqe, fd, name, len, (__u64) value);
+	sqe->xattr_flags = 0;
+}
+
 static inline void io_uring_prep_fsetxattr(struct io_uring_sqe *sqe,
 					   int         fd,
 					   const char *name,
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] liburing: Add new test program to verify xattr support
  2022-03-23 15:44 [PATCH v2 0/4] liburing: support xattr functions Stefan Roesch
                   ` (2 preceding siblings ...)
  2022-03-23 15:44 ` [PATCH v2 3/4] liburing: Add helper functions for fgetxattr and getxattr Stefan Roesch
@ 2022-03-23 15:44 ` Stefan Roesch
  2022-03-30 20:47 ` [PATCH v2 0/4] liburing: support xattr functions Jens Axboe
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Roesch @ 2022-03-23 15:44 UTC (permalink / raw)
  To: io-uring, kernel-team; +Cc: shr

Summary:

This adds a new test program to test the xattr support:
- fgetxattr
- fsetxattr
- getxattr
- setxattr

It also includes test cases for failure conditions and
for passing in an invalid sqe. The test case for checking
of invalid SQE, must be enabled by defining
DESTRUCTIVE_TESTING.

Signed-off-by: Stefan Roesch <[email protected]>
---
 test/Makefile |   1 +
 test/xattr.c  | 425 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+)
 create mode 100644 test/xattr.c

diff --git a/test/Makefile b/test/Makefile
index 84c23c8..a4a7caf 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -154,6 +154,7 @@ test_srcs := \
 	timeout-overflow.c \
 	unlink.c \
 	wakeup-hang.c \
+	xattr.c \
 	skip-cqe.c \
 	# EOL
 
diff --git a/test/xattr.c b/test/xattr.c
new file mode 100644
index 0000000..017017e
--- /dev/null
+++ b/test/xattr.c
@@ -0,0 +1,425 @@
+#include <assert.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/xattr.h>
+#include <unistd.h>
+
+#include "helpers.h"
+#include "liburing.h"
+
+/* Define constants. */
+#define XATTR_SIZE  255
+#define QUEUE_DEPTH 32
+
+#define FILENAME    "xattr.test"
+#define KEY1        "user.val1"
+#define KEY2        "user.val2"
+#define VALUE1      "value1"
+#define VALUE2      "value2-a-lot-longer"
+
+
+/* Call fsetxattr. */
+int io_uring_fsetxattr(struct io_uring *ring,
+		       int              fd,
+		       const char      *name,
+		       const void      *value,
+		       size_t           size,
+		       int              flags)
+{
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
+	int ret;
+
+	sqe = io_uring_get_sqe(ring);
+	if (!sqe) {
+		fprintf(stderr, "Error cannot get sqe\n");
+		return -1;
+	}
+
+	io_uring_prep_fsetxattr(sqe, fd, name, value, flags, size);
+
+	ret = io_uring_submit(ring);
+	if (ret != 1) {
+		fprintf(stderr, "Error io_uring_submit_and_wait: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = io_uring_wait_cqe(ring, &cqe);
+	if (ret) {
+		fprintf(stderr, "Error io_uring_wait_cqe: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(ring, cqe);
+
+	return ret;
+}
+
+/* Submit fgetxattr request. */
+int io_uring_fgetxattr(struct io_uring *ring,
+		       int              fd,
+		       const char      *name,
+		       void            *value,
+		       size_t           size)
+{
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
+	int ret;
+
+	sqe = io_uring_get_sqe(ring);
+	if (!sqe) {
+		fprintf(stderr, "Error cannot get sqe\n");
+		return -1;
+	}
+
+	io_uring_prep_fgetxattr(sqe, fd, name, value, size);
+
+	ret = io_uring_submit(ring);
+	if (ret != 1) {
+		fprintf(stderr, "Error io_uring_submit_and_wait: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = io_uring_wait_cqe(ring, &cqe);
+	if (ret) {
+		fprintf(stderr, "Error io_uring_wait_cqe: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = cqe->res;
+	if (ret == -1) {
+		fprintf(stderr, "Error couldn'tget value\n");
+		return -1;
+	}
+
+	io_uring_cqe_seen(ring, cqe);
+	return ret;
+}
+
+/* Call setxattr. */
+int io_uring_setxattr(struct io_uring *ring,
+		      const char      *path,
+		      const char      *name,
+		      const void      *value,
+		      size_t           size,
+		      int              flags)
+{
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
+	int ret;
+
+	sqe = io_uring_get_sqe(ring);
+	if (!sqe) {
+		fprintf(stderr, "Error cannot get sqe\n");
+		return -1;
+	}
+
+	io_uring_prep_setxattr(sqe, name, value, path, flags, size);
+
+	ret = io_uring_submit_and_wait(ring, 1);
+	if (ret != 1) {
+		fprintf(stderr, "Error io_uring_submit_and_wait: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = io_uring_wait_cqe(ring, &cqe);
+	if (ret) {
+		fprintf(stderr, "Error io_uring_wait_cqe: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(ring, cqe);
+
+	return ret;
+}
+
+/* Submit getxattr request. */
+int io_uring_getxattr(struct io_uring *ring,
+		      const char      *path,
+		      const char      *name,
+		      void            *value,
+		      size_t           size)
+{
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
+	int ret;
+
+	sqe = io_uring_get_sqe(ring);
+	if (!sqe) {
+		fprintf(stderr, "Error cannot get sqe\n");
+		return -1;
+	}
+
+	io_uring_prep_getxattr(sqe, name, value, path, size);
+
+	ret = io_uring_submit(ring);
+	if (ret != 1) {
+		fprintf(stderr, "Error io_uring_submit_and_wait: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = io_uring_wait_cqe(ring, &cqe);
+	if (ret) {
+		fprintf(stderr, "Error io_uring_wait_cqe: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = cqe->res;
+	if (ret == -1) {
+		fprintf(stderr, "Error couldn'tget value\n");
+		return -1;
+	}
+
+	io_uring_cqe_seen(ring, cqe);
+	return ret;
+}
+
+/* Test driver for fsetxattr and fgetxattr. */
+int test_fxattr(void)
+{
+	int rc = 0;
+	size_t value_len;
+	struct io_uring ring;
+	char value[XATTR_SIZE];
+
+	/* Init io-uring queue. */
+	int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0);
+	if (ret) {
+		fprintf(stderr, "child: ring setup failed: %d\n", ret);
+		return -1;
+	}
+
+	/* Create the test file. */
+	int fd = open(FILENAME, O_CREAT | O_RDWR);
+	if (fd < 0) {
+		fprintf(stderr, "Error: cannot open file: ret=%d\n", fd);
+		return -1;
+	}
+
+	/* Test writing attributes. */
+	if (io_uring_fsetxattr(&ring, fd, KEY1, VALUE1, strlen(VALUE1), 0) == -1) {
+		fprintf(stderr, "Error fsetxattr cannot write key1\n");
+		rc = -1;
+		goto Exit;
+	}
+
+	if (io_uring_fsetxattr(&ring, fd, KEY2, VALUE2, strlen(VALUE2), 0) == -1) {
+		fprintf(stderr, "Error fsetxattr cannot write key1\n");
+		rc = -1;
+		goto Exit;
+	}
+
+	/* Test reading attributes. */
+	value_len = io_uring_fgetxattr(&ring, fd, KEY1, value, XATTR_SIZE);
+	if (value_len != strlen(value) || strncmp(value, VALUE1, value_len)) {
+		fprintf(stderr, "Error: fgetxattr expectd value: %s, returned value: %s\n", VALUE1, value);
+		rc = -1;
+		goto Exit;
+	}
+
+	value_len = io_uring_fgetxattr(&ring, fd, KEY2, value, XATTR_SIZE);
+	if (value_len != strlen(value)|| strncmp(value, VALUE2, value_len)) {
+		fprintf(stderr, "Error: fgetxattr expectd value: %s, returned value: %s\n", VALUE2, value);
+		rc = -1;
+		goto Exit;
+	}
+
+	/* Cleanup. */
+Exit:
+	close(fd);
+	unlink(FILENAME);
+
+	io_uring_queue_exit(&ring);
+
+	return rc;
+}
+
+/* Test driver for setxattr and getxattr. */
+int test_xattr(void)
+{
+	int rc = 0;
+	int value_len;
+	struct io_uring ring;
+	char value[XATTR_SIZE];
+
+	/* Init io-uring queue. */
+	int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0);
+	if (ret) {
+		fprintf(stderr, "child: ring setup failed: %d\n", ret);
+		return -1;
+	}
+
+	/* Create the test file. */
+	t_create_file(FILENAME, 0);
+
+	/* Test writing attributes. */
+	if (io_uring_setxattr(&ring, FILENAME, KEY1, VALUE1, strlen(VALUE1), 0) == -1) {
+		fprintf(stderr, "Error setxattr cannot write key1\n");
+		rc = -1;
+		goto Exit;
+	}
+
+	if (io_uring_setxattr(&ring, FILENAME, KEY2, VALUE2, strlen(VALUE2), 0) == -1) {
+		fprintf(stderr, "Error setxattr cannot write key1\n");
+		rc = -1;
+		goto Exit;
+	}
+
+	/* Test reading attributes. */
+	value_len = io_uring_getxattr(&ring, FILENAME, KEY1, value, XATTR_SIZE);
+	if (value_len != strlen(VALUE1) || strncmp(value, VALUE1, value_len)) {
+		fprintf(stderr, "Error: getxattr expectd value: %s, returned value: %s\n", VALUE1, value);
+		rc = -1;
+		goto Exit;
+	}
+
+	value_len = io_uring_getxattr(&ring, FILENAME, KEY2, value, XATTR_SIZE);
+	if (value_len != strlen(VALUE2) || strncmp(value, VALUE2, value_len)) {
+		fprintf(stderr, "Error: getxattr expectd value: %s, returned value: %s\n", VALUE2, value);
+		rc = -1;
+		goto Exit;
+	}
+
+	/* Cleanup. */
+Exit:
+	io_uring_queue_exit(&ring);
+	unlink(FILENAME);
+
+	return rc;
+}
+
+/* Test driver for failure cases of fsetxattr and fgetxattr. */
+int test_failure_fxattr(void)
+{
+	int rc = 0;
+	struct io_uring ring;
+	char value[XATTR_SIZE];
+
+	/* Init io-uring queue. */
+	int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0);
+	if (ret) {
+		fprintf(stderr, "child: ring setup failed: %d\n", ret);
+		return -1;
+	}
+
+	/* Create the test file. */
+	int fd = open(FILENAME, O_CREAT | O_RDWR);
+	if (fd < 0) {
+		fprintf(stderr, "Error: cannot open file: ret=%d\n", fd);
+		return -1;
+	}
+
+	/* Test writing attributes. */
+	assert(io_uring_fsetxattr(&ring, -1, KEY1, VALUE1, strlen(VALUE1), 0) < 0);
+	assert(io_uring_fsetxattr(&ring, fd, NULL, VALUE1, strlen(VALUE1), 0) < 0);
+	assert(io_uring_fsetxattr(&ring, fd, KEY1, NULL,   strlen(VALUE1), 0) < 0);
+	assert(io_uring_fsetxattr(&ring, fd, KEY1, VALUE1, 0,              0) == 0);
+	assert(io_uring_fsetxattr(&ring, fd, KEY1, VALUE1, -1,             0) < 0);
+
+	/* Test reading attributes. */
+	assert(io_uring_fgetxattr(&ring, -1, KEY1, value, XATTR_SIZE) < 0);
+	assert(io_uring_fgetxattr(&ring, fd, NULL, value, XATTR_SIZE) < 0);
+	assert(io_uring_fgetxattr(&ring, fd, KEY1, value, 0)          == 0);
+
+	/* Cleanup. */
+	close(fd);
+	unlink(FILENAME);
+
+	io_uring_queue_exit(&ring);
+
+	return rc;
+}
+
+
+/* Test driver for failure cases for setxattr and getxattr. */
+int test_failure_xattr(void)
+{
+	int rc = 0;
+	struct io_uring ring;
+	char value[XATTR_SIZE];
+
+	/* Init io-uring queue. */
+	int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0);
+	if (ret) {
+		fprintf(stderr, "child: ring setup failed: %d\n", ret);
+		return -1;
+	}
+
+	/* Create the test file. */
+	t_create_file(FILENAME, 0);
+
+	/* Test writing attributes. */
+	assert(io_uring_setxattr(&ring, "complete garbage", KEY1, VALUE1, strlen(VALUE1), 0) < 0);
+	assert(io_uring_setxattr(&ring, NULL,     KEY1, VALUE1, strlen(VALUE1), 0) < 0);
+	assert(io_uring_setxattr(&ring, FILENAME, NULL, VALUE1, strlen(VALUE1), 0) < 0);
+	assert(io_uring_setxattr(&ring, FILENAME, KEY1, NULL,   strlen(VALUE1), 0) < 0);
+	assert(io_uring_setxattr(&ring, FILENAME, KEY1, VALUE1, 0,              0) == 0);
+
+	/* Test reading attributes. */
+	assert(io_uring_getxattr(&ring, "complete garbage", KEY1, value, XATTR_SIZE) < 0);
+	assert(io_uring_getxattr(&ring, NULL,     KEY1, value, XATTR_SIZE) < 0);
+	assert(io_uring_getxattr(&ring, FILENAME, NULL, value, XATTR_SIZE) < 0);
+	assert(io_uring_getxattr(&ring, FILENAME, KEY1, NULL,  XATTR_SIZE) == 0);
+	assert(io_uring_getxattr(&ring, FILENAME, KEY1, value, 0)          == 0);
+
+	/* Cleanup. */
+	io_uring_queue_exit(&ring);
+	unlink(FILENAME);
+
+	return rc;
+}
+
+/* Test for invalid SQE, this will cause a segmentation fault if enabled. */
+int test_invalid_sqe(void)
+{
+#ifdef DESTRUCTIVE_TEST
+	struct io_uring_sqe *sqe = NULL;
+	struct io_uring_cqe *cqe = NULL;
+	struct io_uring ring;
+
+	/* Init io-uring queue. */
+	int ret = io_uring_queue_init(QUEUE_DEPTH, &ring, 0);
+	if (ret) {
+		fprintf(stderr, "child: ring setup failed: %d\n", ret);
+		return -1;
+	}
+
+	/* Pass invalid SQE. */
+	io_uring_prep_setxattr(sqe, FILENAME, KEY1, VALUE1, strlen(VALUE1), 0);
+
+	ret = io_uring_submit(&ring);
+	if (ret != 1) {
+		fprintf(stderr, "Error io_uring_submit_and_wait: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = io_uring_wait_cqe(&ring, &cqe);
+	if (ret) {
+		fprintf(stderr, "Error io_uring_wait_cqe: ret=%d\n", ret);
+		return -1;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(&ring, cqe);
+
+	return ret;
+#else
+	return 0;
+#endif
+}
+
+/* Test driver. */
+int main(int argc, char **argv) {
+	if (test_fxattr()
+		|| test_xattr()
+	    || test_failure_fxattr()
+		|| test_failure_xattr()
+	    || test_invalid_sqe())
+		return EXIT_FAILURE;
+
+	return EXIT_SUCCESS;
+}
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] liburing: support xattr functions
  2022-03-23 15:44 [PATCH v2 0/4] liburing: support xattr functions Stefan Roesch
                   ` (3 preceding siblings ...)
  2022-03-23 15:44 ` [PATCH v2 4/4] liburing: Add new test program to verify xattr support Stefan Roesch
@ 2022-03-30 20:47 ` Jens Axboe
  4 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-03-30 20:47 UTC (permalink / raw)
  To: Stefan Roesch, io-uring, kernel-team

On 3/23/22 9:44 AM, Stefan Roesch wrote:
> Add xattr support and testing to liburing
> 
> Patch 1: liburing: update io_uring
>   Update io_uring.h with io_uring kernel changes.
> 
> Patch 2: liburing: add fsetxattr and setxattr
>   Add new helper functions for fsetxattr and setxattr support
>   in liburing.
> 
> Patch 3: liburing: add fgetxattr and getxattr
>   Add new helper functions for fgetxattr and getxattr support
>   in liburing.
> 
> Patch 4: liburing: add new tests for xattr
>   Adds a  new test program to test the xattr support.
> 
> There are also patches for io_uring and xfstests:
> - Adds xattr support for io_uring
> - Add xattr support to fsstress

Applied in the 'xattr' branch for now, I'll pull it into master
when:

a) The next liburing has been released, and
b) the xattr changes are upstream, targeted 5.19 merge window.

Thanks!

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-30 20:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-23 15:44 [PATCH v2 0/4] liburing: support xattr functions Stefan Roesch
2022-03-23 15:44 ` [PATCH v2 1/4] liburing: Update io_uring in liburing Stefan Roesch
2022-03-23 15:44 ` [PATCH v2 2/4] liburing: add helper functions for setxattr and fsetxattr Stefan Roesch
2022-03-23 15:44 ` [PATCH v2 3/4] liburing: Add helper functions for fgetxattr and getxattr Stefan Roesch
2022-03-23 15:44 ` [PATCH v2 4/4] liburing: Add new test program to verify xattr support Stefan Roesch
2022-03-30 20:47 ` [PATCH v2 0/4] liburing: support xattr functions Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox