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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6DC1C433EF for ; Mon, 16 May 2022 16:48:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0CEA6B0078; Mon, 16 May 2022 12:48:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E95E06B007B; Mon, 16 May 2022 12:48:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D36166B007D; Mon, 16 May 2022 12:48:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C04566B0078 for ; Mon, 16 May 2022 12:48:38 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 96FEB81463 for ; Mon, 16 May 2022 16:48:38 +0000 (UTC) X-FDA: 79472189916.25.B66A387 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf30.hostedemail.com (Postfix) with ESMTP id 9F46B800C0 for ; Mon, 16 May 2022 16:48:15 +0000 (UTC) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GB5rPa007155 for ; Mon, 16 May 2022 09:48:36 -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=uSExTQp1mBOLjPITMmOyzTZ7pNScVBnQfYVTQnZots8=; b=lX7WyPky4+6RmHxwMJhWHxziMfeLQPlhWLW0+Iy8pVp9hLOSyewUNVkfgnfC/MX21S/7 0dlyIJmb0jGgXMPpXFzdN0iZHIIdb1KjTjOu8C/M5U+pz6+6asR5sX1tDjah5D06udbz Y8F92H7pHwS4vQTxFA3ZrMcAxbwsHyVM/tU= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g27rnu22b-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 May 2022 09:48:36 -0700 Received: from twshared6696.05.ash7.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 09:48:35 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 58101F146DD9; Mon, 16 May 2022 09:48:25 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v2 05/16] xfs: add iomap async buffered write support Date: Mon, 16 May 2022 09:47:07 -0700 Message-ID: <20220516164718.2419891-6-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220516164718.2419891-1-shr@fb.com> References: <20220516164718.2419891-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: XiaFRhqbJcxSaEITWJDNJxbIcSfUkT7o X-Proofpoint-GUID: XiaFRhqbJcxSaEITWJDNJxbIcSfUkT7o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-16_15,2022-05-16_02,2022-02-23_01 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9F46B800C0 X-Stat-Signature: f7m7drzudbi8689xyynrpor6uxrbxsx3 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=lX7WyPky; spf=none (imf30.hostedemail.com: domain of "prvs=61354da864=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=61354da864=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652719695-944400 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: This adds the async buffered write support to the iomap layer of XFS. If a lock cannot be acquired or additional reads need to be performed, the request will return -EAGAIN in case this is an async buffered write reque= st. This patch changes the helper function xfs_ilock_for_iomap such that the lock mode needs to be passed in. Signed-off-by: Stefan Roesch --- fs/xfs/xfs_iomap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index e552ce541ec2..1aea962262ad 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -659,7 +659,7 @@ xfs_ilock_for_iomap( unsigned flags, unsigned *lockmode) { - unsigned mode =3D XFS_ILOCK_SHARED; + unsigned int mode =3D *lockmode; bool is_write =3D flags & (IOMAP_WRITE | IOMAP_ZERO); =20 /* @@ -737,7 +737,7 @@ xfs_direct_write_iomap_begin( int nimaps =3D 1, error =3D 0; bool shared =3D false; u16 iomap_flags =3D 0; - unsigned lockmode; + unsigned int lockmode =3D XFS_ILOCK_SHARED; =20 ASSERT(flags & (IOMAP_WRITE | IOMAP_ZERO)); =20 @@ -881,18 +881,22 @@ 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; =20 /* we can't use delayed allocations when using extent size hints */ - if (xfs_get_extsz_hint(ip)) + if (xfs_get_extsz_hint(ip)) { return xfs_direct_write_iomap_begin(inode, offset, count, flags, iomap, srcmap); + } =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)) { @@ -1167,7 +1171,7 @@ xfs_read_iomap_begin( xfs_fileoff_t end_fsb =3D xfs_iomap_end_fsb(mp, offset, length); int nimaps =3D 1, error =3D 0; bool shared =3D false; - unsigned lockmode; + unsigned int lockmode =3D XFS_ILOCK_SHARED; =20 ASSERT(!(flags & (IOMAP_WRITE | IOMAP_ZERO))); =20 --=20 2.30.2