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 9F090C43334 for ; Wed, 1 Jun 2022 21:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbiFAVIL (ORCPT ); Wed, 1 Jun 2022 17:08:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbiFAVIL (ORCPT ); Wed, 1 Jun 2022 17:08:11 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA394CD6D for ; Wed, 1 Jun 2022 14:08:09 -0700 (PDT) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 251KQDXj028690 for ; Wed, 1 Jun 2022 14:08:09 -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=nQH2lmMMGXtJ/jcy4qJSIzXTyuwO7PWxs6HFqy0bsS4=; b=lGs5wtkaRUSFoIsEjC46E4CLsggKbpn3Ugw4yPQahhmLhNYdKNW2ovbSiE6EpKoMz/4R wW6nkR5bi8GfWfc56GP4JxT9IrjDDBOkF9mB2Ju5/E0bpwV8aEOsYHoq+uO3RxKZRuCY g7qXpKCKi4r7eq9pHSSNqC6EHfbdmNlqhOs= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3gdt5jqgua-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 01 Jun 2022 14:08:08 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 1 Jun 2022 14:08:08 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 1CA19FEB23B3; Wed, 1 Jun 2022 14:01:43 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , , , Christoph Hellwig Subject: [PATCH v7 15/15] xfs: Add async buffered write support Date: Wed, 1 Jun 2022 14:01:41 -0700 Message-ID: <20220601210141.3773402-16-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601210141.3773402-1-shr@fb.com> References: <20220601210141.3773402-1-shr@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: BwEN7fmGkP0uIfgaug9k9g0p3sounaR2 X-Proofpoint-ORIG-GUID: BwEN7fmGkP0uIfgaug9k9g0p3sounaR2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-01_08,2022-06-01_01,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 Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_file.c | 11 +++++------ fs/xfs/xfs_iomap.c | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index a60632ecc3f0..4d65ff007c7d 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -410,7 +410,7 @@ xfs_file_write_checks( spin_unlock(&ip->i_flags_lock); =20 out: - return file_modified(file); + return kiocb_modified(iocb); } =20 static int @@ -700,12 +700,11 @@ xfs_file_buffered_write( bool cleared_space =3D false; unsigned 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(iocb, iolock); + if (ret) + return ret; =20 ret =3D xfs_file_write_checks(iocb, from, &iolock); if (ret) @@ -1165,7 +1164,7 @@ xfs_file_open( { if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; - file->f_mode |=3D FMODE_NOWAIT | FMODE_BUF_RASYNC; + file->f_mode |=3D FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC; return generic_file_open(inode, file); } =20 diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index bcf7c3694290..5d50fed291b4 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -886,6 +886,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; @@ -897,7 +898,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