From patchwork Fri Aug 25 13:54:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365734 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B0B2C3DA6F for ; Fri, 25 Aug 2023 13:55:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A85AD2800AB; Fri, 25 Aug 2023 09:55:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0E538E0015; Fri, 25 Aug 2023 09:55:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 889002800AB; Fri, 25 Aug 2023 09:55:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7242D8E0015 for ; Fri, 25 Aug 2023 09:55:22 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 49D7FB26A4 for ; Fri, 25 Aug 2023 13:55:22 +0000 (UTC) X-FDA: 81162774084.21.EFDAF27 Received: from out-247.mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) by imf06.hostedemail.com (Postfix) with ESMTP id 88338180028 for ; Fri, 25 Aug 2023 13:55:19 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=sf0c3BaV; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971719; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=M7eywqhb1fMAXTeyjh6BJsPONBLehGvo8wJ7nQSmBJs=; b=HcqfK5/ViBc7HcMwyTiOoVrXA1UgvMDCheoUsoBw0X3LnFGljRJ60I1Wv9Ho93WcseGDvA iLe4k+BAjlQ+q5HRjD0CJX5nVjnVzoGotFWxDKVYnSpBje3OGgn0WsHMhs2bgkGMalRHJC Zz2tCBywJDtEsA7coXNSlEzniKedS5w= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=sf0c3BaV; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971719; a=rsa-sha256; cv=none; b=O+qNH5ZNwlbXYKlcN6x0bQUmSRL2hWglZdBsWIALyYuiANirZqJl4pii8OKDl/NTNTGnsp Av6AbEaGI6dIZSJxEZ8WiYH1rHFmM2SS9ThfwPge3ehlJbtIAef3E+DYDWFBkJ/NvEodDC HM7qBDZrZN0bucnyY22VmgCsaEKXH9Q= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M7eywqhb1fMAXTeyjh6BJsPONBLehGvo8wJ7nQSmBJs=; b=sf0c3BaV5zKRH4Bb8TUwfPopplZAFyQJxSB3uPd/Bru862GHE/6uLEqra/FCbrZoDX4RQi CIrt1XneKgBJ/A8gWA/etx0kgRlpMUcGJTfa14yTcf5Kv3L0Wt8Br8rgcIz1PY9X6AeQ+Q Vrx6zJaXOEDBrQhrS+G7Zr51TGkx4FM= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 01/29] fs: split off vfs_getdents function of getdents64 syscall Date: Fri, 25 Aug 2023 21:54:03 +0800 Message-Id: <20230825135431.1317785-2-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 88338180028 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 7ds9xzfq5d7infapnga6fkuyzu4bubk4 X-HE-Tag: 1692971719-390689 X-HE-Meta: U2FsdGVkX1+YRqrN9QQSmmwi6ZRj1oqoyINQd0zZOKaa+quHWqK2wtb8h5Q5NNxG4yxd+mZtEXff4L8wljXwl/9g9dFdVsZbDLEVSJy23QTGXfOcE8C8uRaCktG4GEKUtXym0o1KX9QjuySnYm0Fc/wbCaNTHQcJR9PAouzNmbRI/CAsgyEXB0kAvvQivZM4Nlmto1hOWj/RlMb9mf36vph3AX+7cP3FKClIhDYmViBJaToLWZPA3n8lkR0Z/S333WeKuXM38ejh5Ba1JlCpOdEWkps3I9olD8PkcCYPnqGVhN6iUezpC2V1/BcofTr1cAzPJf4izojQggKwdz5X3QdXQB1thezVHrNTDAlAgR/qhIhKWCjQrDcUHd02ZBMTv1J8a4mMrn1CXScEWHr9DgIw+qUQRFfKUxz3Fw8YSuI8qOOcsOdnACI1C7MHMPwVNeY73nMBblo5hkZmcE36OLdIlNvJrowPIwErvkMBP+oc4LTxITVrRE2EN4RGMz9GWY5MwsbB/eRjA+G9lG9R+IZI7ifoPGQcY/osyJOdPMUweUUxvxxBwGg/e74BbKokrntiNQJ6hzDwXNfdyWeOydsDhpfGaVUamHKOGRzVjgZCE8Wlslji4TX8tBaWhNZZ12mif1t1XhW7Z97uh735dM7O3/hol55dnZyxOpSvhxRVaRMybCuwYmRN9A45b2R0dutAz5QBNCFk7Wnpdua4pn9uc+4tnmGT2Z2TQv5SC1W2O3r5UA4mq1rVipJexfr291CLJh6+lRrJ3ygnZbmtJKdM4pWG2vMHGisd29FgrzFzQfHYZ8RET1MLtnARE+cJM8hcb8+elcFVYVEJt7eaBec/4p6kZCxnmCe7fTyiIecTH/cMSu9KwpqKF/GtoajTgTvlXOM4C9Y/yoqmi+m6OIq6WsrGvaRG88KdEmWK/RBB64d3f55JsWBF0spKln05oxZL2g2142HKfzSHCKd AziNisak h89kM1IhKeSN7xTGb2a31OhDTaxdM1ztM18dN9X/O2R4ig6Rq0T0ZgmvgNtlPBVV7yx1zOrIVdDUn4+s8d3oKAQqrjJxFrLcIfFm3bStrX7+aIAdbyws4JsQwYSyyFfih1vZdTW2zAEYDBeKkDy216P/D3zmOQMTaidMaHXVyzJGKzcE/4qe/N34yxM7mhhsaXFDx/R9CbofjBymS7HQq21dLGnPT+WRAN252ngN4CQa548tYX/5lF3FJnNrIlMCA5jDM3f/You8colIYmPjOhCF00LDhFyNQX9gAnfdP66VWWGZTuz1QPKEebrqPKLJnNFngtAoINfvfyMRWLgDHV77vLEuo2VQNQVXySq0p0Up8AdKU4pWsEXVjOw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Dominique Martinet This splits off the vfs_getdents function from the getdents64 system call. This will allow io_uring to call the vfs_getdents function. Co-developed-by: Stefan Roesch Signed-off-by: Stefan Roesch Signed-off-by: Dominique Martinet Signed-off-by: Hao Xu --- fs/internal.h | 8 ++++++++ fs/readdir.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index f7a3dc111026..b1f66e52d61b 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -304,3 +304,11 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns); struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap); void mnt_idmap_put(struct mnt_idmap *idmap); + +/* + * fs/readdir.c + */ +struct linux_dirent64; + +int vfs_getdents(struct file *file, struct linux_dirent64 __user *dirent, + unsigned int count); diff --git a/fs/readdir.c b/fs/readdir.c index b264ce60114d..9592259b7e7f 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -21,6 +21,7 @@ #include #include #include +#include "internal.h" #include @@ -351,10 +352,16 @@ static bool filldir64(struct dir_context *ctx, const char *name, int namlen, return false; } -SYSCALL_DEFINE3(getdents64, unsigned int, fd, - struct linux_dirent64 __user *, dirent, unsigned int, count) + +/** + * vfs_getdents - getdents without fdget + * @file : pointer to file struct of directory + * @dirent : pointer to user directory structure + * @count : size of buffer + */ +int vfs_getdents(struct file *file, struct linux_dirent64 __user *dirent, + unsigned int count) { - struct fd f; struct getdents_callback64 buf = { .ctx.actor = filldir64, .count = count, @@ -362,11 +369,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, }; int error; - f = fdget_pos(fd); - if (!f.file) - return -EBADF; - - error = iterate_dir(f.file, &buf.ctx); + error = iterate_dir(file, &buf.ctx); if (error >= 0) error = buf.error; if (buf.prev_reclen) { @@ -379,6 +382,21 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, else error = count - buf.count; } + return error; +} + +SYSCALL_DEFINE3(getdents64, unsigned int, fd, + struct linux_dirent64 __user *, dirent, unsigned int, count) +{ + struct fd f; + int error; + + f = fdget_pos(fd); + if (!f.file) + return -EBADF; + + error = vfs_getdents(f.file, dirent, count); + fdput_pos(f); return error; } From patchwork Fri Aug 25 13:54:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365735 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2ABAC3DA6F for ; Fri, 25 Aug 2023 13:55:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5088C2800B2; Fri, 25 Aug 2023 09:55:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 491B68E0015; Fri, 25 Aug 2023 09:55:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30BDA2800B2; Fri, 25 Aug 2023 09:55:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1A3828E0015 for ; Fri, 25 Aug 2023 09:55:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EEA1C1C98FD for ; Fri, 25 Aug 2023 13:55:40 +0000 (UTC) X-FDA: 81162774840.26.9ABA3B8 Received: from out-251.mta1.migadu.com (out-251.mta1.migadu.com [95.215.58.251]) by imf30.hostedemail.com (Postfix) with ESMTP id 1B7F780014 for ; Fri, 25 Aug 2023 13:55:38 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=FhWBDojl; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.251 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971739; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T0rAQ2m4NCOjyQSS+sDl9LbRcvD63qBgcFke1LvzwG4=; b=B6gvjuHACrWjGN686iZPdIqFEbMDVQQxKHrV5T3XAp4jeGq+O2sz+2qY9OXcABsMZtRxNH WnYAn8k6vLbG4w+08jIK3/DCaLWpZH5ogLGQQV03OgC75W+FcfkPhCiSc9rEVyg6k7i5XY o6bok1LIJEdkNB4CKuKT1+29D4ENxSQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=FhWBDojl; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.251 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971739; a=rsa-sha256; cv=none; b=lWBgDQgraDpzo5s5bVKnpDNpfA3fbt06QwsdVKsQt31Y0WhE5Fc/DGS7AcPVenP80K4qBD 6iJ6VBp3sSRfTnE6tCmI6uXjLmXYqc50RxfFZT5doyjCZCnjRbFDgZOUSQIDhTPiHv3Vmt 7HowaLOtFCmS2dMtPcFDNrp16r8BOxU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T0rAQ2m4NCOjyQSS+sDl9LbRcvD63qBgcFke1LvzwG4=; b=FhWBDojlb1xYVHNahPbh8JswlNyJ/7jP1EQwNTm7cO8OehSugwUDArDmc1mbqA0BkMNMvY d5QJXx+UI3kBCUhvBoGQg8tDI16sv1k0yhgjUCPvI7yY9h5j0N5DBUGFQcYH7e2p4/SYF7 drCs2jVg1zT9ErcXMBzhoggf+SCjkYU= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 02/29] xfs: rename XBF_TRYLOCK to XBF_NOWAIT Date: Fri, 25 Aug 2023 21:54:04 +0800 Message-Id: <20230825135431.1317785-3-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 1B7F780014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cse6qe87u7m694qs1m9itnz8op877ztk X-HE-Tag: 1692971738-238468 X-HE-Meta: U2FsdGVkX19VfAHJauwAk4dQX8DN7XKhMT75FtLppasOmic0jQskaJwE3GOQR3KFNYmUAKaqsb0BiYO1uX6oqqjNjAsjRLJ9oihwERsH+5nIGbi+cL3z7uDSJEfDR7CHPSeoBxdAcZBwmk5UcBjQIBZaWrOCJKrDeTelqzi9Lb62etz9Nm78jW2vI3uPf2YpB4gHZKlpw7T0N5ocMbXCkmZ7ZOnndQAD2r0Fvs9hAP7SgltRk8b/VZ4yWeKGPQgRD3Hah/BrrmhsmEn2O5AS2ZLESoCF3yZn+/X2JAhSuGJBo7dphIJsbL4dp1aMnvGtne4J6WVtIJGdAaY6sDUJ7WzV8ePs9nHrnPUlA4VzZRofo4snk671Z+Jk0j83ufhspEHlH+GXPdfTxqaWsRDsiecy8jQSQmSptfxjW6wS906d8bi4o670oUgXZQJVCcFU/HgTPUKpxhrEg+1khH8zqfPUV+hbUpPt/5AQv7jocr9qcQQp/p4e+fiw3VsArjOOtJ84UVujIlIGnNNuzDIki5GWMHbRwtUmTA/eaJL3vYbfr3rYh9hYuz905ZrbsEpLonEIBCnfjtYWJyr7aVR9hSMjwIrgVK86XXNNiqmYBMOwTAmX21KO+198nLumHZfjURLs1EmQgv1TvEl9+xcP+BQ/4ahptFeCE0WvvPG9ZGzZX4+Qadgf08MvSQ5aOygu3C1rlNdMTIOjjGIdCqUoBT9B75wwV0crz647TcqOQUtDACu0RQNJhwhNAIO7murCq8N8b3A3YQ9G34pvduMxe4EzrphhmlDryYsWKAlUfZVJQN17dTYPJxULWJhHx6oOp1XjiD3e5sOkwn7SavfAgH7zTmkv0uB70x3oprWzc0mSPkM4vKmaN3cO4MKTZ9sI0W3e0Nazxa90zfY0UfWMA/mRkJR7dEiObYhg981EpCx6phb9IdXq6IdiemZQ/JXrE5VEWh2BC3ZcgL3UTWG MI2EX4eN gFGxldjJEkS8MldiPf5vVXBIp0Y776QiSRA8ixFFqTAmKYnKIKOWEWf9Me33ZgmmBUMdm3Kbr7i8LbXOrgDe2s3+QkGfaYhVx8jMXz7KlrVT55qC7MVFRzzIR/mUEKvcL/Q9V9vlUCNoYZWNaecOBhxh3EqZX8+8LuyjJPP0CeVgzCde1RqneSxMkhAwWIll53Cz7ETEVmzr9RCAbS69UxULSRosrSgVt/DDmDL6RI5swuYbn152u2/9WtYB2/uHtsWdW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu XBF_TRYLOCK means we need lock but don't block on it, we can use it to stand for not waiting for memory allcation. Rename XBF_TRYLOCK to XBF_NOWAIT, which is more generic. Signed-off-by: Hao Xu --- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_btree.c | 2 +- fs/xfs/scrub/repair.c | 2 +- fs/xfs/xfs_buf.c | 6 +++--- fs/xfs/xfs_buf.h | 4 ++-- fs/xfs/xfs_dquot.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 3069194527dd..a75b9298faa8 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -3183,7 +3183,7 @@ xfs_alloc_read_agf( ASSERT((flags & (XFS_ALLOC_FLAG_FREEING | XFS_ALLOC_FLAG_TRYLOCK)) != (XFS_ALLOC_FLAG_FREEING | XFS_ALLOC_FLAG_TRYLOCK)); error = xfs_read_agf(pag, tp, - (flags & XFS_ALLOC_FLAG_TRYLOCK) ? XBF_TRYLOCK : 0, + (flags & XFS_ALLOC_FLAG_TRYLOCK) ? XBF_NOWAIT : 0, &agfbp); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index d440393b40eb..2ccb0867824c 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -661,7 +661,7 @@ xfs_attr_rmtval_invalidate( return error; if (XFS_IS_CORRUPT(args->dp->i_mount, nmap != 1)) return -EFSCORRUPTED; - error = xfs_attr_rmtval_stale(args->dp, &map, XBF_TRYLOCK); + error = xfs_attr_rmtval_stale(args->dp, &map, XBF_NOWAIT); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 6a6503ab0cd7..77c4f1d83475 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -1343,7 +1343,7 @@ xfs_btree_read_buf_block( int error; /* need to sort out how callers deal with failures first */ - ASSERT(!(flags & XBF_TRYLOCK)); + ASSERT(!(flags & XBF_NOWAIT)); error = xfs_btree_ptr_to_daddr(cur, ptr, &d); if (error) diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c index ac6d8803e660..9312cf3b20e2 100644 --- a/fs/xfs/scrub/repair.c +++ b/fs/xfs/scrub/repair.c @@ -460,7 +460,7 @@ xrep_invalidate_block( error = xfs_buf_incore(sc->mp->m_ddev_targp, XFS_FSB_TO_DADDR(sc->mp, fsbno), - XFS_FSB_TO_BB(sc->mp, 1), XBF_TRYLOCK, &bp); + XFS_FSB_TO_BB(sc->mp, 1), XBF_NOWAIT, &bp); if (error) return 0; diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 15d1e5a7c2d3..9f84bc3b802c 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -228,7 +228,7 @@ _xfs_buf_alloc( * We don't want certain flags to appear in b_flags unless they are * specifically set by later operations on the buffer. */ - flags &= ~(XBF_UNMAPPED | XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD); + flags &= ~(XBF_UNMAPPED | XBF_NOWAIT | XBF_ASYNC | XBF_READ_AHEAD); atomic_set(&bp->b_hold, 1); atomic_set(&bp->b_lru_ref, 1); @@ -543,7 +543,7 @@ xfs_buf_find_lock( struct xfs_buf *bp, xfs_buf_flags_t flags) { - if (flags & XBF_TRYLOCK) { + if (flags & XBF_NOWAIT) { if (!xfs_buf_trylock(bp)) { XFS_STATS_INC(bp->b_mount, xb_busy_locked); return -EAGAIN; @@ -886,7 +886,7 @@ xfs_buf_readahead_map( struct xfs_buf *bp; xfs_buf_read_map(target, map, nmaps, - XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD, &bp, ops, + XBF_NOWAIT | XBF_ASYNC | XBF_READ_AHEAD, &bp, ops, __this_address); } diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 549c60942208..8cd307626939 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -45,7 +45,7 @@ struct xfs_buf; /* flags used only as arguments to access routines */ #define XBF_INCORE (1u << 29)/* lookup only, return if found in cache */ -#define XBF_TRYLOCK (1u << 30)/* lock requested, but do not wait */ +#define XBF_NOWAIT (1u << 30)/* mem/lock requested, but do not wait */ #define XBF_UNMAPPED (1u << 31)/* do not map the buffer */ @@ -68,7 +68,7 @@ typedef unsigned int xfs_buf_flags_t; { _XBF_DELWRI_Q, "DELWRI_Q" }, \ /* The following interface flags should never be set */ \ { XBF_INCORE, "INCORE" }, \ - { XBF_TRYLOCK, "TRYLOCK" }, \ + { XBF_NOWAIT, "NOWAIT" }, \ { XBF_UNMAPPED, "UNMAPPED" } /* diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 7f071757f278..5bc01ed4b2d7 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1233,7 +1233,7 @@ xfs_qm_dqflush( * Get the buffer containing the on-disk dquot */ error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, - mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK, + mp->m_quotainfo->qi_dqchunklen, XBF_NOWAIT, &bp, &xfs_dquot_buf_ops); if (error == -EAGAIN) goto out_unlock; From patchwork Fri Aug 25 13:54:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365736 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A4EC3DA6F for ; Fri, 25 Aug 2023 13:55:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E0692800B3; Fri, 25 Aug 2023 09:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 469EC8E0015; Fri, 25 Aug 2023 09:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BCE92800B3; Fri, 25 Aug 2023 09:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 190418E0015 for ; Fri, 25 Aug 2023 09:55:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DC00AC06B9 for ; Fri, 25 Aug 2023 13:55:54 +0000 (UTC) X-FDA: 81162775428.01.003D55F Received: from out-249.mta1.migadu.com (out-249.mta1.migadu.com [95.215.58.249]) by imf17.hostedemail.com (Postfix) with ESMTP id 1A4FC40018 for ; Fri, 25 Aug 2023 13:55:52 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Ps5x6ZR/"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf17.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971753; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dKms4PZoKLZJkif6yJQKB9u00tda86+mJb3olx59XCE=; b=x9jWak1HG0gxJQdoCbsmqjlxXnswdO9qQWHIsHI8E3+aoOERy5wOtmQgsaCapRnpJQtmLA dkAbTeIb06D9vD547gHzEMqjBxIuH+683rvV2ECGA8uV5CrsudB8Dr/VdJAfhHImlB1Fjv kRGUlBrULrfnzS3ZpghrL2mzCabziZs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Ps5x6ZR/"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf17.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971753; a=rsa-sha256; cv=none; b=QqHkaVQm29hCB2K59BCCzJD8eBSOQ6VsR7Y8A6Hojws+kJSBSjyNBxjsxcPP09IaNzy/EY s082nMGc1zioZQwTk6bglyh7aJUEertyvaq+Wjymdvr+lRuumAsjp2CrSK7im947z/N87+ zFMJViqRpbo1dfxhaRkmeqF4RTv0dpA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dKms4PZoKLZJkif6yJQKB9u00tda86+mJb3olx59XCE=; b=Ps5x6ZR/FlKh3oFYzUaxLaQsK0eDYLRFP4rP89FE5SIUJSvSK2X/nU4/R8/vQchrN50SmT nh9mhZ3xwtQmH1h7Q1ucMo2yK2m687xZlecx7xXVwuB1LD400LJfmeJoMNsvONLS4gvGH+ 34YxaU+QFsda1snLti+SvGkuVNK9mlo= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 03/29] xfs: add NOWAIT semantics for readdir Date: Fri, 25 Aug 2023 21:54:05 +0800 Message-Id: <20230825135431.1317785-4-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 1A4FC40018 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jboymzyyrpk459fbbosba1gyub566gkc X-HE-Tag: 1692971752-505698 X-HE-Meta: U2FsdGVkX183x8Mca+hh+saBx184rlEYDd+qZ2mlUZPe+VfZCnqMbIDOZSLEYyfHyJWZtGxZZP4BsGlNrxh5sFb3msd9QboCFJk/PmkVzgfccXBAFE5eO7hjfRNF2rANtmxgEOrkrfH7sA8TEh03yw24e9SW0i+b2r6vT/nOwQUw+N08dIrMqWgT4+ycxYhsmtzQ+SUPjGMOHNZy9UPzs+tPxhjZEuE5tnvb/UyN9IUJX5M4AnfYgUtR7O3tWizpbkaPqqGqilp3Rhe2At6khLXNsa7B/MAgul/GzTeNJldHSk0SDNjrB05UJGMgZm5/61QAqmYtr1mUhq5r0QMX8gWFZyMCzoP1oBjJOgU25dorChzcEF62Wno7rtweood3Q4UVufwdIkaaz8/PthYHTFw66+dWcmhLrN1BRX8Q9oxDK3gEx7LptUX1DWOgsZGcn3pOaVFMD/wqD+c0l1h7N0NPEVBSQwlsAHTjtk6AFx6G2NNGOsdu0Ui3igQwSoxfzrCmHfBh70kcxyycHWgvxw+SkrqyT9bvwrOIXa5JVh8IfuHgITH51L1JxwRXBHuj/No4WkH5X+L+Z+HnhH6SPrKpeT3GttbndzGQ4ua+D5y5yOwHTtS3hErgS87P1rcIquarDp8svfMSbLZIyNVitO4SjXBRo3qbV1AcCRtLj00w4pJCD/Sdk8M4tJ11mwHGq8dcA1t194KtV3i5HZ6HjPenUecYMpsJyGCAX2m+FWhcGNjCSGrrtBeeGVTyGB+1VR00HQzRG1acOj2F/HKZXhyyLg7HsdsjtYKEN26FIc0VkMC75cWqPg/4As4AOw5NNI8ZRlk0oq/ujPV+YkMoQE+vYci4btQsug3UigS7CjxZdylilTwHFr8iEG74ksq2Z58QS1ZD3dl3nLCOTbHUw4jRScJyokYhMfwr6DiGyHGEqIgRZkUNH7NskaBT60sKFHmWiOZ7xwC12qt2nhl SWuF63Fa s3R0+8v0MK5NITntkuW6gbcOo1XXlyVfwVzTgxsOweYdgPp2rpi2HA76bTAb8wgS/cUzdNbUooOw3nb0vMck/JKcMvfiZxaeHSzaWXKgT72oiyYTk13FU0f+fZUR34furxUeaFhDdK1sU9NW7H1+QqgoDQXJGR00075Ve12wL+RwmTnQspgsceHPBy2/87tAGYjOtczYOl2m5SfnynJRBSZ26v1W9S9ZHZ+OQTQens2sQN4E= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Implement NOWAIT semantics for readdir. Return EAGAIN error to the caller if it would block, like failing to get locks, or going to do IO. Co-developed-by: Dave Chinner Signed-off-by: Dave Chinner Signed-off-by: Hao Xu [fixes deadlock issue, tweak code style] --- fs/xfs/libxfs/xfs_da_btree.c | 16 +++++++++++ fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_dir2_block.c | 7 ++--- fs/xfs/libxfs/xfs_dir2_priv.h | 2 +- fs/xfs/scrub/dir.c | 2 +- fs/xfs/scrub/readdir.c | 2 +- fs/xfs/xfs_dir2_readdir.c | 49 ++++++++++++++++++++++++++-------- fs/xfs/xfs_inode.c | 27 +++++++++++++++++++ fs/xfs/xfs_inode.h | 17 +++++++----- 9 files changed, 99 insertions(+), 24 deletions(-) diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index e576560b46e9..2638eb37bc77 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2643,16 +2643,32 @@ xfs_da_read_buf( struct xfs_buf_map map, *mapp = ↦ int nmap = 1; int error; + int buf_flags = 0; *bpp = NULL; error = xfs_dabuf_map(dp, bno, flags, whichfork, &mapp, &nmap); if (error || !nmap) goto out_free; + /* + * NOWAIT semantics mean we don't wait on the buffer lock nor do we + * issue IO for this buffer if it is not already in memory. Caller will + * retry. This will return -EAGAIN if the buffer is in memory and cannot + * be locked, and no buffer and no error if it isn't in memory. We + * translate both of those into a return state of -EAGAIN and *bpp = + * NULL. + */ + if (flags & XFS_DABUF_NOWAIT) + buf_flags |= XBF_NOWAIT | XBF_INCORE; error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0, &bp, ops); if (error) goto out_free; + if (!bp) { + ASSERT(flags & XFS_DABUF_NOWAIT); + error = -EAGAIN; + goto out_free; + } if (whichfork == XFS_ATTR_FORK) xfs_buf_set_ref(bp, XFS_ATTR_BTREE_REF); diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index ffa3df5b2893..32e7b1cca402 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -205,6 +205,7 @@ int xfs_da3_node_read_mapped(struct xfs_trans *tp, struct xfs_inode *dp, */ #define XFS_DABUF_MAP_HOLE_OK (1u << 0) +#define XFS_DABUF_NOWAIT (1u << 1) int xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno); int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno, diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 00f960a703b2..59b24a594add 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -135,13 +135,14 @@ int xfs_dir3_block_read( struct xfs_trans *tp, struct xfs_inode *dp, + unsigned int flags, struct xfs_buf **bpp) { struct xfs_mount *mp = dp->i_mount; xfs_failaddr_t fa; int err; - err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, 0, bpp, + err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, flags, bpp, XFS_DATA_FORK, &xfs_dir3_block_buf_ops); if (err || !*bpp) return err; @@ -380,7 +381,7 @@ xfs_dir2_block_addname( tp = args->trans; /* Read the (one and only) directory block into bp. */ - error = xfs_dir3_block_read(tp, dp, &bp); + error = xfs_dir3_block_read(tp, dp, 0, &bp); if (error) return error; @@ -695,7 +696,7 @@ xfs_dir2_block_lookup_int( dp = args->dp; tp = args->trans; - error = xfs_dir3_block_read(tp, dp, &bp); + error = xfs_dir3_block_read(tp, dp, 0, &bp); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h index 7404a9ff1a92..7d4cf8a0f15b 100644 --- a/fs/xfs/libxfs/xfs_dir2_priv.h +++ b/fs/xfs/libxfs/xfs_dir2_priv.h @@ -51,7 +51,7 @@ extern int xfs_dir_cilookup_result(struct xfs_da_args *args, /* xfs_dir2_block.c */ extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp, - struct xfs_buf **bpp); + unsigned int flags, struct xfs_buf **bpp); extern int xfs_dir2_block_addname(struct xfs_da_args *args); extern int xfs_dir2_block_lookup(struct xfs_da_args *args); extern int xfs_dir2_block_removename(struct xfs_da_args *args); diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c index 0b491784b759..5cc51f201bd7 100644 --- a/fs/xfs/scrub/dir.c +++ b/fs/xfs/scrub/dir.c @@ -313,7 +313,7 @@ xchk_directory_data_bestfree( /* dir block format */ if (lblk != XFS_B_TO_FSBT(mp, XFS_DIR2_DATA_OFFSET)) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk); - error = xfs_dir3_block_read(sc->tp, sc->ip, &bp); + error = xfs_dir3_block_read(sc->tp, sc->ip, 0, &bp); } else { /* dir data format */ error = xfs_dir3_data_read(sc->tp, sc->ip, lblk, 0, &bp); diff --git a/fs/xfs/scrub/readdir.c b/fs/xfs/scrub/readdir.c index e51c1544be63..f0a727311632 100644 --- a/fs/xfs/scrub/readdir.c +++ b/fs/xfs/scrub/readdir.c @@ -101,7 +101,7 @@ xchk_dir_walk_block( unsigned int off, next_off, end; int error; - error = xfs_dir3_block_read(sc->tp, dp, &bp); + error = xfs_dir3_block_read(sc->tp, dp, 0, &bp); if (error) return error; diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c index 9f3ceb461515..dcdbd26e0402 100644 --- a/fs/xfs/xfs_dir2_readdir.c +++ b/fs/xfs/xfs_dir2_readdir.c @@ -149,6 +149,7 @@ xfs_dir2_block_getdents( struct xfs_da_geometry *geo = args->geo; unsigned int offset, next_offset; unsigned int end; + unsigned int flags = 0; /* * If the block number in the offset is out of range, we're done. @@ -156,7 +157,9 @@ xfs_dir2_block_getdents( if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > geo->datablk) return 0; - error = xfs_dir3_block_read(args->trans, dp, &bp); + if (ctx->flags & DIR_CONTEXT_F_NOWAIT) + flags |= XFS_DABUF_NOWAIT; + error = xfs_dir3_block_read(args->trans, dp, flags, &bp); if (error) return error; @@ -240,6 +243,7 @@ xfs_dir2_block_getdents( STATIC int xfs_dir2_leaf_readbuf( struct xfs_da_args *args, + struct dir_context *ctx, size_t bufsize, xfs_dir2_off_t *cur_off, xfs_dablk_t *ra_blk, @@ -258,10 +262,15 @@ xfs_dir2_leaf_readbuf( struct xfs_iext_cursor icur; int ra_want; int error = 0; - - error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK); - if (error) - goto out; + unsigned int flags = 0; + + if (ctx->flags & DIR_CONTEXT_F_NOWAIT) { + flags |= XFS_DABUF_NOWAIT; + } else { + error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK); + if (error) + goto out; + } /* * Look for mapped directory blocks at or above the current offset. @@ -280,7 +289,7 @@ xfs_dir2_leaf_readbuf( new_off = xfs_dir2_da_to_byte(geo, map.br_startoff); if (new_off > *cur_off) *cur_off = new_off; - error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, 0, &bp); + error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, flags, &bp); if (error) goto out; @@ -360,6 +369,7 @@ xfs_dir2_leaf_getdents( int byteoff; /* offset in current block */ unsigned int offset = 0; int error = 0; /* error return value */ + int written = 0; /* * If the offset is at or past the largest allowed value, @@ -391,10 +401,17 @@ xfs_dir2_leaf_getdents( bp = NULL; } - if (*lock_mode == 0) - *lock_mode = xfs_ilock_data_map_shared(dp); - error = xfs_dir2_leaf_readbuf(args, bufsize, &curoff, - &rablk, &bp); + if (*lock_mode == 0) { + *lock_mode = + xfs_ilock_data_map_shared_generic(dp, + ctx->flags & DIR_CONTEXT_F_NOWAIT); + if (!*lock_mode) { + error = -EAGAIN; + break; + } + } + error = xfs_dir2_leaf_readbuf(args, ctx, bufsize, + &curoff, &rablk, &bp); if (error || !bp) break; @@ -479,6 +496,7 @@ xfs_dir2_leaf_getdents( */ offset += length; curoff += length; + written += length; /* bufsize may have just been a guess; don't go negative */ bufsize = bufsize > length ? bufsize - length : 0; } @@ -492,6 +510,8 @@ xfs_dir2_leaf_getdents( ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff; if (bp) xfs_trans_brelse(args->trans, bp); + if (error == -EAGAIN && written > 0) + error = 0; return error; } @@ -514,6 +534,7 @@ xfs_readdir( unsigned int lock_mode; bool isblock; int error; + bool nowait; trace_xfs_readdir(dp); @@ -531,7 +552,11 @@ xfs_readdir( if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL) return xfs_dir2_sf_getdents(&args, ctx); - lock_mode = xfs_ilock_data_map_shared(dp); + nowait = ctx->flags & DIR_CONTEXT_F_NOWAIT; + lock_mode = xfs_ilock_data_map_shared_generic(dp, nowait); + if (!lock_mode) + return -EAGAIN; + error = xfs_dir2_isblock(&args, &isblock); if (error) goto out_unlock; @@ -546,5 +571,7 @@ xfs_readdir( out_unlock: if (lock_mode) xfs_iunlock(dp, lock_mode); + if (error == -EAGAIN) + ASSERT(nowait); return error; } diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 9e62cc500140..d088f7d0c23a 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -120,6 +120,33 @@ xfs_ilock_data_map_shared( return lock_mode; } +/* + * Similar to xfs_ilock_data_map_shared(), except that it will only try to lock + * the inode in shared mode if the extents are already in memory. If it fails to + * get the lock or has to do IO to read the extent list, fail the operation by + * returning 0 as the lock mode. + */ +uint +xfs_ilock_data_map_shared_nowait( + struct xfs_inode *ip) +{ + if (xfs_need_iread_extents(&ip->i_df)) + return 0; + if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) + return 0; + return XFS_ILOCK_SHARED; +} + +int +xfs_ilock_data_map_shared_generic( + struct xfs_inode *dp, + bool nowait) +{ + if (nowait) + return xfs_ilock_data_map_shared_nowait(dp); + return xfs_ilock_data_map_shared(dp); +} + uint xfs_ilock_attr_map_shared( struct xfs_inode *ip) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 7547caf2f2ab..ea206a5a27df 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -490,13 +490,16 @@ int xfs_rename(struct mnt_idmap *idmap, struct xfs_name *target_name, struct xfs_inode *target_ip, unsigned int flags); -void xfs_ilock(xfs_inode_t *, uint); -int xfs_ilock_nowait(xfs_inode_t *, uint); -void xfs_iunlock(xfs_inode_t *, uint); -void xfs_ilock_demote(xfs_inode_t *, uint); -bool xfs_isilocked(struct xfs_inode *, uint); -uint xfs_ilock_data_map_shared(struct xfs_inode *); -uint xfs_ilock_attr_map_shared(struct xfs_inode *); +void xfs_ilock(struct xfs_inode *ip, uint lockmode); +int xfs_ilock_nowait(struct xfs_inode *ip, uint lockmode); +void xfs_iunlock(struct xfs_inode *ip, uint lockmode); +void xfs_ilock_demote(struct xfs_inode *ip, uint lockmode); +bool xfs_isilocked(struct xfs_inode *ip, uint lockmode); +uint xfs_ilock_data_map_shared(struct xfs_inode *ip); +uint xfs_ilock_data_map_shared_nowait(struct xfs_inode *ip); +int xfs_ilock_data_map_shared_generic(struct xfs_inode *ip, + bool nowait); +uint xfs_ilock_attr_map_shared(struct xfs_inode *ip); uint xfs_ip2xflags(struct xfs_inode *); int xfs_ifree(struct xfs_trans *, struct xfs_inode *); From patchwork Fri Aug 25 13:54:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365737 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C631C3DA66 for ; Fri, 25 Aug 2023 13:56:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EA2D2800B5; Fri, 25 Aug 2023 09:56:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 972DA8E0015; Fri, 25 Aug 2023 09:56:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8145D2800B5; Fri, 25 Aug 2023 09:56:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6C8838E0015 for ; Fri, 25 Aug 2023 09:56:10 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4CB7114068E for ; Fri, 25 Aug 2023 13:56:10 +0000 (UTC) X-FDA: 81162776100.25.6A46E1B Received: from out-252.mta1.migadu.com (out-252.mta1.migadu.com [95.215.58.252]) by imf19.hostedemail.com (Postfix) with ESMTP id 92E521A001D for ; Fri, 25 Aug 2023 13:56:08 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TwbW5BAd; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf19.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971768; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=e5tdpTadoLYdZJB8cQ8K1ymkQcAcLx9XJrtCjJGJaVs=; b=Wi9xQh/BaNiyLifYWe/lkyaTVwBu/++oWhvcoFMXihVvIiOHAOA+E249oHjK8wmcFJxSEr jfZIt3yr9H9G2Yz29x+MiSc89LhAmACw280clOnHFhP5H1TgFRo8/8dCbZoFLjx5MWDJxZ ykS6EB0Y7bFqqDFmH8hV8IsMIk247r8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TwbW5BAd; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf19.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971768; a=rsa-sha256; cv=none; b=GZhTbcGkIapUGHtUdDjVDh6LCo4OY92fiVxcWFnhbSVDKFle/QyjpvMFljQZDbYLhS3X43 qmjauchDGu1yspPhYmUxTSqQIN0GZsbzzdCTGq/jpONG0WaSTVzZr9NTf7A8KbbaFSLA23 ByaZKDrfW1W9r/d0I8+mCRmn8lrrLyE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e5tdpTadoLYdZJB8cQ8K1ymkQcAcLx9XJrtCjJGJaVs=; b=TwbW5BAdvmgSbpeRXB5oj2rBwHJYuNVAZ0wuNv54dKDSbdHWvpzdJPpdSYGzhDtIzGSB4F YisrVQZHUjFuGHrj+vJDxnd62bdWDda2XlxMi5lt3S7M7T/A05SHzZ7P+IsnTBGPpTbdoc kkwgLR7zX0hVNtt4X1uvx8MlGeKiBn4= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 04/29] vfs: add nowait flag for struct dir_context Date: Fri, 25 Aug 2023 21:54:06 +0800 Message-Id: <20230825135431.1317785-5-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 92E521A001D X-Stat-Signature: 11rhdgwikdfxkzzseyhipq87q1k11pmk X-Rspam-User: X-HE-Tag: 1692971768-517860 X-HE-Meta: U2FsdGVkX18byK5LCZSJZnifwk/t8esSpLrnBVeefWv4jYsS3zSK1a/9zI30hFH21GuUyuk2MGSlHAO0uqGG+QtKs/t3ZKc44CQEoK9F7wsdX4E8cl4xJV+UKQVN4/iH44ykLkZgLdo4sCoskh8i3zwl/fLOwLdydCxgQFnZzJIc7kJndDh6GUveyRWe76oPxBWgevgH9G4/2iXn9i4+Y9jkuzb7hMOIVhaTkiO3iuGe4Qp+eV3vSqN30coUb3FRJ7KwVScsiF/9QXPpyNsz2T4S8l+u7Pk3eyzAL6bw+UQ4ro8C+AkdHT7N11BS64ygwEl5wy4LIR5j/hxHQl//rLYc98qlnhT0FNkcSSsU7QRKDIlLESw5Qgxrlt5nDp/ifvrl3b6ZM58IM6mwBHOoz5FMrWTguWatOHcdtwYSTjhaCzSczCwCMoc06BPBH2wD9hIkCjPUh4r6gNaxL55p5WNt56j9aqlXwb7cm7rYEtykIHgzLzzrFUEUTtbognWvxPDHpn61rg+LtO0uJnrbUdJCU8fWsc7xppOh4UZnT+0N1wUBCot6kTnt2/tPuFvCY5e6F8fM3t8IHz3cLb0qh4fuwW4tuGiw0/3MqUQWuUYHNh9lctHu43J8S8SquSzRPU82dSGzHGr+M9LDeKgBbIAPkGcRblGeREnC5cTYhpru+bYnARDEctMe7Q2K/zhOFX3lcJ1u+6kZqFQhALbkzmpvzLOtTszFZkvuoRbbFIdNlHqD/R7Yzze53r8zY3kSKXaBBHNSN2N2stjC3K1F34OAVq5nzIY1BslylbCAbeHeYTbXKb2FgP4klCULrFkXlzB+bvQvQbqFOajPTuz3li9o3RyTwOPUCL0GinnJfZ0hrQhQtCDI1a1lfOjeYYqIePVOToOK8W13YFyCotflFOD9M9VJ+7oNEavy7EUOKEUYmYc+2QeGxqi2/OfiKq9Ic53vptRkXBnaZWGN0Tv NauKsQJ/ XdwU4Pn93LgdjwkMlqpe/Dz4mE9Vwm+XAh+0zqsiDygOr+sXhlnBBxqIeCaZhCJcQCfG6aonGX/kYw0ItsKxL1nMw0pE3TVV997jgTiIH6qYULy9cWIryjEjci46Ot/I0zmKHpLkSTkUwE5a4Enc3waWUU5tZK63iS8dyH8XySfES12o14NkRikA4BIIJw0rjHj/YVJ1EpaQQX3LMSNAbZ3mkzhxfjLteGmCtNL+2dKG5dGoUSJSgtfCsiFXbEu50peEffBygPeDozXszxwfS4UB1YVrp1R0CGpElJphvpBj4jTzRs0+ZYBvX0MkQ60cRZze6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu The flags will allow passing DIR_CONTEXT_F_NOWAIT to iterate() implementations that support it (as signaled through FMODE_NWAIT in file->f_mode) Notes: - considered using IOCB_NOWAIT but if we add more flags later it would be confusing to keep track of which values are valid, use dedicated flags - might want to check ctx.flags & DIR_CONTEXT_F_NOWAIT is only set when file->f_mode & FMODE_NOWAIT in iterate_dir() as e.g. WARN_ONCE? Co-developed-by: Dominique Martinet Signed-off-by: Dominique Martinet Signed-off-by: Hao Xu --- fs/internal.h | 2 +- fs/readdir.c | 6 ++++-- include/linux/fs.h | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index b1f66e52d61b..7508d485c655 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -311,4 +311,4 @@ void mnt_idmap_put(struct mnt_idmap *idmap); struct linux_dirent64; int vfs_getdents(struct file *file, struct linux_dirent64 __user *dirent, - unsigned int count); + unsigned int count, unsigned long flags); diff --git a/fs/readdir.c b/fs/readdir.c index 9592259b7e7f..b80caf4c9321 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -358,12 +358,14 @@ static bool filldir64(struct dir_context *ctx, const char *name, int namlen, * @file : pointer to file struct of directory * @dirent : pointer to user directory structure * @count : size of buffer + * @flags : additional dir_context flags */ int vfs_getdents(struct file *file, struct linux_dirent64 __user *dirent, - unsigned int count) + unsigned int count, unsigned long flags) { struct getdents_callback64 buf = { .ctx.actor = filldir64, + .ctx.flags = flags, .count = count, .current_dir = dirent }; @@ -395,7 +397,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, if (!f.file) return -EBADF; - error = vfs_getdents(f.file, dirent, count); + error = vfs_getdents(f.file, dirent, count, 0); fdput_pos(f); return error; diff --git a/include/linux/fs.h b/include/linux/fs.h index 6867512907d6..f3e315e8efdd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1719,8 +1719,16 @@ typedef bool (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64, struct dir_context { filldir_t actor; loff_t pos; + unsigned long flags; }; +/* + * flags for dir_context flags + * DIR_CONTEXT_F_NOWAIT: Request non-blocking iterate + * (requires file->f_mode & FMODE_NOWAIT) + */ +#define DIR_CONTEXT_F_NOWAIT (1 << 0) + /* * These flags let !MMU mmap() govern direct device mapping vs immediate * copying more easily for MAP_PRIVATE, especially for ROM filesystems. From patchwork Fri Aug 25 13:54:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365738 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 228AFC71133 for ; Fri, 25 Aug 2023 13:56:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B499C2800B6; Fri, 25 Aug 2023 09:56:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD2EE8E0015; Fri, 25 Aug 2023 09:56:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 973D82800B6; Fri, 25 Aug 2023 09:56:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 867788E0015 for ; Fri, 25 Aug 2023 09:56:50 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 60552A06C3 for ; Fri, 25 Aug 2023 13:56:50 +0000 (UTC) X-FDA: 81162777780.04.59295E0 Received: from out-244.mta1.migadu.com (out-244.mta1.migadu.com [95.215.58.244]) by imf06.hostedemail.com (Postfix) with ESMTP id AFBD718001B for ; Fri, 25 Aug 2023 13:56:47 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=GYR7q+ed; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971807; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=W04QOWrrBuMFm18D/+g+MI2uZNnKBIsbwxq2wO1dKKw=; b=mjeOUXUsIUCJuWdA0OadErTaf4MzBF1VpQXUt+a0PHOCJIcjfds3GCOu1sBzvVGIs00jTm 1qs66sLkOkCgOrtOfSqJHGZ4J/gkoxnpJ1bjskfG/4KsEhOYWciHSGmops6o5+T+2vs9qf Kyt6rQJUTTVGNFt9myct9Dm75HC8sQg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=GYR7q+ed; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971807; a=rsa-sha256; cv=none; b=ac52tH9D1RWWMuktc/+DQl3PRzVooH9getHE4xikRsB95SN4soDXfgzmR5aUp6togngtfu RQ1xNrxUWHAE4jhc8UWSMntxhXBHqOxc/H6cHbL6EmTPKi+3ZLY3ZtRtxIFgrMeGWB4WkR RFicCk59Qr6q4gKfbe9KpB/E9j6yM9o= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W04QOWrrBuMFm18D/+g+MI2uZNnKBIsbwxq2wO1dKKw=; b=GYR7q+ed6aYuRljJYmvSX9IH2GLL+DVsCTCg/+y32Q33mqJCInZ91y+uQeCstRhUPnoP3N ePQXgcigakNgh8HTbQeNs8AWnI9Lei+c8/zQ92SOW8UgAHTnrdNmJY44TCN57rW11W5x8C QP3i32OeE0C7qn2HcY/8yIvkb/iSTUs= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 05/29] vfs: add a vfs helper for io_uring file pos lock Date: Fri, 25 Aug 2023 21:54:07 +0800 Message-Id: <20230825135431.1317785-6-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: p1rssrq91g81o8japexaczpojdqshfar X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AFBD718001B X-HE-Tag: 1692971807-720306 X-HE-Meta: U2FsdGVkX19EbEAJy8edeNBNY5pXTw7V6bdrej6SWh3ddJ/y+GZWoIebWqJIIhKuhWvfiXsVN+eB6k8poa3XY8bhk4GwlUI+ap4MGMVS4iuRvawjZqSjZA9NgL763NHKtXKYZ5KsMKoAd43zu1fNqodfMKiANxI0ZuY8/ngg8w899AFDMgid/BnmT53fGAFUyv8AKEuB5+gaqjXX/hazWhsgwCOKUqOxwsEm+JnJE2zhsp2/iO9CO1Qwfqa8a3jg/uEBuBPYM9cGU7Yk02T8qDUCZ+P7lWBAWXPARCYvhaQKIWm//xaelvVNpGI+hbzHuu6vManBWT/z/MNiQPStclvwZb9FdSw+Kdu2tjh82n0myPEKY9wAzvFmQeNHcoSG40Mgjog3QBuZjfkmAAhzRS3F5VCfsnIYjGCWbi02e4OzJLq/TZEV9L8MEL8Se7kpmmdMRRk66X5LQHxIzs0nDk+OYvlQfK5aYlA0809N3NpRj0dYHrcGdBOCWv1SSpbTtl2iUtkB22bi0hh1DncaMLd3Rk1wKZWAPMyT6sUUEsl8Lb49/v5+VAPeOBbzxquOuKcaOhjxfUCCcJPDaYQcyzWPL7Xe4QknOWdARrd1rNqxaUUCAHqS3cqVHwdcF2zT3AiAARfvJreivGkkVQcfN0/J7A341IpCB31SIoAq7OkuVtmFyP6YS00jaQF1WpQtyiTdzm4szXYSPhWOIl1Ec9zd3iLYyyLGvffbk469chlu0nT4BvlgbEdwJ+RuMUAR9XmO3LuN+Q5+NQLQNeUuM+t4VpwCw7RyjBjVm7MFnqeYrjqH8vq+bmbQ7uFiwo25WPu/YzTA8lUNOeKzd1OeKoMW8xdpkQYM/YnfSY4A0XyDTK7BiVLOd45ZZ676GGgvdkZnc923fy1CO3QMUlhzM1Cw7f5K1QQSVunjfuhJbWCem2lNTA56sQ9syj/yKATeiAHOJrpZcwF4I+jf9RA xfjGvNLx WYQawyei/VMuYf24BiPGYmIMT0Yr+D4Yn7pdz8pucEh8C84OXyzFljO2bwdK3lqW8qhYB/RrJ1AKYEYGbIRcQwAqmzI1dxv+wQKz9DaCMdh5SLi0ED1dBMGR5abVbQrCkG4Kgstktd9upEYOiiKvlbnByvUMt5ycjS3rJUM73RdrkoTtuGzWKxKSjLf/o8RSvVODXxhdvt0t/YyV40VjZ/X5mAm9RzTqBWLKK9bFA9wFNo4RxxBlHq43A8g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add a vfs helper file_pos_lock_nowait() for io_uring usage. The function have conditional nowait logic, i.e. if nowait is needed, return -EAGAIN when trylock fails. Signed-off-by: Hao Xu --- fs/file.c | 13 +++++++++++++ include/linux/file.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/fs/file.c b/fs/file.c index 35c62b54c9d6..8e5c38f5db52 100644 --- a/fs/file.c +++ b/fs/file.c @@ -1053,6 +1053,19 @@ void __f_unlock_pos(struct file *f) mutex_unlock(&f->f_pos_lock); } +int file_pos_lock_nowait(struct file *file, bool nowait) +{ + if (!(file->f_mode & FMODE_ATOMIC_POS)) + return 0; + + if (!nowait) + mutex_lock(&file->f_pos_lock); + else if (!mutex_trylock(&file->f_pos_lock)) + return -EAGAIN; + + return 1; +} + /* * We only lock f_pos if we have threads or if the file might be * shared with another process. In both cases we'll have an elevated diff --git a/include/linux/file.h b/include/linux/file.h index 6e9099d29343..bcc6ba0aec50 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -81,6 +81,8 @@ static inline void fdput_pos(struct fd f) fdput(f); } +extern int file_pos_lock_nowait(struct file *file, bool nowait); + DEFINE_CLASS(fd, struct fd, fdput(_T), fdget(fd), int fd) extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); From patchwork Fri Aug 25 13:54:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365739 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEAF7C3DA6F for ; Fri, 25 Aug 2023 13:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D9DB2800B7; Fri, 25 Aug 2023 09:57:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83BD38E0015; Fri, 25 Aug 2023 09:57:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DC4F2800B7; Fri, 25 Aug 2023 09:57:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 590448E0015 for ; Fri, 25 Aug 2023 09:57:21 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 14D8C406C6 for ; Fri, 25 Aug 2023 13:57:21 +0000 (UTC) X-FDA: 81162779082.18.F05FA85 Received: from out-244.mta1.migadu.com (out-244.mta1.migadu.com [95.215.58.244]) by imf06.hostedemail.com (Postfix) with ESMTP id 3A5E818002D for ; Fri, 25 Aug 2023 13:57:18 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ZBBdmQmn; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971839; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/w6lIGuCSX5M2SzS7SE+A2P7DaEhoFOZKnfxuRd6M0g=; b=yzKB11NyPGKThPQ3KiKP4ntLHoFUisrg1CIXoy9zTdUlakd0VzjxxBUGTY1MsboWX1t1KC mZ7GgO2UcqQDGm2Sr0vBt5b4SpnadJYwAHRKTxYwE9IcGT0lJK2cKp5/UrtcMyJPzDbCBa GAI0M1rA9HrKM5z72Ya1NAmbBziu/jQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ZBBdmQmn; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971839; a=rsa-sha256; cv=none; b=3OnqNoqgBJRbluMBTOlceaIsQUOeFsL+FXG16Z9EwM07Ne7tc9NjWFESY4nrTsrIbXNR/0 2ow7m//7FZsFCW5PUJ1IEq8FN1EqJ2hAZ9eVOwgnbUEbbm2SVgxbfI0I8UuBx5TAJCH04i dNyzKxucwC/OyY7RP31WsDPXhzwajT0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/w6lIGuCSX5M2SzS7SE+A2P7DaEhoFOZKnfxuRd6M0g=; b=ZBBdmQmn/QswMnMhJaSAfXlf1oUY8DtSqPmmn75d8pDMERuOJJX6J86JCF/c0yd1RLwCFL 31gixh9w5LkzzEj2vO8LvkCfQ90DBKrPt5Zp4Wgls4dziWWNaF03qzW9wejmnudGoy1bT6 SZd55YvanxvHQ0hgcOptPehal51m0m0= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 06/29] vfs: add file_pos_unlock() for io_uring usage Date: Fri, 25 Aug 2023 21:54:08 +0800 Message-Id: <20230825135431.1317785-7-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3A5E818002D X-Stat-Signature: ribhxjwwfmu43mhxq95ny57nkxcwy4kx X-HE-Tag: 1692971838-337195 X-HE-Meta: U2FsdGVkX19XQ5ZG4V4+4sjo297sajUMqjjdfV99d3aNaLKJmLkgZxF8hKmpI81phJkbo0d1RaOGsDMo0BjewolUIttSaCi4gXdwPKFmsbqZtK7gaaCzsCcb+tVakOhcdLLEJZPIidDQBeDagRPotcjO6NVct1FFtHLiU6D7CEC+MKWhhgbO4TcfGGVFnr92UjHkstds7PKq5jF0kApFMESVEZup75FltIvEzQfTepiJPayey2OS0OBeB/afDvbBNL0mSiGysTnRYYdYrLgUf1dgYTV3XKIkGRQ/yeLFK8AK5FgWvV8WH/BPy5VzgrWZNHkfnOFT4BSBgyf41cNT39vF+snK6fEjQp/PS9Xu3qwtpwguOOWK/jew9A9Xvp5zuHzqj4bYCv5AjtYg/bZhUQzPuPh4QbPPyTYvoLNZu8LuJAVGePlruo1WNw93H7RLLbqHWBocu1f9O5m0VIxTvHomFDUtDStK5uRjV4HRn9pgT7hBfMG42QgVGpjFp5v+MhRePZTBl+ahvWjyAcgp4BSGMPvb0LNTWpY2Z3gbq4i+wrmbowqhtY2JAKnUwJuYRs69zp/z3undLAyLzgmURKlN42p/zEtyMcxyyhNJzO63w4zX3iGfhcYFCKU9kuL2sAMXF0II3xFnloL3WLZNyqUBgjvrQLiEhrFkdulIQbZktQQVAiaUyUepJXCTlBmSRn+XDgKVXQlXGgZ6BXtMob2qKGxSTL80NaeeQYddr1iqGAmxGb/xO0r1qA26kPv/plJodpMtK2F8VTz516odUNeJq7HnjATqLM4b9M02Zedmyl9V/NTJpsheKK0V4iKT8hK7LmEADByr8xza2NzN1S6n+q0XO0JtXd9kUz0QH/iQ1fp25plTFd/p/alDDppcjUY49Wx153pLizc1cQIKNH2d3zEhAuZrX2tEqPNs76Hy3tX2eju3h2gG6e30CfErW2xTuePPiZFqQwu5TsK JwxAUbby 0qxy7FyJuzi3pELTcogFEoUlhpCvIEPBLImTow8F1nrEsszjvkmHHV/xG5zzg7HQ3B2VVgh04qwLgNy30hPT7eBk0L+QhSUi/tvlQgn7yD5hBKtBBlM1Qso+j5ey2xvsf5Raoxf3KxKgQ6DQ2An8QHklyrxdrOai6jkWNcbY46RDHkhgOi7I4KszK7oG9Dx1rlYN++cJ1yhI1GWeHnpWgmC1JpnPjXG0bthZRj5w52QHobRPtjliGuGsDaw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add a helper to unlock f_pos_lock without any condition. Introduce this since io_uring handles f_pos_lock not with a fd struct, thus FDPUT_POS_UNLOCK isn't used. Signed-off-by: Hao Xu --- include/linux/file.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/file.h b/include/linux/file.h index bcc6ba0aec50..a179f4794341 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -81,6 +81,11 @@ static inline void fdput_pos(struct fd f) fdput(f); } +static inline void file_pos_unlock(struct file *file) +{ + __f_unlock_pos(file); +} + extern int file_pos_lock_nowait(struct file *file, bool nowait); DEFINE_CLASS(fd, struct fd, fdput(_T), fdget(fd), int fd) From patchwork Fri Aug 25 13:54:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365790 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 562E3C71133 for ; Fri, 25 Aug 2023 13:58:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E58932800B8; Fri, 25 Aug 2023 09:58:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E08528E0015; Fri, 25 Aug 2023 09:58:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD05F2800B8; Fri, 25 Aug 2023 09:58:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BC6F68E0015 for ; Fri, 25 Aug 2023 09:58:25 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 96E3CC06B7 for ; Fri, 25 Aug 2023 13:58:25 +0000 (UTC) X-FDA: 81162781770.13.695653F Received: from out-246.mta1.migadu.com (out-246.mta1.migadu.com [95.215.58.246]) by imf10.hostedemail.com (Postfix) with ESMTP id CD66AC0006 for ; Fri, 25 Aug 2023 13:58:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=H+vckW3u; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.246 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971904; a=rsa-sha256; cv=none; b=WcxzGhzLTE4EwzwlS0KIE3yJ/X8QW07vYDfEBoqgeq8p8qMwu2oM0RgVosTFGzgLlCu0BF UtRyAca7NDywnZcF2GbBs5j6SMszWgF2mSqB0GalolomJVqBoqaQNOP4HmRaWIwag68zWJ W0DgVM60sqMKrcFx5FS69tVkLN7ye5U= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=H+vckW3u; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.246 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971904; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/SxFJtissRd8EFEKfjvtrzUrKe2UZWHAXBAv8XN+2Ws=; b=UIEn2wp0xuGTcfwKBR3SFrRl9/PZRNmllElSkuIyrWudWL5tmPU6FiV34vLyTHisMJouBR Z/4S4hrI7AB0OZrsHd6Q/fFqnrnUxOWgr+B3TsZHL8nZsanIeWBAQ6WZrWPRDkwr9Trjif 5QMvxCyybPJxSbxPm+p+vttOCl+xBtg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971902; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/SxFJtissRd8EFEKfjvtrzUrKe2UZWHAXBAv8XN+2Ws=; b=H+vckW3ukzz5hjvgszvW+1Vskdq8aMOiLkYCBE1Az9/xG1yWB6DZ1XyeKFMPNSqNSLbo4Q BK4s/Y8OqUoLH1ryggMh8Z7KOoNgKutNOuqFDsqEXi2EBbOwNmuW7uA4ULqzQhkjnOziKD v+STrU9jb3kQlof7g0vxHj3RnnOLFJ0= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 07/29] vfs: add a nowait parameter for touch_atime() Date: Fri, 25 Aug 2023 21:54:09 +0800 Message-Id: <20230825135431.1317785-8-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CD66AC0006 X-Stat-Signature: 8azsco1xwhrbmmjyjz6cdeiyhp7rssac X-HE-Tag: 1692971903-450969 X-HE-Meta: U2FsdGVkX1+YRepB6R/HdxVjk+E92mW5vuX2XXywlg0UjPH2C+XE7aj8+IXfMobnNo7XkqJboHb5bwS8yA4eCe0FFaxUwEDM3iHNHlkNWdtchaRy8asp3b/95pCJg82qyBy/0duZnPiYmMMf8aP1ta1lGI7KcwV+p5BIV+3YRP95OI1Ln79N3Mr1Iy+849lTUbAtrICU9tB/7THZdZk9sZLF2v7Fa6xdSvfUpuq0KFq71Re+Q3oiB2lVp0GePuXoCC7tUeFsl764wcxQFPa6SzpBesCbbMaSzE4WTTYl08Ei2oJ0GKfAcfqSQe5+xql65TRQnuO+Ulm1TfaFu21KIBnrxQtzaXxbCPfT7FjdM9Q5zUT6BBaOX8i+1rRYr6KAjQhyBREgedAYKdcQDgN8OLPtRbHDJ0wFvCmZkbMHxIj/tFn549UN+jY5bqd5Rqy2B7cFzkk2fgDXQdRJ+D5FedrVs+e7eJdhd2crYQ0l9Tt3oCsHSxYm6NwVEAJs4i2c15Tv95OrU8VWJjYfBmCrN8LDGS52DrlgAiBVpDTmtROQWIBXAzCjw2ExbtDm2ZLBrOYfo1SEyqUtLLnlL2cMR6TznpXoauVE6luzkWCYmF/Sgikscj5CPpiNNz9f1Mf2Jpmc1ksRPEGKiteDKe+xR4jupTufOk3LH2M9ae4mSIczWBTJxflxN8nuO0v4wUvh3tWeTJwnjmNkN2mBfP2T5tX0SU1lmd4+r32UQ8QUjdMCaCM+94Mg7o2aBKCp3C5xFVhNLFkyOQSEf5IiKrLVKKPQrF/4XdImuif3XpprpKlJhgbW7ZyBOE41c+WxWkISmaKjc2DivHvgPNG4FurmPUGb2/Gikq+6SEWvi1Gt8AkG2qFCaj5VxUBmoPizyKD15BBfGBujgZQa8vPgDM31HrlPeUzjqc88YVcrERT7w0kAov4xkIlDQcyEwGmXPe6m0T3wL/2r4ErwlJkbfwV 38AGx+T9 zxnH2uc/0j40ELbpZk9Sg5EMotWsl5LJ99r+3tYzbgkc8wH4ecDXSat0hhYM/uQeUCaF/spFtysBHCi4ak7mz27xg3PaI2NmJNcmlDtuzYMtMnpwIg5Tirvgf91VusfBN2y7XeiW0KKPFCyPWX/OnsTNMpGWPXuCdl6ATpXDKYe8x48sKKEEGNibUfiRDgIM03f5YuxYSKTNTPmheNLYdVZTUUz1Picgdwof0VisRrV3AaWxEezjKQT7aeA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add a nowait boolean parameter for touch_atime() to support nowait semantics. It is true only when io_uring is the initial caller. Signed-off-by: Hao Xu --- fs/cachefiles/namei.c | 2 +- fs/ecryptfs/file.c | 4 ++-- fs/inode.c | 7 ++++--- fs/namei.c | 4 ++-- fs/nfsd/vfs.c | 2 +- fs/overlayfs/file.c | 2 +- fs/overlayfs/inode.c | 2 +- fs/stat.c | 2 +- include/linux/fs.h | 4 ++-- kernel/bpf/inode.c | 4 ++-- net/unix/af_unix.c | 4 ++-- 11 files changed, 19 insertions(+), 18 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index d9d22d0ec38a..7a21bf0e36b8 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -591,7 +591,7 @@ static bool cachefiles_open_file(struct cachefiles_object *object, * used to keep track of culling, and atimes are only updated by read, * write and readdir but not lookup or open). */ - touch_atime(&file->f_path); + touch_atime(&file->f_path, false); dput(dentry); return true; diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index ce0a3c5ed0ca..3db7006cc440 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -39,7 +39,7 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, rc = generic_file_read_iter(iocb, to); if (rc >= 0) { path = ecryptfs_dentry_to_lower_path(file->f_path.dentry); - touch_atime(path); + touch_atime(path, false); } return rc; } @@ -64,7 +64,7 @@ static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos, rc = filemap_splice_read(in, ppos, pipe, len, flags); if (rc >= 0) { path = ecryptfs_dentry_to_lower_path(in->f_path.dentry); - touch_atime(path); + touch_atime(path, false); } return rc; } diff --git a/fs/inode.c b/fs/inode.c index 8fefb69e1f84..e83b836f2d09 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1961,17 +1961,17 @@ bool atime_needs_update(const struct path *path, struct inode *inode) return true; } -void touch_atime(const struct path *path) +int touch_atime(const struct path *path, bool nowait) { struct vfsmount *mnt = path->mnt; struct inode *inode = d_inode(path->dentry); struct timespec64 now; if (!atime_needs_update(path, inode)) - return; + return 0; if (!sb_start_write_trylock(inode->i_sb)) - return; + return 0; if (__mnt_want_write(mnt) != 0) goto skip_update; @@ -1989,6 +1989,7 @@ void touch_atime(const struct path *path) __mnt_drop_write(mnt); skip_update: sb_end_write(inode->i_sb); + return 0; } EXPORT_SYMBOL(touch_atime); diff --git a/fs/namei.c b/fs/namei.c index e56ff39a79bc..35731d405730 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1776,12 +1776,12 @@ static const char *pick_link(struct nameidata *nd, struct path *link, return ERR_PTR(-ELOOP); if (!(nd->flags & LOOKUP_RCU)) { - touch_atime(&last->link); + touch_atime(&last->link, false); cond_resched(); } else if (atime_needs_update(&last->link, inode)) { if (!try_to_unlazy(nd)) return ERR_PTR(-ECHILD); - touch_atime(&last->link); + touch_atime(&last->link, false); } error = security_inode_follow_link(link->dentry, inode, diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 8a2321d19194..3179e7b5d209 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1569,7 +1569,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) if (unlikely(!d_is_symlink(path.dentry))) return nfserr_inval; - touch_atime(&path); + touch_atime(&path, false); link = vfs_get_link(path.dentry, &done); if (IS_ERR(link)) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 21245b00722a..6ff466ef98ea 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -255,7 +255,7 @@ static void ovl_file_accessed(struct file *file) inode->i_ctime = upperinode->i_ctime; } - touch_atime(&file->f_path); + touch_atime(&file->f_path, false); } static rwf_t ovl_iocb_to_rwf(int ifl) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index a63e57447be9..66e03025e748 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -703,7 +703,7 @@ int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags) }; if (upperpath.dentry) { - touch_atime(&upperpath); + touch_atime(&upperpath, false); inode->i_atime = d_inode(upperpath.dentry)->i_atime; } } diff --git a/fs/stat.c b/fs/stat.c index 7c238da22ef0..713773e61110 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -485,7 +485,7 @@ static int do_readlinkat(int dfd, const char __user *pathname, if (d_is_symlink(path.dentry) || inode->i_op->readlink) { error = security_inode_readlink(path.dentry); if (!error) { - touch_atime(&path); + touch_atime(&path, false); error = vfs_readlink(path.dentry, buf, bufsiz); } } diff --git a/include/linux/fs.h b/include/linux/fs.h index f3e315e8efdd..ba54879089ac 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2201,13 +2201,13 @@ enum file_time_flags { }; extern bool atime_needs_update(const struct path *, struct inode *); -extern void touch_atime(const struct path *); +extern int touch_atime(const struct path *path, bool nowait); int inode_update_time(struct inode *inode, struct timespec64 *time, int flags); static inline void file_accessed(struct file *file) { if (!(file->f_flags & O_NOATIME)) - touch_atime(&file->f_path); + touch_atime(&file->f_path, false); } extern int file_modified(struct file *file); diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 4174f76133df..bc020b45d5c8 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -517,7 +517,7 @@ static void *bpf_obj_do_get(int path_fd, const char __user *pathname, raw = bpf_any_get(inode->i_private, *type); if (!IS_ERR(raw)) - touch_atime(&path); + touch_atime(&path, false); path_put(&path); return raw; @@ -591,7 +591,7 @@ struct bpf_prog *bpf_prog_get_type_path(const char *name, enum bpf_prog_type typ return ERR_PTR(ret); prog = __get_prog_inode(d_backing_inode(path.dentry), type); if (!IS_ERR(prog)) - touch_atime(&path); + touch_atime(&path, false); path_put(&path); return prog; } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 123b35ddfd71..5868e4e47320 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1084,7 +1084,7 @@ static struct sock *unix_find_bsd(struct sockaddr_un *sunaddr, int addr_len, err = -EPROTOTYPE; if (sk->sk_type == type) - touch_atime(&path); + touch_atime(&path, false); else goto sock_put; @@ -1114,7 +1114,7 @@ static struct sock *unix_find_abstract(struct net *net, dentry = unix_sk(sk)->path.dentry; if (dentry) - touch_atime(&unix_sk(sk)->path); + touch_atime(&unix_sk(sk)->path, false); return sk; } From patchwork Fri Aug 25 13:54:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365791 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF8FC3DA6F for ; Fri, 25 Aug 2023 13:58:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 223E52800B9; Fri, 25 Aug 2023 09:58:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FB1B8E0015; Fri, 25 Aug 2023 09:58:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09BF72800B9; Fri, 25 Aug 2023 09:58:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EBEE78E0015 for ; Fri, 25 Aug 2023 09:58:56 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BD7411206BB for ; Fri, 25 Aug 2023 13:58:56 +0000 (UTC) X-FDA: 81162783072.24.4185798 Received: from out-251.mta1.migadu.com (out-251.mta1.migadu.com [95.215.58.251]) by imf03.hostedemail.com (Postfix) with ESMTP id DD5612000B for ; Fri, 25 Aug 2023 13:58:54 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QKw9hcAJ; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.251 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971935; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8SowR/5OB7dg0Ze+leVLqrAkBaJI/dvgnJq74oNV+rw=; b=fJ2kEKfZ5D4XBTHh9JQU5I0HDI58j/zXyea8MGx4GwC8DJD1WbkgK2wbnLIWfCBP4sa8l/ fewf67YybBHX5qUE9JwskYBrJmEVEh55mX5Qs6hhgnUiFCpoFpyoEQLDWaVqVtYD/ozFDJ NiafR0LyDUaaWr1LG/HlGmnLrcomqVo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QKw9hcAJ; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.251 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971935; a=rsa-sha256; cv=none; b=HIXWHEJDB4YRZYbVBIKiVv+NnMCflZTur4at1TnTgsBbPu6zaf/W7qDHKYe+P8n8eeKkQB 5Z14yB/+paPqVkypwKNjJOC8a7g9f8jUeYr1ZiVMwiIcBIPiBrh+lMsaWUqcuiCnC5Rc9G P3zYjQet4qg4XxS3Sc+51j4ndpnGO3I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8SowR/5OB7dg0Ze+leVLqrAkBaJI/dvgnJq74oNV+rw=; b=QKw9hcAJq2VJ+E+jYOKnMmH8w8K+jLHiRmy3j0jFaQu7wDFWtvq6D42S+fwtRDrDHFBm52 yMZak6CXYYTjkGqEAa6ANC2jeSWDstw2tKWSFGVL395IWPbSBnsJfY/hvcJv/3pN0ebW1t ojdd0T7x0JE49StsxMXe8e/kwImhmTY= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 08/29] vfs: add nowait parameter for file_accessed() Date: Fri, 25 Aug 2023 21:54:10 +0800 Message-Id: <20230825135431.1317785-9-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: DD5612000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wd4sykez7j8hgcskamdw6nrqzgpjmoie X-HE-Tag: 1692971934-58820 X-HE-Meta: U2FsdGVkX18blr5A4UDURniDHY3Sd5e1J9nBUstXGFpMe2cacfhUV97BFcGZnIhxaEBKn0qLutt3iowsy9kto5SDw2aSLaOfECSk4F0x9ITul3Lnvi0vcjP8GSh3Em2R3cPZ/ociYzT+mReB3piTigjtUhBgiEzKJIAn1/+Eum3HkBdvWJCaqY9ttiGVfVftG3CanioaI1wtIbjgCvuvTfrEvBFnoUrb7U7ujQ3Z6Ac6Md0LEmWqRnx6hvv+yqyaE55RrVMW7fmRIPddsfEeTIBEFW2+l9xJ4MjbaXhX7hoRop1o/bYmVilnI0mH+C3RUCMqWi1NiEeCD3EmiMroswzhdz/I62eYIiGsvfLkOXHXISAEoHBE4NdyD+pgkYJKZSwJ2n7KHVPSKvgAf1i4eMd0g0aMnc6Ug6m3k72qSUL2yORrrPNd/E72+Zjmx5j2x1mKXz7rq91sZuVQsEWg00wsuKtSWWthHD7n2UEC44mnDwlb32hB/N+Oa4Sf8wDEnv21C7mI+znMuW7dH7rGviEx87+Tn8bUtHgxJRZZfVoPkiBi0ZRiQUBF5o6iz6On8bAWoZMr3pclTwRD/jRen129zShEhTQ0OfWCZ6uC4kne3RAqKbQin5Bli4un0Ev8QaXIghiBiMf+djarByBdOhuh0ELDEdd7a/b7V1TKl9wzTNTAbmONYF2Nscm1oQtGFd22Iz1HO9O1xFRXUizpWlMLGwBwy/wN3seOZmK+VaQ4SeY1oLpL6vKDNGLPVXzn+6WEEwkMd2ouXuuKeP+mhvufk4MGeebKlksVRFXEkmD+dBbOkPXqC+esMRvjoVGpMHwmIg44I/qb9iwad83Z2CpaTrWkKEYgS330mLp759iOeQF6y3Oq/z2U1lDujCEMdEa5Zq1lj6G+guHo3t6mPQHnqc7mJ2FCazxX4cZ4wy4i9Y7Cwbo9Z4sEJ9ilZWnhi8Bez+C5XT7v/GIp8gX PmjXpLJ1 zGzR28hebjZFaD6ajIrbZhbRPzs7+KNgd93wrz/4ljXIq7kxNFn+fmaG3FEy7ZRpgNwLkgXbMmsgKoOPROy0eQ6mrHu72IqbPKRmtIGYlb/Q/43ho56i4ZePCrvs71lzBl0nZNTlwlIy0dnbbZPzuJMj52R6B+S75YcanWmNa4t+6nqni05sbYbWpsteV/CnvmnYd3ky4pZG3HnMWvvGRwEaly95Ko7Z/s/2kNkswFttm8X+zQRko6mZLF9YDPNgJ91Wq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add a boolean parameter for file_accessed() to support nowait semantics. Currently it is true only with io_uring as its initial caller. Signed-off-by: Hao Xu --- arch/s390/hypfs/inode.c | 2 +- block/fops.c | 2 +- fs/btrfs/file.c | 2 +- fs/btrfs/inode.c | 2 +- fs/coda/dir.c | 4 ++-- fs/ext2/file.c | 4 ++-- fs/ext4/file.c | 6 +++--- fs/f2fs/file.c | 4 ++-- fs/fuse/dax.c | 2 +- fs/fuse/file.c | 4 ++-- fs/gfs2/file.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/nilfs2/file.c | 2 +- fs/orangefs/file.c | 2 +- fs/orangefs/inode.c | 2 +- fs/pipe.c | 2 +- fs/ramfs/file-nommu.c | 2 +- fs/readdir.c | 2 +- fs/smb/client/cifsfs.c | 2 +- fs/splice.c | 2 +- fs/ubifs/file.c | 2 +- fs/udf/file.c | 2 +- fs/xfs/xfs_file.c | 6 +++--- fs/zonefs/file.c | 4 ++-- include/linux/fs.h | 5 +++-- mm/filemap.c | 8 ++++---- mm/shmem.c | 6 +++--- 27 files changed, 43 insertions(+), 42 deletions(-) diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index ee919bfc8186..55f562027c4f 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -157,7 +157,7 @@ static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!count) return -EFAULT; iocb->ki_pos = pos + count; - file_accessed(file); + file_accessed(file, false); return count; } diff --git a/block/fops.c b/block/fops.c index a286bf3325c5..546ecd3c8084 100644 --- a/block/fops.c +++ b/block/fops.c @@ -601,7 +601,7 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) ret = kiocb_write_and_wait(iocb, count); if (ret < 0) goto reexpand; - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); ret = blkdev_direct_IO(iocb, to); if (ret >= 0) { diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index fd03e689a6be..24c0bf3818a6 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2013,7 +2013,7 @@ static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma) if (!mapping->a_ops->read_folio) return -ENOEXEC; - file_accessed(filp); + file_accessed(filp, false); vma->vm_ops = &btrfs_file_vm_ops; return 0; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index dbbb67293e34..50e9ae8c388c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10153,7 +10153,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter, struct extent_map *em; bool unlocked = false; - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED); diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 8450b1bd354b..1d94c013ac88 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -436,12 +436,12 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx) if (host_file->f_op->iterate_shared) { inode_lock_shared(host_inode); ret = host_file->f_op->iterate_shared(host_file, ctx); - file_accessed(host_file); + file_accessed(host_file, false); inode_unlock_shared(host_inode); } else { inode_lock(host_inode); ret = host_file->f_op->iterate(host_file, ctx); - file_accessed(host_file); + file_accessed(host_file, false); inode_unlock(host_inode); } } diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 0b4c91c62e1f..dc059cae50a4 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -44,7 +44,7 @@ static ssize_t ext2_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) ret = dax_iomap_rw(iocb, to, &ext2_iomap_ops); inode_unlock_shared(inode); - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); return ret; } @@ -127,7 +127,7 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) if (!IS_DAX(file_inode(file))) return generic_file_mmap(file, vma); - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &ext2_dax_vm_ops; return 0; } diff --git a/fs/ext4/file.c b/fs/ext4/file.c index c457c8517f0f..2ab790a668a8 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -94,7 +94,7 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to) ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, 0, NULL, 0); inode_unlock_shared(inode); - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); return ret; } @@ -122,7 +122,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) ret = dax_iomap_rw(iocb, to, &ext4_iomap_ops); inode_unlock_shared(inode); - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); return ret; } #endif @@ -820,7 +820,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) if (!daxdev_mapping_supported(vma, dax_dev)) return -EOPNOTSUPP; - file_accessed(file); + file_accessed(file, false); if (IS_DAX(file_inode(file))) { vma->vm_ops = &ext4_dax_vm_ops; vm_flags_set(vma, VM_HUGEPAGE); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 093039dee992..246e61d78f92 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -524,7 +524,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma) if (!f2fs_is_compress_backend_ready(inode)) return -EOPNOTSUPP; - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &f2fs_file_vm_ops; set_inode_flag(inode, FI_MMAP_FILE); return 0; @@ -4380,7 +4380,7 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to) f2fs_up_read(&fi->i_gc_rwsem[READ]); - file_accessed(file); + file_accessed(file, false); out: trace_f2fs_direct_IO_exit(inode, pos, count, READ, ret); return ret; diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 8e74f278a3f6..8a43c37195dd 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -858,7 +858,7 @@ static const struct vm_operations_struct fuse_dax_vm_ops = { int fuse_dax_mmap(struct file *file, struct vm_area_struct *vma) { - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &fuse_dax_vm_ops; vm_flags_set(vma, VM_MIXEDMAP | VM_HUGEPAGE); return 0; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index bc4115288eec..3c4cbc5e2de6 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2496,7 +2496,7 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) fuse_link_write_file(file); - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &fuse_file_vm_ops; return 0; } @@ -3193,7 +3193,7 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in, clear_bit(FUSE_I_SIZE_UNSTABLE, &fi_out->state); inode_unlock(inode_out); - file_accessed(file_in); + file_accessed(file_in, false); fuse_flush_time_update(inode_out); diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 1bf3c4453516..3003be5b8266 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -601,7 +601,7 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) return error; /* grab lock to update inode */ gfs2_glock_dq_uninit(&i_gh); - file_accessed(file); + file_accessed(file, false); } vma->vm_ops = &gfs2_vm_ops; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 7b17ccfa039d..729f66346c3c 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -161,7 +161,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) return -EINVAL; inode_lock(inode); - file_accessed(file); + file_accessed(file, false); ret = -ENOMEM; if (!hugetlb_reserve_pages(inode, diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index a9eb3487efb2..a857ebcf099c 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -119,7 +119,7 @@ static const struct vm_operations_struct nilfs_file_vm_ops = { static int nilfs_file_mmap(struct file *file, struct vm_area_struct *vma) { - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &nilfs_file_vm_ops; return 0; } diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index d68372241b30..5c7a17995fe1 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -412,7 +412,7 @@ static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma) /* set the sequential readahead hint */ vm_flags_mod(vma, VM_SEQ_READ, VM_RAND_READ); - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &orangefs_file_vm_ops; return 0; } diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 9014bbcc8031..77d56703bb09 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -597,7 +597,7 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, ret = total_count; if (ret > 0) { if (type == ORANGEFS_IO_READ) { - file_accessed(file); + file_accessed(file, false); } else { file_update_time(file); if (*offset > i_size_read(inode)) diff --git a/fs/pipe.c b/fs/pipe.c index 2d88f73f585a..ce1038d3de4b 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -393,7 +393,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) wake_up_interruptible_sync_poll(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM); kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); if (ret > 0) - file_accessed(filp); + file_accessed(filp, false); return ret; } diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index efb1b4c1a0a4..ad69f828f6ad 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c @@ -267,7 +267,7 @@ static int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma) if (!is_nommu_shared_mapping(vma->vm_flags)) return -ENOSYS; - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &generic_file_vm_ops; return 0; } diff --git a/fs/readdir.c b/fs/readdir.c index b80caf4c9321..2f4c9c663a39 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -68,7 +68,7 @@ int iterate_dir(struct file *file, struct dir_context *ctx) res = file->f_op->iterate(file, ctx); file->f_pos = ctx->pos; fsnotify_access(file); - file_accessed(file); + file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT); } if (shared) inode_unlock_shared(inode); diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index a4d8b0ea1c8c..20156c5e83e6 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1307,7 +1307,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, rc = target_tcon->ses->server->ops->copychunk_range(xid, smb_file_src, smb_file_target, off, len, destoff); - file_accessed(src_file); + file_accessed(src_file, false); /* force revalidate of size and timestamps of target file now * that target is updated on the server diff --git a/fs/splice.c b/fs/splice.c index 004eb1c4ce31..e4dcfa1c0fef 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1104,7 +1104,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, done: pipe->tail = pipe->head = 0; - file_accessed(in); + file_accessed(in, false); return bytes; read_failure: diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 6738fe43040b..a27c73848571 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1603,7 +1603,7 @@ static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_ops = &ubifs_file_vm_ops; if (IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT)) - file_accessed(file); + file_accessed(file, false); return 0; } diff --git a/fs/udf/file.c b/fs/udf/file.c index 243840dc83ad..46edf6e64632 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -191,7 +191,7 @@ static int udf_release_file(struct inode *inode, struct file *filp) static int udf_file_mmap(struct file *file, struct vm_area_struct *vma) { - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &udf_file_vm_ops; return 0; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4f502219ae4f..c72efdb9e43e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -227,7 +227,7 @@ xfs_file_dio_read( if (!iov_iter_count(to)) return 0; /* skip atime */ - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); if (ret) @@ -257,7 +257,7 @@ xfs_file_dax_read( ret = dax_iomap_rw(iocb, to, &xfs_read_iomap_ops); xfs_iunlock(ip, XFS_IOLOCK_SHARED); - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); return ret; } @@ -1434,7 +1434,7 @@ xfs_file_mmap( if (!daxdev_mapping_supported(vma, target->bt_daxdev)) return -EOPNOTSUPP; - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &xfs_file_vm_ops; if (IS_DAX(inode)) vm_flags_set(vma, VM_HUGEPAGE); diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index 92c9aaae3663..664ebae181bd 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -323,7 +323,7 @@ static int zonefs_file_mmap(struct file *file, struct vm_area_struct *vma) (vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) return -EINVAL; - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &zonefs_file_vm_ops; return 0; @@ -736,7 +736,7 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) ret = -EINVAL; goto inode_unlock; } - file_accessed(iocb->ki_filp); + file_accessed(iocb->ki_filp, false); ret = iomap_dio_rw(iocb, to, &zonefs_read_iomap_ops, &zonefs_read_dio_ops, 0, NULL, 0); } else { diff --git a/include/linux/fs.h b/include/linux/fs.h index ba54879089ac..ed60b3d70d1e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2204,10 +2204,11 @@ extern bool atime_needs_update(const struct path *, struct inode *); extern int touch_atime(const struct path *path, bool nowait); int inode_update_time(struct inode *inode, struct timespec64 *time, int flags); -static inline void file_accessed(struct file *file) +static inline int file_accessed(struct file *file, bool nowait) { if (!(file->f_flags & O_NOATIME)) - touch_atime(&file->f_path, false); + return touch_atime(&file->f_path, nowait); + return 0; } extern int file_modified(struct file *file); diff --git a/mm/filemap.c b/mm/filemap.c index 9e44a49bbd74..1f2032f4fd10 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2723,7 +2723,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, folio_batch_init(&fbatch); } while (iov_iter_count(iter) && iocb->ki_pos < isize && !error); - file_accessed(filp); + file_accessed(filp, false); return already_read ? already_read : error; } @@ -2809,7 +2809,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) retval = kiocb_write_and_wait(iocb, count); if (retval < 0) return retval; - file_accessed(file); + file_accessed(file, false); retval = mapping->a_ops->direct_IO(iocb, iter); if (retval >= 0) { @@ -2978,7 +2978,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, out: folio_batch_release(&fbatch); - file_accessed(in); + file_accessed(in, false); return total_spliced ? total_spliced : error; } @@ -3613,7 +3613,7 @@ int generic_file_mmap(struct file *file, struct vm_area_struct *vma) if (!mapping->a_ops->read_folio) return -ENOEXEC; - file_accessed(file); + file_accessed(file, false); vma->vm_ops = &generic_file_vm_ops; return 0; } diff --git a/mm/shmem.c b/mm/shmem.c index 2f2e0e618072..440b23e2d9e1 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2317,7 +2317,7 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma) /* arm64 - allow memory tagging on RAM-based files */ vm_flags_set(vma, VM_MTE_ALLOWED); - file_accessed(file); + file_accessed(file, false); /* This is anonymous shared memory if it is unlinked at the time of mmap */ if (inode->i_nlink) vma->vm_ops = &shmem_vm_ops; @@ -2727,7 +2727,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) } *ppos = ((loff_t) index << PAGE_SHIFT) + offset; - file_accessed(file); + file_accessed(file, false); return retval ? retval : error; } @@ -2859,7 +2859,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, if (folio) folio_put(folio); - file_accessed(in); + file_accessed(in, false); return total_spliced ? total_spliced : error; } From patchwork Fri Aug 25 13:54:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365792 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 221C7C71133 for ; Fri, 25 Aug 2023 13:59:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B24CC2800BA; Fri, 25 Aug 2023 09:59:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD66D8E0015; Fri, 25 Aug 2023 09:59:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99E192800BA; Fri, 25 Aug 2023 09:59:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8AF1A8E0015 for ; Fri, 25 Aug 2023 09:59:17 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 59B79806F6 for ; Fri, 25 Aug 2023 13:59:17 +0000 (UTC) X-FDA: 81162783954.24.F043988 Received: from out-251.mta1.migadu.com (out-251.mta1.migadu.com [95.215.58.251]) by imf23.hostedemail.com (Postfix) with ESMTP id 9E4F8140017 for ; Fri, 25 Aug 2023 13:59:15 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hhFKi9wh; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.251 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971955; a=rsa-sha256; cv=none; b=nVRFk0pSY2h4FhuvoJsSfE033ye3WkTDAiwgqtRhchaULrtdioC49QN4M4oeDlQEJctrb5 ShigVzj5vm7vlMkLv0TOQOjZwPqKCyn6+UpGzWVGPBApuben6d3jCgm0jHcXUUTEyDIJBQ OpwrAYWzDPN+279kFyHsp+slR6zEwnc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hhFKi9wh; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.251 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971955; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X5RgYva0uI/YfpMcRAQXXXC0hBNumZORbEO2XQnoCOE=; b=ot8NNeBudBqt7UhiuNrv31mMbR8cKDKSAMSsu+r+ezKk/yvBLzPaxEni3Uv4SwjpW1dTXr qRv2yUrV2tzYkQR8agkA/7ZVIoPbiEKI0iBPys7W8sUpXch4Prmy7WlntnSQ2FYjQhZTHs T8aJI5erOo5O44Qic76FsiblTxGxFVE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X5RgYva0uI/YfpMcRAQXXXC0hBNumZORbEO2XQnoCOE=; b=hhFKi9whhR2X2IEmGg/HYYhsZrqTloqAijCXD8QFPZxM06DdOnuDX6HZcxaVx0GnWwP31a M0So32b6G0CBwnmz/554zgdXEAR2EreGyRvroTNj1npSBetZMZwgSp6p2inhLbOwP9M7D3 1+ZqQCM/k54TMM1J4bjoCTeLz5qWIys= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 09/29] vfs: move file_accessed() to the beginning of iterate_dir() Date: Fri, 25 Aug 2023 21:54:11 +0800 Message-Id: <20230825135431.1317785-10-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9E4F8140017 X-Stat-Signature: fyf3ine5n41gutrnqzzfepo5yaqhcn6t X-HE-Tag: 1692971955-767880 X-HE-Meta: U2FsdGVkX18z5jx6XID7lbdWY1TpuBz6EV7N8dbqYVL7Lf8udUO9VP1FdKHmL/OpvVmE5S9UnyFD5rra+MvzntcX0/ycW3nW3ZzsebWszdMDG8l8sAo3N/9qTtnj3DGC/VrTjbMMLu982w8zWRnsQtJLRcpIqH7Nb20nu1AVWDJqnP0g0gPsopPPTMoWoEaEJ+ypEg3oexmQjlekothMAoEITUb8bN7mrRqB9oe0/y2dSIhSYnKbSgYOlv8QaO3sTUwNURS5BJDRtXSzVuflToplJ67YNO0qz1NM27PkA0XTa4rZ8MLhP/B0VTOKgJM30r69dgUuhv+BGGK8YCIJv3QH34Kl9VSZxmpsCZc8Rj5yka8hg7QANhwV2dETa2RLyWnerlHYZPNZZSJ+ENrWmAUUuPdVo5IvgIMzmTsP+g5SCnbpBAPFdPm1EjBOQF+DXdlwzfGZYGm+L1pY71knJ8LMKbtzSmpbmWSMGtK1y3HDdCdpgosr8LK6NBwa5yxui4ZSi8BrKdxcahHtpwZ33qaWtQiyH+z8TPZDwH56dEGt2D3KJ8amqM/hGeSo9uTi83jFo3WkasGUb0ase0MFB2DlQucS75qIK92z0+3MFAwuGWJRG7a4vuCJnst92omoT/6EKCcr5iFqL6ulW2sAuajTZPDw6NPbAIpD2Ohdxt+WQMXFj4Q2wCvKP0JAPhQsD5+JHzawmSSu1eeaUQsBDBuCck+lzyYlxI+Zj7aWbYUzH54avuAaVbv5FroZSVHzFqYmoqmkQh3jWm6dtyxx4wuug9yWLah7DnEuuUGWYdgZ9VYi672YS8VWCVX5Jf98v5Wr5YnZsnG9ue0WP+oCN/pe2966jC8lkwfuVeytJ7TLvbCq8jnDtT1ES9KnAxHER6fwhAichTVxpHJ04hG/y3MdX42nW3I8hMnMRQO0U1fQKfROHXrgkq9u1teoMBwjHVgKw3MTbLaTJjo7Ln+ 5Bt/dlzy uNXG48THKnYBK8AALInzkrsL+4SEJEsC3IgTojMycLB80lS3+OiQ7DjkJjK7MFTD2bNjBjTRPdBR9xZcto4uT+d+LBlm4AcA2RjUkO7fx1r24/hzuRDESPiQ8rWrZeqA6O1v5BzG21LCgkdIJMmDv8tOwnfSgQenrel7NnEbWQhLpYMphSD/GrPBHp4CbpWzcKFcwpVr3RCxLtJSEVYxTpANiV2Gsaugiutr/VdK3vFUM18hy5oy5rDoyvP/d2s4vN5Bd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Move file_accessed() to the beginning of iterate_dir() so that we don't need to rollback all the work done when file_accessed() returns -EAGAIN at the end of getdents. Signed-off-by: Hao Xu --- fs/readdir.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/readdir.c b/fs/readdir.c index 2f4c9c663a39..6469f076ba6e 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -61,6 +61,10 @@ int iterate_dir(struct file *file, struct dir_context *ctx) res = -ENOENT; if (!IS_DEADDIR(inode)) { + res = file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT); + if (res == -EAGAIN) + goto out_unlock; + ctx->pos = file->f_pos; if (shared) res = file->f_op->iterate_shared(file, ctx); @@ -68,8 +72,9 @@ int iterate_dir(struct file *file, struct dir_context *ctx) res = file->f_op->iterate(file, ctx); file->f_pos = ctx->pos; fsnotify_access(file); - file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT); } + +out_unlock: if (shared) inode_unlock_shared(inode); else From patchwork Fri Aug 25 13:54:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365808 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4372FC71133 for ; Fri, 25 Aug 2023 13:59:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D5BC2800C8; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 383428E0019; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2242B2800C8; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 044438E0019 for ; Fri, 25 Aug 2023 09:59:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DFCF6B268C for ; Fri, 25 Aug 2023 13:59:54 +0000 (UTC) X-FDA: 81162785508.25.556F6C3 Received: from out-249.mta1.migadu.com (out-249.mta1.migadu.com [95.215.58.249]) by imf21.hostedemail.com (Postfix) with ESMTP id 314E81C000F for ; Fri, 25 Aug 2023 13:59:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=KOUX30U5; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf21.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971993; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WRD02daxOp9FNChzaFYS1lXdVleuK5a0no8X9tPyoYM=; b=Jk6NaHNj/c/jOs8Z2YEx5vtGEnMVw+SfyLtqvuadneFh8/dAfLnRJkVo3Uh54hh61Pc7ie zaqkjNjVwv62+KUiIyBtCqZ4RdtkvCp8OJoPPNhvPsOYX28rFX13K0P3OVaXU+IusUbR71 lr+DJNl4g2VSy23q0Cduu/bf+PObh9k= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=KOUX30U5; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf21.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971993; a=rsa-sha256; cv=none; b=iI5IHFj0S9HsXkt0fIHtLRUAsCa42vrVUQt36ZNVwu4y73L0OPmpxMhlUVcqwVGTqsfl9N RcPWxUOaCV5zW5cjhATwrKvnlBJYQoH3NGw36Ck30wWN5fpz3D52HlHJCLaaEEsY09Z60/ 1uR/2Xa4fKO6tBW01flfUcNIn1rboAg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692971991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WRD02daxOp9FNChzaFYS1lXdVleuK5a0no8X9tPyoYM=; b=KOUX30U5aMel7ZOrU6vyW+bfFawd12zc010HOkye0FIA5XwWQ8KuInrnnmEFvcM8/s51Q/ AaOybn5P1rP9UUeek73yc4I2uwInaXUHDAuF9iPRuAYZ+C8EXUIDSwZm4Bf0ZiLG750HKq BEWS22oRahJI/f4a4TxHtu+cFMHMdVg= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 10/29] vfs: add S_NOWAIT for nowait time update Date: Fri, 25 Aug 2023 21:54:12 +0800 Message-Id: <20230825135431.1317785-11-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: prxrs788xaentdas755uqijpf4hceqyw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 314E81C000F X-HE-Tag: 1692971992-59919 X-HE-Meta: U2FsdGVkX1/JukW8dcuHUqzZq3AMmFGuwKmuuXeGw6d98j/OvB+rTSI+OO2SYm09Fc1Ix1Vaf/aDR8aGCS+POVZ7+TPzD9oP6YZWQ7KUNhnY7PDvi0ui6KZHCXefZOumZTcAz+VKECiCmMjSuJf2MbMYpgjYXC5oCghM6wOTJOFx3Duh5NcP0z8ACRbzBdX02yUd+txWibvHr5VaY5Nz4dYoqhMvyfxnMuKe3kvrzg9XPyGITIAm/pNQo2PyCUNfFVHMJVTunWeEID+ujPO+AGIdfytFaC04An0HDUsSvV8H36ZAmLtRY1otUNznCsCHNflZw84SE1a5y7XB1jz82kaPNOofC8BJARarSjEELqwCqjLR+eLQa1C892RAhJ2CXVAIpkRgNtmxfcdVS19Q49mKpBkSWY4erSxUnjhf4Cz3uLliDYnZBXz8u0XM8e5d1l6RbLMbU/Mt0JQLzWVQFVTEMHVv5bGyJK4QdyjbaOC1yBbQkjVm7JjH6eL35eomfJxkWr4/mI0GDhhP+SrgPfRLtV8EeGcMcxAELJ4tHHVyyRfQ/MliZulTyGYO9rd6tOa1X4wu45Dyq8ZjMEBfscwV4pWe+ZZdAW3Sd/kUrO6wWcFebYekGJKldLUNHa5ZGHg/V4q4Z5WEkdnqOsd/T+rVPhGb6UOMsH4jPLcYX6q/415L069OXn//TIwNGI8ccjxmususam9kJojzvPLnEBZKWGZs1JY9KGWKCM878lacKuL+6jbZM1NlNyPX+UBpZ0bxVb3p2jIwxh29AwWajUInwxHTxo9myZNo8zNSXzLoyUK2aAgPfEPaiVAEBzWiyc7vrZ8scUswNVtvWwvHOamhkf0rrLcHoT0wbWZjt2PiuLVktLgZz58aBajT0mMf5MWEgF4O3b6vTI5nVqJ6Q2iO+NzOi5+ghKbEPhrzKOZ0XfvIlZQ3YHrY/UsrbxEDt+pdWdSQcAd4lUDHCc7 qP6Syx62 dLwAv0cxmxbbInYbBgKJyb//nQpbMiUcMiqQtUeaOz54AS/VNtt6IIXPXHzb8clVnPlqMWhQ4ZJ7nxDsObbNSM/MFHm7JyTT+3LfSTyGDWMoBKJEyNC40qx7cwVZW0wazAk69PGisVs2rzopwOzJXYEzWgXQ23Wguf6nzcbW26MTIrjMxQHD+15LAuuPQK8IDgyaotyasL74/erzUGIneiaudeQUALar1ae9ygoDBLjN8cs9sg1sKzht9EA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add a new time flag S_NOWAIT to support nowait time update. Deliver it to specific filesystem and error out -EAGAIN when it would block. Signed-off-by: Hao Xu --- fs/inode.c | 9 +++++---- fs/xfs/xfs_iops.c | 8 +++++++- include/linux/fs.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index e83b836f2d09..eb3db34a3e6e 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1966,12 +1966,13 @@ int touch_atime(const struct path *path, bool nowait) struct vfsmount *mnt = path->mnt; struct inode *inode = d_inode(path->dentry); struct timespec64 now; + int ret = 0; if (!atime_needs_update(path, inode)) - return 0; + return ret; if (!sb_start_write_trylock(inode->i_sb)) - return 0; + return ret; if (__mnt_want_write(mnt) != 0) goto skip_update; @@ -1985,11 +1986,11 @@ int touch_atime(const struct path *path, bool nowait) * of the fs read only, e.g. subvolumes in Btrfs. */ now = current_time(inode); - inode_update_time(inode, &now, S_ATIME); + ret = inode_update_time(inode, &now, S_ATIME | (nowait ? S_NOWAIT : 0)); __mnt_drop_write(mnt); skip_update: sb_end_write(inode->i_sb); - return 0; + return ret; } EXPORT_SYMBOL(touch_atime); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 24718adb3c16..bf1d4c31f009 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1053,7 +1053,13 @@ xfs_vn_update_time( if (error) return error; - xfs_ilock(ip, XFS_ILOCK_EXCL); + if (flags & S_NOWAIT) { + if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) + return -EAGAIN; + } else { + xfs_ilock(ip, XFS_ILOCK_EXCL); + } + if (flags & S_CTIME) inode->i_ctime = *now; if (flags & S_MTIME) diff --git a/include/linux/fs.h b/include/linux/fs.h index ed60b3d70d1e..f8c267ee5cb7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2198,6 +2198,7 @@ enum file_time_flags { S_MTIME = 2, S_CTIME = 4, S_VERSION = 8, + S_NOWAIT = 16, }; extern bool atime_needs_update(const struct path *, struct inode *); From patchwork Fri Aug 25 13:54:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365809 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBBD9C71133 for ; Fri, 25 Aug 2023 14:00:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 669F62800C9; Fri, 25 Aug 2023 10:00:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61A918E0019; Fri, 25 Aug 2023 10:00:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 509832800C9; Fri, 25 Aug 2023 10:00:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 34E6D8E0019 for ; Fri, 25 Aug 2023 10:00:20 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0FD6FC06B7 for ; Fri, 25 Aug 2023 14:00:20 +0000 (UTC) X-FDA: 81162786600.04.628FF87 Received: from out-253.mta1.migadu.com (out-253.mta1.migadu.com [95.215.58.253]) by imf15.hostedemail.com (Postfix) with ESMTP id 23646A000E for ; Fri, 25 Aug 2023 14:00:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UXdbOLDk; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf15.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.253 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972017; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CL8wzJoAbQ75iZcN0EHSqoGXIWt+IFMvEgcKIhs6zqE=; b=O0j7tln3la2bjKNS/F6MaZfJXkhnU8FxUabUJFkVlCwwpeXqgxEovRs1aemr/UL1VeXSMN O2Zx8PSXS6HF679cpFvia+W/Jweuk4M7BlDniMiblf5MLfL062v6TDhjyPMhLtkp3dJOed S/T1yWNOj++mHBenKffknQ932aGBXWE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UXdbOLDk; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf15.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.253 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972017; a=rsa-sha256; cv=none; b=N7LU8S8TTiFunr3D5W8WSI6LFA79zUGfbrGF20ea2c/0iFLsFXDxVHpXt1lN7tY+cj6ra2 oYoFFaEkneicJNfyo4Sj+hLTg8/HR9qBorSeVfBF9fuuSdZ4f8pyKPjgwDuUoa+lfE+FIo tWxrcxmaRjnK43cVQrWpPOyEbNNrN0w= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CL8wzJoAbQ75iZcN0EHSqoGXIWt+IFMvEgcKIhs6zqE=; b=UXdbOLDkxTPiI/RUD6vA6Y59upGR8p9yuOS0cheVOmW9wy55dk0PwGqrHNQocUaxtZPqwl 8SMpVuiY/GUEZaQEBzm6P0e4nsRhzT+GENJ6bzTIZGRyqbBvQsF+Q3u8++NZNdyfo398WE Pbto4Fcj8Lgxb50rhsqaYEakh0iY2/E= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 11/29] vfs: trylock inode->i_rwsem in iterate_dir() to support nowait Date: Fri, 25 Aug 2023 21:54:13 +0800 Message-Id: <20230825135431.1317785-12-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 23646A000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: yzhmzubrbj91z1wfmb8yt31o38qagktt X-HE-Tag: 1692972016-625632 X-HE-Meta: U2FsdGVkX18tXw81TnrONvUFc0kcCnQJ82phooMb9v6WL8ZAq+wnZlye00H/LPcuJ/HsqaC8vYWfDW1i50R2fjXxbHL7DZd7T0IlS2bS1pLhImacBHG0bj5ELA12kfwGA9ozmuWwEMkWNq2Z1qWGDhaffW7Mp32kkG/jb+mwmPatMqfoBjg8qRnTzHD1CIpWov4asCY5/7odhBMEA1/uckeMpOWx/S3uz8vCq62Guar+yw/GjMNiW97PizjKNHUJRwSR0MBkrFrp6hkp52a8LUHSw4bZ86R7LFWvq0E5lHMixA14Jjl9aJN0uTMW6W3lxifFNoGnJPp6LcHnZX5n2cCgMUF/jLUI/e/eS2DiYFhJoTnnLSZoPT5JF3H+hXFETE1pA6SSYAu7JCcaHA2WNk6oRM84ahbWIZkaOafKi+u6CY750TWtUJr58vvtnx9X3HjQiAo9MwRUjVfyoV/YWXSTzgv5rr6JQEqI1IXa6q9gmSNBd70AvWghL0IXFY88ZMC6rnmyTsexPX73wdIJTQBD9rGxarI5uUt7KvkJ3LnyZZeta8LYBjq/5cWGvRD8zDx5GPGYpPzUEv1ABLDqA+lCYHHek4PhdOnkZO1yNnWG+pZ+Cxpw4zJS8qWYPFVH5cxaqq5X9rW6ydj/phPZ9/l8zrAr6nChU+oY1exLFGBWie+K3Kx9IB1US6CqyOsGOvpFTPNXc64OzBc2dhM+MRyC+oXsJtSjbuW753sGXr6Adgzz44SwKj1lqQDqEUvO2ceUdJ9wc0BvbuKv/I5Swob70Mxxi432dgMYBXsXl7y3+BbAruIX8rRpsy92ag4HxXT9zp7WgbyVfB3F5nlxTMuXksVqWv+qkF6qvIDdbrKi696nrvPN/bxmMVJd+H7AaQ+MIchf2Tcq4mPtkWIUdsCmweQ8V2Y5CZOetQl5SaICtMGYzAfUdrNWi0AnRKyvOrlrASrEWbbkfNcQ9eS KicdXPtY 3gODA2PF40vNCXp9X8MRLiMKK+pA4fFyoOh3l7Vm4j4ft/QrZpbzpu5khaO2VeXhFqNBiMJkNGIXjV0MPo/FsrEwzXKiYcXlfIk3VOiwMKpM9+i7adjTPIOS0ugXrjjcu1mKj/o6NYWsOCFyXt4RLahs0WLnzf2JC4uD34cbnXPsUwdx4osBrIZnSgjig4SbH2F2e5BHmxLM+tp3DEDPNkns6nt51PNOrVpwVA9Zk/LmEGWKerlIGibLRjbjgI4wyRr6Dgj1BWKLsr+Y1qjcxL8uupOpFeg7rkunhFXf9CoHDj3Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Trylock inode->i_rwsem in iterate_dir() to support nowait semantics and error out -EAGAIN when there is contention. Signed-off-by: Hao Xu --- fs/readdir.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/readdir.c b/fs/readdir.c index 6469f076ba6e..664ecd9665a1 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -43,6 +43,8 @@ int iterate_dir(struct file *file, struct dir_context *ctx) struct inode *inode = file_inode(file); bool shared = false; int res = -ENOTDIR; + bool nowait; + if (file->f_op->iterate_shared) shared = true; else if (!file->f_op->iterate) @@ -52,16 +54,22 @@ int iterate_dir(struct file *file, struct dir_context *ctx) if (res) goto out; - if (shared) - res = down_read_killable(&inode->i_rwsem); - else - res = down_write_killable(&inode->i_rwsem); - if (res) + nowait = ctx->flags & DIR_CONTEXT_F_NOWAIT; + if (nowait) { + res = shared ? down_read_trylock(&inode->i_rwsem) : + down_write_trylock(&inode->i_rwsem); + if (!res) + res = -EAGAIN; + } else { + res = shared ? down_read_killable(&inode->i_rwsem) : + down_write_killable(&inode->i_rwsem); + } + if (res < 0) goto out; res = -ENOENT; if (!IS_DEADDIR(inode)) { - res = file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT); + res = file_accessed(file, nowait); if (res == -EAGAIN) goto out_unlock; From patchwork Fri Aug 25 13:54:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365810 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74325C71133 for ; Fri, 25 Aug 2023 14:00:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13B872800CB; Fri, 25 Aug 2023 10:00:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EB088E0019; Fri, 25 Aug 2023 10:00:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF5222800CB; Fri, 25 Aug 2023 10:00:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DC47B8E0019 for ; Fri, 25 Aug 2023 10:00:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B7019806A2 for ; Fri, 25 Aug 2023 14:00:42 +0000 (UTC) X-FDA: 81162787524.02.01F20C8 Received: from out-248.mta1.migadu.com (out-248.mta1.migadu.com [95.215.58.248]) by imf24.hostedemail.com (Postfix) with ESMTP id B7B3B18001F for ; Fri, 25 Aug 2023 14:00:40 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=pz2+RJXn; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.248 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972040; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=A8n142m+ckTq2ok9t7Tm2FnSZDGwRTGaDgQRQd0QVrs=; b=Yuv8ADsiY6xuzBTwr8aWbKSMLJm8gXVFQjNRmnGp6XvvKEcrcGNGrNpkta9gCaSl+Y2K0k XdFjsJPlvQOy5W64ciDomqoey2WLRyu/4SEjuurDF1WVaSkTQkuviSpxMcXbfcvuMJxOdd Pt/RTARGlzZQ0fm36QyhVIL85zdCVOk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=pz2+RJXn; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.248 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972040; a=rsa-sha256; cv=none; b=tlysBA+Vz5rz+cYmg04Q7RkUH6r8gtWEcGXSU2B4wB9I3eKkdWSj9XHRh/RAF+4fi5Url5 4wVfu3j9Cz10690vnyzmwiZA+INq8IXc4hdYW64buqwEE38EgPTCoeOpsyulMyp0ya+wfi wuMuIRJjQx6BVdXa0xwGoltcvcMhyXA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A8n142m+ckTq2ok9t7Tm2FnSZDGwRTGaDgQRQd0QVrs=; b=pz2+RJXny/FRc9X5ZHvo0v2sP0AhNIbG6GqEDC3f4IgSNhM3HBNVDwOESMUSOR4IEMUxcQ QeB+zNMG6saCP+3Ee3iNvTaLm94PmwVrh29h0zPxcQxdxo6uNrunXvw2MGBXff+gKAxGGD nCmOsY1G1aaOlGneScmRPtSGG9/rCYg= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 12/29] xfs: enforce GFP_NOIO implicitly during nowait time update Date: Fri, 25 Aug 2023 21:54:14 +0800 Message-Id: <20230825135431.1317785-13-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: mp9gib8kwzfnq5cn5ubuhtsxbsubbsdi X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B7B3B18001F X-HE-Tag: 1692972040-63998 X-HE-Meta: U2FsdGVkX19nA8xEZ0kPE5pdXPIPxMSP0gVJ3ehBFtRzc2cKYVkha8/BEwS5oEWM2i/CreF/mE/iRVPseE1yyN5MqsF6ePdSt6EDzqD1bIT3QYeqgeTld8PELgOfb6MHMNn3vtMlVeF8lYtVTyQahn0lHKfnqF2cSmD/jKPC6SicC8ORN+WsLrtl54jdYxYQXJgFgPw4BTapzVgh4/q3P702TII+dQA8OD5KO5hGQzlgXgacaPNXxW6wTdIlZhiEMkrUogCyzmXALNJNshAtbaf7qWxkcONT45S9N4YBh6rJ6V3hN2fPAjBkarmU8hTN0rzjt+dA5y5dl3X3K5EeswX6FtmGW1ylrs1esUzMdz6AFQjjhdtJ7yRfOq9H1MB63vyIH6wKHBb0fPavb2K5RNCr6AaLCKGcmTrwEwlQuzQ/bO1w3eIYm8giMcdHDMdQ3E0dhptDlJ2Ngkgq5hSL6WxbX1K8twf/toQ46i/P03IkzSgWmKbXpX4MB/FWBBRV8NYsq75NAkXc77syPAtBUB/fNI6+x+ysCZIIwK/hLbni3cezcqFl8IPlDhxC49WYIGb5UmFEOxodIk0/I9s7VP+S7VNdl5Yy/xVXRUMcQe6ZZGHhqNCJVuDYc8erUAKFliqfH4holi4LBvd2gCm+W8ptNNhGoN7UuTZXigpbrTvKl7FdohG7omU+NeaLf+wnfTVBQkXOYa2MLFOm3Agi7s78+WyGVmy01T8oPnkcdjCIYawoGRZaGxJLGa92xv9FZKM07b0HpLms7tMFMeVnVODbAZp+qiIRHyuOgtkmXA4AWSCA96dzFlTwQiermfU37Z8mHvqPkBI7sYiVsaw1lO7Y5AriDrj95EYlhc5clb7gOvIJMXnj+IB4b2m8hI9RQokEI7gCsc6V+JhBAraUzqMvWFmcUHAQLOAJ2qBwgQ1hT1agur9qBfD2zankMjB/HJ5Nklk6XCJAxE6H/uz q7kljTYZ egDYUcQA4GfD7MRV2bWY6o927fkB8Sy67LJgu5e7Lqh9dWxiWhg1qfwtvkLz5cFPWuTqIT1x4lJouF0h1ZTQFx3fOxXBmHQo0AvhSa8PA3rnobV+VRsnFGrzfkBPftrsVrGrFw5Ik3M8vXdA6/27/ftHFElQAH+49JUPihEM9+4+oi8aZX24/HAHABEROP2Qo+EMulbG0dMHBYapgf1acA0Qfplm8+7TXB0ibAWKfTa7w132gBz/S7G2T2fTyebjcR3KU X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Enforce GFP_NOIO logic implicitly by set pflags if we are in nowait time update process. Nowait semantics means no waiting for IO, therefore GFP_NOIO is needed. Signed-off-by: Hao Xu --- fs/xfs/xfs_iops.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index bf1d4c31f009..5fa391083de9 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1037,6 +1037,8 @@ xfs_vn_update_time( int log_flags = XFS_ILOG_TIMESTAMP; struct xfs_trans *tp; int error; + int old_pflags; + bool nowait = flags & S_NOWAIT; trace_xfs_update_time(ip); @@ -1049,13 +1051,18 @@ xfs_vn_update_time( log_flags |= XFS_ILOG_CORE; } + if (nowait) + old_pflags = memalloc_noio_save(); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); if (error) - return error; + goto out; - if (flags & S_NOWAIT) { - if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) - return -EAGAIN; + if (nowait) { + if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { + error = -EAGAIN; + goto out; + } } else { xfs_ilock(ip, XFS_ILOCK_EXCL); } @@ -1069,7 +1076,12 @@ xfs_vn_update_time( xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_log_inode(tp, ip, log_flags); - return xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + +out: + if (nowait) + memalloc_noio_restore(old_pflags); + return error; } STATIC int From patchwork Fri Aug 25 13:54:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365811 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24271C71133 for ; Fri, 25 Aug 2023 14:01:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3B192800CC; Fri, 25 Aug 2023 10:01:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EB6D8E0019; Fri, 25 Aug 2023 10:01:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B4A92800CC; Fri, 25 Aug 2023 10:01:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 78B998E0019 for ; Fri, 25 Aug 2023 10:01:08 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4BF2A14068B for ; Fri, 25 Aug 2023 14:01:08 +0000 (UTC) X-FDA: 81162788616.15.3E634E6 Received: from out-252.mta1.migadu.com (out-252.mta1.migadu.com [95.215.58.252]) by imf11.hostedemail.com (Postfix) with ESMTP id 4802840016 for ; Fri, 25 Aug 2023 14:01:06 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=T5TsYuTv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972066; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8gDZUIYfeApELVxpIbTdhBYkuCUYVAI89qfTIaKdMRE=; b=nnnhdIepowXfCFiQSV/6n/f05YBP7bKOiW/d8PV2ZQkBckiFdldsVS1S/C1TTUhdDC5t2r 3pz0EmMn7MIZWfwooTfMWj1wFx0jUmHX4Q2CnX+jvjDE140xvPi04XQkFr+eutTP+GyNOs pqqJswocknC2mPorlY/l+jlCuTKKrQk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=T5TsYuTv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972066; a=rsa-sha256; cv=none; b=0CTQKYAKgb/KI0LFi0h+dw6YTCefR30fCFJTNbgkRIGg/0PKMAA8HTGnJCFWqnNRLMGig0 PzvT6m0Y3SU+Mj/U0aOCzkhX6pAeT/1v9r8MSFnJGLUpy2/pntvShAl+V6JnHS+TtEmC8O SOcKRIrzI5+Bxk1njhuAvfqWxRnWgSs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8gDZUIYfeApELVxpIbTdhBYkuCUYVAI89qfTIaKdMRE=; b=T5TsYuTvtADJBxiHqsewoSqqKK2UBuXMKNSoxaDNp/NJgc7Q8+g8JEetIByTzkVFCGvNzG tWnxRnfXklKMFPsrmWvd4eLQKArJQqjl9a4PVTfDC36l8fZblJzTpI0+nRJbIbwH5cYBhh 1gSrwgjCBl1L9hu8cUoTezmUDMAfEak= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 13/29] xfs: make xfs_trans_alloc() support nowait semantics Date: Fri, 25 Aug 2023 21:54:15 +0800 Message-Id: <20230825135431.1317785-14-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 4802840016 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9wyqmf8gs46g1mxteo65koy5m3us1f65 X-HE-Tag: 1692972066-318999 X-HE-Meta: U2FsdGVkX19hSpET2RoL4T3/qo/rdK2gievJe8qxk4afHd22nBLbVshPBM29cWc1Sg1co5EQbN4a5Pq2871qDdmN9eTDOD5VlJPpBj2Ty6RK7eJu+8y3jdkCXqsH/CUzNYiLhqh5HcBArvwDuYUHkdPbj3OcAEaYmj/QmRxOPyWNnOUuenS4XXY+7cAcTpSlve5BjowgWDgMXXVtzldUVdZylp+RXFaDKCsDuZg/m8ghrJF9WMoObCBVOuyD1HmGYZrRqLW5Vn33/3mLfE9BjZttyLBR3oTzyaO2NY92+zRf81zy7zDMPA6991QdYRw6ECj7WRw0752yvHsL7v7MEEu9/ipob1BfmK9rM1uh5uZrLbPpbOMo/DDw/URJYALvhJvSY3ULmPu9UpsvVrsjVfg7P9Yw/RsXs2iWh6GsVR/5PCi74NeZs53EPUev1TZj6NCe4ODnzUxT3BIATmPgBr/HIOxdrPYDpONb9jv7d6Z2nbhn0pXn4+XSedBde+kASqvkOwe/YRJpd7F9t1yUgGSu9p+iwLda7WdO3laNtGRCewlNFGP2rvp8cbPlAFVTNckHmaBmM8bjcHyeVaCQXj0/fK9FCMuM+GWKpcWZi3/S92JEwnV0FRdbnxQq61LSyDK0dCCFNhA3Dt/52rdvahZIdRzGqsv1jYs+/VeWB3pOf9OhqJmbFCCZiMtvxTpb6wnbFI6df4vmdDKKDMBEKxJJgTLStMqrR1kcRVEnMZ8VVmrZKSHi0PFb/BNosw7W7f9du+lCh0Ju8kygn57GFOX9ocjkIYYty7EhAi7dW8034EPJDlM/ePijpoG5/86GGn4TiQwQ4d4S739h1/hhn9TdQH8jCUd82/gzM9XbdmX4U7XG4O4DlOB9mAIU/Bgfp6FoxPvjh60MlsPSaScAswWMMLux+zg1VFItZ0vx/juYcBQVONgNTxcXzpw5RsaMQN4Y1DnlQo9+3ZMsTCA EaP0a2Ck k7y7tU62Q6YCpPBFvwnENQm5xmgQXja6dlNpwkJ1dfHsMzCV7pe3NS5ywX+ZT3tXUsnDn0AAno6QpMRR2TsxPZMHpCikn2Lew8/QEyObXQKsB0STebXTjo/MejuVFjAVpLbtpHSQVux//zz0ZidKjU7y1xD2pyIE/d1dOwfDmnfeMIzMFBMIllpb18s7gZXBwAFs4pJa+WlZqJTdl07grK2L36r2ZGqJB/kTPYIPF2U0XtxV4Ha5M8Hp/71wfS1RNk28K X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu There are locks in xfs_trans_alloc(), spot them and apply trylock logic. Make them return -EAGAIN when it would block. To achieve this, add nowait parameter for those functions in the path. Besides, add a generic transaction flag XFS_TRANS_NOWAIT to deliver nowait info. Signed-off-by: Hao Xu --- fs/xfs/libxfs/xfs_shared.h | 2 ++ fs/xfs/xfs_iops.c | 3 ++- fs/xfs/xfs_trans.c | 21 ++++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index c4381388c0c1..0ba3d6f53405 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -83,6 +83,8 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp, * made then this algorithm will eventually find all the space it needs. */ #define XFS_TRANS_LOWMODE 0x100 /* allocate in low space mode */ +/* Transaction should follow nowait semantics */ +#define XFS_TRANS_NOWAIT (1u << 9) /* * Field values for xfs_trans_mod_sb. diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 5fa391083de9..47b4fd5f8f5c 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1054,7 +1054,8 @@ xfs_vn_update_time( if (nowait) old_pflags = memalloc_noio_save(); - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, + nowait ? XFS_TRANS_NOWAIT : 0, &tp); if (error) goto out; diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 8c0bfc9a33b1..dbec685f4f4a 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -251,6 +251,9 @@ xfs_trans_alloc( struct xfs_trans *tp; bool want_retry = true; int error; + bool nowait = flags & XFS_TRANS_NOWAIT; + gfp_t gfp_flags = GFP_KERNEL | + (nowait ? 0 : __GFP_NOFAIL); /* * Allocate the handle before we do our freeze accounting and setting up @@ -258,9 +261,21 @@ xfs_trans_alloc( * by doing GFP_KERNEL allocations inside sb_start_intwrite(). */ retry: - tp = kmem_cache_zalloc(xfs_trans_cache, GFP_KERNEL | __GFP_NOFAIL); - if (!(flags & XFS_TRANS_NO_WRITECOUNT)) - sb_start_intwrite(mp->m_super); + tp = kmem_cache_zalloc(xfs_trans_cache, gfp_flags); + if (!tp) + return -EAGAIN; + if (!(flags & XFS_TRANS_NO_WRITECOUNT)) { + if (nowait) { + bool locked = sb_start_intwrite_trylock(mp->m_super); + + if (!locked) { + xfs_trans_cancel(tp); + return -EAGAIN; + } + } else { + sb_start_intwrite(mp->m_super); + } + } xfs_trans_set_context(tp); /* From patchwork Fri Aug 25 13:54:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365812 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C4E4C79F61 for ; Fri, 25 Aug 2023 14:01:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5ED38E0019; Fri, 25 Aug 2023 10:01:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0ED96B0083; Fri, 25 Aug 2023 10:01:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAF338E0019; Fri, 25 Aug 2023 10:01:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 984EC6B0082 for ; Fri, 25 Aug 2023 10:01:25 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 502501406AC for ; Fri, 25 Aug 2023 14:01:25 +0000 (UTC) X-FDA: 81162789330.16.233AB77 Received: from out-252.mta1.migadu.com (out-252.mta1.migadu.com [95.215.58.252]) by imf08.hostedemail.com (Postfix) with ESMTP id C5797160042 for ; Fri, 25 Aug 2023 14:01:22 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=j54ewDh2; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972083; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Q7GJNVQ0Y96opNfJhfWJzC+SabxuYOtwTQfKCmbWXKc=; b=fq0qHp4WHkZGqF/12ZphgFw5r6gJ0sYkn1kdaAaIy4wAuZToZSNfvfJCWBGmFYme9CWUsn UHVdjcw0RnP6YdnE2AbBnEtLmMoJijuwUG3gxpvu8W8FSfAVRijNfq9IsqJ+t5BNIpiOwP Eq7AhKM0h99kXX0VABrhjfSdyXNQ4mk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=j54ewDh2; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972083; a=rsa-sha256; cv=none; b=qwzwZD49TJQgawgu7tUoQnflOFmz3/klhG0PEmyp+MXGRAv5I+YevMQuULmHPKY83mAdod FoGraeY6VkmK2yzAKKdU1zanNImTCD3wj2x2eVjGLmNUGRPQ+Eriy2FmkxPBo7X0kZhaOB w4Gr5+10csZOpwg61iW3VQ5sTGciVuw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q7GJNVQ0Y96opNfJhfWJzC+SabxuYOtwTQfKCmbWXKc=; b=j54ewDh2CRDqfk/+h1q/85e0wp1lISfhgPRb5rHWHTlFySJ45nMdNr3rimnyqzcUlx54Dm 1Iv+GJ+fa2J/Cn+NCS092MkLu4BW3Xiql1+sxKLKb2TiHKwHVsneMm/7FSrPTTHc2KwWos w1EYET3XCov0zpVmPbiOAtQWe7vzjrk= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 14/29] xfs: support nowait for xfs_log_reserve() Date: Fri, 25 Aug 2023 21:54:16 +0800 Message-Id: <20230825135431.1317785-15-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: C5797160042 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: j37xhmcqqrwrupzzo35113pgimkibxxb X-HE-Tag: 1692972082-315764 X-HE-Meta: U2FsdGVkX18f2rVTus5a9tUtybUj0OqHyD/5V8gCYkVWAWzuN2VjWAgs/E8xXUtxU8h31QmMMoYWJTysiSI80vysVpOJAzm7snPgu4GqRes9Ws6DQZXqmSMeyRpenAwSKYi2mrxpmNuhwoPm5cbYLlChAsI1sU35zqordXew+cdLxtXxkwiPB5924ltd3ApmAScnsU4fi+haZA+1CVzLjxi3iHBw9Tbw1yNcX+78pDc8wUVlxUMvg0hWRrXO3O5dDVVwl12b17ldTVPiP2I9ywwntDKmb2OSE9fc4zkS5k0G2wcrWi973qGVK2ARGgE1rRq948A1QKnXRzKr4gYegdGcrexsPZKVEJOC6iCLCDNM4vpwwFQIiIkSGXvg2+HI4+ID7ExqSumiiY+mwL/7PyrzCfirQw70cM4YV3W59kN27hGaAAgXKkrdjFDH6i1tV8YiDhnwQvemPcThbVj8WM83risvUh1HMvh2Mazhc7S++x7tRPwBFjNI7ajfj1XWBYE6ZPjkzM3N/h6+8JviPe9JtAB7XCeyFppRi4S3l+McGeHrTZnlQRyDqhqLxg0lAAsb57P2hUHshmYHjdh9aPSyqWtcUEJRqWSykO9A7yxPyepshk7vR0fLaPr8SFPQuPoLTTS1nDu+nvi3VNqk7m4+Rat4IsHwpdOzs5p0id7p1zU4VpWfQP/XpnN7X1qR+is6jRmev99xqpaUuhw+xOxRuayXrgs9j54OEcJ8sZ/ne9sEo68GONty0yl9imSk02X4Y2DdIsVkOi0prWcllhu5/QtNcCYrPXsoJuH6rAJyfppxJDcA4vADJjTiCbpff0ryF+JDLAsRc7XAgh2TaLQufanrVmkuiaCnTlYWw9Jbby/XrVWW2snXJqWgkwuRTs2KRDYDAt2EXfsQYiPtV5ABs0BGZWTyRpN77aEvL7qO5/llZzC47WV7Tj1UrnOshl/FY6epWvxUkboYorB LYX7JhIN 9GFTC++mW8OgEMvRR5Vr0wGJwnKlWG9WZRSGa6av4nixQ8tkpYSlNeQsts56yzO6BrGfGhdoq+76ZBjskOMIQI8CA67QlVAkNRk5J+z2Pm3sDsANrjPCwxpCmiSwY87bEDpGxuAMTeAhqKprZIbIT0OlKMrVJT/0Z2o+53PyOucxO5TYAKILLde2DNCEZY+s1YHc0zgkpKEffAU5HusFBNj3Z5qZAEgJDsNrMqouxMsQVrYujjeLVRmfZjQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Support nowait logic for xfs_log_reserve(), including add a nowait boolean parameter and error out -EAGAIN for ticket allocation. Signed-off-by: Hao Xu --- fs/xfs/xfs_log.c | 18 +++++++++++++----- fs/xfs/xfs_log.h | 5 +++-- fs/xfs/xfs_log_cil.c | 2 +- fs/xfs/xfs_log_priv.h | 2 +- fs/xfs/xfs_trans.c | 5 +++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 79004d193e54..90fbb1c0eca2 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -462,7 +462,8 @@ xfs_log_reserve( int unit_bytes, int cnt, struct xlog_ticket **ticp, - bool permanent) + bool permanent, + bool nowait) { struct xlog *log = mp->m_log; struct xlog_ticket *tic; @@ -475,7 +476,9 @@ xfs_log_reserve( XFS_STATS_INC(mp, xs_try_logspace); ASSERT(*ticp == NULL); - tic = xlog_ticket_alloc(log, unit_bytes, cnt, permanent); + tic = xlog_ticket_alloc(log, unit_bytes, cnt, permanent, nowait); + if (!tic) + return -EAGAIN; *ticp = tic; xlog_grant_push_ail(log, tic->t_cnt ? tic->t_unit_res * tic->t_cnt @@ -974,7 +977,7 @@ xlog_unmount_write( struct xlog_ticket *tic = NULL; int error; - error = xfs_log_reserve(mp, 600, 1, &tic, 0); + error = xfs_log_reserve(mp, 600, 1, &tic, 0, false); if (error) goto out_err; @@ -3527,12 +3530,17 @@ xlog_ticket_alloc( struct xlog *log, int unit_bytes, int cnt, - bool permanent) + bool permanent, + bool nowait) { struct xlog_ticket *tic; int unit_res; - tic = kmem_cache_zalloc(xfs_log_ticket_cache, GFP_NOFS | __GFP_NOFAIL); + gfp_t gfp_flags = GFP_NOFS | + (nowait ? 0 : __GFP_NOFAIL); + tic = kmem_cache_zalloc(xfs_log_ticket_cache, gfp_flags); + if (!tic) + return NULL; unit_res = xlog_calc_unit_res(log, unit_bytes, &tic->t_iclog_hdrs); diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 2728886c2963..ba515df443c3 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -139,8 +139,9 @@ void xfs_log_mount_cancel(struct xfs_mount *); xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp); void xfs_log_space_wake(struct xfs_mount *mp); -int xfs_log_reserve(struct xfs_mount *mp, int length, int count, - struct xlog_ticket **ticket, bool permanent); +int xfs_log_reserve(struct xfs_mount *mp, int length, + int count, struct xlog_ticket **ticket, + bool permanent, bool nowait); int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic); void xfs_log_unmount(struct xfs_mount *mp); bool xfs_log_writable(struct xfs_mount *mp); diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index eccbfb99e894..f17c1799b3c4 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -37,7 +37,7 @@ xlog_cil_ticket_alloc( { struct xlog_ticket *tic; - tic = xlog_ticket_alloc(log, 0, 1, 0); + tic = xlog_ticket_alloc(log, 0, 1, 0, false); /* * set the current reservation to zero so we know to steal the basic diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 1bd2963e8fbd..41edaa0ae869 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -503,7 +503,7 @@ extern __le32 xlog_cksum(struct xlog *log, struct xlog_rec_header *rhead, extern struct kmem_cache *xfs_log_ticket_cache; struct xlog_ticket *xlog_ticket_alloc(struct xlog *log, int unit_bytes, - int count, bool permanent); + int count, bool permanent, bool nowait); void xlog_print_tic_res(struct xfs_mount *mp, struct xlog_ticket *ticket); void xlog_print_trans(struct xfs_trans *); diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index dbec685f4f4a..7988b4c7f36e 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -155,6 +155,7 @@ xfs_trans_reserve( struct xfs_mount *mp = tp->t_mountp; int error = 0; bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; + bool nowait = tp->t_flags & XFS_TRANS_NOWAIT; /* * Attempt to reserve the needed disk blocks by decrementing @@ -192,8 +193,8 @@ xfs_trans_reserve( error = xfs_log_regrant(mp, tp->t_ticket); } else { error = xfs_log_reserve(mp, resp->tr_logres, - resp->tr_logcount, - &tp->t_ticket, permanent); + resp->tr_logcount, &tp->t_ticket, + permanent, nowait); } if (error) From patchwork Fri Aug 25 13:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365813 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A4FC71133 for ; Fri, 25 Aug 2023 14:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 311262800CE; Fri, 25 Aug 2023 10:02:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C002280053; Fri, 25 Aug 2023 10:02:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 188BA2800CE; Fri, 25 Aug 2023 10:02:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 074F0280053 for ; Fri, 25 Aug 2023 10:02:04 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DEBF8806E6 for ; Fri, 25 Aug 2023 14:02:03 +0000 (UTC) X-FDA: 81162790926.15.2B0A446 Received: from out-244.mta1.migadu.com (out-244.mta1.migadu.com [95.215.58.244]) by imf01.hostedemail.com (Postfix) with ESMTP id 1DF1440042 for ; Fri, 25 Aug 2023 14:02:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=khe71NuA; spf=pass (imf01.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972122; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=d4c4JLcaw2hXejiOrGnFBQPVU2RM5hO/J+/aXcCYNEw=; b=geQuLtNvdDk4SVM2vLsVVPYvfh94AxYKfQoZPPTQVFEPPDP71zMu0DVi9Ivi2MFIIdP07Z ggYmRLjnVciBg7OA54nkQEmx4OinmlErrGuPtcVvoL/vXL9qV6sgeDybaYnLd6tKZuRuvh M6pwdIL9KUcH2WG764+d0RcSQe+eyB4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972122; a=rsa-sha256; cv=none; b=Y0oQlv1zRvHh+wLmpfzYhoFAlgEaW63v5DLPC0ASHktdZUUnv6PSLWI/Kr9m/7Lt/uNA0r Oa/XEJn4FU6+WfauqeEqULtmhTgRgX7OCtoaHD/2llvYAgla1wdwSPjhA2BqHjiNPjG7VZ PIkk6IGyTLa6QL5utubHGjkyESoeOVM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=khe71NuA; spf=pass (imf01.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4c4JLcaw2hXejiOrGnFBQPVU2RM5hO/J+/aXcCYNEw=; b=khe71NuAofqjJQcQBQh8qaSLQW5l+ABTZSFJ8Vvkem+VJ7Uz3lPnhsRbG1QiQpVIB0WzKu TWSkBSbRJUjuC3LbOfeO0WhIFxiibQKBlsbXK8GLa0a537NlmAJDnBgPGmvzDTS140+5t+ gKh3+G5l/F0DpREKKRmtO+kz90FC86s= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 15/29] xfs: don't wait for free space in xlog_grant_head_check() in nowait case Date: Fri, 25 Aug 2023 21:54:17 +0800 Message-Id: <20230825135431.1317785-16-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 1DF1440042 X-Rspam-User: X-Stat-Signature: j7zgeqfbggfoaaarg4hieei8wirc14xm X-Rspamd-Server: rspam03 X-HE-Tag: 1692972121-721219 X-HE-Meta: U2FsdGVkX19pYPJr0fL8JmQaLmSzVN7LGdjPg6gUHU54LAe+MHDbRBn52to2GewxfK/KuCHfS9jJsSrdQovc7d8wTW6ZRZ54TDeVqgaCRjpCPXSheKzy+i4aOQHs28QzGsII8KNhOn+Jlajqd3c+qxH7093IzKrrKch1mgZRG4NQGi3eVWQTDjySrg2+EVvSi2NVAYcbtb7VUSTmD7ExcMAkImS+aFtYO7Sk53ShjGh95BuUCTwdjb0B1nz4LxZshUNxeMqfdvEWQx+mygvZ4k2l9lSFif5W33XxL8DWi0H1HXvCnmDWw9dt0uvVPHgjlE9LhSvQHjh8IXV/aZJXsRADyuksVqwOrFMXhrxuZWtGxw5KFrJF+MA2lk9Oe45QFRXVePkRKLkp21/jnXd4tGj8Y7kHxJGKFuOdcr2mxmTyNVzWysE6jX7c8qiCR163nKsxNwfm5vhGn4LrFZtDjVfS5+S+gfoBGDPw9zfV4w8xXA+o3L5YObQuHSB3YnOUn2lxYTvdafgznpBO8p876JZSd5lFM5ej/R2H5cSoa8SrXPl7ahvn0iiu1IH63GxMHookMv/dVyill+eWTwvlDNpBfNeYGrgbaImWvR+hlcMTXXjabzW32uydTF5XYvWUVU+noiGjBnKlUQdhvDvmDyW4Ny9c5hcwaGb0gPuE5uc44xwWhjNOpaBCOPUvuyew0pEn/sgstCf1szvpWojrl4IxfX0xP1Lb0dBWz9QES6ktoYuzMVoULGbRlB5XOY9z9CLGN4G4FQ5Hwooj4HTIWKL/YuWDoAQ/+q6pepgTuzIqHOAi8F+/wZiTQlxZ5mvbRIDNyokN6ukFTCysPXmYqeOa5QWzULpQUbMwxApvuJT6c9MskCWst4wCEIGqtX5qD6O4KMZEUES7Nb2KQVx6yEuR83KXGQlsM/xsigxswd5cVZFSHIrMIV6crDNMFdWy4kK4tBb4nyiz0UyuyAa SCzgs4np DQtwh+M7pvTEGjnj/pkXoEQ0FtEvvzoUTRrkdg0vuZCGw+XZos22HidsokzdrYDYDKwB+KjAFqjmLgwD2+2J9plNTzpXXJDlcThrA0H3eEdQqK3b28rFZghSbRvw9BE9u4qo7ZKkJzd+V6AthsuOST7BsgzaqqsNvE3E/Y0g1R+5GRu6OY6cZRmRUSSv6CL7yQiD2b9Pm1ZlcIFf3YDTHKKBlekS5NJMf59Z8CzqPNI0eyISOwt6pRu6Q+XcVcBaql1IcynUPMxXVZwmYf/8wgij9vVmcCkUuGTmyX2n0I3LXjv0F0gMHCH6DNhVgL/v8QrbD X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Don't sleep and wait for more space for a log ticket in xlog_grant_head_check() when it is in nowait case. Signed-off-by: Hao Xu --- fs/xfs/xfs_log.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 90fbb1c0eca2..a2aabdd42a29 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -341,7 +341,8 @@ xlog_grant_head_check( struct xlog *log, struct xlog_grant_head *head, struct xlog_ticket *tic, - int *need_bytes) + int *need_bytes, + bool nowait) { int free_bytes; int error = 0; @@ -360,13 +361,15 @@ xlog_grant_head_check( spin_lock(&head->lock); if (!xlog_grant_head_wake(log, head, &free_bytes) || free_bytes < *need_bytes) { - error = xlog_grant_head_wait(log, head, tic, - *need_bytes); + error = nowait ? + -EAGAIN : xlog_grant_head_wait(log, head, tic, + *need_bytes); } spin_unlock(&head->lock); } else if (free_bytes < *need_bytes) { spin_lock(&head->lock); - error = xlog_grant_head_wait(log, head, tic, *need_bytes); + error = nowait ? -EAGAIN : xlog_grant_head_wait(log, head, tic, + *need_bytes); spin_unlock(&head->lock); } @@ -428,7 +431,7 @@ xfs_log_regrant( trace_xfs_log_regrant(log, tic); error = xlog_grant_head_check(log, &log->l_write_head, tic, - &need_bytes); + &need_bytes, false); if (error) goto out_error; @@ -487,7 +490,7 @@ xfs_log_reserve( trace_xfs_log_reserve(log, tic); error = xlog_grant_head_check(log, &log->l_reserve_head, tic, - &need_bytes); + &need_bytes, nowait); if (error) goto out_error; From patchwork Fri Aug 25 13:54:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365814 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55C75C71133 for ; Fri, 25 Aug 2023 14:02:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0DB52800CF; Fri, 25 Aug 2023 10:02:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBD57280053; Fri, 25 Aug 2023 10:02:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C670C2800CF; Fri, 25 Aug 2023 10:02:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B2BCE280053 for ; Fri, 25 Aug 2023 10:02:18 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7D353A05CF for ; Fri, 25 Aug 2023 14:02:18 +0000 (UTC) X-FDA: 81162791556.05.4D0DDF4 Received: from out-252.mta1.migadu.com (out-252.mta1.migadu.com [95.215.58.252]) by imf14.hostedemail.com (Postfix) with ESMTP id E578810003B for ; Fri, 25 Aug 2023 14:02:15 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=W3mJ9hHH; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972136; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KWqxpxLv+BWdZ1zPLCWWiPjW3gW3QR8GdaNCgbqB+rA=; b=Plg2fwnCCvt9p7QHe9sUfMZ7bn6yXNbJqqb7zaUTpzR21pCMiZzkASwgv3axWBkaJDVY+o jB47i/g/gfM8XhrXF/+kllrjDg6Eps1J/ujoh8y3U3FRMt2Kfu4h8B0fi3xn/iqqIzmlPP 1lLa+loJ48HtaP/AhClr61NwDcCkF3o= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=W3mJ9hHH; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972136; a=rsa-sha256; cv=none; b=0T8JA51FK2RO6idPWkteq2KVm+pYxXg4eOyCs9QwMhp3jVJidgGJjTt36G1IbrnPGYp5Uu K8JI/IK+RiuDU4WhekJA/7qjDCr8cPr732kUppVh9917z1Xk1yitmSTZ+qszLHS+OWMZs0 WGCeap9s09WpKH6VeZRtygjt6P+zl44= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KWqxpxLv+BWdZ1zPLCWWiPjW3gW3QR8GdaNCgbqB+rA=; b=W3mJ9hHH5VKigloC5U9bTjeZXL1WzXE+if57PbkgslJR/vwxXv7urAz03rnLzn8z8erL5h VCpx6iOsBDC23kpw8k8XGE0qr0cLxvBRgKj1NfrV6YtEtntJMub0qfyQ1aHr3mZsH0O0dL P836PFFsTuNux9i0jwQOVu5ehTDOpZM= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 16/29] xfs: add nowait parameter for xfs_inode_item_init() Date: Fri, 25 Aug 2023 21:54:18 +0800 Message-Id: <20230825135431.1317785-17-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: E578810003B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tiw31hy8w9wqba41fsbtowat4wkn91wf X-HE-Tag: 1692972135-996961 X-HE-Meta: U2FsdGVkX1//CfaId1jRUnnQsbxAtp2QDOjby0dOyfDQYYlYSmHJcRJDs5WcOITZ9vRq3FpN0lOOwAvseLNeeo8acIy1daWVrXzOYF6y+QdvyfjtJCx5XTDoJ1LNJQBFxgwkW1JKL2NjUtIvz6Zuvj8YfeVqLPvhC9tCn8cbPcQIFXBzzoytUhZSW0OknDExECcs3cduLiHsla4pfl5KL7K6fY/+dt4jBrPgyti/wQkRhfJUzhEg3Qv+mTpg2TwmvhWd6F/KIr3C2lHM37APn/XlGe/++R2YdRelki5MPEQln3LX0Ks7Jc5QJFrCYseb+zTdqZRBXwFloBSjHUc3QY2hLgkkncQ+NKoZMbD2tFTXOc0C5uFkcypDaGB0it7r06eazRalHbTS/ylSu98Els+WnibSjuHsUEUnB0TzejKi/DvlyhaH1AyAjDO/TLvNXWinElpcQt98Tw5KWtF21HXHxXZXFEzpnz2RO60NqB5u4gYDOjZnDuF7fSc3rVHTJyF28eljzJOUljS+mQKEhaD+iZrZ34wb8lmAmqZlffeY45CKcbpOftvGRW7BhwmhZRQmSGKnbKFoHd++KFs2kljEAEq+MPaTe19SxQN6nYwJwXZOGhqWTFGywZHKC9y+98gxMuVDK+g6Z7BfyU6xS9rtwc5/AwSsGPjSSuQ18slUIxeIK5DW3x4t7Vg3QOfZQ0as3dUOGepZmclZqhPf2hbcpdTURZrXdvGM/vO3Ga8aLqJEgVdL1zi5i5fsRnR698LaVyUmL51cc8+S5tZ0uVcM/WrNR92rC86LYNQviiK9pfH6WNw36ImDQbM+Rwp5KkYap1nH3Ugf4odv4TyZcD5OcpXuwa4C+2923EL+u8KP6wTKhhEUltV6SE/lSGCfzHlBTvXtuh9ne4sO+5Wrwj9D9fn4GnrKmikktFykZhHqcHBtECteOka5ohnAYj6EE+hX8Gzw9Myb8AQXmzU zlK8s1TU NP0DxLpsNI0iz5g6YVN6fbbaYtgdQHhEOUJ5DQdmjsLzZkWAsqNx43sETFTI2RoWNygYsDqhGpoZ3CzNjGboSKbB/sp2d0wTh3wuAoEFXG0hkb9aR3NuRrbqQW0aDb/3/xPx9NAFZMuVUQVPE3BNFiM66k8GMy5+U6zCK94cAO5TN1BeL4cARYSzV6ItcXK6UAHRXIXRtpPozSuRMEiTkRBmsXh3XwJEsh0olv9JMxgqetAMctGSmxPd/40VU41wncdDb X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add nowait parameter for xfs_inode_item_init() to support nowait semantics. Signed-off-by: Hao Xu --- fs/xfs/libxfs/xfs_trans_inode.c | 3 ++- fs/xfs/xfs_inode_item.c | 12 ++++++++---- fs/xfs/xfs_inode_item.h | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index cb4796b6e693..e7a8f63c8975 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -33,7 +33,8 @@ xfs_trans_ijoin( ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); if (ip->i_itemp == NULL) - xfs_inode_item_init(ip, ip->i_mount); + xfs_inode_item_init(ip, ip->i_mount, + tp->t_flags & XFS_TRANS_NOWAIT); iip = ip->i_itemp; ASSERT(iip->ili_lock_flags == 0); diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 91c847a84e10..1742920bb4ce 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -825,21 +825,25 @@ static const struct xfs_item_ops xfs_inode_item_ops = { /* * Initialize the inode log item for a newly allocated (in-core) inode. */ -void +int xfs_inode_item_init( struct xfs_inode *ip, - struct xfs_mount *mp) + struct xfs_mount *mp, + bool nowait) { struct xfs_inode_log_item *iip; + gfp_t gfp_flags = GFP_KERNEL | (nowait ? 0 : __GFP_NOFAIL); ASSERT(ip->i_itemp == NULL); - iip = ip->i_itemp = kmem_cache_zalloc(xfs_ili_cache, - GFP_KERNEL | __GFP_NOFAIL); + iip = ip->i_itemp = kmem_cache_zalloc(xfs_ili_cache, gfp_flags); + if (!iip) + return -EAGAIN; iip->ili_inode = ip; spin_lock_init(&iip->ili_lock); xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE, &xfs_inode_item_ops); + return 0; } /* diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h index 377e06007804..7ba6f8a6b243 100644 --- a/fs/xfs/xfs_inode_item.h +++ b/fs/xfs/xfs_inode_item.h @@ -42,7 +42,8 @@ static inline int xfs_inode_clean(struct xfs_inode *ip) return !ip->i_itemp || !(ip->i_itemp->ili_fields & XFS_ILOG_ALL); } -extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); +extern int xfs_inode_item_init(struct xfs_inode *ip, struct xfs_mount *mp, + bool nowait); extern void xfs_inode_item_destroy(struct xfs_inode *); extern void xfs_iflush_abort(struct xfs_inode *); extern void xfs_iflush_shutdown_abort(struct xfs_inode *); From patchwork Fri Aug 25 13:54:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365921 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 869FDC79F60 for ; Fri, 25 Aug 2023 14:02:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24CDB2800D1; Fri, 25 Aug 2023 10:02:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FCFB2800D0; Fri, 25 Aug 2023 10:02:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EC602800D1; Fri, 25 Aug 2023 10:02:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F0E9E2800D0 for ; Fri, 25 Aug 2023 10:02:43 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C1DAEB259B for ; Fri, 25 Aug 2023 14:02:43 +0000 (UTC) X-FDA: 81162792606.30.7CD5D16 Received: from out-248.mta1.migadu.com (out-248.mta1.migadu.com [95.215.58.248]) by imf21.hostedemail.com (Postfix) with ESMTP id 05C3E1C002D for ; Fri, 25 Aug 2023 14:02:41 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Eb4iAdgT; spf=pass (imf21.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.248 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972162; a=rsa-sha256; cv=none; b=77yhf2W5ozMIWZ3o3J9Zq0qAfhkJXFWTgrrLBAfiM8D1+L3m9yI92UwvzDeiwQhGTB/AlS 2TSzMiFeKX8SJGtyXLAaAOSgLgUsqeRG6r9BuK/GtfF5MPNFUm4LbPODJ0k/FmbcJ6wuyc ZOp2aNBntYTTAo5YWLdkyyiApdLfJ4M= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Eb4iAdgT; spf=pass (imf21.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.248 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972162; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3IHqyAGVDJ58osMbe/1AdWvJDmRup4/lFC37whRevKc=; b=aJB9O/WdQLzrUkNP49k8YxeBtLNxJ1ENtkcz9eW4JsKdhHLiEoAUAY92KqOzFrAFC9y7bP DNn8M7yktfEAQtiN/+B7/iHAdw4r1zU8qQisnmAQjUbGKipC1Er2X9Bxa8GdNVmJaCoPhc 4b4dHD8zPz9weQOouyFJnjboMVpR8j0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972160; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3IHqyAGVDJ58osMbe/1AdWvJDmRup4/lFC37whRevKc=; b=Eb4iAdgTR0TpdbPqUzDwHbHxPEh5V68LsiBX5YVrmluxRTdzMTEqMqKrZvLhm9MDpgg3K/ D2eTyYZZZ+bfvHLihjIIZJ2OKJ2cQ07lnUU3TLxQlV7ixmfK6NG3WLuhhK+cGvea8pFBoo CGGtOLVSVaB7g8RjjJfuG0O31ub2h9Y= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 17/29] xfs: make xfs_trans_ijoin() error out -EAGAIN Date: Fri, 25 Aug 2023 21:54:19 +0800 Message-Id: <20230825135431.1317785-18-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 05C3E1C002D X-Stat-Signature: 3kn3hy8nzg3z5k6bd1ucmib6g8obefsn X-Rspam-User: X-HE-Tag: 1692972161-179699 X-HE-Meta: U2FsdGVkX18m5iAR39uuMb0yHoOrCw+ukxELbu/r0epjP9euzJVn59ODvbA0JUBRj4SYYPdWDl/gf8VRHMmquqP+KOCzJ3poWxU9HWFtK0Eb1NYl/zqpxLdoRoZ6qyxH56IMiX6OCNyj/NdaBc3t/ewEBTHsZaTMEHNn+DVDikMn+q+c6if4DSBXUTVCaCZqnjed9X104It6xvbVa0RPrnn5k73/AC7a1aTV957TMYXhb4dqsLtBuGCTwrkuT7wTK2aHUhUQOrzFjbdt4jLG7nLBBtiIWYyKlcl0XnYIOPDFwWBWmfadqlgD5jzhyYIb+J4v9IPftpFvuoc8qz4+vT2s6LLlU8DTSZsbA6M71f0QpfGtNIQmPyh7H54yBl3IUDCVhlRHh8qMZvxOnJG4mjUVN6n5o2CNyr6Pijf38eEq8qY3vV5OcOcmWJ9m5IpEa1tBZa+yQVMxWrHc+11Ed9taglHKlwIPFTs0oREOSj0Vya1x8NhZse0OTjBqaIMoCWKxbKmqPIbBpwDRDLQg3QHlyzBxIVWSo1wfq9ibez8uL+qRJJqYc4iL88NH5jR9PrUrQpH3ijU1aTKbFOO6Fc+UZPoS/Lt10awACXjzdV2pOtC5svQ92la0aoDSayKeht/bMe0phY1iDS8sA5kyyNZRE8/6GKvn0iphPs4QyAivH17k7+UQ6gPI3jsGFA+3jGentcKiV3/UZkGuf98AA+Zc8cTIg9zkJxmvDMM1+M+yF5nV3OWdB3d7qTrBlr+piPMIrjkkNxsnsNzVH3RARbLlMJFyJkdEv6B3lMpFdNlIJvk+FT9bS6FWhB33AbX7t6RUNgGNkFAzLjvHtcBKTe4QxZzLn1OEydVhlnVglvtmXNWjhSZxqot2xSK7UYGwpfMETC8L1g3qwA7zRX64OtLn0IsiGiUtg/lK/+RzZTUyC+Q4CffDxxHpx9gNNGOUdS3Sivx6LCMUDCynF98 Uz1KXyMY M9GSde/sbzMtuVU3x0Om4eZ3vTw1JCBHeaNIsbUEQCMa8BN9S/LxdaNBPGGbol+PNJOcN9oKPZLak7bKKaTX2ivMjOc5wOZUt0cTLv3S7jHDTJ4UsXfBIR/4CfJ8T2lAA5yJ1gfToEXm+d2LhhBxmEDT5GClqk2Aas4eNsYTddD1ke+8KpQkporWJ5TiyXiOb6C0TPsdZPQks2mMgmpf1mNmXu1p0WsmZImF2YuqdpAxVmkQFXedip7sBbBi8BXH2qXUr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Change return value of xfs_trans_ijoin() to error out -EAGAIN. Signed-off-by: Hao Xu --- fs/xfs/libxfs/xfs_trans_inode.c | 13 +++++++++---- fs/xfs/xfs_iops.c | 4 +++- fs/xfs/xfs_trans.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index e7a8f63c8975..7bda62bad90a 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -23,7 +23,7 @@ * The inode must be locked, and it cannot be associated with any transaction. * If lock_flags is non-zero the inode will be unlocked on transaction commit. */ -void +int xfs_trans_ijoin( struct xfs_trans *tp, struct xfs_inode *ip, @@ -32,9 +32,12 @@ xfs_trans_ijoin( struct xfs_inode_log_item *iip; ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - if (ip->i_itemp == NULL) - xfs_inode_item_init(ip, ip->i_mount, - tp->t_flags & XFS_TRANS_NOWAIT); + if (ip->i_itemp == NULL) { + int ret = xfs_inode_item_init(ip, ip->i_mount, + tp->t_flags & XFS_TRANS_NOWAIT); + if (ret == -EAGAIN) + return ret; + } iip = ip->i_itemp; ASSERT(iip->ili_lock_flags == 0); @@ -44,6 +47,8 @@ xfs_trans_ijoin( /* Reset the per-tx dirty context and add the item to the tx. */ iip->ili_dirty_flags = 0; xfs_trans_add_item(tp, &iip->ili_item); + + return 0; } /* diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 47b4fd5f8f5c..034a8fea1f8e 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1075,7 +1075,9 @@ xfs_vn_update_time( if (flags & S_ATIME) inode->i_atime = *now; - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + error = xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + if (error) + goto out; xfs_trans_log_inode(tp, ip, log_flags); error = xfs_trans_commit(tp); diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 6e3646d524ce..f2c05884c4b6 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -226,7 +226,7 @@ bool xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint); void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *); void xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); -void xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); +int xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *, uint); void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint, uint); void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); From patchwork Fri Aug 25 13:54:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365922 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 293B6C71133 for ; Fri, 25 Aug 2023 14:03:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFFA92800D2; Fri, 25 Aug 2023 10:03:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAFF42800D0; Fri, 25 Aug 2023 10:03:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99F602800D2; Fri, 25 Aug 2023 10:03:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 876082800D0 for ; Fri, 25 Aug 2023 10:03:09 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5DB48B26B3 for ; Fri, 25 Aug 2023 14:03:09 +0000 (UTC) X-FDA: 81162793698.30.A01EFDD Received: from out-244.mta1.migadu.com (out-244.mta1.migadu.com [95.215.58.244]) by imf03.hostedemail.com (Postfix) with ESMTP id D840820005 for ; Fri, 25 Aug 2023 14:03:06 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="F3s/OJUc"; spf=pass (imf03.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972187; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qTb/druvnHmAZS3W1u50TERu+WCPGmDec9gQaqemBTg=; b=0+jfkGl2N9Evvn/jz5SDGxNkPr0lfcKCXlUutnBkcyGXtTlZItY8v4v25OzGDNJTouurGs iUwfAOO1n+zxEZEQ2ldtlMw503OdYM6pFsq0cwg+19UX7aBP6hVh91TEsSzaw8Y9raNsb3 mQYmHcQ0cJWBSda6JZZ0Qg18OayZ0hY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="F3s/OJUc"; spf=pass (imf03.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972187; a=rsa-sha256; cv=none; b=pcieO6VddlwwZIKbFoVrQ0zTs0SMUnN1pTsZgkuC79k1B1KMzV1qaryFv1QJp7dvflcytB X10h4fljhL1OGpF0+MJG6i0Ecer2tMFOhJUctbkgJJ5FzXNiMUjMBh/F2i/X6JQoEycE9m MS5pSmcpQYp9zwHsz8QuYYkUIwBlnLs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qTb/druvnHmAZS3W1u50TERu+WCPGmDec9gQaqemBTg=; b=F3s/OJUcPEY5Zlidje3R3yeS51LSjhWu/qJIZQ5RlOJtYZFuPHsEDcjE4qLEmmAUjn6Noq 1FuuA0oBiaR8ILzLTnrrBydu7XR0r/KR3HJXB7nZmLWLG0jXn8HNnNNNLFYiSbQJ1kLBWH sWlvtA/UHWBfhR+BdKG+F5ETxQfMgq0= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 18/29] xfs: set XBF_NOWAIT for xfs_buf_read_map if necessary Date: Fri, 25 Aug 2023 21:54:20 +0800 Message-Id: <20230825135431.1317785-19-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: D840820005 X-Rspam-User: X-Stat-Signature: iqutfu3q5tpt1a8f6dj37td333c66fkb X-Rspamd-Server: rspam01 X-HE-Tag: 1692972186-900081 X-HE-Meta: U2FsdGVkX19m34ttG0qAJxGzSRuE4jQAOZ+94p1iK5Xzk/L0GD51dnOTDV/qi3WZewHU62e6aHOzun4CMxj5PAfzRjAvqYTtUuBYbDloVYPH281T6CgeX5Cb51JNtVajBiLx2xTnc9gOoBk+9PyVRPPEisMDMUyImWqqMSvpCruN5FDvJveBbIscY9pdYBSbImFyvJIlqREDuacPv/vliPnGCEjHTF3YJ7gik+A/TUAfQcZA0rYupwUeeTEFhNqVa84tK8URoz1F5qPWpr9SxK2VdYT/Y9k42wGjc5xu9DqMxqYuTyrS+V/OtPF+C9T8OPXCxEHcVmgFeDFYTYb69yjPuviOMOWDTJ0N7KE7uQx9P1tYolVwXbD/6iVKZsOQcaieUJTE1+jps0AVVYc9f/w+UH9deKvGWSCjxTBz7mvS3IQ8jJey1SSQqwwbbJqwuIkRPimthyFWmrBZuoI5ZFqq5baEOqRvCs50vY1sshImHxystfkPPA9uVVL3iDFTEzQoU8cgm0MG0r4BtAb5b3dVJhUYXc17CyugI4B+VjdJgl0Uox8TtrzEpMSeoo6j/WSYhdnIJ2izr0ZgXtCu9ajRBxBifiTXs7+XeX1OBUmk2K9mgInqfXsjfJk3p1IPS/zPlUpuBBDO8Zibh8iQtrwi8eRPk2lwgeymTXUCl7o2hmKJk6klz6o0hXFM2y0Tt/YHoKkCgPf8miwVM3n3esHrBY1t3PYryw+OeURJvCjBA1gQqYour1/vZZv9mTjxYFRMvJSxpRKVo+R2YjYRvRyoSnev8bHmjuIfrAe5bIYcQL01ZeF0AXV1L3ttpateWfeWPdzQ0VScXeiffWqWtu3I26SjeR/lHe4xhzwwAQEIJGAGc1nml3Dn+ZOm2aU0ygLOM8qgmMeTPN3Epd2r42ACQWpZrgh+D61zeSnmFLEXaoGvtD575yOVsFemdR2ImECq4uB7KIaaQWTAXB/ f9vd6mVz 7yUV7dU3BqZl90ZLebyDU6YhRK1GXILYtKXME4dUBtu3rKFSkYmOBqTZ1Ypw+UaurgENmsg2uUR/CVGxrHTXazaqcHVJ+ufXrerAuPsfzxNCeHvtt7uMFRe81H+QzKump53R9/DnflT9EomNTtz41Fjmx0IzYxnsWRIZa5vQZ4S7X37WF6RVYjcQ2TbxgisWagJjRQvj/Nchx2ORwXi/h6Yi4dzLxvecGivvvw618a1u89AwQfUSkbNFtPxeAZvq3s50d X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Set XBF_NOWAIT for xfs_buf_read_map() if necessary. Signed-off-by: Hao Xu --- fs/xfs/xfs_trans_buf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 6549e50d852c..016371f58f26 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c @@ -286,6 +286,8 @@ xfs_trans_read_buf_map( return 0; } + if (tp && (tp->t_flags & XFS_TRANS_NOWAIT)) + flags |= XBF_NOWAIT; error = xfs_buf_read_map(target, map, nmaps, flags, &bp, ops, __return_address); switch (error) { From patchwork Fri Aug 25 13:54:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365923 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54B99C3DA6F for ; Fri, 25 Aug 2023 14:03:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE7692800D4; Fri, 25 Aug 2023 10:03:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D96162800D0; Fri, 25 Aug 2023 10:03:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5E402800D4; Fri, 25 Aug 2023 10:03:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B66432800D0 for ; Fri, 25 Aug 2023 10:03:22 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 956391406A6 for ; Fri, 25 Aug 2023 14:03:22 +0000 (UTC) X-FDA: 81162794244.02.B97C6E8 Received: from out-244.mta1.migadu.com (out-244.mta1.migadu.com [95.215.58.244]) by imf11.hostedemail.com (Postfix) with ESMTP id 95DE740011 for ; Fri, 25 Aug 2023 14:03:20 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=j1kjownA; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972200; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oO47LbY0b5fVyG7D8YYQFkwRO57XM5uT3mfj/DxMSkA=; b=EDKU+ZxA9Up2VAuuyrSnG3efMPgoagKAZCY7k9HfybYRJA5GQv3Obq2dfL4KwHF19x0kqq AfUAgZHvVeoaMMxTpscH+7L7E1NgBQe+ZFNca1DBHJ+CZjHmbuvwpDpY7If/Og5XAJfoIz EtrhhqSJtwnzjSAslZreZP0RH/bKcgs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=j1kjownA; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.244 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972200; a=rsa-sha256; cv=none; b=sujbrjst98GcK7wLIgQyoYvabqnDAHtVX1cJgaXUkgpqmWLERVmpemfKOKgXOwph84RoAy rDRXie87A66VmyHNY5nq9qs4NwjVJr7B6cw8brpSUefJ5ChxZormuABHdQu7HlGnsZ8noE MUxOsRCVwEf+ow4paG4pfyBsOr2+0+Q= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oO47LbY0b5fVyG7D8YYQFkwRO57XM5uT3mfj/DxMSkA=; b=j1kjownAAX9hJfB2BxApQkooYMrevfaPLxvPystRVIJaNfbMrYunmfkjCazr0ChWhlvVjY lRX7+a9ciN0hwgjNK4X5Fb69aObVTB6DVFK6AZND7C0g5qPAW+vA7D+a0HhCiOEWDX9QRj DdPtV8aYlp/xMHVmKP0gIoyMuJWp9/M= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 19/29] xfs: support nowait memory allocation in _xfs_buf_alloc() Date: Fri, 25 Aug 2023 21:54:21 +0800 Message-Id: <20230825135431.1317785-20-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: k5iiuzh18a6d93bp41ceahbotag3m4i6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 95DE740011 X-HE-Tag: 1692972200-490621 X-HE-Meta: U2FsdGVkX19JNVSRAAaV1lpLEVBwBM+u+hC5yGjEtdgFPEqJ6TL3uiG0qCU7Vd7z5MpYfyVti7bDyRT9G5+9IZGwDekvIjxm+zYyzY43rLmYguchlnep9/9AUiRbmxSuarXFZGsUuRslUYqZjcyt+/0d908AAxvlFeI6zKL6JCJoSfDH46zt2h4G9GzHDcoOMVGc2X6L4iMn+6Kxrp7/X6JGEWLQfNLMBkcwb+pnso3/P9yT5xQvABcAw6V+fEUZnKP6QkT8fMmOx0F3uhxDPI/egy9muQDhZsyDenHw33dJ4aQXxjqTOLZ9+xcsvB+gl45oP7wNTgN6noQchx/qI5lzj+xtyH8HqthPqmLKZGOD0nwJwKn4cUrua6772Ki3VmC2+ojys9PEf9RD660WHIShMlq6lvVlywhKlU9MsegiDdrSY4jfTOI9J3P80ybcEbQ8nHZ9wodYsVnlAxKZMigZCev43XcHrWJht3Kbn4oWrf9uPO6WxU3Ul/kCsBZ0JQQy3bfkdpFQGq+dJT/RVh+chkU6erDXdTNojZHXPSoI0udipAqPOqmYesDf8zcLMCKs8FFvpnKUsBsuoLw7MtxEjPIo5dLLshSrYGfEp60BDlUMXzJEIt2yyc8gK8ziYCzCaDifyyX3Aa6MlFCpkhBYQfiVPdelSacEJ9OaRoXo4ZiPbPhHUldpaOAhCuZ9yZrTHaXiehbcbpMDZka1vFTV8aNf8Y2H/nYjzmncTZVJrKFl2RTm2POa4yVhn9wtLB8xxAH2jYHxFsrsOdYfm19hq4Fukm+CuKgemDXLn/rMlc8mzVkPw5h0M8I/HVWmgs+4FRjl5Sp3yJ5ezdMSi25sMRaUyixvWTGQq8ihEaY4MKzZJxls77jTFeFzJWu3yJ0E45ryxqI9U1dansMG2TmG/oV+D/nZ6vlCiAHoHFjpNy4Z+8576V6CpcRpe/bKuBPJ284lq21HERvyzlG HqD1EfbU Hixvr4mB+L1tIPxbFMst5ZZxz7JlQ3iPpXVnHnT2VTIyfmBtlg7SYvLcAJIry4AcgExaC5btX7SdpEQU3I9FzAo9w4ePNyi1/SimI5u7QkyR4y9zOoao1Diy8fHwsgqS2cYYkQh4ScSZzELlQWqTlB2A/6JAcaSvsa+KvJHRlW2mB5RBf5ZY6kXstGR1c1LWG/5L+EeVGhBnPpBMDonX9RAC2tsBJe4rmKh/BrjCVgj53cIThfIsj3QMz41cJaTmXDLkx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Choose different gfp flags to support nowait memory allocation in _xfs_buf_alloc(). Signed-off-by: Hao Xu --- fs/xfs/xfs_buf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 9f84bc3b802c..8b800ce28996 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -220,9 +220,14 @@ _xfs_buf_alloc( struct xfs_buf *bp; int error; int i; + bool nowait = flags & XBF_NOWAIT; + gfp_t gfp_flags = GFP_NOFS | + (nowait ? 0 : __GFP_NOFAIL); *bpp = NULL; - bp = kmem_cache_zalloc(xfs_buf_cache, GFP_NOFS | __GFP_NOFAIL); + bp = kmem_cache_zalloc(xfs_buf_cache, gfp_flags); + if (!bp) + return -EAGAIN; /* * We don't want certain flags to appear in b_flags unless they are From patchwork Fri Aug 25 13:54:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365924 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 665E8C7EE2C for ; Fri, 25 Aug 2023 14:03:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 003692800D5; Fri, 25 Aug 2023 10:03:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF5F12800D0; Fri, 25 Aug 2023 10:03:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBE002800D5; Fri, 25 Aug 2023 10:03:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CC89B2800D0 for ; Fri, 25 Aug 2023 10:03:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 98737B26B8 for ; Fri, 25 Aug 2023 14:03:37 +0000 (UTC) X-FDA: 81162794874.14.8FDDFEE Received: from out-246.mta1.migadu.com (out-246.mta1.migadu.com [95.215.58.246]) by imf17.hostedemail.com (Postfix) with ESMTP id 7EB2340018 for ; Fri, 25 Aug 2023 14:03:35 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ES2TiCn9; spf=pass (imf17.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.246 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972215; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T6ViUZBPx7ad0ZahN3iXc6h6e/WwSaru8OskP5bAugQ=; b=5oPTzUg580bcdkOoL9lBWUIpASQAxaNsgFG7GKSjpm90XSKZJ0vjyjEbt5uixHcoN0nvXI yGwC9i61z9y5FQrUiDUjEtIeRKmzR88ZW3QBTQgfwmIrB/9td+MxYjIfJ28ooD2zjA9iG1 qK32iqS6PceLWShUE0XsmM80Xf9xw6Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972215; a=rsa-sha256; cv=none; b=s6n5rA2e23MPZ7kGrMrDf6bI9hscI4lJ21qftJxmoyh/GZCeSern3W2+mZsgNfhK1rhpZW 9oahAVa7LK7n7+MZvC3f/lWwj+b+9026YnG7k7+oPu4/cGv2gdhjtN/LfQiP3rEa3pK4KD bUxHp36tbZWit7c3NyU0HSMThl15cqg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ES2TiCn9; spf=pass (imf17.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.246 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T6ViUZBPx7ad0ZahN3iXc6h6e/WwSaru8OskP5bAugQ=; b=ES2TiCn948OXPBoEBgWTcBO0RS4z23ivDrdXlTdAtaw6PThdxWDWOdUDMqwN5Zn7WD+dyR mB9Bpqj2y+SXbSPXBOj6qNtlf9PRruM/6AA9li5Lcnl6yPomOz6TlD4q7SN/nyqOvAgxMU ufKXd8FiPwyCFvbnzPL8RetLQf6iEEM= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 20/29] xfs: distinguish error type of memory allocation failure for nowait case Date: Fri, 25 Aug 2023 21:54:22 +0800 Message-Id: <20230825135431.1317785-21-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 4xb3u96to3cqwo7fpkjk4gu9ied6nr1e X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7EB2340018 X-Rspam-User: X-HE-Tag: 1692972215-801269 X-HE-Meta: U2FsdGVkX1/U/jFMfPzeYGsXHYE+0re3L+FYNevdzT1gdGco4MQI5DpY3+VDIRXfBSchO93QlJgeyaFcbqVWcxJQ1h5hZvEp+5ZMNMPHMBMYxt4Lh3v2tDjhZvzM6cBWIlEDw+zDliqKIhLTgBehfEeVojrIb/2R8EA52Vf4j2XMfJfQNOi9KCKQSll63O9eZhpfVgspO0PdygwoUpbKkcLjaqPk7EFzvoLQCVLbLGDoNvPNmCJkqphU0JAfkik+9fAOfWHf5fPfC82t94cR0tSPzbfixVOL/k+DJUQf+ADjVoc1S7ebewAoHkBS2W0eiMajR5qmAIUKmJp8LctBZgAE/Tl8/PGPQ8AzhuU1TJq+kOo5bSE6prbGbaq8nRsAh8snqwZXJG8F0k5B5jPr3bnIsm21ZhqFdKWyV+i6fTb+xt+bshazBPFsJ+oPuLuD3VQA5v1D2lx00uIxqiS5Z50FZaC7ZLQ/zFU5eg2POzWOFs3rcHU+0sKOGfVUgwuRbRHsv4L85xjyzNbZqmL7J3jHdLU9E2EFkTMiTLcgyP0wXk5qCmiI8uv4UDwcSwz6CcHzEGusqmH35mQ9fSZzeaMtgHXIHO4YAX0e0Ne6J4Uf7FNcCfVDUjvQ16DPHN3KtCq8aM8GScpeIspsbkYmKPAo+ZsMmPXDKAbM3KRrr7YDmP6rfp5bg43JsIsFlvrQwYBJ27fvYynzwwdeE+/7h3Ot4tiyXTcuueY6QUjRDSbTIASDBfAeklvtT8xhR6UhCv8lnnlp4glzzCX+d0AdATPdV8eqh9oMdy4MRTXQj4HVLkB1uNwx8YiK75lq3f45Gy+Op1brfvO9+No+Pm/eyu7McKQfxMb9MuY29M4GsrWlNs14hskRF/yhx1L65kLBCQUKjjuB5ltVf598I1xnf1uvGC9C3i6ryAFq5S2MpjUddFTiSNvsmVrSNiPLzmFKsDD2jIE8jEdKn4x4bg4 rJace8Az CyGnyTtBoAU+NSA46V5DlogBirkdKdl8WNiHUbgjufv6Vy4Jp1ob5lq/q3A46SZGbYxoKXnOajCEoZaD0mdU/lyGk45D6md/rlm0Z6MrLiShiQnVPZHyVrTf4a3IHbk70pUdaZ2eBl0iWkdM+3kE2QQL562rfFHRTgvz+Gis41lANNx/TirBIOeivtvnkRowOysFlxObxnQtOP2U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Previously, if we fail to get the memory we need, -ENOMEM is returned. It can be -EAGAIN now since we support nowait now. Return the latter when it is the case. Involved functions are: _xfs_buf_map_pages(), xfs_buf_get_maps(), xfs_buf_alloc_kmem() and xfs_buf_alloc_pages(). Signed-off-by: Hao Xu --- fs/xfs/xfs_buf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 8b800ce28996..a6e6e64ff940 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -192,7 +192,7 @@ xfs_buf_get_maps( bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map), KM_NOFS); if (!bp->b_maps) - return -ENOMEM; + return bp->b_flags & XBF_NOWAIT ? -EAGAIN : -ENOMEM; return 0; } @@ -339,7 +339,7 @@ xfs_buf_alloc_kmem( bp->b_addr = kmem_alloc(size, kmflag_mask); if (!bp->b_addr) - return -ENOMEM; + return flags & XBF_NOWAIT ? -EAGAIN : -ENOMEM; if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) != ((unsigned long)bp->b_addr & PAGE_MASK)) { @@ -363,6 +363,7 @@ xfs_buf_alloc_pages( { gfp_t gfp_mask = __GFP_NOWARN; long filled = 0; + bool nowait = flags & XBF_NOWAIT; if (flags & XBF_READ_AHEAD) gfp_mask |= __GFP_NORETRY; @@ -377,7 +378,7 @@ xfs_buf_alloc_pages( bp->b_pages = kzalloc(sizeof(struct page *) * bp->b_page_count, gfp_mask); if (!bp->b_pages) - return -ENOMEM; + return nowait ? -EAGAIN : -ENOMEM; } bp->b_flags |= _XBF_PAGES; @@ -451,7 +452,7 @@ _xfs_buf_map_pages( memalloc_nofs_restore(nofs_flag); if (!bp->b_addr) - return -ENOMEM; + return flags & XBF_NOWAIT ? -EAGAIN : -ENOMEM; } return 0; From patchwork Fri Aug 25 13:54:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365925 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 987AFC3DA6F for ; Fri, 25 Aug 2023 14:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35FB12800D6; Fri, 25 Aug 2023 10:03:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 336312800D0; Fri, 25 Aug 2023 10:03:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FEE02800D6; Fri, 25 Aug 2023 10:03:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 11BCC2800D0 for ; Fri, 25 Aug 2023 10:03:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DCAD81406A3 for ; Fri, 25 Aug 2023 14:03:52 +0000 (UTC) X-FDA: 81162795504.22.399B94B Received: from out-249.mta1.migadu.com (out-249.mta1.migadu.com [95.215.58.249]) by imf13.hostedemail.com (Postfix) with ESMTP id CEC1E20018 for ; Fri, 25 Aug 2023 14:03:50 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XN4VKQ0v; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf13.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972231; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=k/4ZXSLCSyhuRHiUlNViF+vdvrXezEQu+Nm95mQGfD4=; b=WrNB0r9DJobxlMrO6PpgNKBrFxjR2us+qS/tvS20sz6Q/TSfCy2fLcbwXxVg8RxQgdAmtb mhMFkJ50s7KUq1v1sm+M0kBI+IpjMxdknKs8f7Y056ma30W/L/hvUALecMlm6wdEltVhQN F2mC/vVGNgttzYaooD68hg4kE1vgWoI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XN4VKQ0v; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf13.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.249 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972231; a=rsa-sha256; cv=none; b=equiaJAeUzN87+8WqvymhbOWS3pUP27qnUu6/VMhU1fei0PDnz4l6zcQCOPCUOhNasvZMU yNTTdLxSdO1nzN0fiKXjwDTw+1mozKKwKBnZuAygfXyQar76uQ1PkwgaYb+s7YFiUclijt K6t5/goDsurG3xGT+jMbwFhpNTVjv44= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k/4ZXSLCSyhuRHiUlNViF+vdvrXezEQu+Nm95mQGfD4=; b=XN4VKQ0vJWdKOqygAoO6O9s0mfT9sbRl6WKC6PlM4YizrHDbuoZWPHymJ4boioTyhTPsXz mzB7w7XoqaVp3khAiC/KVcJAYhLbwQjG/YZ+xeSDe8Sd8K9S+AePqNUb6KBAAuKlTSuaCl kFQBsj5S1c42QHrr1w1CZcr0QQo5mJc= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 21/29] xfs: return -EAGAIN when bulk memory allocation fails in nowait case Date: Fri, 25 Aug 2023 21:54:23 +0800 Message-Id: <20230825135431.1317785-22-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CEC1E20018 X-Stat-Signature: yenyn1dcbk7xbjb35k64uqfp7e5fjxa3 X-Rspam-User: X-HE-Tag: 1692972230-685593 X-HE-Meta: U2FsdGVkX19rY8bq7XLMEb56It7ZAlLJaWxm672CZ8KiRm/5F3N84Uvy7hL9ds6kXPsHrQ16DunADnCa0eZMjfcQuEQOs8tP4v/gNSf7Hi95D80blbWGdjHJb1Dq8eYgDlGFArPTQc3naOyzHqb9dOuug3XGiLhxkNfhMZZ7o0ugSHeEtcQSUfwJw9ALymE2cVaQdw5N3eXggVuIJroPPCRToMTJ66o6XcKbYrDQynve6OhqGt4LYa1pc50/pso9nPm49IV+76eK3VSQBVePzjqV+ez9lANqq9m/RucfokB5wVCbIAnphkOq7VJjvrYwRNaJCO4ORAlyuAp0FSPKRi/eRFztk/YMZQA2AHQf4cvbUl/ggcsERQZc0mz5pxmOvZNTKyX7RStdpRyLOeTl6X3OcM/UGxrCbemUB+Cpesr6TFIQ0I8pr38kd0kFLv738t5SV6NyXBJKptAFkWdZCMTqDM/DBMT9oXPotqac4gUy0J8YI8eU4QbOm8B3gR+HjmP8s9DTiuaszHaCq1Z+4zYSWrlf7l356nTJoxVDvxpSy17MDc4vMkMr4TMvLrJtr3O34Zc+twY8IDQ6B6Lx6F8QUiAwWe5n2uqRqY+3gb2KS5dD5/iD2UGKePM2L5moXbOQv8t4M90Fc6jajlWhPL8fT3Ykf5isYQHH4Hhr0oEWODYtH8yzJ4bZ7Mq3l9eKmWY21L+7MW8Noxv0FTDqbEp355ilkcjbv/Ylee9EgjynOBprRfFf01oTHAKlk2VF4BsZWn0KZitXZ7WT5zrnUiX/jzpkS05zsBK3jy7Aqjy58ZLxLF3AoL0MMYRQimGHFcFYl6kQFa2ADFh6lBO4DBrW/nvGjN7j1TB0VOqMfBq7Co7+8G/ujMcbFuUapL/5Q7ts1PNTEeldOHRXyz+mbLdSWuSE7YYnpZSMoc8/y+2enRSz/T8wGRczGn0OQ66HliExLXt5M1y0xiyR83Z fMakMd0h vWuuxh2qaG7a09664GZUfAjWCN1swtOTxzAq4kpF5WgXhxQHTpQCIUk4uVeqdGWj4lPnnv3Wqm7AHvqK3l9gPVO9YNPidziZbAfMzsrbvx0wubvViib9iuupqV+BUHV/3EJ6k07nB6JbbnyxgoBPPOLUw49GE4xGaSdg+LUDiYEE9E7D8FA7OABqdDIRzHcMj4Uzt X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Rather than wait for a moment and retry, we return -EAGAIN when we fail to allocate bulk memory in xfs_buf_alloc_pages() in nowait case. Signed-off-by: Hao Xu --- fs/xfs/xfs_buf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index a6e6e64ff940..eb3cd7702545 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -404,6 +404,11 @@ xfs_buf_alloc_pages( if (filled != last) continue; + if (nowait) { + xfs_buf_free_pages(bp); + return -EAGAIN; + } + if (flags & XBF_READ_AHEAD) { xfs_buf_free_pages(bp); return -ENOMEM; From patchwork Fri Aug 25 13:54:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365926 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15B06C71133 for ; Fri, 25 Aug 2023 14:04:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8B012800D7; Fri, 25 Aug 2023 10:04:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3B542800D0; Fri, 25 Aug 2023 10:04:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92ABD2800D7; Fri, 25 Aug 2023 10:04:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8399E2800D0 for ; Fri, 25 Aug 2023 10:04:12 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5AA061206BA for ; Fri, 25 Aug 2023 14:04:12 +0000 (UTC) X-FDA: 81162796344.27.4B5D737 Received: from out-245.mta1.migadu.com (out-245.mta1.migadu.com [95.215.58.245]) by imf23.hostedemail.com (Postfix) with ESMTP id 81725140032 for ; Fri, 25 Aug 2023 14:04:10 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=rqq9t63T; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.245 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972250; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZAHRQkTlH3B9Ayy3ByDVW6IFO8x4JKviNIiMKvNnRxw=; b=4EVTJgrWtdD3Ezn6wpxDHhUcRh2a/0aDgKBUlJ8yfPXeWuclmEHLfzoF/sX5/GL4nGdxI4 55wSgZCQzOEoGXW8CfeKuMxMu4eQa1ONCUC4UI0CiWCxEnYpMX++ozKMHF3qqymrbc2//L t6RC1U5cPF3KrO3p5QgLwB/RBG2W6fE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=rqq9t63T; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.245 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972250; a=rsa-sha256; cv=none; b=STc6nl30EMX4fr7J6VdmkX6kCwavD0epICdzwp2RlMqvckVMWYBN6ppvVubNN0/tcdwRLk nsCEFnEIMQntSTgLSWhXf7RwooXcNOorcZkAdxBXG38SQq4bgK9zlCbUVg4SUf/hrJRKbG /4QmntL49jKhTlRwrz1Z2WTLDLJxoW4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZAHRQkTlH3B9Ayy3ByDVW6IFO8x4JKviNIiMKvNnRxw=; b=rqq9t63T1b93nHdvHPb4iPnifbVgNhCPhaGA0/+lVUtdq72oLevGN3oePkSOWgj4tFeMJO 883BuPqR+igY5LuYYZDHjdap5mSmKgc54EL0giqHkQRTPmks0t1/1oKfHQU1t1pMyd2ThX 7baCMPgFPzeqpA42kG/A+w1RFMlPw/c= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 22/29] xfs: comment page allocation for nowait case in xfs_buf_find_insert() Date: Fri, 25 Aug 2023 21:54:24 +0800 Message-Id: <20230825135431.1317785-23-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 81725140032 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: xhx93isuusdtnuoiqmwu1z9pkxp85q5z X-HE-Tag: 1692972250-740529 X-HE-Meta: U2FsdGVkX19aix9Ko4hi2Ri28saZaDKJIdkxV+3F7EP8q9xpGIicAdv09K/rPuu7IDJc0RIGcj96JxCkmvjGr+G+KWIDvPenwhV7q2ygM1sJTMYjsxRHjMU/5yTUlzGggYJctD8f+18tglN2gnHLG+Of+eNhKDLKdtXXIWhEGhkLk/3yJdAcRLzWlohBWCT/gTzgOaxc4Cwf5kAXRu/0EfB0yUpn5NUFuC3NWv2Fr9JcJzVdLVim/X9iZEsj3TSBYcH7eQjoLVQK0U2CUt+vNXPa1gRUKnMyEc6/i05liwWcUxD/49OA+c9Rxudm0pzu7e/9l866CJJ6HhFL16bDnoagEWJOKxgaWMfysSZ7M4DixEjlywl1aKT0RV7Y2nzWiT+PFEGFJZOCbVSDz2qRelpHwMR/RllxzIT+q9wZvDfY2CQfecMJ02fWl3ywcPI1O/cddcW9y1BOhJWbm33HrxHoVfD10zDeJ+kMkOWCaOK531MQd92lXrLCEK7EnZi2T+YUlA8T9Dl3fJ575G4HVwNlWHMQBoJf2MU8LopDH9aenVcP2GIdhzMoDuydHFT6MiiI3e+QUWxiP1k2togRACZbvLgh0YBRKh4oTMD8JTW/nJt/J5K9dm9yMMcSAD33LQgGXJPjnEqyjsC3cJk54Nb5Mx1olP/hxkPCd/889xCtE3tEySk8xz6rfD0udflQUHeLMt4r2YVVuSowkhvkJqrNJO/v1gw3w33K1OvEStl7AoX+YWhN3cHfaKBVfQJNxC7NMX5WTfsrMGHNQ/hz2RK6Z/HTsDqmcbkD8vTqY+NiSm/9qojjBfXgsMrkeU2aDPFkgeGYUUzV5UPcIF09CQpFvXkCbjSQXj3FM7BF7pUiEGTxQs6nETnGsT8j3Lnyh0ZEQ3nnhZzrlBZbRR+jmcCmtX0YNBQ+CRB35mvzUd1OWAhfB3MiMc2XMJ0ffehutR8Zna+PnvAPR8P2+x7 1/naEQwF xR+QIWqnKJbjbNeZCpNPZn8gLIy1yb+afLVvllJgu1MQZvtZ1LWqxe7RnMztHGvTqJo9Boua5v1RSLguWI84+MV4ZH1cHEr4fO5UsuDXR90e1tr8iTjEQAfmAF9aIsBkUR72tN1NAnNalWebJ5wCxMt0z3FHYWleS/+tSXlfWmdJFGmnpDgBpB5u5E8K6HDnPj8yaUsniw/OqvZVOX8vVp7yfHyn9mHgRRO/4rK89Z1kgAgs3rFVynwQghQBXTk9vm07x X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Add comments for page allocation in nowait case in xfs_buf_find_insert() Signed-off-by: Hao Xu --- fs/xfs/xfs_buf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index eb3cd7702545..57bdc4c5dde1 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -633,6 +633,8 @@ xfs_buf_find_insert( * allocate the memory from the heap to minimise memory usage. If we * can't get heap memory for these small buffers, we fall back to using * the page allocator. + * xfs_buf_alloc_kmem may return -EAGAIN, let's not return it but turn + * to page allocator as well. */ if (BBTOB(new_bp->b_length) >= PAGE_SIZE || xfs_buf_alloc_kmem(new_bp, flags) < 0) { From patchwork Fri Aug 25 13:54:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365927 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EA9EC71133 for ; Fri, 25 Aug 2023 14:04:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FBBE680002; Fri, 25 Aug 2023 10:04:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AC4C680001; Fri, 25 Aug 2023 10:04:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27439680002; Fri, 25 Aug 2023 10:04:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 18A59680001 for ; Fri, 25 Aug 2023 10:04:41 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5A0391206C8 for ; Fri, 25 Aug 2023 14:04:40 +0000 (UTC) X-FDA: 81162797520.07.F30F2EF Received: from out-247.mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) by imf28.hostedemail.com (Postfix) with ESMTP id A269DC002C for ; Fri, 25 Aug 2023 14:04:38 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=cYsDGPpj; spf=pass (imf28.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972278; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sCdpGKioQF34weG5w+z0/y3PF/fjvtNNI35yO4EvtLk=; b=KNPBYbDLbclm8CV4BjrF5e6lTLGuiKsIr56lv29WllhdHPcYp+xOtyzsjUjZvX6szM1MaJ x6hvQqEY8qFHEd8sK5niOLs5XfA0wgymyzuHyMG71hIGPvz8aPZTsW8TAKg5NJmKByohjh kjS1NuFv0IoAvEOCkvz4WP8/YpY2uDk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972278; a=rsa-sha256; cv=none; b=EeFpAIP+OpDUoGEx/buLZ2LKvc0y5NTcPyZ7A5Jc0xZwBEs5SvAQ6RFJ9wm/bMHjelUTBO zpuzBzEFuwoWpZQkgSfVdVRSXM361uDqN29/IGXbDy8AQXR+cxWoEZiYBrrNQeYLmVc8uZ 6+gC9BeZq3ktK5iDGXYcGrxSYFfTfHk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=cYsDGPpj; spf=pass (imf28.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sCdpGKioQF34weG5w+z0/y3PF/fjvtNNI35yO4EvtLk=; b=cYsDGPpjRbWUMOTIPyMO/haz1FlbbiWizE4L6+4KiNimBQndM5dbyTTkg9jBA2egpwU6Cb fkg5cTnWwTpMK0RxO73BKMbVgecaeb3ZdD5hvh5LwNn8nQIo0z4wNaoOSgDtnANIdxLDF6 nhdxpWfLei5X8co+EkZeZUy0T4PzeHk= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 23/29] xfs: don't print warn info for -EAGAIN error in xfs_buf_get_map() Date: Fri, 25 Aug 2023 21:54:25 +0800 Message-Id: <20230825135431.1317785-24-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: bpa91es1jrhh9k8rrh3rcdyxbycbqmhz X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A269DC002C X-Rspam-User: X-HE-Tag: 1692972278-742627 X-HE-Meta: U2FsdGVkX19tn1V1gsidx6eZRvY76zmFNO7mn2O3CZPvsw9xBfJae4FQ5nNCje3gwZX3t+XqPkaZZwunuoCVRjlnwbELW7KKk2zfZPpqITLIWzuNYlELR6Z8oxSSkZRlTAXj9bmIlvcKS779Llq0wu9U+bDuXuIva9jH7PyZ1FSXYDC2Scdp0W+shKzLJX843Gq7qiv04TQNj/rS5a9YoYYmqxfHhArqTu0fRgdd6cxY21ap6gbpp0XNCTKqp9BBMap2eMpUw3aztsXvfdnrDKF7Dm3wyUw4TZ6Ybb8+8S/P6YApDYzANLIHO3adsRmw7wfH75UvbXzF8saksmxtzohWdZiIYnoDI2m8AgrRAeFABJhVSvPdkaEzgtdYpICOQIBygKE44R2OHvZC/oZZng6e9y4WbJ8/P26pXmh8rEIQGnDYUbSKA2YKV8LTIF3gSKUgQD3zd9TkLP8v3x4ezZkfsHUpbXYhdEtBFKoAKhgHSQ0MD7/s8Aa5mXE4ECUFGRu0N7NZGp8d72MnC6dRSHaM02XWTWRZuzTNh9UbV1SAIkoQEE5gmIAhf7eXej2FMwUFLGKlX3YyCbApqd+4/A5mqbVydtgHEjwa7j2JneXKTqAajXutcOHnjBof3cREosLCK5nsd4Y/ipPaMUDKw7SIQ80Oqq0xwbJYIq/FzHgVWqe8lWFKXtse10bv4BkOdOO3jzqaQoLiZAYDKLUcN8ReaoxCHIN8cWD6ZMKxMXAZ51+zW+Op6Y2chCGaJTiK2Aakh4LrSsfz/lm/1zqa1jI939oPVUnD7mDarG4wUEY15+lDQ5qtPb5tKXQZEGvii8ufLP40epddh197V59Voml1LZ/rGKkAwZp7EIZkkIHy/liwDnjdwFg/j4dXCQ6vuNfcT+NnRkgi+mDnEjNJcqHw95Cql/6GlcQAft2YZHdTXpD0WLHJQx2dsuhzRojpIhF2ImgX2Cx/2p/SLxu Z6hsELiB dFAEHmgTxxZldg5z8tgE/gEcbhfmPdQf+P9FfzyPpQqWKBPzarFD2TUxEHYN8kLOCaorzc38+7BckfjdZDd2utOrS+SsQ3S9quyWCmWNMrBccGGb34Ty1q7ESM/r1TJ8YWV7YhNAx1DzKcMwyQdm5uW2vS82Z8Bt+Qc7D3pLfddoZQkXoBORHgFuQscoHrD4IIbFN2mopyVrq8zihZkSVd2h2lfwmpgzGwRO3cEHzJ0wVFswgFDiBMsk9U44AlD/2WCfi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu -EAGAIN is internal error to indicate a retry, no needs to print a warn. Signed-off-by: Hao Xu --- fs/xfs/xfs_buf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 57bdc4c5dde1..cdad80e1ae25 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -730,9 +730,10 @@ xfs_buf_get_map( if (!bp->b_addr) { error = _xfs_buf_map_pages(bp, flags); if (unlikely(error)) { - xfs_warn_ratelimited(btp->bt_mount, - "%s: failed to map %u pages", __func__, - bp->b_page_count); + if (error != -EAGAIN) + xfs_warn_ratelimited(btp->bt_mount, + "%s: failed to map %u pages", __func__, + bp->b_page_count); xfs_buf_relse(bp); return error; } From patchwork Fri Aug 25 13:54:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365928 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48E78C79F77 for ; Fri, 25 Aug 2023 14:05:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D71DC680003; Fri, 25 Aug 2023 10:05:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2249680001; Fri, 25 Aug 2023 10:05:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEA54680003; Fri, 25 Aug 2023 10:05:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AEE25680001 for ; Fri, 25 Aug 2023 10:05:11 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 878C91406AC for ; Fri, 25 Aug 2023 14:05:11 +0000 (UTC) X-FDA: 81162798822.13.BEF3E33 Received: from out-247.mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) by imf26.hostedemail.com (Postfix) with ESMTP id AFF30140019 for ; Fri, 25 Aug 2023 14:05:09 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mPHInzP0; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf26.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972309; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xYVJABOgP4/8L2CV4jLRK/KE5S9+YcPlTWp5R3EisXs=; b=G/50DzuZMGMkbQr6pvfleKKzKU45C8vYwC/feF2A5pcqYJ/YNj7wr2eW1zNAiOGexHa430 FkP8uxM7tanEy5E3yrhxRUHGAHxjmwqIg/QIJIQWzlc8JBYQyEORE3pbk0H6R+r+TOHJVk uRw8mDss9tF7bsXZg3Y4EjbSVFmuoeQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mPHInzP0; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf26.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972309; a=rsa-sha256; cv=none; b=s3/79yQxczjW+bMLDd/ZC03lDRMiMaNr5POEwi3GwjzYvlFczWvJ9b3ElFeVTUjMfMPD99 oIljKQ3WKHcWsoMxL/iQjrvDbEh9i/JCPPuuU4kUQERVy23co2kGq3seN69FQi9ULkkV5F mNSS5T+vhQOCbsJH+b/VTIePGIIlJ1Y= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xYVJABOgP4/8L2CV4jLRK/KE5S9+YcPlTWp5R3EisXs=; b=mPHInzP0NdE0PARLrMiNVwBxHc2RcZZ9h1TcJI1UDo2PmUbrGHosmFv1DSPqUTrb8M6kqp 4M25de/KL1vHeKbgvgWIJvfxIGajB7oK9YCJR4tOksovz6wykfv/qKqEWZZksomlKe2dSa K35zik9gA6wCtduft3CmT9CQD0iaLDk= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 24/29] xfs: support nowait for xfs_buf_read_map() Date: Fri, 25 Aug 2023 21:54:26 +0800 Message-Id: <20230825135431.1317785-25-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Stat-Signature: ftktk3y47fon11kzxnyi6wxdudyt6r56 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AFF30140019 X-HE-Tag: 1692972309-151781 X-HE-Meta: U2FsdGVkX1/0QgtlAkr+AHYGkDfMZhl41YSfHWiAPwmdmJHe/0awG2gTx+bc8uZefqV6F6389BDuk8AMheRUCQ16Sq8fEsKR4KftUFZ7HrOJWZUQzCAq/NnnYoSKDTd7SfGzXLS6NR0rY0Y6PdAlshLcF4SdhPxSeRtn09SUmc+3eK4XmaiKI0gLOtx9CsT20C91BnhUJkcMtFKN5xuux16tAWBEJDxwl23r4EJhpLnmcDmUCE/1+UKrmGbpwvHfjEiXDNr5ABAM2/jWYIhwZslVG1YcUFMvkUOtBT/0L2E28CBpCmcFWYR45Drao9nMcsb2MJl0tdcCWDZaPXTsEP1f3+u366YOqpbOspQayXeBUMQbhd8q15m+ejiW242rRwZ8+inBEkePolgaRo6sEavhIZcGtB/EpVH7YmbDVwHBetnCG+vrqfknUVOe0fIZlZWbg9rjY59caMhnPm1G68ClymBeFBLehKvAN7lH9yYEG9TphoGdc9I+Y05IXhSvx0gxnYAH3X/Cp0sdiqhKWb+2me9FJSLUSWo6L4vWbVvQ1doAaSkR9a7t19VKswulQt9L9EA2u6rUD/ZlO1Q/0y1UG1qLJM6s6YAWSKhyo/uT831fG76iq73qATetWrg/sAuz79CJINebVsCiKRBj63Aag7KXwVo5stfAPwz7jeducmqqUXVLPjMkJ2l4hdrRUD85nW2WGzYLbY8f8T0t/VeDUY1LrwkTpvJRuKceOk/riQHa4cORJQkStqgqj5zoX2i8rBYc4/Rn8BXNdg3lD/hVsN6BCJA6A+QbaaAJi7Hm72HH6iAj0RmTLox3UpwBiu+Xe3Tti/6Bv3FaFQl2iHNgrTqGv5SCdRfdW74727DxVHfaKhBZWSMMsYyciNxLBYbpQHBRs50fTQDmrVCGKJr5Qeefg4OXV2ogDU+zv8Tdxi9pS2808kh0QcpHKwIdVLGIv8cqOX29i1Sfx7O yNOFdHAy jMXzlqDIUKBS8vdDAxyq/p2+JenrQeLhgj6Hqm+/HLYCjZlf9aOc2+UIeo++U7rl2dCP1v6vZX6UQZvFhQFEzbgydQG9ys+2ak4jk45wImWbXZzWpkmLOACZHkZlgXIkjgIFCrNrA237MLa9NAmi/JBZqdHd/IPTAJMRCgQCy1xzIAz47GXpeytJ80UVXC5g8oxVPkkKEnHfFYV4zO/rlMgA5Zzbg6vgcF41FrNzl79Wvt+oZ/qwG11YTZ6fTBjTJqCg5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu This causes xfstests generic/232 hung in umount process, waiting for ail push, so I comment it for now, need some hints from xfs folks. Not a real patch. Signed-off-by: Hao Xu --- fs/xfs/xfs_buf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index cdad80e1ae25..284962a9f31a 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -828,6 +828,13 @@ xfs_buf_read_map( trace_xfs_buf_read(bp, flags, _RET_IP_); if (!(bp->b_flags & XBF_DONE)) { +// /* +// * Let's bypass the _xfs_buf_read() for now +// */ +// if (flags & XBF_NOWAIT) { +// xfs_buf_relse(bp); +// return -EAGAIN; +// } /* Initiate the buffer read and wait. */ XFS_STATS_INC(target->bt_mount, xb_get_read); bp->b_ops = ops; From patchwork Fri Aug 25 13:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365929 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75411C79F60 for ; Fri, 25 Aug 2023 14:05:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F0DA680004; Fri, 25 Aug 2023 10:05:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09F84680001; Fri, 25 Aug 2023 10:05:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA997680004; Fri, 25 Aug 2023 10:05:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DD119680001 for ; Fri, 25 Aug 2023 10:05:25 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2C8E80706 for ; Fri, 25 Aug 2023 14:05:25 +0000 (UTC) X-FDA: 81162799410.21.FE6E09F Received: from out-243.mta1.migadu.com (out-243.mta1.migadu.com [95.215.58.243]) by imf14.hostedemail.com (Postfix) with ESMTP id 95313100021 for ; Fri, 25 Aug 2023 14:05:23 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=KEbezTf0; spf=pass (imf14.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.243 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972323; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6/Nd9xxoGpB2Y5m9xwXDJRTcGKza/1aMnRr8dKaa6VQ=; b=AfLccUPdCNg7KnWn6nNUM1ErMg6HQNSl3Omp7288V/XgL2/yn+IhbbfaCtNjgwJ3BLbgkp R63dokiejBJtlNlCpbYLbOmeGXXv/W3Jj6LNYVnfwu7fdB7EwGdNszzWBGRe6/2iMzqxvX z66cRKaqSBf4ujxBpIqRW0QSlEJbJis= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972323; a=rsa-sha256; cv=none; b=FR7pghYEpNsmX2bz1j5A1KH//0+BLfWdLvv6G0wBjZMy9yBD7oD+itWuVuRmp21Yd+Nrb4 usP5BLo8k8f8btQXnjeEGDWFzKom0IMguusXdHmB5DXKjOpdJODzMeaDvQQ0RY5JtwrXRV tqlMCRLRLUurQx1jHFidwXlTtK07HvE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=KEbezTf0; spf=pass (imf14.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.243 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6/Nd9xxoGpB2Y5m9xwXDJRTcGKza/1aMnRr8dKaa6VQ=; b=KEbezTf0obDqS0d0+ZY03Au9A3+XAlHMaifao/gSyVuoHlKJlTUkwmI81DvHZmrTrUQaLF sGTDWP5rChj2LFxWYHnJBky5ZudbW2OzCc+00JgxX/lbJXlYqo7/5HQVTOk8DmfuG/wY54 UCC6hfeA7Mu6K3Y30dgBdV885aCoMfc= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 25/29] xfs: support nowait for xfs_buf_item_init() Date: Fri, 25 Aug 2023 21:54:27 +0800 Message-Id: <20230825135431.1317785-26-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 95313100021 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yn45cc796dk3hkngpypw9i95pfosikxr X-HE-Tag: 1692972323-846627 X-HE-Meta: U2FsdGVkX19AGtBCFAgVapxzRAktwe27bHYC4i3y1jsg24nMLH/BG9pzXu8Ea+3Bi93gMPXYTD29kGMo/HNx0k0HRHZq1WFcyn/UWVxkjvfpxDUbrYyu0f51C2283p3x3m7hIxToajAEXQqMwFxoNlG7fZNPzuyl6NhkXFyBuIlRt/VkfZcsDx5oqGDMdwfgxtZiBRWnY4mSFia9McMp4ckDKR82gSN/ovkXC4cqwl9DvK+YKbkRSk3Mim1edYsHTFrWmEVh8IgRAzN9TgVOJPMSzPxsSKEbd2gn8lEBVpPg7zt9VyArxtlmg8qmvTyYQ6dNu86p9V49otglGGG4bHTA8F7guhtZruoBfLb4fRyjQNocUsBUdOsHhI7HpFXBwg3w7OgDo01f62lYXNBfd9HzIror76V/uM0uAst9SO+QB+UBv5e3NyYAjn1/WbWePCdbRx6Ht06zeLlHuCJtA0hqaJw7G3Jh7BAcjhLO2s5pIDyu4tjy8F/58pJ4z7ZhaH1v42HC2k7emiaRJs1qC6gaYnnLEoSy3noz+8hQ5YeL7YkVysPgmEq39KKlX0cKyHL90NJMwN8DGmjf4PjKttY9cThq5auyeJc2h0Fk6RB3gPIHcG0brybHaezGefIjrluapvN2ayIff5G19Op+q6L8Yr+gFYIiZNlAnwE0znNNZlXi4yHvJoeSih6Uexv6Y2tUu33Pi5Luq4b6c+j7pjdITgJOTkQzeXVDi/g1MxmCyJGYnv/xZbW84AXlX1YVPNZDJAcFhAhpj0uDmFOpXQwSwyo/bgpzRr9l1QNV+vUj8gHqphtj9lh6OsxnRHRCfReAOM5v7LJpo27zVqB7OvRJ0XHKSTozus69B/99JSiDn9gn9qi4JGHsEWH0KuhG9+fTdC5gOq7Jvo5tycSL1lo8t2WodTYe2E8VcdGTdqH6DGWQcUnko4TzYVxE48enZRW++p7zbJCcCFrRX1Z +XZ1Yd5T sT37VJDioMhr0pI1p1HySQ+psNK9Kv4+aty+glNdJYHIsEbRQQZh2qdLNFllJzeZSGqrCc1DMeyxlq0XuSb6yKjwfJYZ+ZMsIaRR3BoIeNvpsQVT60nASLXs/xodxnSRlRnP9xDDptloKd35HwkzR3oXdIhh2+fiXX8Nqmsb2iNVYiJTvBW0ivqDF1OZ9SB+hFuC12lPKZ0jKHrXUsM+sBpuKNqwpDBjyFHPX27UMymd4yOPPzqReYp9JrsA5kIqDtYUS X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu support nowait for xfs_buf_item_init() and error out -EAGAIN to _xfs_trans_bjoin() when it would block. Signed-off-by: Hao Xu --- fs/xfs/xfs_buf_item.c | 9 +++++++-- fs/xfs/xfs_buf_item.h | 2 +- fs/xfs/xfs_buf_item_recover.c | 2 +- fs/xfs/xfs_trans_buf.c | 16 +++++++++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 023d4e0385dd..b1e63137d65b 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -827,7 +827,8 @@ xfs_buf_item_free_format( int xfs_buf_item_init( struct xfs_buf *bp, - struct xfs_mount *mp) + struct xfs_mount *mp, + bool nowait) { struct xfs_buf_log_item *bip = bp->b_log_item; int chunks; @@ -847,7 +848,11 @@ xfs_buf_item_init( return 0; } - bip = kmem_cache_zalloc(xfs_buf_item_cache, GFP_KERNEL | __GFP_NOFAIL); + bip = kmem_cache_zalloc(xfs_buf_item_cache, + GFP_KERNEL | (nowait ? 0 : __GFP_NOFAIL)); + if (!bip) + return -EAGAIN; + xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops); bip->bli_buf = bp; diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h index 4d8a6aece995..b1daf8988280 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h @@ -47,7 +47,7 @@ struct xfs_buf_log_item { struct xfs_buf_log_format __bli_format; /* embedded in-log header */ }; -int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); +int xfs_buf_item_init(struct xfs_buf *bp, struct xfs_mount *mp, bool nowait); void xfs_buf_item_done(struct xfs_buf *bp); void xfs_buf_item_relse(struct xfs_buf *); bool xfs_buf_item_put(struct xfs_buf_log_item *); diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c index 43167f543afc..aa64d5a499d6 100644 --- a/fs/xfs/xfs_buf_item_recover.c +++ b/fs/xfs/xfs_buf_item_recover.c @@ -429,7 +429,7 @@ xlog_recover_validate_buf_type( struct xfs_buf_log_item *bip; bp->b_flags |= _XBF_LOGRECOVERY; - xfs_buf_item_init(bp, mp); + xfs_buf_item_init(bp, mp, false); bip = bp->b_log_item; bip->bli_item.li_lsn = current_lsn; } diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 016371f58f26..a1e4f2e8629a 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c @@ -57,13 +57,14 @@ xfs_trans_buf_item_match( * If the buffer does not yet have a buf log item associated with it, * then allocate one for it. Then add the buf item to the transaction. */ -STATIC void +STATIC int _xfs_trans_bjoin( struct xfs_trans *tp, struct xfs_buf *bp, int reset_recur) { struct xfs_buf_log_item *bip; + int ret; ASSERT(bp->b_transp == NULL); @@ -72,7 +73,11 @@ _xfs_trans_bjoin( * it doesn't have one yet, then allocate one and initialize it. * The checks to see if one is there are in xfs_buf_item_init(). */ - xfs_buf_item_init(bp, tp->t_mountp); + ret = xfs_buf_item_init(bp, tp->t_mountp, + tp->t_flags & XFS_TRANS_NOWAIT); + if (ret < 0) + return ret; + bip = bp->b_log_item; ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL)); @@ -92,6 +97,7 @@ _xfs_trans_bjoin( xfs_trans_add_item(tp, &bip->bli_item); bp->b_transp = tp; + return 0; } void @@ -309,7 +315,11 @@ xfs_trans_read_buf_map( } if (tp) { - _xfs_trans_bjoin(tp, bp, 1); + error = _xfs_trans_bjoin(tp, bp, 1); + if (error) { + xfs_buf_relse(bp); + return error; + } trace_xfs_trans_read_buf(bp->b_log_item); } ASSERT(bp->b_ops != NULL || ops == NULL); From patchwork Fri Aug 25 13:54:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365930 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D96F9C79F61 for ; Fri, 25 Aug 2023 14:05:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A6D1680005; Fri, 25 Aug 2023 10:05:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 756B4680001; Fri, 25 Aug 2023 10:05:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61E2E680005; Fri, 25 Aug 2023 10:05:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5295E680001 for ; Fri, 25 Aug 2023 10:05:41 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 331F61A0512 for ; Fri, 25 Aug 2023 14:05:41 +0000 (UTC) X-FDA: 81162800082.17.385D3F2 Received: from out-246.mta1.migadu.com (out-246.mta1.migadu.com [95.215.58.246]) by imf19.hostedemail.com (Postfix) with ESMTP id 684561A0027 for ; Fri, 25 Aug 2023 14:05:39 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=O2I4LuIV; spf=pass (imf19.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.246 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972339; a=rsa-sha256; cv=none; b=nUOaCNSzEqK/GXb8hL8n9CdNJiWJhlV9bk3TTOMDEG50UyW8AXeVHkLyjC8wi2XJE7HU3/ eUMDGTelivI+Qj1docnyFc+2xn6xBDAItTP4GHydL+8hXgcHbLl5zXRAv+SutM7NkyGHjI l/zkUUCyJp9q4ayQJEjf6xmYrHWWkF0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=O2I4LuIV; spf=pass (imf19.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.246 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972339; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mjhC+caj2gJRQH+sSsUlDYCC/6KksdCJUKl454sdMkA=; b=mAxFWmcGrdt8gAOkk2GrZaIXPC9K1z3jE9TLuUvAbaWpdmaJFeH5BjA2TJpEqdemtKqj/Z d/dL7E+9X51wavqPDVZjt75marlWcbWaU5fu7kTCs5ANIGw7DBLMkKMnjXyuQILZua4A7r adDRz7/kXqT9YpQypI+Wg+aN/t+Fk68= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mjhC+caj2gJRQH+sSsUlDYCC/6KksdCJUKl454sdMkA=; b=O2I4LuIVYgSn+nmzJUq/UHofHubEntakWSPFjqloiwwujETAFgWOGN3xteSPe9gSVMqAFq d8hRn0Wa7uhhjg2GTvasuKf8CHjMi2bI9Lkmg+s4bspXsO5Xaxy412PPH/FB0SLGDG9CfT 9ayHr7HUCratE15Bg5Ihc+obof/8RuQ= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 26/29] xfs: return -EAGAIN when nowait meets sync in transaction commit Date: Fri, 25 Aug 2023 21:54:28 +0800 Message-Id: <20230825135431.1317785-27-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 684561A0027 X-Stat-Signature: zztnmnfef1tnjycjipoym3adf1xnwzhp X-Rspam-User: X-HE-Tag: 1692972339-262004 X-HE-Meta: U2FsdGVkX1+5Xnf5FY9bibEp4gBkMOad/cNUgl3qjNhJQI/WQHYcG8mG/ZDdyb6T7oRIvUGtTK28cMaluls6zcGfr7dMboBjJkj4wc2mgMtEyuxDzJyfeSG5Gi5WooxErs9QPDol7cVjqi1uJqz8jkM/V58KwYSsfotZBTc5RO1v0Ysi+fYtvreqJZkLW/GOEMpKSuO0K0rjHeE5C+4EWP4yF0EpoMgvXMKkKkJQyrNjPCwq+6mBkGjY3+HOH0E3LKtMRR3dHaNjpnr3g7r0WvSxtXqMxk0285sX3leIKVC47bk8p4R6A5rOCMMOd0WOXTV6mPmJU1ELA2MMSU+T86SLvmRNAtH3jSOacSIQssjThcZhELAmNQHjTcPOz3mRQaSEkyLRUM7siQkHA2z8lId+psjZlyH3qw/+Cdtuk/gAdIin5qcBF7b/2/1PUXjWfT2eyxLF8fKGsgBQvwbMA5K7wyfwnuxiun95mCKvfGqFordAbjMiYKPetDPxH+Yd3oGdYC7kDPM9AkzsUQE33fSg/c6h5GOv5oFbdwxV6YgPKNF2/bZUBlnIsajrDKF8JP9Y4GJo9LXJql9dQoxGP8rD6g4sg+In8wJ+JKF9OhJ5KsXsYK9HENTfF7QTOBvy+Y5bNX5O/k29I6Os3gyylTL/ik52xG3zADPggfFb0BnlluyWe722m+xSpskPF/1hbQhE6YMmER20LF2fmQbTbixY2tAp9YQls3eFugiw+JEFY4lALZMRdbUkIiY9NiEDR6xYccRc65N0ZXm3B2NUg9cXoKyAX0cGNMr7fnGLPnjVGcxwo3IGICDhuF9mBs5YXtikc9qdYM7xg68xdrL54/linBDot4qCNMdm6nCk6Zs4yTi9X2O4GHzzFqzpb7msjD6dDgqjEOuFqwwWFq0chfwSAY2sLfYXfj+s1HnMI2ew6fjFvJCVwXHozKjLcj2fD+i97p1knvNrB4t+tzp hv1h2jSt ECOsB8t8mpmDKz2M7e15RIPWdZfJf7piJgEFuUGHkVCreXupzNDrM0DqPZ3ORyScdXDrzshh9hy/3mKTPR6bS2/B6vIHqvuWIOdGkUzrqW3m3okRLPyxqS4EVEuPLbzyf70scOgGQKR36zOIq7jKIyUrgPgIk+r19gN1T3UpsjJ+cKsjUr8h+ULNUmopLXNKvaFQTueDPwHq7d8E= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu if the log transaction is a sync one, let's fail the nowait try and return -EAGAIN directly since sync transaction means blocked by IO. Signed-off-by: Hao Xu --- fs/xfs/xfs_trans.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 7988b4c7f36e..f1f84a3dd456 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -968,12 +968,24 @@ __xfs_trans_commit( xfs_csn_t commit_seq = 0; int error = 0; int sync = tp->t_flags & XFS_TRANS_SYNC; + bool nowait = tp->t_flags & XFS_TRANS_NOWAIT; + bool perm_log = tp->t_flags & XFS_TRANS_PERM_LOG_RES; trace_xfs_trans_commit(tp, _RET_IP_); + if (nowait && sync) { + /* + * Currently nowait is only from xfs_vn_update_time() + * so perm_log is always false here, but let's make + * code general. + */ + if (perm_log) + xfs_defer_cancel(tp); + goto out_unreserve; + } error = xfs_trans_run_precommits(tp); if (error) { - if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) + if (perm_log) xfs_defer_cancel(tp); goto out_unreserve; } From patchwork Fri Aug 25 13:54:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365931 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F360C71133 for ; Fri, 25 Aug 2023 14:05:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EABAB680007; Fri, 25 Aug 2023 10:05:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5B19680001; Fri, 25 Aug 2023 10:05:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFDB1680007; Fri, 25 Aug 2023 10:05:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BE91F680001 for ; Fri, 25 Aug 2023 10:05:56 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 82E0E1206CF for ; Fri, 25 Aug 2023 14:05:56 +0000 (UTC) X-FDA: 81162800712.03.0553875 Received: from out-252.mta1.migadu.com (out-252.mta1.migadu.com [95.215.58.252]) by imf01.hostedemail.com (Postfix) with ESMTP id CD44B40029 for ; Fri, 25 Aug 2023 14:05:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=gfnw7iot; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972355; a=rsa-sha256; cv=none; b=JvB3AyWKG937MEj8vPSUhcwM0FSNx2b0hjT42W2s5vrjlv2VrN+cb6WGyTXRawlYs1KjIe YSoH313QvGOQD8zxP/9z8h/EgpYiQu96bEt7b8xPO2JYifBHG9TKaoVbwgXOkrzYFbMrO1 YHKaimH8mvjC5cgHWfbar7Vi7uPjcCY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=gfnw7iot; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.252 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972355; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4gmh1Yl1nIIBwKe+EGho8dT2/H6COtTrErlOIONZgFQ=; b=OhCpy+7G35mkdbBVioTA3mv2AzjroRvI8xOZ0OYfcr4t06Edev31Z8fRe5H2A+zNVuQ4qW 0EtKdRiwepW3wQNbBVN8Z5APpCbVmi3lCEZjMk7ljKaorYvkdyWixsACIhY8xd9CHm2Smc Ou+Rj82I/sGoGCaW/eHcihwf4JcVei0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4gmh1Yl1nIIBwKe+EGho8dT2/H6COtTrErlOIONZgFQ=; b=gfnw7iot2v83zX2rBTLz1spXwFLJTgZUr3L11o+Xtkb6kMiY2V8isvCmRHCyeGMc3m+Cgc 4QGEiH3BvMZ39xF7zrn0F0ImfXnteloPQ0HANELCYOPXSgll6hNjSPIHSsKK/xLoS1sTMP 6uHJDx4f8EyPCrO0C+jtU3MY4km0+Ig= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 27/29] xfs: add a comment for xlog_kvmalloc() Date: Fri, 25 Aug 2023 21:54:29 +0800 Message-Id: <20230825135431.1317785-28-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CD44B40029 X-Stat-Signature: w8gkqejr5si7awfqnc9g69scdmt7rq9n X-HE-Tag: 1692972354-682451 X-HE-Meta: U2FsdGVkX1+5V6jMKaYa4sJ7mrBc6emSb9QluTj+ckp9nhhSx/qPHysvw/LEol7uNd/MQb7KmWz2fwWMX1MkhrGNcVtRLhCDyI+0n8C4EwvsoloHPALFBakkKJP1aZ77zOBhqZ4UIFEih6NOIQmNJk1KyrdwRhMOpgpYJLcqU9jU5S9kBLJJtOAaDY28Xc0x6lDDxBm17mj2xujx+ajMBjNem8Glq+w9xOUbgoT0+tzXN1LZB8BohQcRdCe9rImiVP+pALNy+M90B72svsz9+gLNYZ0keJd8dPXBA71Wi1yHDNrKMlqQ9JjZsbTG8TyWu7SqO2oEmutQWtUdFI/wGvM1jO9/P4BAUjqHnLJ203S+hUY4faJxCWUfOhV7iCabd1gHf5VcYzpqIwZQz+uAMjsOl8EqslxYzT2oCWUn4w42kcRtl2sVja+F5t6w4HJrFKWZj3g/YbvY14LfliqrNyCf+utT5maWY3YULOryt5MCnniUfCZRYORDNq5WVJtFOD/eKMdw6AXOPeWGCQGb959IJlYd6MAGUg8SDBk0lFEZCWZebrBdttk6Cy9XjEbgvTadJcg0QMp1XJufg3g0Wos+jboB6kfIXRVGOMmpammqezm5prooMbI0+qj7IVJWYMLnmyl7FHsAriblyR7KCRIBIZJ8dzqNFdCB97KeJ+EoI67zb1ZqpCIOflXxj/CREMI77A3I0CX3PoJrM2ZEQ7EcN8NK+s6pN99ojK+zMsRqZvK01cQP8Z/1fWsjNA8zTPqWNjtOCFKKm+nQ7+FOth0DnLJdSLnUjj/SVnmeYJIEYwGqzSKOhFqLN30QcwS4M5wANZ6W917ZzCpPQPQiB73oAhzWIknEyOM/Zl0SPmicq0ey826/b+X9tfhnn9Wa3AFkE8z93gmZkKgrBsCm9+ujUxLDAzGCzZpZC8UnaPdAn/FK59Uk/5A3ZHssEVz+R2Oz5P+RXufa8d+R6G9 d2IxIgbq XkdcJpdeM+f086QiDK7cHAaISkuzMV4yCHWKKrLfEgkA9jcVWIayTbpZqwnKNOHSW4xhK5crtkBTK1Y/MEhjs9UvXuT11DW99r2xl3zypYTrRAOdkF7aVK5hvIPy/qdEfGBSIK120gVb5dbd+ngsqtowr1tXuePfo77ZlY9zNvls0LS9R640UhQ3Rgx+yyk4KpxyY5cFt3bB40iVQ6xD3Bs4Hu2AAx+U/rq6vrGVdzjK7C+lOy5qQVYrMbA7SoR1ZtzWG X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu vmalloc() always succeed in 64 bit system? Not a real patch. Signed-off-by: Hao Xu --- fs/xfs/xfs_log_cil.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index f17c1799b3c4..b31830ee36dd 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -335,6 +335,9 @@ xlog_cil_alloc_shadow_bufs( * storage. */ kmem_free(lip->li_lv_shadow); + /* + * May this be indefinite loop in nowait case? + */ lv = xlog_kvmalloc(buf_size); memset(lv, 0, xlog_cil_iovec_space(niovecs)); From patchwork Fri Aug 25 13:54:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365932 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81221C71133 for ; Fri, 25 Aug 2023 14:06:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DA2A680008; Fri, 25 Aug 2023 10:06:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18A8B680001; Fri, 25 Aug 2023 10:06:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05265680008; Fri, 25 Aug 2023 10:06:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EAAB3680001 for ; Fri, 25 Aug 2023 10:06:11 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A765E80702 for ; Fri, 25 Aug 2023 14:06:11 +0000 (UTC) X-FDA: 81162801342.09.E8D1BB1 Received: from out-247.mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) by imf14.hostedemail.com (Postfix) with ESMTP id 96D83100034 for ; Fri, 25 Aug 2023 14:06:09 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="IDkI/8Fc"; spf=pass (imf14.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972369; a=rsa-sha256; cv=none; b=pa1Xgg47MwNm1qi/3nOHOGZOgzshcWHr5IQiYFdZEyy/a/Z3OpjCLle0rlmA1OUUEXS1et 2EGJFlHi24T/wiqgi7UIeqgskuo0ea8Fyld1WVMKc2cxSmIP+kMQzZ/PmsLX8iaOlASMGd TiI+TjgT+y1YyaVtUS0qXj2egUKkeVc= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="IDkI/8Fc"; spf=pass (imf14.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972369; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=o5eD4gq5Ypmv7xNjaJcQB3ZOSw79lNA3YgufxQ7kbUU=; b=xNJecd7hd73J+WR3njCn2ICwRMwev9cl4txMjzxmr0Oui+R6KuT3pysitGIteV2Qk5LnGS wODv23AlwPlRBfpafeEZ15PjRDuhTWyFWZx+oAwKC1tFGCO19Rx01SI8bA6WVlU3bny+LI VlN/EwsNiobw447XzTI6X5ASZ+z/8vs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o5eD4gq5Ypmv7xNjaJcQB3ZOSw79lNA3YgufxQ7kbUU=; b=IDkI/8FcKGXMrBLpAzKCujyKyUIvnRClPZG+PDDA+Kg6Ww/HgNrG0d8/UaYBPttRvdNV2G ImRsaH6EObyEWgQtf31bAS82oxf65cz7kpZXIj7D5nH1V4igKHLmt2T1OZkYhVy9UsI8OJ u9rq7LaZ7EE10dyazZwRdVBs5aqDaMI= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 28/29] xfs: support nowait semantics for xc_ctx_lock in xlog_cil_commit() Date: Fri, 25 Aug 2023 21:54:30 +0800 Message-Id: <20230825135431.1317785-29-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 96D83100034 X-Stat-Signature: az11nf8w4kaftoymjj1hptb7mjmwqfnf X-Rspam-User: X-HE-Tag: 1692972369-242929 X-HE-Meta: U2FsdGVkX1/RN6TVQqawaLgc2DijbnAnMyNPY2pmYmsa1Fd/e+kayIRDw8/AyIkR4uRFFdm4kzj0OwsSaVyYuq5+74ztDOu31UOa6NtlXSTz6ZhNR6AviWYfePPwNzPb+L2LkkyNvSPgBjDhartygsWeQ5nzt2PjYKzUXi69zDrfW6b8OIWZJ+s4QMl7ieiiUPTasXVJ7xvASzhM1LrWB5pLfeZ6axuUIwgpBuZRsBEDg6nnrEQ7cRKjg1W7XD4djbGsgvFhS5AyhJBGv6VfG9r8Fe6Mwi/5TojUnryAENLhDEk0Z//SRHB5NNZCM+cFF70X8NTR7oWgBZIuXxYdDk1gQvWr95p2tMKJV5q2bG4cMq4yatozHhORj6JFDMpt9COSbPW7LXSMsR2jmpoiejt+vqodlLXz8krMhh2O79ARgbHH/T0aEgHvBbvmZXIAnf4vS4i6kRN3iOpYeGhXXJNoNsaMY1H6XRQ3uKm6C7RMFSiIt8MQ3ab4TQXl4BeeLFpjjiyVnTkbMi8U+MPsjGWG+8J38w0FUIhlZXf58jRqRa1rWWU8M1jmVjoNjWouwrza8zMW0/wQFvB7sCWGZsFugMxPxFiAH/m/mSn2zyMhAvLSJgIXoR3tYbxQLI39ZPpd4OmiMf7pJ0lGJY567XuZwA1MMfOOhjgz49KToM4X9q3/bAymZHOWe/KgGeaXFOS5BsgtdYVnojvRBUuV4Z0tFQ3nSE/Iv5NOGpsgU6I6DuTcjY6tp1ijEk+35ty07TuD1PiKVAkNFNp+NUoz+iqrlVZWtLIcbmwSDTOjkFYdeftWvhIM+7EcH7K6brDHsmTs13HflKcq1dm7AZTriepLDZuZaSgZnclnX6jCF1qfuaWn2Ed7ygPACEKjBIAy1VuFFMU5CpOUPPBww4mxJ2bykt3blAE1a2sYKCsqpl+IjcB0LZh7fNn612mzkL2BDaivi5pkIfC5wJGsjVJ YO6FUjsh YeN3ESHIJJ7oVXgr+KD8szk9UfaTVnScFQhDCQMLMIwrCVzjCVD3uKc0aMysnNAKkq24EIL9g6oBI58PRxU4a43LH6E/OX89hdjdA1aLn5aka6smOqM7o9AAriSZ9ag+N99W+k/E0G4eizfQ7UgpBBoiiL2kMMBzqzGVerYumo0I20tlZ/9zrJaBgHpMk1LZr6oVgClmO3sZS608MCvmbPGkT6Z25RSOSHzQGjc0awVpB8WGR3bDZDcuwfQbFsZmI15qJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu Apply trylock logic for xc_ctx_lock in xlog_cil_commit() in nowait case and error out -EAGAIN for xlog_cil_commit(). Signed-off-by: Hao Xu --- fs/xfs/xfs_log_cil.c | 12 ++++++++++-- fs/xfs/xfs_log_priv.h | 2 +- fs/xfs/xfs_trans.c | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index b31830ee36dd..6d054359bbb5 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -1613,7 +1613,7 @@ xlog_cil_process_intents( * background commit, returns without it held once background commits are * allowed again. */ -void +int xlog_cil_commit( struct xlog *log, struct xfs_trans *tp, @@ -1623,6 +1623,7 @@ xlog_cil_commit( struct xfs_cil *cil = log->l_cilp; struct xfs_log_item *lip, *next; uint32_t released_space = 0; + bool nowait = tp->t_flags & XFS_TRANS_NOWAIT; /* * Do all necessary memory allocation before we lock the CIL. @@ -1632,7 +1633,12 @@ xlog_cil_commit( xlog_cil_alloc_shadow_bufs(log, tp); /* lock out background commit */ - down_read(&cil->xc_ctx_lock); + if (nowait) { + if (!down_read_trylock(&cil->xc_ctx_lock)) + return -EAGAIN; + } else { + down_read(&cil->xc_ctx_lock); + } if (tp->t_flags & XFS_TRANS_HAS_INTENT_DONE) released_space = xlog_cil_process_intents(cil, tp); @@ -1668,6 +1674,8 @@ xlog_cil_commit( /* xlog_cil_push_background() releases cil->xc_ctx_lock */ xlog_cil_push_background(log); + + return 0; } /* diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 41edaa0ae869..eb7a1241deab 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -580,7 +580,7 @@ int xlog_cil_init(struct xlog *log); void xlog_cil_init_post_recovery(struct xlog *log); void xlog_cil_destroy(struct xlog *log); bool xlog_cil_empty(struct xlog *log); -void xlog_cil_commit(struct xlog *log, struct xfs_trans *tp, +int xlog_cil_commit(struct xlog *log, struct xfs_trans *tp, xfs_csn_t *commit_seq, bool regrant); void xlog_cil_set_ctx_write_state(struct xfs_cil_ctx *ctx, struct xlog_in_core *iclog); diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index f1f84a3dd456..e5beda636a37 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1037,7 +1037,9 @@ __xfs_trans_commit( xfs_trans_apply_sb_deltas(tp); xfs_trans_apply_dquot_deltas(tp); - xlog_cil_commit(log, tp, &commit_seq, regrant); + error = xlog_cil_commit(log, tp, &commit_seq, regrant); + if (error) + goto out_unreserve; xfs_trans_free(tp); From patchwork Fri Aug 25 13:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 13365933 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CAE3C79F60 for ; Fri, 25 Aug 2023 14:07:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5ECC680009; Fri, 25 Aug 2023 10:07:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0DDA680001; Fri, 25 Aug 2023 10:07:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C88F7680009; Fri, 25 Aug 2023 10:07:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B318C680001 for ; Fri, 25 Aug 2023 10:07:25 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9736E1C9A13 for ; Fri, 25 Aug 2023 14:07:25 +0000 (UTC) X-FDA: 81162804450.21.0524BD4 Received: from out-247.mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) by imf13.hostedemail.com (Postfix) with ESMTP id AF17620016 for ; Fri, 25 Aug 2023 14:07:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=sbYFUS6B; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf13.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692972444; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NAMtHKwgj081g8lIPVs72MliioxtTYHj7D9CTN85ELE=; b=QhSlQ91PngxpHt546bJDn2kpvxHLd5QdPz5f9K84LDIw2FiYADL/PZKeeAyUwm+dpc6bD3 o9CF7rpgKr8lL+7d42XWHWFEQUkG2NKczKHl2mtoDwjCCrBwg1vb+uvb+LoYEYba+D6yxO yHVV9s6IPW9GKBP9zYx/jrFVplBrYSM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=sbYFUS6B; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf13.hostedemail.com: domain of hao.xu@linux.dev designates 95.215.58.247 as permitted sender) smtp.mailfrom=hao.xu@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692972444; a=rsa-sha256; cv=none; b=TiHzdx4Jh2lvH839bQC5O5zz3Y8q7XsWME5ZkVIJRMEzEOHoG+1gNboADnVvR1BAPp7h1p 69TFeuBHvYPGLCSYDU1jXcc4fW+XDM+V6WlyzI4AIsYhUmcJ37Rvg8yopAUrEU28X3vfes 0p0np7NP9us2dRgNNIo3uBkSCwunvf4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692972442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NAMtHKwgj081g8lIPVs72MliioxtTYHj7D9CTN85ELE=; b=sbYFUS6BU4QMfloFkojbf7LlIvBmbwqI6WjTGL8/Nwev4csxD24mU9E4d6JXOYCR7eZA1m PqI1zbyFtIGUv/PonAelJnAkImEIFlhA1NIhorTVqtvxfqefn7QdiSQXQ23nqD5sCFBkVJ VzfeXLG9iKOnGGbqPpV4YVYm/Xq84uM= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cachefs@redhat.com, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, Wanpeng Li Subject: [PATCH 29/29] io_uring: add support for getdents Date: Fri, 25 Aug 2023 21:54:31 +0800 Message-Id: <20230825135431.1317785-30-hao.xu@linux.dev> In-Reply-To: <20230825135431.1317785-1-hao.xu@linux.dev> References: <20230825135431.1317785-1-hao.xu@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: AF17620016 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: uqbbjsqxsd86ozryw6fqttssdax18iyk X-HE-Tag: 1692972443-401390 X-HE-Meta: U2FsdGVkX18+cvApabn05mNYAie6Cq/FDr4yO8HWiJf4OXZ+f/mptinafaFzkLShJm5Tz893uIEs9aXTwX0QfVCleE01DGqHPdkT9rTJ8tZnkaMdaxw40x0LTbEj4RWjQ6ln/yx36K3hYwPYdM8857g2eQdAby+QdiC5b4kApdVt5xRfCM37nC2ket5uAusOv1n37QGdkTjVMxTU4rutHKK7o9Fvw/oTO/A+3EkV5eViGAMSwpgUrUe4h8ALpyPtfLUCkRYxdNyLhXdF8yzxS/DqQjxHU8rPSnCn5BXpY5yoPLwZo+gD/pXutLPDUJkbDsJN4Wv4WqBDs6rGc59GI+GMx9OfmlYa+Yl260exxdaUc6cWp1SDQ0tBw7ehBe4Ws0kZTTACfK+xotuBueNtIVoUOFbxuyRTlLVU0m2aiHKCmPLRqSX6zaQK9FFaZKWMUdT6M9zYN11JaIWFduaRXi3Y7qm3JzY4BVazi/Jxc60FdfVSg8A5PftDjMZ5NKzy/uItpBdDg0NOb0tfb7vV1nVfA6NrLo8E36lxQBukNvPhKqhYvCUI+o/HkAjA4n702OnSjT6mZi+KF22CadtS3iIpk2eFPLMPADukUw4nU2vfz/RhzjXaUmQDmKHjNBJGOqOr7Kqw5aankecgOaHlhdG+ufjU/QPG6KuOehphXZRZctLk9FGzSIOyl16SpcFjBpBqLXKJJ2bHg4MxM0Rea7h7Z3k/PwCrclM/t5MUlp5MuNnnrRh3W3aF9P/YR0bddT1J2k9mq6sybfvyPoIOFlK0LoPthsj9Ie1O4LACRpAOULw6AXQoUC4PkW6JzL3cbUIibT7k+WlMVtOjeIxRyoecDoBfVIa7S9NHq33TzX9AceQHfFCT5vh6xdHRJS38/vkbbBNOB4DrMNG4pVpG3uGsHSbRsSuExWJHmEguTbRPRo6OprWjokOggiojGKGVY8Tz9r3u/XsA6YhI1Wo 0EEs16Zn +pcoG3hF9207lAXl1lH6m+5ukOBQ02Xr8HnyJYg1ob9QOcsLdySOfleGY8rxZzwWDTxIe8avCS/QsevYC5hOhc2cGFu81jgkfdhEd9YKyoOlCRmGTRUTJKO276tsTpRekCOCIn54neeZOjGd5n9Fb4EiM320Mohk3l3OnXa4WZoDZ3ifS5YX2Zy6+sKa9kmmN2Zcpgw2mMTAnTaTF5ThVT6iEfe5Ar43y0G6eGvca1nIKA6jsK3IX5KjcHArde2tQWc/7oy3qLdHBJzLXmUjCt8PeqzjMANZRsuS9mRkYmxVbw7A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Hao Xu This add support for getdents64 to io_uring, acting exactly like the syscall: the directory is iterated from it's current's position as stored in the file struct, and the file's position is updated exactly as if getdents64 had been called. For filesystems that support NOWAIT in iterate_shared(), try to use it first; if a user already knows the filesystem they use do not support nowait they can force async through IOSQE_ASYNC in the sqe flags, avoiding the need to bounce back through a useless EAGAIN return. Co-developed-by: Dominique Martinet Signed-off-by: Dominique Martinet Signed-off-by: Hao Xu --- include/uapi/linux/io_uring.h | 1 + io_uring/fs.c | 53 +++++++++++++++++++++++++++++++++++ io_uring/fs.h | 3 ++ io_uring/opdef.c | 8 ++++++ 4 files changed, 65 insertions(+) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 8e61f8b7c2ce..3896397a1998 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -240,6 +240,7 @@ enum io_uring_op { IORING_OP_URING_CMD, IORING_OP_SEND_ZC, IORING_OP_SENDMSG_ZC, + IORING_OP_GETDENTS, /* this goes last, obviously */ IORING_OP_LAST, diff --git a/io_uring/fs.c b/io_uring/fs.c index f6a69a549fd4..04711feac4e6 100644 --- a/io_uring/fs.c +++ b/io_uring/fs.c @@ -47,6 +47,12 @@ struct io_link { int flags; }; +struct io_getdents { + struct file *file; + struct linux_dirent64 __user *dirent; + unsigned int count; +}; + int io_renameat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct io_rename *ren = io_kiocb_to_cmd(req, struct io_rename); @@ -291,3 +297,50 @@ void io_link_cleanup(struct io_kiocb *req) putname(sl->oldpath); putname(sl->newpath); } + +int io_getdents_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) +{ + struct io_getdents *gd = io_kiocb_to_cmd(req, struct io_getdents); + + if (READ_ONCE(sqe->off)) + return -EINVAL; + + gd->dirent = u64_to_user_ptr(READ_ONCE(sqe->addr)); + gd->count = READ_ONCE(sqe->len); + + return 0; +} + +int io_getdents(struct io_kiocb *req, unsigned int issue_flags) +{ + struct io_getdents *gd = io_kiocb_to_cmd(req, struct io_getdents); + struct file *file = req->file; + unsigned long getdents_flags = 0; + bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; + bool locked; + int ret; + + if (force_nonblock) { + if (!(file->f_flags & O_NONBLOCK) && + !(file->f_mode & FMODE_NOWAIT)) + return -EAGAIN; + + getdents_flags = DIR_CONTEXT_F_NOWAIT; + } + + ret = file_pos_lock_nowait(file, force_nonblock); + if (ret == -EAGAIN) + return ret; + locked = ret; + + ret = vfs_getdents(file, gd->dirent, gd->count, getdents_flags); + if (locked) + file_pos_unlock(file); + + if (ret == -EAGAIN && force_nonblock) + return -EAGAIN; + + io_req_set_res(req, ret, 0); + return 0; +} + diff --git a/io_uring/fs.h b/io_uring/fs.h index 0bb5efe3d6bb..f83a6f3a678d 100644 --- a/io_uring/fs.h +++ b/io_uring/fs.h @@ -18,3 +18,6 @@ int io_symlinkat(struct io_kiocb *req, unsigned int issue_flags); int io_linkat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_linkat(struct io_kiocb *req, unsigned int issue_flags); void io_link_cleanup(struct io_kiocb *req); + +int io_getdents_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); +int io_getdents(struct io_kiocb *req, unsigned int issue_flags); diff --git a/io_uring/opdef.c b/io_uring/opdef.c index 3b9c6489b8b6..1bae6b2a8d0b 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -428,6 +428,11 @@ const struct io_issue_def io_issue_defs[] = { .prep = io_eopnotsupp_prep, #endif }, + [IORING_OP_GETDENTS] = { + .needs_file = 1, + .prep = io_getdents_prep, + .issue = io_getdents, + }, }; @@ -648,6 +653,9 @@ const struct io_cold_def io_cold_defs[] = { .fail = io_sendrecv_fail, #endif }, + [IORING_OP_GETDENTS] = { + .name = "GETDENTS", + }, }; const char *io_uring_get_opcode(u8 opcode)