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; }