Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4596399rwb; Tue, 8 Aug 2023 10:41:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHarfJK7TtDCuUmnP7QcaCDsPm9g1MthkAHUQv8rmJ7dO9JJjuYYY3JQeQhr1z2om/xAmRR X-Received: by 2002:a05:6a20:3ca9:b0:13b:7533:6839 with SMTP id b41-20020a056a203ca900b0013b75336839mr248418pzj.29.1691516490464; Tue, 08 Aug 2023 10:41:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691516490; cv=none; d=google.com; s=arc-20160816; b=mfI502+HltXFIieUjqzA3m/hRSaBBeyln7K97OWfBbjokmK1Bl6ECyvl9sGdgcU6CP 7LI/4koO5OgrdfRYBd4lD4c8W25qfNQ7CH7LUJjvS+lbo2tAdfDc5jSPc8Gi5btE/1Vs xVnK41rlVC2jnnDcAqZyjGQEuPDLlkhsbUzec7wY46jJ9fp9PhM/X+rCf89E3CqI/N73 0uZP9lvPZ5PJw3LJtLZ7EF4ieap8gQeYnxEknTqYHY5RtrvASmEMZ9Gyb2y+aFzYVm4i mSrR+BNpmX3O8Pq/b4zbQnnbKmshLtao7sHlD/TwqayVdYLKiCVZ++GR93bPXGGUdDeS sGDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=cOTJYjkBLnwjV/lxEVtUyReuFAMisDvl/3KW3rcsa80=; fh=VDS1Ji1Jg94b8HYa+h+b069MTX7Y1JPYBeWAMaZH+VI=; b=aKdPJZc/m3BenHNGp6JmNDYhYfwY3B11wYU11D292GoiJBCUkbLZ6Iddz36mp8vRLU 9JrRz33O4CCeFhV7DeCbcrFAndHSxDaOHR9YE5Rl29odM9zeCAxk02uP4eefI4FyozF+ TO6SGBwFRvw+ysYUpGBGN063eWRqXVtgXfXqkwT8SyFRl6cjw00g4DJds2ZUFZkLITOP bZRS2ckiJvcJmeMpussTNmCMyMaPUX9eUMd7/VGrV11uOHVRs6Ua2/WK9Bdz3S20W2bX 9o7tc1Q1fuMu6SioZ1gBt7191BfJEvx+Cr3v9K2kMu+OfMmEg+NjjXenaHqBq1x3RQul 7eQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=RYwrn0fd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=3BwMkd6c; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a056a0008c200b0068288aaf240si7676613pfu.212.2023.08.08.10.41.11; Tue, 08 Aug 2023 10:41:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=RYwrn0fd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=3BwMkd6c; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234011AbjHHRIC (ORCPT + 99 others); Tue, 8 Aug 2023 13:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234110AbjHHRHQ (ORCPT ); Tue, 8 Aug 2023 13:07:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 959AE1BC3; Tue, 8 Aug 2023 09:02:57 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3FF9421C09; Tue, 8 Aug 2023 10:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691489158; 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=cOTJYjkBLnwjV/lxEVtUyReuFAMisDvl/3KW3rcsa80=; b=RYwrn0fdjwhhRR7l27SfhU6sEIZlfDKsRmqY6BlBC/mbMQlEPGtvhbIdRr7h8egn/oN8yh Oz6U9UuTleHENrCE1avR3NSOn0guqcLSLu7iBXijjb70nxn/BQDxhjUWhk7QvvA5/v4PB8 VNLrqst7KIs78O2ejOjXiqcNSNVttFQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691489158; 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=cOTJYjkBLnwjV/lxEVtUyReuFAMisDvl/3KW3rcsa80=; b=3BwMkd6c3zAZ5/EGX3xW7irKJimW+k7SoacxDa/XvD8/WW5BAqfXsGAeW7PnSgHdphBpnB 7inqEIuyeW8nM7Cw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2554713451; Tue, 8 Aug 2023 10:05:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9iarCIYT0mRwKwAAMHmgww (envelope-from ); Tue, 08 Aug 2023 10:05:58 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9F18AA0769; Tue, 8 Aug 2023 12:05:57 +0200 (CEST) Date: Tue, 8 Aug 2023 12:05:57 +0200 From: Jan Kara To: Jeff Layton 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 , OGAWA Hirofumi , 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@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 Subject: Re: [PATCH v7 13/13] btrfs: convert to multigrain timestamps Message-ID: <20230808100557.dowlxz2destpseqr@quack3> References: <20230807-mgctime-v7-0-d1dec143a704@kernel.org> <20230807-mgctime-v7-13-d1dec143a704@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230807-mgctime-v7-13-d1dec143a704@kernel.org> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon 07-08-23 15:38:44, Jeff Layton wrote: > Enable multigrain timestamps, which should ensure that there is an > apparent change to the timestamp whenever it has been written after > being actively observed via getattr. > > Beyond enabling the FS_MGTIME flag, this patch eliminates > update_time_for_write, which goes to great pains to avoid in-memory > stores. Just have it overwrite the timestamps unconditionally. > > Signed-off-by: Jeff Layton > Acked-by: David Sterba Looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/btrfs/file.c | 24 ++++-------------------- > fs/btrfs/super.c | 5 +++-- > 2 files changed, 7 insertions(+), 22 deletions(-) > > diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c > index d7a9ece7a40b..b9e75c9f95ac 100644 > --- a/fs/btrfs/file.c > +++ b/fs/btrfs/file.c > @@ -1106,25 +1106,6 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode) > btrfs_drew_write_unlock(&inode->root->snapshot_lock); > } > > -static void update_time_for_write(struct inode *inode) > -{ > - struct timespec64 now, ctime; > - > - if (IS_NOCMTIME(inode)) > - return; > - > - now = current_time(inode); > - if (!timespec64_equal(&inode->i_mtime, &now)) > - inode->i_mtime = now; > - > - ctime = inode_get_ctime(inode); > - if (!timespec64_equal(&ctime, &now)) > - inode_set_ctime_to_ts(inode, now); > - > - if (IS_I_VERSION(inode)) > - inode_inc_iversion(inode); > -} > - > static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, > size_t count) > { > @@ -1156,7 +1137,10 @@ static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, > * need to start yet another transaction to update the inode as we will > * update the inode when we finish writing whatever data we write. > */ > - update_time_for_write(inode); > + if (!IS_NOCMTIME(inode)) { > + inode->i_mtime = inode_set_ctime_current(inode); > + inode_inc_iversion(inode); > + } > > start_pos = round_down(pos, fs_info->sectorsize); > oldsize = i_size_read(inode); > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index f1dd172d8d5b..8eda51b095c9 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -2144,7 +2144,7 @@ static struct file_system_type btrfs_fs_type = { > .name = "btrfs", > .mount = btrfs_mount, > .kill_sb = btrfs_kill_super, > - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA, > + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_MGTIME, > }; > > static struct file_system_type btrfs_root_fs_type = { > @@ -2152,7 +2152,8 @@ static struct file_system_type btrfs_root_fs_type = { > .name = "btrfs", > .mount = btrfs_mount_root, > .kill_sb = btrfs_kill_super, > - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_ALLOW_IDMAP, > + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | > + FS_ALLOW_IDMAP | FS_MGTIME, > }; > > MODULE_ALIAS_FS("btrfs"); > > -- > 2.41.0 > -- Jan Kara SUSE Labs, CR