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+EVvSi2NVAYc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CkUuGTmyX2n0I3LXjv0F0gMHCH6DNhVgL/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;