Skip to contentSkip to conversation

liburing: support xattr functions

PATCH Applied Stefan Roesch 2 participants 7 messages Mar 23, 2022 – Mar 31, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

v2 cover liburing: support xattr functions

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

Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/4 liburing: Update io_uring in liburing

Summary:

Update liburing with the kernel changes in io_uring.

---
 src/include/liburing.h          |  3 ++-
 src/include/liburing/io_uring.h | 10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
src/include/liburing.h +2 -1
index 5c03061..949a351 100644
@@ -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;
 }
 
 /**
src/include/liburing/io_uring.h +8 -2
index 15516b7..57ad631 100644
@@ -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 {
Signature · 1 line
2.30.2
#2 lore raw

PATCH v2 2/4 liburing: add helper functions for setxattr and fsetxattr

In reply to Stefan Roesch

Summary:

This adds the helper functions for:
- fsetxattr
- setxattr

---
 src/include/liburing.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
src/include/liburing.h +23 -0
index 949a351..0b5dfab 100644
@@ -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
Signature · 1 line
2.30.2
#3 lore raw

PATCH v2 3/4 liburing: Add helper functions for fgetxattr and getxattr

In reply to Stefan Roesch

Summary:

This adds the helper functions for:
- fgetxattr
- getxattr

---
 src/include/liburing.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
src/include/liburing.h +21 -0
index 0b5dfab..105f5dc 100644
@@ -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,
Signature · 1 line
2.30.2
#4 lore raw

PATCH v2 4/4 liburing: Add new test program to verify xattr support

In reply to Stefan Roesch

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.

---
 test/Makefile |   1 +
 test/xattr.c  | 425 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+)
 create mode 100644 test/xattr.c
test/Makefile +1 -0
index 84c23c8..a4a7caf 100644
@@ -154,6 +154,7 @@ test_srcs := \
 	timeout-overflow.c \
 	unlink.c \
 	wakeup-hang.c \
+	xattr.c \
 	skip-cqe.c \
 	# EOL
 
test/xattr.c new file +425 -0

425 lines not on this page · raw message

Signature · 1 line
2.30.2
maintainer Applied
#5 lore raw
In reply to Stefan Roesch
Quoted 13 lines · Stefan Roesch

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.

Quoted 6 lines

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!

Signature · 1 line
Jens Axboe
maintainer Applied
#6 lore raw
In reply to Stefan Roesch
Quoted 10 lines · Stefan Roesch

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.

[...]

Applied, thanks!

[1/4] liburing: Update io_uring in liburing
(no commit info)
[2/4] liburing: add helper functions for setxattr and fsetxattr
(no commit info)
[3/4] liburing: Add helper functions for fgetxattr and getxattr
(no commit info)
[4/4] liburing: Add new test program to verify xattr support
(no commit info)

Best regards,

Signature · 1 line
Jens Axboe