From patchwork Mon Dec 20 18:15:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12688367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E919C433F5 for ; Mon, 20 Dec 2021 18:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232777AbhLTSQE (ORCPT ); Mon, 20 Dec 2021 13:16:04 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:64476 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235769AbhLTSQA (ORCPT ); Mon, 20 Dec 2021 13:16:00 -0500 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BKC6N1v029457 for ; Mon, 20 Dec 2021 10:16:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=zn6jxkM4Y25aTbJWFdGLUkBW+V+Z0uRa1A14SVmat/k=; b=g3NNhp1Sv4CdZ32aXulQytRmRfItGoyG8f85dWSb/QWJlALMyTCCpzDemhxGB9waeZTw fPESPgVoJoki6tUnLXwUbcVbTwTg0JdL9D1exty9OTKSlH+yrr5o/0yrELQZGL9aEIaU jNTGwbLRlFZ1dtvFG7LRfcKzfDpYYwt/sUo= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3d2shkjg08-19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 20 Dec 2021 10:16:00 -0800 Received: from twshared12416.02.ash9.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 20 Dec 2021 10:15:49 -0800 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 194F184C9B81; Mon, 20 Dec 2021 10:15:45 -0800 (PST) From: Stefan Roesch To: , CC: Subject: [PATCH v5 1/2] fstress: add suport for using liburing setxattr Date: Mon, 20 Dec 2021 10:15:39 -0800 Message-ID: <20211220181540.1557109-2-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211220181540.1557109-1-shr@fb.com> References: <20211220181540.1557109-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: sg19ubFA3l_LlOFa0wvF6dAle8iwOthr X-Proofpoint-GUID: sg19ubFA3l_LlOFa0wvF6dAle8iwOthr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-20_08,2021-12-20_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=fb_outbound_notspam policy=fb_outbound score=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 priorityscore=1501 adultscore=0 suspectscore=0 mlxscore=0 bulkscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112200102 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org 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 --- ltp/fsstress.c | 181 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 118 insertions(+), 63 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 5f3126e6..bc4db73a 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -142,6 +142,7 @@ typedef enum { OP_UNLINK, OP_UNRESVSP, OP_URING_READ, + OP_URING_SETXATTR, OP_URING_WRITE, OP_WRITE, OP_WRITEV, @@ -151,6 +152,7 @@ typedef enum { 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; @@ -273,79 +275,81 @@ void truncate_f(opnum_t, long); void unlink_f(opnum_t, long); void unresvsp_f(opnum_t, long); void uring_read_f(opnum_t, long); +void uring_setxattr_f(opnum_t, long); void uring_write_f(opnum_t, long); void write_f(opnum_t, long); void writev_f(opnum_t, long); char *xattr_flag_to_string(int); struct opdesc ops[OP_LAST] = { - /* [OP_ENUM] = {"name", function, freq, iswrite }, */ - [OP_AFSYNC] = {"afsync", afsync_f, 0, 1 }, - [OP_ALLOCSP] = {"allocsp", allocsp_f, 1, 1 }, - [OP_AREAD] = {"aread", aread_f, 1, 0 }, - [OP_ATTR_REMOVE] = {"attr_remove", attr_remove_f, 0, 1 }, - [OP_ATTR_SET] = {"attr_set", attr_set_f, 0, 1 }, - [OP_AWRITE] = {"awrite", awrite_f, 1, 1 }, - [OP_BULKSTAT] = {"bulkstat", bulkstat_f, 1, 0 }, - [OP_BULKSTAT1] = {"bulkstat1", bulkstat1_f, 1, 0 }, - [OP_CHOWN] = {"chown", chown_f, 3, 1 }, - [OP_CLONERANGE] = {"clonerange", clonerange_f, 4, 1 }, - [OP_COPYRANGE] = {"copyrange", copyrange_f, 4, 1 }, - [OP_CREAT] = {"creat", creat_f, 4, 1 }, - [OP_DEDUPERANGE] = {"deduperange", deduperange_f, 4, 1 }, - [OP_DREAD] = {"dread", dread_f, 4, 0 }, - [OP_DWRITE] = {"dwrite", dwrite_f, 4, 1 }, - [OP_FALLOCATE] = {"fallocate", fallocate_f, 1, 1 }, - [OP_FDATASYNC] = {"fdatasync", fdatasync_f, 1, 1 }, - [OP_FIEMAP] = {"fiemap", fiemap_f, 1, 1 }, - [OP_FREESP] = {"freesp", freesp_f, 1, 1 }, - [OP_FSYNC] = {"fsync", fsync_f, 1, 1 }, - [OP_GETATTR] = {"getattr", getattr_f, 1, 0 }, - [OP_GETDENTS] = {"getdents", getdents_f, 1, 0 }, + /* [OP_ENUM] = {"name", function, freq, iswrite }, */ + [OP_AFSYNC] = {"afsync", afsync_f, 0, 1 }, + [OP_ALLOCSP] = {"allocsp", allocsp_f, 1, 1 }, + [OP_AREAD] = {"aread", aread_f, 1, 0 }, + [OP_ATTR_REMOVE] = {"attr_remove", attr_remove_f, 0, 1 }, + [OP_ATTR_SET] = {"attr_set", attr_set_f, 0, 1 }, + [OP_AWRITE] = {"awrite", awrite_f, 1, 1 }, + [OP_BULKSTAT] = {"bulkstat", bulkstat_f, 1, 0 }, + [OP_BULKSTAT1] = {"bulkstat1", bulkstat1_f, 1, 0 }, + [OP_CHOWN] = {"chown", chown_f, 3, 1 }, + [OP_CLONERANGE] = {"clonerange", clonerange_f, 4, 1 }, + [OP_COPYRANGE] = {"copyrange", copyrange_f, 4, 1 }, + [OP_CREAT] = {"creat", creat_f, 4, 1 }, + [OP_DEDUPERANGE] = {"deduperange", deduperange_f, 4, 1 }, + [OP_DREAD] = {"dread", dread_f, 4, 0 }, + [OP_DWRITE] = {"dwrite", dwrite_f, 4, 1 }, + [OP_FALLOCATE] = {"fallocate", fallocate_f, 1, 1 }, + [OP_FDATASYNC] = {"fdatasync", fdatasync_f, 1, 1 }, + [OP_FIEMAP] = {"fiemap", fiemap_f, 1, 1 }, + [OP_FREESP] = {"freesp", freesp_f, 1, 1 }, + [OP_FSYNC] = {"fsync", fsync_f, 1, 1 }, + [OP_GETATTR] = {"getattr", getattr_f, 1, 0 }, + [OP_GETDENTS] = {"getdents", getdents_f, 1, 0 }, /* get extended attribute */ - [OP_GETFATTR] = {"getfattr", getfattr_f, 1, 0 }, - [OP_LINK] = {"link", link_f, 1, 1 }, + [OP_GETFATTR] = {"getfattr", getfattr_f, 1, 0 }, + [OP_LINK] = {"link", link_f, 1, 1 }, /* list extent attributes */ - [OP_LISTFATTR] = {"listfattr", listfattr_f, 1, 0 }, - [OP_MKDIR] = {"mkdir", mkdir_f, 2, 1 }, - [OP_MKNOD] = {"mknod", mknod_f, 2, 1 }, - [OP_MREAD] = {"mread", mread_f, 2, 0 }, - [OP_MWRITE] = {"mwrite", mwrite_f, 2, 1 }, - [OP_PUNCH] = {"punch", punch_f, 1, 1 }, - [OP_ZERO] = {"zero", zero_f, 1, 1 }, - [OP_COLLAPSE] = {"collapse", collapse_f, 1, 1 }, - [OP_INSERT] = {"insert", insert_f, 1, 1 }, - [OP_READ] = {"read", read_f, 1, 0 }, - [OP_READLINK] = {"readlink", readlink_f, 1, 0 }, - [OP_READV] = {"readv", readv_f, 1, 0 }, + [OP_LISTFATTR] = {"listfattr", listfattr_f, 1, 0 }, + [OP_MKDIR] = {"mkdir", mkdir_f, 2, 1 }, + [OP_MKNOD] = {"mknod", mknod_f, 2, 1 }, + [OP_MREAD] = {"mread", mread_f, 2, 0 }, + [OP_MWRITE] = {"mwrite", mwrite_f, 2, 1 }, + [OP_PUNCH] = {"punch", punch_f, 1, 1 }, + [OP_ZERO] = {"zero", zero_f, 1, 1 }, + [OP_COLLAPSE] = {"collapse", collapse_f, 1, 1 }, + [OP_INSERT] = {"insert", insert_f, 1, 1 }, + [OP_READ] = {"read", read_f, 1, 0 }, + [OP_READLINK] = {"readlink", readlink_f, 1, 0 }, + [OP_READV] = {"readv", readv_f, 1, 0 }, /* remove (delete) extended attribute */ - [OP_REMOVEFATTR] = {"removefattr", removefattr_f, 1, 1 }, - [OP_RENAME] = {"rename", rename_f, 2, 1 }, - [OP_RNOREPLACE] = {"rnoreplace", rnoreplace_f, 2, 1 }, - [OP_REXCHANGE] = {"rexchange", rexchange_f, 2, 1 }, - [OP_RWHITEOUT] = {"rwhiteout", rwhiteout_f, 2, 1 }, - [OP_RESVSP] = {"resvsp", resvsp_f, 1, 1 }, - [OP_RMDIR] = {"rmdir", rmdir_f, 1, 1 }, + [OP_REMOVEFATTR] = {"removefattr", removefattr_f, 1, 1 }, + [OP_RENAME] = {"rename", rename_f, 2, 1 }, + [OP_RNOREPLACE] = {"rnoreplace", rnoreplace_f, 2, 1 }, + [OP_REXCHANGE] = {"rexchange", rexchange_f, 2, 1 }, + [OP_RWHITEOUT] = {"rwhiteout", rwhiteout_f, 2, 1 }, + [OP_RESVSP] = {"resvsp", resvsp_f, 1, 1 }, + [OP_RMDIR] = {"rmdir", rmdir_f, 1, 1 }, /* set attribute flag (FS_IOC_SETFLAGS ioctl) */ - [OP_SETATTR] = {"setattr", setattr_f, 0, 1 }, + [OP_SETATTR] = {"setattr", setattr_f, 0, 1 }, /* set extended attribute */ - [OP_SETFATTR] = {"setfattr", setfattr_f, 2, 1 }, + [OP_SETFATTR] = {"setfattr", setfattr_f, 2, 1 }, /* set project id (XFS_IOC_FSSETXATTR ioctl) */ - [OP_SETXATTR] = {"setxattr", setxattr_f, 1, 1 }, - [OP_SNAPSHOT] = {"snapshot", snapshot_f, 1, 1 }, - [OP_SPLICE] = {"splice", splice_f, 1, 1 }, - [OP_STAT] = {"stat", stat_f, 1, 0 }, - [OP_SUBVOL_CREATE] = {"subvol_create", subvol_create_f, 1, 1 }, - [OP_SUBVOL_DELETE] = {"subvol_delete", subvol_delete_f, 1, 1 }, - [OP_SYMLINK] = {"symlink", symlink_f, 2, 1 }, - [OP_SYNC] = {"sync", sync_f, 1, 1 }, - [OP_TRUNCATE] = {"truncate", truncate_f, 2, 1 }, - [OP_UNLINK] = {"unlink", unlink_f, 1, 1 }, - [OP_UNRESVSP] = {"unresvsp", unresvsp_f, 1, 1 }, - [OP_URING_READ] = {"uring_read", uring_read_f, 1, 0 }, - [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_SETXATTR] = {"setxattr", setxattr_f, 1, 1 }, + [OP_SNAPSHOT] = {"snapshot", snapshot_f, 1, 1 }, + [OP_SPLICE] = {"splice", splice_f, 1, 1 }, + [OP_STAT] = {"stat", stat_f, 1, 0 }, + [OP_SUBVOL_CREATE] = {"subvol_create", subvol_create_f, 1, 1 }, + [OP_SUBVOL_DELETE] = {"subvol_delete", subvol_delete_f, 1, 1 }, + [OP_SYMLINK] = {"symlink", symlink_f, 2, 1 }, + [OP_SYNC] = {"sync", sync_f, 1, 1 }, + [OP_TRUNCATE] = {"truncate", truncate_f, 2, 1 }, + [OP_UNLINK] = {"unlink", unlink_f, 1, 1 }, + [OP_UNRESVSP] = {"unresvsp", unresvsp_f, 1, 1 }, + [OP_URING_READ] = {"uring_read", uring_read_f, 1, 0 }, + [OP_URING_SETXATTR] = {"uring_setxattr", uring_setxattr_f, 1, 1 }, + [OP_URING_WRITE] = {"uring_write", uring_write_f, 1, 1 }, + [OP_WRITE] = {"write", write_f, 4, 1 }, + [OP_WRITEV] = {"writev", writev_f, 4, 1 }, }, *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) +{ + 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; @@ -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) { From patchwork Mon Dec 20 18:15:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12688365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86421C433EF for ; Mon, 20 Dec 2021 18:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240368AbhLTSQE (ORCPT ); Mon, 20 Dec 2021 13:16:04 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:30500 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232777AbhLTSQA (ORCPT ); Mon, 20 Dec 2021 13:16:00 -0500 Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BKHNhuY008403 for ; Mon, 20 Dec 2021 10:16:00 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=kah7li1vYIV9zvMRkB8+JbYEgjGfhybErksyiN57sJU=; b=cbzFwSYtCnAYhrSo0I+OEDucWPB7hi9LWpF9qtextg4Ikm28euFqCF/Pg+cTj9gZ0dXp D+V7mDlswP3QK2/0uv3JU7877teI7hA9YI5nEZvF7cJmlt0K23LLRQARa7t24jzxUyih jnTwg5Ko6L2UaPCnBJLbFYLgkGN2JFnWPWk= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3d2maq4g4g-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 20 Dec 2021 10:16:00 -0800 Received: from twshared7460.02.ash7.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 20 Dec 2021 10:15:59 -0800 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 1EB7A84C9B83; Mon, 20 Dec 2021 10:15:45 -0800 (PST) From: Stefan Roesch To: , CC: Subject: [PATCH v5 2/2] fstress: add suport for using liburing getxattr Date: Mon, 20 Dec 2021 10:15:40 -0800 Message-ID: <20211220181540.1557109-3-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211220181540.1557109-1-shr@fb.com> References: <20211220181540.1557109-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: FwXEh5-7BG9VIc01iYIN3qmp7p_zSr2P X-Proofpoint-ORIG-GUID: FwXEh5-7BG9VIc01iYIN3qmp7p_zSr2P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-20_08,2021-12-20_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=fb_outbound_notspam policy=fb_outbound score=0 lowpriorityscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 clxscore=1015 mlxlogscore=895 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112200102 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Liburing added support for getxattr. This change adds support for this this in fsstress when fsstress is built with liburing support. Signed-off-by: Stefan Roesch --- ltp/fsstress.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index bc4db73a..efd154a6 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -141,6 +141,7 @@ typedef enum { OP_TRUNCATE, OP_UNLINK, OP_UNRESVSP, + OP_URING_GETXATTR, OP_URING_READ, OP_URING_SETXATTR, OP_URING_WRITE, @@ -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 { @@ -274,6 +276,7 @@ void sync_f(opnum_t, long); void truncate_f(opnum_t, long); void unlink_f(opnum_t, long); void unresvsp_f(opnum_t, long); +void uring_getxattr_f(opnum_t, long); void uring_read_f(opnum_t, long); void uring_setxattr_f(opnum_t, long); void uring_write_f(opnum_t, long); @@ -345,6 +348,7 @@ struct opdesc ops[OP_LAST] = { [OP_TRUNCATE] = {"truncate", truncate_f, 2, 1 }, [OP_UNLINK] = {"unlink", unlink_f, 1, 1 }, [OP_UNRESVSP] = {"unresvsp", unresvsp_f, 1, 1 }, + [OP_URING_GETXATTR] = {"uring_getxattr", uring_getxattr_f, 1, 0 }, [OP_URING_READ] = {"uring_read", uring_read_f, 1, 0 }, [OP_URING_SETXATTR] = {"uring_setxattr", uring_setxattr_f, 1, 1 }, [OP_URING_WRITE] = {"uring_write", uring_write_f, 1, 1 }, @@ -3891,8 +3895,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; @@ -3928,7 +3968,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", @@ -3950,7 +3990,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", @@ -3960,6 +4001,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) {