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 684AEC433EF for ; Thu, 2 Jun 2022 08:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 011F56B0072; Thu, 2 Jun 2022 04:44:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F00F76B0073; Thu, 2 Jun 2022 04:44:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DED626B0074; Thu, 2 Jun 2022 04:44:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CF4CA6B0072 for ; Thu, 2 Jun 2022 04:44:04 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id A4882808AF for ; Thu, 2 Jun 2022 08:44:04 +0000 (UTC) X-FDA: 79532658408.20.21C788E Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf29.hostedemail.com (Postfix) with ESMTP id BA575120060 for ; Thu, 2 Jun 2022 08:43:50 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6F89721B1F; Thu, 2 Jun 2022 08:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654159442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hFYJc+foy0kL9AQh3F2/xhQWy8ou48B+B8HKY3UwAao=; b=rF1vC06UFf+8ahNW34M/a5R0s6h+SOT9rzekfmKAQKR5o0m5fT+cfrM87kxaKY6abayhCs im7mz1hzHuil+Ee/udcpBzD2vmeDLFnertXuVKq/FYbYVRvFRh6c0uMFJ4/ByBkWSu62w2 5Jzq/V6wOMoUqjvV72uhhT2BwCUuLB0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654159442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hFYJc+foy0kL9AQh3F2/xhQWy8ou48B+B8HKY3UwAao=; b=evLTtgjsj/1Qiv+nnXaQPZ2fzhM9ic9DBvG36WT/b/J1RCH555s7OCcWcztOC2Gz4pUO5x GedJZ5oRDu6pQmAQ== Received: from quack3.suse.cz (unknown [10.100.224.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3A5ED2C141; Thu, 2 Jun 2022 08:44:02 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id E4475A0633; Thu, 2 Jun 2022 10:44:01 +0200 (CEST) Date: Thu, 2 Jun 2022 10:44:01 +0200 From: Jan Kara 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, david@fromorbit.com, jack@suse.cz, hch@infradead.org, axboe@kernel.dk Subject: Re: [PATCH v7 09/15] fs: Split off inode_needs_update_time and __file_update_time Message-ID: <20220602084401.iahhjzompyn5nejx@quack3.lan> References: <20220601210141.3773402-1-shr@fb.com> <20220601210141.3773402-10-shr@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220601210141.3773402-10-shr@fb.com> Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rF1vC06U; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=evLTtgjs; dmarc=none; spf=pass (imf29.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz X-Stat-Signature: 7nbzaq1idfiohs15qkiyo6eouay6dpzu X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: BA575120060 X-HE-Tag: 1654159430-395416 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 Wed 01-06-22 14:01:35, Stefan Roesch wrote: > This splits off the functions inode_needs_update_time() and > __file_update_time() from the function file_update_time(). > > This is required to support async buffered writes. > No intended functional changes in this patch. > > Signed-off-by: Stefan Roesch Looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/inode.c | 76 +++++++++++++++++++++++++++++++++++------------------- > 1 file changed, 50 insertions(+), 26 deletions(-) > > diff --git a/fs/inode.c b/fs/inode.c > index ac1cf5aa78c8..c44573a32c6a 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -2049,35 +2049,18 @@ int file_remove_privs(struct file *file) > } > EXPORT_SYMBOL(file_remove_privs); > > -/** > - * file_update_time - update mtime and ctime time > - * @file: file accessed > - * > - * Update the mtime and ctime members of an inode and mark the inode > - * for writeback. Note that this function is meant exclusively for > - * usage in the file write path of filesystems, and filesystems may > - * choose to explicitly ignore update via this function with the > - * S_NOCMTIME inode flag, e.g. for network filesystem where these > - * timestamps are handled by the server. This can return an error for > - * file systems who need to allocate space in order to update an inode. > - */ > - > -int file_update_time(struct file *file) > +static int inode_needs_update_time(struct inode *inode, struct timespec64 *now) > { > - struct inode *inode = file_inode(file); > - struct timespec64 now; > int sync_it = 0; > - int ret; > > /* First try to exhaust all avenues to not sync */ > if (IS_NOCMTIME(inode)) > return 0; > > - now = current_time(inode); > - if (!timespec64_equal(&inode->i_mtime, &now)) > + if (!timespec64_equal(&inode->i_mtime, now)) > sync_it = S_MTIME; > > - if (!timespec64_equal(&inode->i_ctime, &now)) > + if (!timespec64_equal(&inode->i_ctime, now)) > sync_it |= S_CTIME; > > if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode)) > @@ -2086,15 +2069,50 @@ int file_update_time(struct file *file) > if (!sync_it) > return 0; > > - /* Finally allowed to write? Takes lock. */ > - if (__mnt_want_write_file(file)) > - return 0; > + return sync_it; > +} > + > +static int __file_update_time(struct file *file, struct timespec64 *now, > + int sync_mode) > +{ > + int ret = 0; > + struct inode *inode = file_inode(file); > > - ret = inode_update_time(inode, &now, sync_it); > - __mnt_drop_write_file(file); > + /* try to update time settings */ > + if (!__mnt_want_write_file(file)) { > + ret = inode_update_time(inode, now, sync_mode); > + __mnt_drop_write_file(file); > + } > > return ret; > } > + > + /** > + * file_update_time - update mtime and ctime time > + * @file: file accessed > + * > + * Update the mtime and ctime members of an inode and mark the inode for > + * writeback. Note that this function is meant exclusively for usage in > + * the file write path of filesystems, and filesystems may choose to > + * explicitly ignore updates via this function with the _NOCMTIME inode > + * flag, e.g. for network filesystem where these imestamps are handled > + * by the server. This can return an error for file systems who need to > + * allocate space in order to update an inode. > + * > + * Return: 0 on success, negative errno on failure. > + */ > +int file_update_time(struct file *file) > +{ > + int ret; > + struct inode *inode = file_inode(file); > + struct timespec64 now = current_time(inode); > + > + ret = inode_needs_update_time(inode, &now); > + if (ret <= 0) > + return ret; > + > + return __file_update_time(file, &now, ret); > +} > EXPORT_SYMBOL(file_update_time); > > /** > @@ -2111,6 +2129,8 @@ EXPORT_SYMBOL(file_update_time); > int file_modified(struct file *file) > { > int ret; > + 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. > @@ -2123,7 +2143,11 @@ int file_modified(struct file *file) > if (unlikely(file->f_mode & FMODE_NOCMTIME)) > return 0; > > - return file_update_time(file); > + ret = inode_needs_update_time(inode, &now); > + if (ret <= 0) > + return ret; > + > + return __file_update_time(file, &now, ret); > } > EXPORT_SYMBOL(file_modified); > > -- > 2.30.2 > -- Jan Kara SUSE Labs, CR