From patchwork Wed May 18 23:37:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12854315 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 97CC9C433F5 for ; Wed, 18 May 2022 23:37:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1E548D0003; Wed, 18 May 2022 19:37:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C31A38D0002; Wed, 18 May 2022 19:37:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A85178D0003; Wed, 18 May 2022 19:37:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8995A8D0002 for ; Wed, 18 May 2022 19:37:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 58C13209B8 for ; Wed, 18 May 2022 23:37:45 +0000 (UTC) X-FDA: 79480478490.27.3139FAB Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf09.hostedemail.com (Postfix) with ESMTP id 44B0B1400B4 for ; Wed, 18 May 2022 23:37:34 +0000 (UTC) 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 24IN6AdS017366 for ; Wed, 18 May 2022 16:37:43 -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=LWT7/rgVKJvUBvBuLFTZOcg1EE8pCJNmk5mdhmfBzd4=; b=i6RESA2kBFbZf2YcYKS9NClp2rdwS4z3e5YrkTDrp5aQB3JPLVdlytwpVGLaoojFgIFG fOUNWAAU+p9M23iJxh3uuhMsjYlkvF+SRyBlyCNt0jLDi1Sv6Nr8XAD0gZrBAN1rVLay VV1wCr4qjitYxB6F7cIAO1jZh82uTcaZ7Ec= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3g4ck0m9vj-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 18 May 2022 16:37:43 -0700 Received: from twshared4937.07.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 18 May 2022 16:37:38 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id E5A10F3ED865; Wed, 18 May 2022 16:37:12 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , Subject: [RFC PATCH v3 10/18] xfs: Add async buffered write support Date: Wed, 18 May 2022 16:37:01 -0700 Message-ID: <20220518233709.1937634-11-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220518233709.1937634-1-shr@fb.com> References: <20220518233709.1937634-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 39jxkjlEg_w9Y_TQmB2EdhBJpZAxw0Nx X-Proofpoint-ORIG-GUID: 39jxkjlEg_w9Y_TQmB2EdhBJpZAxw0Nx 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-18_06,2022-05-17_02,2022-02-23_01 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 44B0B1400B4 X-Stat-Signature: whibgrnobsgn3ysxpgix341owg455kuh Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=i6RESA2k; spf=none (imf09.hostedemail.com: domain of "prvs=6137e46c81=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=6137e46c81=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-HE-Tag: 1652917054-496985 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 XFS. For async buffered write requests, the request will return -EAGAIN if the ilock cannot be obtained immediately. This splits off a new helper xfs_ilock_inode from the existing helper xfs_ilock_iocb so it can be used for this function. The exising helper cannot be used as it hardcoded the inode to be used. Signed-off-by: Stefan Roesch --- fs/xfs/xfs_file.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 793918c83755..ad3175b7d366 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -190,14 +190,13 @@ xfs_file_fsync( return error; } -static int -xfs_ilock_iocb( - struct kiocb *iocb, +static inline int +xfs_ilock_xfs_inode( + struct xfs_inode *ip, + int flags, unsigned int lock_mode) { - struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); - - if (iocb->ki_flags & IOCB_NOWAIT) { + if (flags & IOCB_NOWAIT) { if (!xfs_ilock_nowait(ip, lock_mode)) return -EAGAIN; } else { @@ -222,7 +221,7 @@ xfs_file_dio_read( file_accessed(iocb->ki_filp); - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, XFS_IOLOCK_SHARED); if (ret) return ret; ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, 0, 0); @@ -244,7 +243,7 @@ xfs_file_dax_read( if (!iov_iter_count(to)) return 0; /* skip atime */ - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, XFS_IOLOCK_SHARED); if (ret) return ret; ret = dax_iomap_rw(iocb, to, &xfs_read_iomap_ops); @@ -264,7 +263,7 @@ xfs_file_buffered_read( trace_xfs_file_buffered_read(iocb, to); - ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, XFS_IOLOCK_SHARED); if (ret) return ret; ret = generic_file_read_iter(iocb, to); @@ -343,7 +342,7 @@ xfs_file_write_checks( if (*iolock == XFS_IOLOCK_SHARED && !IS_NOSEC(inode)) { xfs_iunlock(ip, *iolock); *iolock = XFS_IOLOCK_EXCL; - error = xfs_ilock_iocb(iocb, *iolock); + error = xfs_ilock_xfs_inode(ip, iocb->ki_flags, *iolock); if (error) { *iolock = 0; return error; @@ -516,7 +515,7 @@ xfs_file_dio_write_aligned( int iolock = XFS_IOLOCK_SHARED; ssize_t ret; - ret = xfs_ilock_iocb(iocb, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); if (ret) return ret; ret = xfs_file_write_checks(iocb, from, &iolock); @@ -583,7 +582,7 @@ xfs_file_dio_write_unaligned( flags = IOMAP_DIO_FORCE_WAIT; } - ret = xfs_ilock_iocb(iocb, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); if (ret) return ret; @@ -659,7 +658,7 @@ xfs_file_dax_write( ssize_t ret, error = 0; loff_t pos; - ret = xfs_ilock_iocb(iocb, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); if (ret) return ret; ret = xfs_file_write_checks(iocb, from, &iolock); @@ -702,12 +701,11 @@ xfs_file_buffered_write( bool cleared_space = false; int iolock; - if (iocb->ki_flags & IOCB_NOWAIT) - return -EOPNOTSUPP; - write_retry: iolock = XFS_IOLOCK_EXCL; - xfs_ilock(ip, iolock); + ret = xfs_ilock_xfs_inode(ip, iocb->ki_flags, iolock); + if (ret) + return ret; ret = xfs_file_write_checks(iocb, from, &iolock); if (ret)