From mboxrd@z Thu Jan 1 00:00:00 1970 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF937C83F35 for ; Tue, 29 Aug 2023 08:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693298479; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=epfMkrQolroQNBpOg6y64aVsi28tc37lZ8Fvv6H8WuQ=; b=MHc8XrF7JjdA1/uqelRb+2JEfDljA5Kia2uoT+L+c9idr1F49+49/tEudF8mUB442XFCBl DTpNicoAuJptx95MvCifev6+mSmItCm1jZNQ3BxkyGx0QqTdzU7tQbt+qnYpaylSHTPwqU kK03ldPmQ13l9j3KXVt24Go7hSMZ3MM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-446-SdL8H1NvMrKR5gnCoiLC8Q-1; Tue, 29 Aug 2023 04:41:15 -0400 X-MC-Unique: SdL8H1NvMrKR5gnCoiLC8Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD7C6823D71; Tue, 29 Aug 2023 08:41:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2FCD6B292; Tue, 29 Aug 2023 08:41:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 885791946A41; Tue, 29 Aug 2023 08:41:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A7B1719465A8 for ; Fri, 25 Aug 2023 14:05:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 924AE6B59A; Fri, 25 Aug 2023 14:05:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B7F16B59E for ; Fri, 25 Aug 2023 14:05:26 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BE683801BCA for ; Fri, 25 Aug 2023 14:05:26 +0000 (UTC) Received: from out-248.mta1.migadu.com (out-248.mta1.migadu.com [95.215.58.248]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-467-TTkb5fM6MkmQoQkT_eeV7w-1; Fri, 25 Aug 2023 10:05:23 -0400 X-MC-Unique: TTkb5fM6MkmQoQkT_eeV7w-1 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe 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-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mailman-Approved-At: Tue, 29 Aug 2023 08:41:07 +0000 Subject: [Cluster-devel] [PATCH 25/29] xfs: support nowait for xfs_buf_item_init() X-BeenThere: cluster-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: "\[Cluster devel\]" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , "Darrick J . Wong" , Dominique Martinet , Dave Chinner , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Stefan Roesch , Clay Harris , linux-s390@vger.kernel.org, linux-nilfs@vger.kernel.org, codalist@coda.cs.cmu.edu, cluster-devel@redhat.com, linux-cachefs@redhat.com, linux-ext4@vger.kernel.org, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-block@vger.kernel.org, Alexander Viro , Christian Brauner , netdev@vger.kernel.org, samba-technical@lists.samba.org, linux-unionfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org, bpf@vger.kernel.org, Pavel Begunkov , linux-btrfs@vger.kernel.org Errors-To: cluster-devel-bounces@redhat.com Sender: "Cluster-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="US-ASCII"; x-default=true 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( =09struct xfs_buf=09*bp, -=09struct xfs_mount *mp) +=09struct xfs_mount *mp, +=09bool nowait) { =09struct xfs_buf_log_item=09*bip =3D bp->b_log_item; =09int=09=09=09chunks; @@ -847,7 +848,11 @@ xfs_buf_item_init( =09=09return 0; =09} =20 -=09bip =3D kmem_cache_zalloc(xfs_buf_item_cache, GFP_KERNEL | __GFP_NOFAIL= ); +=09bip =3D kmem_cache_zalloc(xfs_buf_item_cache, +=09=09=09=09GFP_KERNEL | (nowait ? 0 : __GFP_NOFAIL)); +=09if (!bip) +=09=09return -EAGAIN; + =09xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops); =09bip->bli_buf =3D bp; =20 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 { =09struct xfs_buf_log_format __bli_format;=09/* embedded in-log header */ }; =20 -int=09xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); +int=09xfs_buf_item_init(struct xfs_buf *bp, struct xfs_mount *mp, bool now= ait); void=09xfs_buf_item_done(struct xfs_buf *bp); void=09xfs_buf_item_relse(struct xfs_buf *); bool=09xfs_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( =09=09struct xfs_buf_log_item=09*bip; =20 =09=09bp->b_flags |=3D _XBF_LOGRECOVERY; -=09=09xfs_buf_item_init(bp, mp); +=09=09xfs_buf_item_init(bp, mp, false); =09=09bip =3D bp->b_log_item; =09=09bip->bli_item.li_lsn =3D current_lsn; =09} 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( =09struct xfs_trans=09*tp, =09struct xfs_buf=09=09*bp, =09int=09=09=09reset_recur) { =09struct xfs_buf_log_item=09*bip; +=09int ret; =20 =09ASSERT(bp->b_transp =3D=3D NULL); =20 @@ -72,7 +73,11 @@ _xfs_trans_bjoin( =09 * it doesn't have one yet, then allocate one and initialize it. =09 * The checks to see if one is there are in xfs_buf_item_init(). =09 */ -=09xfs_buf_item_init(bp, tp->t_mountp); +=09ret =3D xfs_buf_item_init(bp, tp->t_mountp, +=09=09=09=09tp->t_flags & XFS_TRANS_NOWAIT); +=09if (ret < 0) +=09=09return ret; + =09bip =3D bp->b_log_item; =09ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); =09ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL)); @@ -92,6 +97,7 @@ _xfs_trans_bjoin( =09xfs_trans_add_item(tp, &bip->bli_item); =09bp->b_transp =3D tp; =20 +=09return 0; } =20 void @@ -309,7 +315,11 @@ xfs_trans_read_buf_map( =09} =20 =09if (tp) { -=09=09_xfs_trans_bjoin(tp, bp, 1); +=09=09error =3D _xfs_trans_bjoin(tp, bp, 1); +=09=09if (error) { +=09=09=09xfs_buf_relse(bp); +=09=09=09return error; +=09=09} =09=09trace_xfs_trans_read_buf(bp->b_log_item); =09} =09ASSERT(bp->b_ops !=3D NULL || ops =3D=3D NULL); --=20 2.25.1