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 80F88C433F5 for ; Tue, 26 Apr 2022 22:55:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1019F6B0075; Tue, 26 Apr 2022 18:55:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B21F6B0078; Tue, 26 Apr 2022 18:55:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBB966B007B; Tue, 26 Apr 2022 18:55:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id DE6BC6B0075 for ; Tue, 26 Apr 2022 18:55:22 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BEA2D61365 for ; Tue, 26 Apr 2022 22:55:22 +0000 (UTC) X-FDA: 79400538084.01.D38EB53 Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by imf25.hostedemail.com (Postfix) with ESMTP id B8CABA0042 for ; Tue, 26 Apr 2022 22:55:14 +0000 (UTC) Received: from dread.disaster.area (pa49-195-62-197.pa.nsw.optusnet.com.au [49.195.62.197]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id C2E635358F5; Wed, 27 Apr 2022 08:55:20 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1njU5X-004vXS-6A; Wed, 27 Apr 2022 08:55:19 +1000 Date: Wed, 27 Apr 2022 08:55:19 +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 10/18] xfs: Enable async write file modification handling. Message-ID: <20220426225519.GR1544202@dread.disaster.area> References: <20220426174335.4004987-1-shr@fb.com> <20220426174335.4004987-11-shr@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220426174335.4004987-11-shr@fb.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=e9dl9Yl/ c=1 sm=1 tr=0 ts=62687858 a=KhGSFSjofVlN3/cgq4AT7A==:117 a=KhGSFSjofVlN3/cgq4AT7A==:17 a=kj9zAlcOel0A:10 a=z0gMJWrwH1QA:10 a=FOH2dFAWAAAA:8 a=7-415B0cAAAA:8 a=MVNmPsfJR0OwgcQHr6QA:9 a=CjuIK1q_8ugA:10 a=i3VuKzQdj-NEYjvDI-p3:22 a=biEYGPWJfzWAr4FL6Ov7:22 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B8CABA0042 X-Stat-Signature: ncxwku3j14buy48mqyo7nu3o71kgxhgk X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=none; spf=none (imf25.hostedemail.com: domain of david@fromorbit.com has no SPF policy when checking 211.29.132.246) smtp.mailfrom=david@fromorbit.com; dmarc=none X-HE-Tag: 1651013714-395882 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 Tue, Apr 26, 2022 at 10:43:27AM -0700, Stefan Roesch wrote: > This modifies xfs write checks to return -EAGAIN if the request either > requires to remove privileges or needs to update the file modification > time. This is required for async buffered writes, so the request gets > handled in the io worker. > > Signed-off-by: Stefan Roesch > --- > fs/xfs/xfs_file.c | 39 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 5bddb1e9e0b3..6f9da1059e8b 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -299,6 +299,43 @@ xfs_file_read_iter( > return ret; > } > > +static int xfs_file_modified(struct file *file, int flags) > +{ > + int ret; > + struct dentry *dentry = file_dentry(file); > + struct inode *inode = file_inode(file); > + struct timespec64 now = current_time(inode); > + > + /* > + * Clear the security bits if the process is not being run by root. > + * This keeps people from modifying setuid and setgid binaries. > + */ > + ret = need_file_remove_privs(inode, dentry); > + if (ret < 0) { > + return ret; > + } else if (ret > 0) { > + if (flags & IOCB_NOWAIT) > + return -EAGAIN; > + > + ret = do_file_remove_privs(file, inode, dentry, ret); > + if (ret) > + return ret; > + } > + > + ret = need_file_update_time(inode, file, &now); > + if (ret <= 0) > + return ret; > + if (flags & IOCB_NOWAIT) { > + if (IS_PENDING_TIME(inode)) > + return 0; > + > + inode->i_flags |= S_PENDING_TIME; > + return -EAGAIN; > + } > + > + return do_file_update_time(inode, file, &now, ret); > +} This has nothing XFS specific in it. It belongs in the VFS code. -Dave. -- Dave Chinner david@fromorbit.com