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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1CF5C04FE1 for ; Wed, 9 Aug 2023 14:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbjHIOXG (ORCPT ); Wed, 9 Aug 2023 10:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjHIOXE (ORCPT ); Wed, 9 Aug 2023 10:23:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00A5210F5; Wed, 9 Aug 2023 07:23:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7EAEF62D6B; Wed, 9 Aug 2023 14:23:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D2D2C433C7; Wed, 9 Aug 2023 14:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691590982; bh=LgXOvH2tCTHIjBx4H7FiUs60LQPWskUEsq2zDenCRXk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=d3tvC2K0q9zmSKovb3MCz70OZ0zDUfwQjvtmqpayy/+0zTCRnvBnhoitfla9mzpYS 6/IQTcAliZ/qw+jQL6ikoz6PNYzqJ5V/AqPdhloBtpJ7o+04K1HJBA1CLTORrD2v+D 7LM1T9XMRPVFf25JkonEGd6tPIqFqFkNRPbUkBuWrkC1zyTV3QcmWREwMXrZwRBWOf qlZSX+5xrbt2rURYBov8h1oSuPFEc5pUfvutsD/+H96L3ykp7YO0AtG9js4MbdLlC5 xVqrAhV0e5CphxqERFiIWxatm9vmAPUWZveD51138XqFFJM1+SpLi461h67PgiJAZz 6pxgp2dPf4+Bg== Message-ID: <7edc9239f73022b9c2a1d3f4f946153f85f94739.camel@kernel.org> Subject: Re: [PATCH v7 05/13] fat: make fat_update_time get its own timestamp From: Jeff Layton To: OGAWA Hirofumi Cc: Alexander Viro , Christian Brauner , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Chris Mason , Josef Bacik , David Sterba , Xiubo Li , Ilya Dryomov , Jan Harkes , coda@cs.cmu.edu, Tyler Hicks , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Namjae Jeon , Sungjong Seo , Jan Kara , Theodore Ts'o , Andreas Dilger , Jaegeuk Kim , Miklos Szeredi , Bob Peterson , Andreas Gruenbacher , Greg Kroah-Hartman , Tejun Heo , Trond Myklebust , Anna Schumaker , Konstantin Komarov , Mark Fasheh , Joel Becker , Joseph Qi , Mike Marshall , Martin Brandenburg , Luis Chamberlain , Kees Cook , Iurii Zaikin , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Sergey Senozhatsky , Richard Weinberger , Hans de Goede , Hugh Dickins , Andrew Morton , Amir Goldstein , "Darrick J. Wong" , Benjamin Coddington , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, codalist@telemann.coda.cs.cmu.edu, ecryptfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, ntfs3@lists.linux.dev, ocfs2-devel@lists.linux.dev, devel@lists.orangefs.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-mtd@lists.infradead.org, linux-mm@kvack.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org Date: Wed, 09 Aug 2023 10:22:54 -0400 In-Reply-To: <878rak8hia.fsf@mail.parknet.co.jp> References: <20230807-mgctime-v7-0-d1dec143a704@kernel.org> <20230807-mgctime-v7-5-d1dec143a704@kernel.org> <87msz08vc7.fsf@mail.parknet.co.jp> <52bead1d6a33fec89944b96e2ec20d1ea8747a9a.camel@kernel.org> <878rak8hia.fsf@mail.parknet.co.jp> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, 2023-08-09 at 22:36 +0900, OGAWA Hirofumi wrote: > Jeff Layton writes: >=20 > > On Wed, 2023-08-09 at 17:37 +0900, OGAWA Hirofumi wrote: > > > Jeff Layton writes: > > >=20 > > > > Also, it may be that things have changed by the time we get to call= ing > > > > fat_update_time after checking inode_needs_update_time. Ensure that= we > > > > attempt the i_version bump if any of the S_* flags besides S_ATIME = are > > > > set. > > >=20 > > > I'm not sure what it meaning though, this is from > > > generic_update_time(). Are you going to change generic_update_time() > > > too? If so, it doesn't break lazytime feature? > > >=20 > >=20 > > Yes. generic_update_time is also being changed in a similar fashion. > > This shouldn't break the lazytime feature: lazytime is all about how an= d > > when timestamps get written to disk. This work is all about which > > clocksource the timestamps originally come from. >=20 > I can only find the following update in this series, another series > updates generic_update_time()? The patch updates only if S_VERSION is > set. >=20 > Your fat patch sets I_DIRTY_SYNC always instead of I_DIRTY_TIME. When I > last time checked lazytime, and it was depending on I_DIRTY_TIME. >=20 > Are you sure it doesn't break lazytime? I'm totally confusing, and > really similar with generic_update_time()? >=20 I'm a little confused too. Why do you believe this will break -o relatime handling? This patch changes two things: 1/ it has fat_update_time fetch its own timestamp (and ignore the "now" parameter). This is in line with the changes in patch #3 of this series, which explains the rationale for this in more detail. 2/ it changes fat_update_time to also update the i_version if any of S_CTIME|S_MTIME|S_VERSION are set. relatime is all about the S_ATIME, and it is specifically excluded from that set. The rationale for the second change is is also in patch #3, but basically, we can't guarantee that current_time hasn't changed since we last checked for inode_needs_update_time, so if any of S_CTIME/S_MTIME/S_VERSION have changed, then we need to assume that any of them may need to be changed and attempt to update all 3. That said, I think the logic in fat_update_time isn't quite right. I think want something like this on top of this patch to ensure that the S_CTIME and S_MTIME get updated, even if the flags only have S_VERSION set. Thoughts? ---------------------8<----------------------- diff --git a/fs/fat/misc.c b/fs/fat/misc.c index 080a5035483f..313eef02f45c 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c @@ -346,15 +346,21 @@ int fat_update_time(struct inode *inode, int flags) if (inode->i_ino =3D=3D MSDOS_ROOT_INO) return 0; =20 - if (flags & (S_ATIME | S_CTIME | S_MTIME)) { - fat_truncate_time(inode, NULL, flags); - if (inode->i_sb->s_flags & SB_LAZYTIME) - dirty_flags |=3D I_DIRTY_TIME; - else - dirty_flags |=3D I_DIRTY_SYNC; - } + /* + * If any of the flags indicate an expicit change to the file, then= we + * need to ensure that we attempt to update all of 3. We do not do + * this in the case of an S_ATIME-only update. + */ + if (flags & (S_CTIME | S_MTIME | S_VERSION)) + flags |=3D S_CTIME | S_MTIME | S_VERSION; + + fat_truncate_time(inode, NULL, flags); + if (inode->i_sb->s_flags & SB_LAZYTIME) + dirty_flags |=3D I_DIRTY_TIME; + else + dirty_flags |=3D I_DIRTY_SYNC; =20 - if ((flags & (S_VERSION|S_CTIME|S_MTIME)) && inode_maybe_inc_iversi= on(inode, false)) + if ((flags & S_VERSION) && inode_maybe_inc_iversion(inode, false)) dirty_flags |=3D I_DIRTY_SYNC;