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 1B139C433FE for ; Thu, 28 Apr 2022 21:54:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 515E46B0071; Thu, 28 Apr 2022 17:54:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C5A06B0072; Thu, 28 Apr 2022 17:54:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38DCA6B0073; Thu, 28 Apr 2022 17:54:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 2A38A6B0071 for ; Thu, 28 Apr 2022 17:54:46 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EE02F2AC90 for ; Thu, 28 Apr 2022 21:54:45 +0000 (UTC) X-FDA: 79407642930.16.EB80EBE Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by imf23.hostedemail.com (Postfix) with ESMTP id C6899140063 for ; Thu, 28 Apr 2022 21:54:38 +0000 (UTC) Received: from dread.disaster.area (pa49-180-32-1.pa.nsw.optusnet.com.au [49.180.32.1]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id CA0F810E5E76; Fri, 29 Apr 2022 07:54:43 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1nkC5y-005hah-7B; Fri, 29 Apr 2022 07:54:42 +1000 Date: Fri, 29 Apr 2022 07:54:42 +1000 From: Dave Chinner To: Stefan Roesch Cc: io-uring@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC PATCH v1 11/18] xfs: add async buffered write support Message-ID: <20220428215442.GW1098723@dread.disaster.area> References: <20220426174335.4004987-1-shr@fb.com> <20220426174335.4004987-12-shr@fb.com> <20220426225652.GS1544202@dread.disaster.area> <30f2920c-5262-7cb0-05b5-6e84a76162a7@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <30f2920c-5262-7cb0-05b5-6e84a76162a7@fb.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=VuxAv86n c=1 sm=1 tr=0 ts=626b0d24 a=0Ysg4n7SwsYHWQMxibB6iw==:117 a=0Ysg4n7SwsYHWQMxibB6iw==:17 a=kj9zAlcOel0A:10 a=z0gMJWrwH1QA:10 a=FOH2dFAWAAAA:8 a=7-415B0cAAAA:8 a=VUOJFI46L-dW_0rXThcA:9 a=CjuIK1q_8ugA:10 a=i3VuKzQdj-NEYjvDI-p3:22 a=biEYGPWJfzWAr4FL6Ov7:22 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C6899140063 X-Stat-Signature: ewowcs7afr93h47aenbhmy6ywbjkgxpi X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=none; spf=none (imf23.hostedemail.com: domain of david@fromorbit.com has no SPF policy when checking 211.29.132.249) smtp.mailfrom=david@fromorbit.com; dmarc=none X-HE-Tag: 1651182878-824530 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: On Thu, Apr 28, 2022 at 12:58:59PM -0700, Stefan Roesch wrote: > > > On 4/26/22 3:56 PM, Dave Chinner wrote: > > On Tue, Apr 26, 2022 at 10:43:28AM -0700, Stefan Roesch wrote: > >> 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 | 10 ++++++---- > >> 1 file changed, 6 insertions(+), 4 deletions(-) > >> > >> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > >> index 6f9da1059e8b..49d54b939502 100644 > >> --- a/fs/xfs/xfs_file.c > >> +++ b/fs/xfs/xfs_file.c > >> @@ -739,12 +739,14 @@ 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); > >> + if (iocb->ki_flags & IOCB_NOWAIT) { > >> + if (!xfs_ilock_nowait(ip, iolock)) > >> + return -EAGAIN; > >> + } else { > >> + xfs_ilock(ip, iolock); > >> + } > > > > xfs_ilock_iocb(). > > > > The helper xfs_ilock_iocb cannot be used as it hardcoded to use iocb->ki_filp to > get a pointer to the xfs_inode. And the problem with that is? I mean, look at what xfs_file_buffered_write() does to get the xfs_inode 10 lines about that change: xfs_file_buffered_write( struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; struct address_space *mapping = file->f_mapping; struct inode *inode = mapping->host; struct xfs_inode *ip = XFS_I(inode); In what cases does file_inode(iocb->ki_filp) point to a different inode than iocb->ki_filp->f_mapping->host? The dio write path assumes that file_inode(iocb->ki_filp) is correct, as do both the buffered and dio read paths. What makes the buffered write path special in that file_inode(iocb->ki_filp) is not correctly set whilst iocb->ki_filp->f_mapping->host is? Regardless, if this is a problem, then just pass the XFS inode to xfs_ilock_iocb() and this is a moot point. > However here we need to use iocb->ki_filp->f_mapping->host. > I'll split off new helper for this in the next version of the patch. We don't need a new helper here, either. Cheers, Dave. -- Dave Chinner david@fromorbit.com