From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_SOFTFAIL,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9725C433EF for ; Thu, 26 May 2022 17:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348340AbiEZRjb (ORCPT ); Thu, 26 May 2022 13:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348372AbiEZRj0 (ORCPT ); Thu, 26 May 2022 13:39:26 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D23AA76E7 for ; Thu, 26 May 2022 10:39:22 -0700 (PDT) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24QBRjtP009001 for ; Thu, 26 May 2022 10:39:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=xrXV6DDKAu8edht2TcHb7XC2Tqf/DAsX1r3VS5rTvoo=; b=W1pwgmeBz/Gu6rpwaqvVbg9pNPeWiUxgi5QOSJePV8Z01xqfpKqNcIoh/NmwFo6dn4cl Q/dhdBUxR2bv5Ani5aB0STfoquRD3YVnC8NNw2KkBng1W3B+rY2IeBelDLlQZ9iz1bSt +7SJdd5HXqXDs0vxWEJ7pWhuNBaZK1Lzl7U= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3ga8puth7u-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 26 May 2022 10:39:21 -0700 Received: from twshared10560.18.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 26 May 2022 10:39:20 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id B2369FA621EA; Thu, 26 May 2022 10:38:45 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , Subject: [PATCH v6 15/16] xfs: Add async buffered write support Date: Thu, 26 May 2022 10:38:39 -0700 Message-ID: <20220526173840.578265-16-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220526173840.578265-1-shr@fb.com> References: <20220526173840.578265-1-shr@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: ZLurzw2OEvCGoCc2rGjDqlCZsXZDOq4m X-Proofpoint-GUID: ZLurzw2OEvCGoCc2rGjDqlCZsXZDOq4m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-26_09,2022-05-25_02,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This adds the async buffered write support to XFS. For async buffered write requests, the request will return -EAGAIN if the ilock cannot be obtained immediately. Signed-off-by: Stefan Roesch --- fs/xfs/xfs_file.c | 9 ++++----- fs/xfs/xfs_iomap.c | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 50dea07f5e56..e9d615f4c209 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -409,7 +409,7 @@ xfs_file_write_checks( spin_unlock(&ip->i_flags_lock); =20 out: - return file_modified(file); + return kiocb_modified(iocb); } =20 static int @@ -701,12 +701,11 @@ xfs_file_buffered_write( bool cleared_space =3D false; int iolock; =20 - if (iocb->ki_flags & IOCB_NOWAIT) - return -EOPNOTSUPP; - write_retry: iolock =3D XFS_IOLOCK_EXCL; - xfs_ilock(ip, iolock); + ret =3D xfs_ilock_iocb(ip, iocb->ki_flags, iolock); + if (ret) + return ret; =20 ret =3D xfs_file_write_checks(iocb, from, &iolock); if (ret) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 3aa60e53a181..af8c50140f0f 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -881,6 +881,7 @@ xfs_buffered_write_iomap_begin( bool eof =3D false, cow_eof =3D false, shared =3D false; int allocfork =3D XFS_DATA_FORK; int error =3D 0; + unsigned int lockmode =3D XFS_ILOCK_EXCL; =20 if (xfs_is_shutdown(mp)) return -EIO; @@ -892,7 +893,9 @@ xfs_buffered_write_iomap_begin( =20 ASSERT(!XFS_IS_REALTIME_INODE(ip)); =20 - xfs_ilock(ip, XFS_ILOCK_EXCL); + error =3D xfs_ilock_for_iomap(ip, flags, &lockmode); + if (error) + return error; =20 if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) || XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) { --=20 2.30.2