Skip to contentSkip to conversation

Add support for using liburing xattr

PATCH Superseded Stefan Roesch 2 participants 5 messages Nov 29, 2021 – Dec 1, 2021

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Add support for using liburing xattr

This adds support for using the xattr implementation in liburing.

Patch 1: fstress: add suport for using liburing setxattr
Uses the liburing setxattr implementation in fsstress.

Patch 2: fstress: add suport for using liburing getxattr
Uses the liburing getxattr implementation in fsstress.

There are two additional patch series related to this:
- io_uring: add xattr support
- liburing: add xattr support

Stefan Roesch (2):
fstress: add suport for using liburing setxattr
fstress: add suport for using liburing getxattr

 ltp/fsstress.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 88 insertions(+), 3 deletions(-)

base-commit: 2050356437e3576673ec5ead79ad72eb619f0d72

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 fstress: add suport for using liburing setxattr

Summary:

Liburing added support for setxattr. This change adds support for this this in fsstress when fsstress is built with liburing support.

---
 ltp/fsstress.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
ltp/fsstress.c +42 -1
index 003e0e49..4a5c4afe 100644
@@ -4779,6 +4779,43 @@ setattr_f(opnum_t opno, long r)
 	close(fd);
 }
 
+static int
+io_uring_setxattr(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) {
+		printf("io_uring_get_sqe failed\n");
+		ret = -1;
+		goto out;
+	}
+
+	io_uring_prep_setxattr(sqe, name, value, path, flags, size);
+
+	ret = io_uring_submit_and_wait(&ring, 1);
+	if (ret != 1) {
+		printf("io_uring_submit_and_wait failed, ret=%d\n", ret);
+		ret = -1;
+		goto out;
+    	}
+
+	ret = io_uring_wait_cqe(&ring, &cqe);
+	if (ret < 0) {
+		printf("io_uring_wait_cqe failed, ret=%d\n", ret);
+		goto out;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(&ring, cqe);
+
+out:
+	return ret;
+}
+
 void
 setfattr_f(opnum_t opno, long r)
 {
@@ -4842,7 +4879,11 @@ setfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+	if (have_io_uring)
+		e = io_uring_setxattr(f.path, name, value, value_len, flag);
+	else
+		e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+
 	if (e == 0)
 		fep->xattr_counter++;
 	if (v)
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH v1 1/2] fstress: add suport for using liburing setxattr

Quoted 60 lines · Stefan Roesch

Summary:

Liburing added support for setxattr. This change adds support for this this in fsstress when fsstress is built with liburing support.

---
 ltp/fsstress.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
ltp/fsstress.c +37 -0
index 003e0e49..4a5c4afe 100644
@@ -4779,6 +4779,43 @@ setattr_f(opnum_t opno, long r)
 	close(fd);
 }
 
+static int
+io_uring_setxattr(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) {
+		printf("io_uring_get_sqe failed\n");
+		ret = -1;
+		goto out;
+	}
+
+	io_uring_prep_setxattr(sqe, name, value, path, flags, size);
+
+	ret = io_uring_submit_and_wait(&ring, 1);
+	if (ret != 1) {
+		printf("io_uring_submit_and_wait failed, ret=%d\n", ret);
+		ret = -1;
+		goto out;
+    	}
+
+	ret = io_uring_wait_cqe(&ring, &cqe);
+	if (ret < 0) {
+		printf("io_uring_wait_cqe failed, ret=%d\n", ret);
+		goto out;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(&ring, cqe);
+
+out:
+	return ret;
+}
+
 void
 setfattr_f(opnum_t opno, long r)
 {

ltp/fsstress.c setfattr_f(opnum_t opno, long r) · line 4885

Quoted 8 lines
ltp/fsstress.c +4 -1
@@ -4842,7 +4879,11 @@ setfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+	if (have_io_uring)
+		e = io_uring_setxattr(f.path, name, value, value_len, flag);
+	else
+		e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;

While this is technically correct, it is architecturally wrong. This replaces testing of the existing setxattr() syscall path on systems that have io_uring enabled (which is most modern, upstream test instances). That's a significant regression in test coverage, especially given that most applications using xattrs do not use io_uring...

The io_uring functionality should be added in the same way that OP_URING_READ/OP_URING_WRITE were added. That is, new operations were added in addition to the existing syscall based OP_READ/OP_WRITE, OP_READV/OP_WRITEV and the AIO based versions OP_AREAD/OP_AWRITE.

This way fsstress adds the io_uring mechanisms in addition to all the normal syscall methods it already uses rather than replacing them. This also allow io_uring operations to race with existing syscall operations running the same operations on the same files concurrently...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw

Re: [PATCH v1 1/2] fstress: add suport for using liburing setxattr

Quoted 83 lines · Dave Chinner
Quoted 60 lines · Stefan Roesch

Summary:

Liburing added support for setxattr. This change adds support for this this in fsstress when fsstress is built with liburing support.

---
 ltp/fsstress.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
ltp/fsstress.c +37 -0
index 003e0e49..4a5c4afe 100644
@@ -4779,6 +4779,43 @@ setattr_f(opnum_t opno, long r)
 	close(fd);
 }
 
+static int
+io_uring_setxattr(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) {
+		printf("io_uring_get_sqe failed\n");
+		ret = -1;
+		goto out;
+	}
+
+	io_uring_prep_setxattr(sqe, name, value, path, flags, size);
+
+	ret = io_uring_submit_and_wait(&ring, 1);
+	if (ret != 1) {
+		printf("io_uring_submit_and_wait failed, ret=%d\n", ret);
+		ret = -1;
+		goto out;
+    	}
+
+	ret = io_uring_wait_cqe(&ring, &cqe);
+	if (ret < 0) {
+		printf("io_uring_wait_cqe failed, ret=%d\n", ret);
+		goto out;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(&ring, cqe);
+
+out:
+	return ret;
+}
+
 void
 setfattr_f(opnum_t opno, long r)
 {

ltp/fsstress.c setfattr_f(opnum_t opno, long r) · line 4885

Quoted 8 lines
ltp/fsstress.c +4 -1
@@ -4842,7 +4879,11 @@ setfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+	if (have_io_uring)
+		e = io_uring_setxattr(f.path, name, value, value_len, flag);
+	else
+		e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;

While this is technically correct, it is architecturally wrong. This replaces testing of the existing setxattr() syscall path on systems that have io_uring enabled (which is most modern, upstream test instances). That's a significant regression in test coverage, especially given that most applications using xattrs do not use io_uring...

The io_uring functionality should be added in the same way that OP_URING_READ/OP_URING_WRITE were added. That is, new operations were added in addition to the existing syscall based OP_READ/OP_WRITE, OP_READV/OP_WRITEV and the AIO based versions OP_AREAD/OP_AWRITE.

Quoted 6 lines

This way fsstress adds the io_uring mechanisms in addition to all the normal syscall methods it already uses rather than replacing them. This also allow io_uring operations to race with existing syscall operations running the same operations on the same files concurrently...

Dave, thanks for the review. I sent out an updated version (v2) of the patch series that implements the changes as dedicated operations where the user can select what type of operation is preferred.

Quoted 4 lines

Cheers,

Dave.

#4 lore raw

PATCH 2/2 fstress: add suport for using liburing getxattr

In reply to Stefan Roesch

Summary:

Liburing added support for getxattr. This change adds support for this this in fsstress when fsstress is built with liburing support.

---
 ltp/fsstress.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)
ltp/fsstress.c +46 -2
index 4a5c4afe..df7820d6 100644
@@ -3895,6 +3895,42 @@ getdents_f(opnum_t opno, long r)
 	closedir(dir);
 }
 
+static int
+io_uring_getxattr(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) {
+		printf("io_uring_get_sqe failed\n");
+		ret = -1;
+		goto out;
+	}
+
+	io_uring_prep_getxattr(sqe, name, value, path, size);
+
+	ret = io_uring_submit_and_wait(&ring, 1);
+	if (ret != 1) {
+		printf("io_uring_submit_and_wait failed, ret=%d\n", ret);
+		ret = -1;
+		goto out;
+    	}
+
+	ret = io_uring_wait_cqe(&ring, &cqe);
+	if (ret < 0) {
+		printf("io_uring_wait_cqe failed, ret=%d\n", ret);
+		goto out;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(&ring, cqe);
+
+out:
+	return ret;
+}
+
 void
 getfattr_f(opnum_t opno, long r)
 {
@@ -3932,7 +3968,11 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	value_len = getxattr(f.path, name, NULL, 0);
+	if (have_io_uring)
+        	value_len = io_uring_getxattr(f.path, name, NULL, 0);
+    	else
+        	value_len = getxattr(f.path, name, NULL, 0);
+
 	if (value_len < 0) {
 		if (v)
 			printf("%d/%lld: getfattr file %s name %s failed %d\n",
@@ -3954,7 +3994,11 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
+	if (have_io_uring)
+		e = io_uring_getxattr(f.path, name, value, value_len);
+	else
+		e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
+
 out_log:
 	if (v)
 		printf("%d/%lld: getfattr file %s name %s value length %d %d\n",
Signature · 1 line
2.30.2