Skip to contentSkip to conversation

Add support for using liburing xattr

PATCH Superseded Stefan Roesch 3 participants 9 messages Dec 1, 2021 – Dec 16, 2021

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 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

base-commit: 2050356437e3576673ec5ead79ad72eb619f0d72
---
V2: - Introduce dedicated functions for uring getxattr and
uring setxattr, so they are not automatically linked in if liburing is available.

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

 ltp/fsstress.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 116 insertions(+), 6 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 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 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
ltp/fsstress.c +57 -2
index 003e0e49..aba7c6f7 100644
@@ -145,12 +145,14 @@ typedef enum {
 	OP_URING_WRITE,
 	OP_WRITE,
 	OP_WRITEV,
+	OP_URING_SETXATTR,
 	OP_LAST
 } opty_t;
 
 typedef long long opnum_t;
 
 typedef void (*opfnc_t)(opnum_t, long);
+typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
 
 typedef struct opdesc {
 	opty_t	op;
@@ -277,6 +279,7 @@ void	uring_read_f(opnum_t, long);
 void	uring_write_f(opnum_t, long);
 void	write_f(opnum_t, long);
 void	writev_f(opnum_t, long);
+void	uring_setxattr_f(opnum_t, long);
 char	*xattr_flag_to_string(int);
 
 opdesc_t	ops[] = {
@@ -347,6 +350,7 @@ opdesc_t	ops[] = {
 	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
 	{ OP_WRITE, "write", write_f, 4, 1 },
 	{ OP_WRITEV, "writev", writev_f, 4, 1 },
+	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },
 }, *ops_end;
 
 flist_t	flist[FT_nft] = {
@@ -4779,8 +4783,45 @@ 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)
+setfattr_f_cbk(opnum_t opno, long r, setxattr_cbk cbk)
 {
 	int		e;
 	pathname_t	f;
@@ -4842,7 +4883,7 @@ setfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+	e = cbk(f.path, name, value, value_len, flag) < 0 ? errno : 0;
 	if (e == 0)
 		fep->xattr_counter++;
 	if (v)
@@ -4854,6 +4895,20 @@ out:
 	free_pathname(&f);
 }
 
+void
+uring_setxattr_f(opnum_t opno, long r)
+{
+#ifdef URING
+	setfattr_f_cbk(opno, r, io_uring_setxattr);
+#endif
+}
+
+void
+setfattr_f(opnum_t opno, long r)
+{
+	setfattr_f_cbk(opno, r, setxattr);
+}
+
 void
 snapshot_f(opnum_t opno, long r)
 {
Signature · 1 line
2.30.2
#2 lore raw

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

Quoted 39 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 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
ltp/fsstress.c +3 -0
index 003e0e49..aba7c6f7 100644
@@ -145,12 +145,14 @@ typedef enum {
 	OP_URING_WRITE,
 	OP_WRITE,
 	OP_WRITEV,
+	OP_URING_SETXATTR,
 	OP_LAST
 } opty_t;
 
 typedef long long opnum_t;
 
 typedef void (*opfnc_t)(opnum_t, long);
+typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
 
 typedef struct opdesc {
 	opty_t	op;
@@ -277,6 +279,7 @@ void	uring_read_f(opnum_t, long);
 void	uring_write_f(opnum_t, long);
 void	write_f(opnum_t, long);
 void	writev_f(opnum_t, long);
+void	uring_setxattr_f(opnum_t, long);
 char	*xattr_flag_to_string(int);
 
 opdesc_t	ops[] = {

ltp/fsstress.c opdesc_t ops[] = { · line 353

Quoted 4 lines
ltp/fsstress.c +1 -0
@@ -347,6 +350,7 @@ opdesc_t	ops[] = {
 	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
 	{ OP_WRITE, "write", write_f, 4, 1 },
 	{ OP_WRITEV, "writev", writev_f, 4, 1 },
+	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },

Due to 160a3b4b4477 "(fsstress: consistently index the ops array by OP_ type)" has been merged, so this patchset might need to rebase on that.

Thanks,
Zorro

Quoted 83 lines
ltp/fsstress.c +53 -2
 }, *ops_end;
 
 flist_t	flist[FT_nft] = {
@@ -4779,8 +4783,45 @@ 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)
+setfattr_f_cbk(opnum_t opno, long r, setxattr_cbk cbk)
 {
 	int		e;
 	pathname_t	f;
@@ -4842,7 +4883,7 @@ setfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+	e = cbk(f.path, name, value, value_len, flag) < 0 ? errno : 0;
 	if (e == 0)
 		fep->xattr_counter++;
 	if (v)
@@ -4854,6 +4895,20 @@ out:
 	free_pathname(&f);
 }
 
+void
+uring_setxattr_f(opnum_t opno, long r)
+{
+#ifdef URING
+	setfattr_f_cbk(opno, r, io_uring_setxattr);
+#endif
+}
+
+void
+setfattr_f(opnum_t opno, long r)
+{
+	setfattr_f_cbk(opno, r, setxattr);
+}
+
 void
 snapshot_f(opnum_t opno, long r)
 {
Signature · 1 line
2.30.2
#3 lore raw

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

Quoted 48 lines · Zorro Lang
Quoted 39 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 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
ltp/fsstress.c +3 -0
index 003e0e49..aba7c6f7 100644
@@ -145,12 +145,14 @@ typedef enum {
 	OP_URING_WRITE,
 	OP_WRITE,
 	OP_WRITEV,
+	OP_URING_SETXATTR,
 	OP_LAST
 } opty_t;
 
 typedef long long opnum_t;
 
 typedef void (*opfnc_t)(opnum_t, long);
+typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
 
 typedef struct opdesc {
 	opty_t	op;
@@ -277,6 +279,7 @@ void	uring_read_f(opnum_t, long);
 void	uring_write_f(opnum_t, long);
 void	write_f(opnum_t, long);
 void	writev_f(opnum_t, long);
+void	uring_setxattr_f(opnum_t, long);
 char	*xattr_flag_to_string(int);
 
 opdesc_t	ops[] = {

ltp/fsstress.c opdesc_t ops[] = { · line 353

Quoted 4 lines
ltp/fsstress.c +1 -0
@@ -347,6 +350,7 @@ opdesc_t	ops[] = {
 	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
 	{ OP_WRITE, "write", write_f, 4, 1 },
 	{ OP_WRITEV, "writev", writev_f, 4, 1 },
+	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },

Due to 160a3b4b4477 "(fsstress: consistently index the ops array by OP_ type)" has been merged, so this patchset might need to rebase on that.

Quoted 3 lines

Thanks,
Zorro

Zorro, thanks for notifying me. I rebased and sent out a new patch version.

Quoted 84 lines
Quoted 83 lines
ltp/fsstress.c +53 -2
 }, *ops_end;
 
 flist_t	flist[FT_nft] = {
@@ -4779,8 +4783,45 @@ 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)
+setfattr_f_cbk(opnum_t opno, long r, setxattr_cbk cbk)
 {
 	int		e;
 	pathname_t	f;
@@ -4842,7 +4883,7 @@ setfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = setxattr(f.path, name, value, value_len, flag) < 0 ? errno : 0;
+	e = cbk(f.path, name, value, value_len, flag) < 0 ? errno : 0;
 	if (e == 0)
 		fep->xattr_counter++;
 	if (v)
@@ -4854,6 +4895,20 @@ out:
 	free_pathname(&f);
 }
 
+void
+uring_setxattr_f(opnum_t opno, long r)
+{
+#ifdef URING
+	setfattr_f_cbk(opno, r, io_uring_setxattr);
+#endif
+}
+
+void
+setfattr_f(opnum_t opno, long r)
+{
+	setfattr_f_cbk(opno, r, setxattr);
+}
+
 void
 snapshot_f(opnum_t opno, long r)
 {
Signature · 1 line
2.30.2
#4 lore raw

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

In reply to Stefan Roesch

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

---
 ltp/fsstress.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 59 insertions(+), 4 deletions(-)
ltp/fsstress.c +59 -4
index aba7c6f7..5a18701a 100644
@@ -145,6 +145,7 @@ typedef enum {
 	OP_URING_WRITE,
 	OP_WRITE,
 	OP_WRITEV,
+	OP_URING_GETXATTR,
 	OP_URING_SETXATTR,
 	OP_LAST
 } opty_t;
@@ -152,6 +153,7 @@ typedef enum {
 typedef long long opnum_t;
 
 typedef void (*opfnc_t)(opnum_t, long);
+typedef ssize_t (*getxattr_cbk)(const char *, const char *, void *, size_t);
 typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
 
 typedef struct opdesc {
@@ -279,6 +281,7 @@ void	uring_read_f(opnum_t, long);
 void	uring_write_f(opnum_t, long);
 void	write_f(opnum_t, long);
 void	writev_f(opnum_t, long);
+void	uring_getxattr_f(opnum_t, long);
 void	uring_setxattr_f(opnum_t, long);
 char	*xattr_flag_to_string(int);
 
@@ -350,6 +353,7 @@ opdesc_t	ops[] = {
 	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
 	{ OP_WRITE, "write", write_f, 4, 1 },
 	{ OP_WRITEV, "writev", writev_f, 4, 1 },
+	{ OP_URING_GETXATTR, "uring_getxattr", uring_getxattr_f, 1, 0 },
 	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },
 }, *ops_end;
 
@@ -3899,8 +3903,44 @@ getdents_f(opnum_t opno, long r)
 	closedir(dir);
 }
 
-void
-getfattr_f(opnum_t opno, long r)
+static ssize_t
+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;
+}
+
+static void
+getfattr_f_cbk(opnum_t opno, long r, getxattr_cbk cbk)
 {
 	fent_t	        *fep;
 	int		e;
@@ -3936,7 +3976,7 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	value_len = getxattr(f.path, name, NULL, 0);
+        value_len = cbk(f.path, name, NULL, 0);
 	if (value_len < 0) {
 		if (v)
 			printf("%d/%lld: getfattr file %s name %s failed %d\n",
@@ -3958,7 +3998,8 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
+	e = cbk(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",
@@ -3968,6 +4009,20 @@ out:
 	free_pathname(&f);
 }
 
+void
+uring_getxattr_f(opnum_t opno, long r)
+{
+#ifdef URING
+	getfattr_f_cbk(opno, r, io_uring_getxattr);
+#endif
+}
+
+void
+getfattr_f(opnum_t opno, long r)
+{
+	getfattr_f_cbk(opno, r, getxattr);
+}
+
 void
 link_f(opnum_t opno, long r)
 {
Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH v2 2/2] fstress: add suport for using liburing getxattr

Quoted 93 lines · Stefan Roesch

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

---
 ltp/fsstress.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 59 insertions(+), 4 deletions(-)
ltp/fsstress.c +42 -2
index aba7c6f7..5a18701a 100644
@@ -145,6 +145,7 @@ typedef enum {
 	OP_URING_WRITE,
 	OP_WRITE,
 	OP_WRITEV,
+	OP_URING_GETXATTR,
 	OP_URING_SETXATTR,
 	OP_LAST
 } opty_t;
@@ -152,6 +153,7 @@ typedef enum {
 typedef long long opnum_t;
 
 typedef void (*opfnc_t)(opnum_t, long);
+typedef ssize_t (*getxattr_cbk)(const char *, const char *, void *, size_t);
 typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
 
 typedef struct opdesc {
@@ -279,6 +281,7 @@ void	uring_read_f(opnum_t, long);
 void	uring_write_f(opnum_t, long);
 void	write_f(opnum_t, long);
 void	writev_f(opnum_t, long);
+void	uring_getxattr_f(opnum_t, long);
 void	uring_setxattr_f(opnum_t, long);
 char	*xattr_flag_to_string(int);
 
@@ -350,6 +353,7 @@ opdesc_t	ops[] = {
 	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
 	{ OP_WRITE, "write", write_f, 4, 1 },
 	{ OP_WRITEV, "writev", writev_f, 4, 1 },
+	{ OP_URING_GETXATTR, "uring_getxattr", uring_getxattr_f, 1, 0 },
 	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },
 }, *ops_end;
 
@@ -3899,8 +3903,44 @@ getdents_f(opnum_t opno, long r)
 	closedir(dir);
 }
 
-void
-getfattr_f(opnum_t opno, long r)
+static ssize_t
+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;
+}
+
+static void
+getfattr_f_cbk(opnum_t opno, long r, getxattr_cbk cbk)
 {
 	fent_t	        *fep;
 	int		e;

ltp/fsstress.c getfattr_f(opnum_t opno, long r) · line 3979

Quoted 5 lines
ltp/fsstress.c +1 -1
@@ -3936,7 +3976,7 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	value_len = getxattr(f.path, name, NULL, 0);
+        value_len = cbk(f.path, name, NULL, 0);

Use tab for indention here.

Thanks,
Eryu

Quoted 36 lines
ltp/fsstress.c +16 -1
 	if (value_len < 0) {
 		if (v)
 			printf("%d/%lld: getfattr file %s name %s failed %d\n",
@@ -3958,7 +3998,8 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
+	e = cbk(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",
@@ -3968,6 +4009,20 @@ out:
 	free_pathname(&f);
 }
 
+void
+uring_getxattr_f(opnum_t opno, long r)
+{
+#ifdef URING
+	getfattr_f_cbk(opno, r, io_uring_getxattr);
+#endif
+}
+
+void
+getfattr_f(opnum_t opno, long r)
+{
+	getfattr_f_cbk(opno, r, getxattr);
+}
+
 void
 link_f(opnum_t opno, long r)
 {
Signature · 1 line
2.30.2
#6 lore raw

Re: [PATCH v2 2/2] fstress: add suport for using liburing getxattr

Quoted 97 lines · Eryu Guan
Quoted 96 lines · Stefan Roesch

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

---
 ltp/fsstress.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 59 insertions(+), 4 deletions(-)
ltp/fsstress.c +42 -2
index aba7c6f7..5a18701a 100644
@@ -145,6 +145,7 @@ typedef enum {
 	OP_URING_WRITE,
 	OP_WRITE,
 	OP_WRITEV,
+	OP_URING_GETXATTR,
 	OP_URING_SETXATTR,
 	OP_LAST
 } opty_t;
@@ -152,6 +153,7 @@ typedef enum {
 typedef long long opnum_t;
 
 typedef void (*opfnc_t)(opnum_t, long);
+typedef ssize_t (*getxattr_cbk)(const char *, const char *, void *, size_t);
 typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
 
 typedef struct opdesc {
@@ -279,6 +281,7 @@ void	uring_read_f(opnum_t, long);
 void	uring_write_f(opnum_t, long);
 void	write_f(opnum_t, long);
 void	writev_f(opnum_t, long);
+void	uring_getxattr_f(opnum_t, long);
 void	uring_setxattr_f(opnum_t, long);
 char	*xattr_flag_to_string(int);
 
@@ -350,6 +353,7 @@ opdesc_t	ops[] = {
 	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
 	{ OP_WRITE, "write", write_f, 4, 1 },
 	{ OP_WRITEV, "writev", writev_f, 4, 1 },
+	{ OP_URING_GETXATTR, "uring_getxattr", uring_getxattr_f, 1, 0 },
 	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },
 }, *ops_end;
 
@@ -3899,8 +3903,44 @@ getdents_f(opnum_t opno, long r)
 	closedir(dir);
 }
 
-void
-getfattr_f(opnum_t opno, long r)
+static ssize_t
+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;
+}
+
+static void
+getfattr_f_cbk(opnum_t opno, long r, getxattr_cbk cbk)
 {
 	fent_t	        *fep;
 	int		e;
@@ -3936,7 +3976,7 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
Quoted 8 lines

ltp/fsstress.c getfattr_f(opnum_t opno, long r) · line 3979

Quoted 2 lines
ltp/fsstress.c +1 -1
-	value_len = getxattr(f.path, name, NULL, 0);
+        value_len = cbk(f.path, name, NULL, 0);

Use tab for indention here.

Thanks,
Eryu

Fixed with v4.

Quoted 36 lines
Quoted 36 lines
ltp/fsstress.c +16 -1
 	if (value_len < 0) {
 		if (v)
 			printf("%d/%lld: getfattr file %s name %s failed %d\n",
@@ -3958,7 +3998,8 @@ getfattr_f(opnum_t opno, long r)
 		goto out;
 	}
 
-	e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
+	e = cbk(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",
@@ -3968,6 +4009,20 @@ out:
 	free_pathname(&f);
 }
 
+void
+uring_getxattr_f(opnum_t opno, long r)
+{
+#ifdef URING
+	getfattr_f_cbk(opno, r, io_uring_getxattr);
+#endif
+}
+
+void
+getfattr_f(opnum_t opno, long r)
+{
+	getfattr_f_cbk(opno, r, getxattr);
+}
+
 void
 link_f(opnum_t opno, long r)
 {
Signature · 1 line
2.30.2
#7 lore raw
In reply to Stefan Roesch
Quoted 11 lines · Stefan Roesch

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

Patches look fine to me overall, just one minor issue in patch 2.

But I'd like to firstly make sure the above patches for kernel and liburing will be accepted, so we don't merge tests for features that are never upstreamed. They don't have to be actually upstreamed, as long as the maintainers don't reject the new features.

And fsstress.c has been updated, would you please rebase & resend by then?

Thanks,
Eryu

Quoted 19 lines

base-commit: 2050356437e3576673ec5ead79ad72eb619f0d72
---
V2: - Introduce dedicated functions for uring getxattr and
uring setxattr, so they are not automatically linked in if liburing is available.

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

 ltp/fsstress.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 116 insertions(+), 6 deletions(-)
Signature · 1 line
2.30.2
#8 lore raw
Quoted 15 lines · Eryu Guan
Quoted 11 lines · Stefan Roesch

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

Patches look fine to me overall, just one minor issue in patch 2.

Quoted 8 lines

But I'd like to firstly make sure the above patches for kernel and liburing will be accepted, so we don't merge tests for features that are never upstreamed. They don't have to be actually upstreamed, as long as the maintainers don't reject the new features.

And fsstress.c has been updated, would you please rebase & resend by then?

I fixed the tab issue and rebased to version 4.

Quoted 22 lines

Thanks,
Eryu

Quoted 19 lines

base-commit: 2050356437e3576673ec5ead79ad72eb619f0d72
---
V2: - Introduce dedicated functions for uring getxattr and
uring setxattr, so they are not automatically linked in if liburing is available.

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

 ltp/fsstress.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 116 insertions(+), 6 deletions(-)
Signature · 1 line
2.30.2