From: Eryu Guan <guan@eryu.me>
To: Stefan Roesch <shr@fb.com>
Cc: fstests@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v4 1/2] fstress: add suport for using liburing setxattr
Date: Mon, 20 Dec 2021 00:02:28 +0800 [thread overview]
Message-ID: <Yb9XlIZkjnBlHmGZ@desktop> (raw)
In-Reply-To: <20211216184319.851514-2-shr@fb.com>
On Thu, Dec 16, 2021 at 10:43:18AM -0800, Stefan Roesch wrote:
> Summary:
>
> Liburing added support for setxattr. This change adds
> support for this this in fsstress when fsstress is built
> with liburing support.
>
> Signed-off-by: Stefan Roesch <shr@fb.com>
> ---
> ltp/fsstress.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 57 insertions(+), 2 deletions(-)
>
> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
> index 5f3126e6..48d93436 100644
> --- a/ltp/fsstress.c
> +++ b/ltp/fsstress.c
> @@ -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 {
> char *name;
> @@ -276,6 +278,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);
Order it by name?
> char *xattr_flag_to_string(int);
>
> struct opdesc ops[OP_LAST] = {
> @@ -346,6 +349,7 @@ struct opdesc ops[OP_LAST] = {
> [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 },
Make it aligned with other ops as well?
> }, *ops_end;
>
> flist_t flist[FT_nft] = {
> @@ -4771,8 +4775,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)
Space before tab in above line.
> +{
> + 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);
Seems we have to wait for the liburing patches go in first, otherwise
we'll hit compile error.
> +
> + 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;
> + }
Space before tab in above line.
Thanks,
Eryu
> +
> + 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;
> @@ -4834,7 +4875,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)
> @@ -4846,6 +4887,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)
> {
> --
> 2.30.2
next prev parent reply other threads:[~2021-12-19 16:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 18:43 [PATCH v4 0/2] Add support for using liburing xattr Stefan Roesch
2021-12-16 18:43 ` [PATCH v4 1/2] fstress: add suport for using liburing setxattr Stefan Roesch
2021-12-19 16:02 ` Eryu Guan [this message]
2021-12-16 18:43 ` [PATCH v4 2/2] fstress: add suport for using liburing getxattr Stefan Roesch
2021-12-17 4:20 ` [PATCH v4 0/2] Add support for using liburing xattr Zorro Lang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yb9XlIZkjnBlHmGZ@desktop \
--to=guan@eryu.me \
--cc=fstests@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=shr@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox