All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"David Sterba" <dsterba@suse.cz>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Eric Biederman" <ebiederm@xmission.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Jeremy Kerr" <jk@ozlabs.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Mattia Dongili" <malattia@linux.it>,
	"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Brad Warrum" <bwarrum@linux.ibm.com>,
	"Ritu Agarwal" <rituagar@linux.ibm.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Mark Gross" <markgross@kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Eric Van Hensbergen" <ericvh@kernel.org>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	"Dominique Martinet" <asmadeus@codewreck.org>,
	"Christian Schoenebeck" <linux_oss@crudebyte.com>,
	"David Sterba" <dsterba@suse.com>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Ian Kent" <raven@themaw.net>,
	"Luis de Bethencourt" <luisbg@kernel.org>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
	"Chris Mason" <clm@fb.com>, "Josef Bacik" <josef@toxicpanda.com>,
	"Xiubo Li" <xiubli@redhat.com>,
	"Ilya Dryomov" <idryomov@gmail.com>,
	"Jan Harkes" <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, "Joel Becker" <jlbec@evilplan.org>,
	"Christoph Hellwig" <hch@lst.de>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Gao Xiang" <xiang@kernel.org>, "Chao Yu" <chao@kernel.org>,
	"Yue Hu" <huyue2@coolpad.com>,
	"Jeffle Xu" <jefflexu@linux.alibaba.com>,
	"Namjae Jeon" <linkinjeon@kernel.org>,
	"Sungjong Seo" <sj1557.seo@samsung.com>,
	"Jan Kara" <jack@suse.com>,
	"Andreas Dilger" <adilger.kernel@dilger.ca>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"OGAWA Hirofumi" <hirofumi@mail.parknet.co.jp>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Bob Peterson" <rpeterso@redhat.com>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Muchun Song" <muchun.song@linux.dev>, "Jan Kara" <jack@suse.cz>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Dave Kleikamp" <shaggy@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Trond Myklebust" <trond.myklebust@hammerspace.com>,
	"Anna Schumaker" <anna@kernel.org>,
	"Chuck Lever" <chuck.lever@oracle.com>,
	"Neil Brown" <neilb@suse.de>,
	"Olga Kornievskaia" <kolga@netapp.com>,
	"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Anton Altaparmakov" <anton@tuxera.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Bob Copeland" <me@bobcopeland.com>,
	"Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Iurii Zaikin" <yzaikin@google.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Anders Larsen" <al@alarsen.net>,
	"Steve French" <sfrench@samba.org>,
	"Paulo Alcantara" <pc@manguebit.com>,
	"Ronnie Sahlberg" <lsahlber@redhat.com>,
	"Shyam Prasad N" <sprasad@microsoft.com>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	"Phillip Lougher" <phillip@squashfs.org.uk>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Evgeniy Dushistov" <dushistov@mail.ru>,
	"Chandan Babu R" <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <jth@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"John Johansen" <john.johansen@canonical.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Eric Paris" <eparis@parisplace.org>,
	"Kent Overstreet" <kent.overstreet@linux.dev>,
	"Brian Foster" <bfoster@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-usb@vger.kernel.org, v9fs@lists.linux.dev,
	linux-afs@lists.infradead.org, autofs@vger.kernel.org,
	linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org,
	codalist@coda.cs.cmu.edu, linux-efi@vger.kernel.org,
	linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, gfs2@lists.linux.dev,
	linux-um@lists.infradead.org, linux-mtd@lists.infradead.org,
	jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org,
	linux-nilfs@vger.kernel.org,
	linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev,
	ocfs2-devel@lists.linux.dev,
	linux-karma-devel@lists.sourceforge.net,
	devel@lists.orangefs.org, linux-unionfs@vger.kernel.org,
	linux-hardening@vger.kernel.org, reiserfs-devel@vger.kernel.org,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
	selinux@vger.kernel.org, linux-bcachefs@vger.kernel.org
Subject: [PATCH v2 01/89] fs: new accessor methods for atime and mtime
Date: Wed,  4 Oct 2023 14:52:37 -0400	[thread overview]
Message-ID: <20231004185239.80830-1-jlayton@kernel.org> (raw)
In-Reply-To: <20231004185221.80802-1-jlayton@kernel.org>

Recently, we converted the ctime accesses in the kernel to use new
accessor functions. Linus recently pointed out though that if we add
accessors for the atime and mtime, then that would allow us to
seamlessly change how these timestamps are stored in the inode.

Add new accessor functions for the atime and mtime that mirror the
accessors for the ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/libfs.c         | 41 ++++++++++++++++------
 include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 37f2d34ee090..abe2b5a40ba1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -541,7 +541,8 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -582,7 +583,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 */
 	root->i_ino = 1;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
+	simple_inode_init_ts(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -638,8 +639,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,8 +674,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -709,9 +710,10 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct inode *newino = d_inode(new_dentry);
 
-	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
 	if (new_dir != old_dir)
-		new_dir->i_mtime = inode_set_ctime_current(new_dir);
+		inode_set_mtime_to_ts(new_dir,
+				      inode_set_ctime_current(new_dir));
 	inode_set_ctime_current(d_inode(old_dentry));
 	if (newino)
 		inode_set_ctime_current(newino);
@@ -926,7 +928,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	 */
 	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -952,7 +954,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 			goto out;
 		}
 		inode->i_mode = S_IFREG | files->mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1520,7 +1522,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
@@ -1912,3 +1914,20 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 	return direct_written + buffered_written;
 }
 EXPORT_SYMBOL_GPL(direct_write_fallback);
+
+/**
+ * simple_inode_init_ts - initialize the timestamps for a new inode
+ * @inode: inode to be initialized
+ *
+ * When a new inode is created, most filesystems set the timestamps to the
+ * current time. Add a helper to do this.
+ */
+struct timespec64 simple_inode_init_ts(struct inode *inode)
+{
+	struct timespec64 ts = inode_set_ctime_current(inode);
+
+	inode_set_atime_to_ts(inode, ts);
+	inode_set_mtime_to_ts(inode, ts);
+	return ts;
+}
+EXPORT_SYMBOL(simple_inode_init_ts);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b8c6a9d52ec..3ca610d42176 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1515,24 +1515,81 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
 struct timespec64 current_time(struct inode *inode);
 struct timespec64 inode_set_ctime_current(struct inode *inode);
 
-/**
- * inode_get_ctime - fetch the current ctime from the inode
- * @inode: inode from which to fetch ctime
- *
- * Grab the current ctime from the inode and return it.
- */
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+	return inode->i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+	return inode->i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+	return inode->i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_atime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+	return inode->i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_mtime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
 	return inode->__i_ctime;
 }
 
-/**
- * inode_set_ctime_to_ts - set the ctime in the inode
- * @inode: inode in which to set the ctime
- * @ts: value to set in the ctime field
- *
- * Set the ctime in @inode to @ts
- */
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
@@ -1557,6 +1614,8 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 	return inode_set_ctime_to_ts(inode, ts);
 }
 
+struct timespec64 simple_inode_init_ts(struct inode *inode);
+
 /*
  * Snapshotting support.
  */
-- 
2.41.0


WARNING: multiple messages have this Message-ID (diff)
From: Jeff Layton <jlayton@kernel.org>
To: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"David Sterba" <dsterba@suse.cz>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Eric Biederman" <ebiederm@xmission.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Jeremy Kerr" <jk@ozlabs.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Mattia Dongili" <malattia@linux.it>,
	"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Brad Warrum" <bwarrum@linux.ibm.com>,
	"Ritu Agarwal" <rituagar@linux.ibm.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Mark Gross" <markgross@kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Eric Van Hensbergen" <ericvh@kernel.org>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	"Dominique Martinet" <asmadeus@codewreck.org>,
	"Christian Schoenebeck" <linux_oss@crudebyte.com>,
	"David Sterba" <dsterba@suse.com>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Ian Kent" <raven@themaw.net>,
	"Luis de Bethencourt" <luisbg@kernel.org>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
	"Chris Mason" <clm@fb.com>, "Josef Bacik" <josef@toxicpanda.com>,
	"Xiubo Li" <xiubli@redhat.com>,
	"Ilya Dryomov" <idryomov@gmail.com>,
	"Jan Harkes" <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, "Joel Becker" <jlbec@evilplan.org>,
	"Christoph Hellwig" <hch@lst.de>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Gao Xiang" <xiang@kernel.org>, "Chao Yu" <chao@kernel.org>,
	"Yue Hu" <huyue2@coolpad.com>,
	"Jeffle Xu" <jefflexu@linux.alibaba.com>,
	"Namjae Jeon" <linkinjeon@kernel.org>,
	"Sungjong Seo" <sj1557.seo@samsung.com>,
	"Jan Kara" <jack@suse.com>,
	"Andreas Dilger" <adilger.kernel@dilger.ca>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"OGAWA Hirofumi" <hirofumi@mail.parknet.co.jp>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Bob Peterson" <rpeterso@redhat.com>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Muchun Song" <muchun.song@linux.dev>, "Jan Kara" <jack@suse.cz>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Dave Kleikamp" <shaggy@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Trond Myklebust" <trond.myklebust@hammerspace.com>,
	"Anna Schumaker" <anna@kernel.org>,
	"Chuck Lever" <chuck.lever@oracle.com>,
	"Neil Brown" <neilb@suse.de>,
	"Olga Kornievskaia" <kolga@netapp.com>,
	"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Anton Altaparmakov" <anton@tuxera.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Bob Copeland" <me@bobcopeland.com>,
	"Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Iurii Zaikin" <yzaikin@google.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Anders Larsen" <al@alarsen.net>,
	"Steve French" <sfrench@samba.org>,
	"Paulo Alcantara" <pc@manguebit.com>,
	"Ronnie Sahlberg" <lsahlber@redhat.com>,
	"Shyam Prasad N" <sprasad@microsoft.com>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	"Phillip Lougher" <phillip@squashfs.org.uk>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Evgeniy Dushistov" <dushistov@mail.ru>,
	"Chandan Babu R" <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <jth@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"John Johansen" <john.johansen@canonical.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Eric Paris" <eparis@parisplace.org>,
	"Kent Overstreet" <kent.overstreet@linux.dev>,
	"Brian Foster" <bfoster@redhat.com>
Cc: jfs-discussion@lists.sourceforge.net, linux-efi@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, gfs2@lists.linux.dev,
	linux-mm@kvack.org, linux-mtd@lists.infradead.org,
	linux-hardening@vger.kernel.org, linux-afs@lists.infradead.org,
	linux-s390@vger.kernel.org, linux-nilfs@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-unionfs@vger.kernel.org,
	codalist@coda.cs.cmu.edu, linux-bcachefs@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-ext4@vger.kernel.org,
	devel@lists.orangefs.org, linux-trace-kernel@vger.kernel.org,
	linux-cifs@vger.kernel.org, selinux@vger.kernel.org,
	apparmor@lists.ubuntu.com, autofs@vger.kernel.org,
	linux-um@lists.infradead.org, reiserfs-devel@vger.kernel.org,
	ocfs2-devel@lists.linux.dev, ceph-devel@vger.kernel.org,
	linux-nfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net,
	linuxppc-dev@lists.ozlabs.org, v9fs@lists.linux.dev,
	linux-usb@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-xfs@vger.kernel.org, linux-security-module@vger.kernel.org,
	netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	bpf@vger.kernel.org, ntfs3@lists.linux.dev,
	linux-erofs@lists.ozlabs.org,
	linux-karma-devel@lists.sourceforge.net,
	linux-btrfs@vger.kernel.org
Subject: [f2fs-dev] [PATCH v2 01/89] fs: new accessor methods for atime and mtime
Date: Wed,  4 Oct 2023 14:52:37 -0400	[thread overview]
Message-ID: <20231004185239.80830-1-jlayton@kernel.org> (raw)
In-Reply-To: <20231004185221.80802-1-jlayton@kernel.org>

Recently, we converted the ctime accesses in the kernel to use new
accessor functions. Linus recently pointed out though that if we add
accessors for the atime and mtime, then that would allow us to
seamlessly change how these timestamps are stored in the inode.

Add new accessor functions for the atime and mtime that mirror the
accessors for the ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/libfs.c         | 41 ++++++++++++++++------
 include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 37f2d34ee090..abe2b5a40ba1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -541,7 +541,8 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -582,7 +583,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 */
 	root->i_ino = 1;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
+	simple_inode_init_ts(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -638,8 +639,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,8 +674,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -709,9 +710,10 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct inode *newino = d_inode(new_dentry);
 
-	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
 	if (new_dir != old_dir)
-		new_dir->i_mtime = inode_set_ctime_current(new_dir);
+		inode_set_mtime_to_ts(new_dir,
+				      inode_set_ctime_current(new_dir));
 	inode_set_ctime_current(d_inode(old_dentry));
 	if (newino)
 		inode_set_ctime_current(newino);
@@ -926,7 +928,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	 */
 	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -952,7 +954,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 			goto out;
 		}
 		inode->i_mode = S_IFREG | files->mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1520,7 +1522,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
@@ -1912,3 +1914,20 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 	return direct_written + buffered_written;
 }
 EXPORT_SYMBOL_GPL(direct_write_fallback);
+
+/**
+ * simple_inode_init_ts - initialize the timestamps for a new inode
+ * @inode: inode to be initialized
+ *
+ * When a new inode is created, most filesystems set the timestamps to the
+ * current time. Add a helper to do this.
+ */
+struct timespec64 simple_inode_init_ts(struct inode *inode)
+{
+	struct timespec64 ts = inode_set_ctime_current(inode);
+
+	inode_set_atime_to_ts(inode, ts);
+	inode_set_mtime_to_ts(inode, ts);
+	return ts;
+}
+EXPORT_SYMBOL(simple_inode_init_ts);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b8c6a9d52ec..3ca610d42176 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1515,24 +1515,81 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
 struct timespec64 current_time(struct inode *inode);
 struct timespec64 inode_set_ctime_current(struct inode *inode);
 
-/**
- * inode_get_ctime - fetch the current ctime from the inode
- * @inode: inode from which to fetch ctime
- *
- * Grab the current ctime from the inode and return it.
- */
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+	return inode->i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+	return inode->i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+	return inode->i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_atime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+	return inode->i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_mtime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
 	return inode->__i_ctime;
 }
 
-/**
- * inode_set_ctime_to_ts - set the ctime in the inode
- * @inode: inode in which to set the ctime
- * @ts: value to set in the ctime field
- *
- * Set the ctime in @inode to @ts
- */
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
@@ -1557,6 +1614,8 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 	return inode_set_ctime_to_ts(inode, ts);
 }
 
+struct timespec64 simple_inode_init_ts(struct inode *inode);
+
 /*
  * Snapshotting support.
  */
-- 
2.41.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jeff Layton <jlayton@kernel.org>
To: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"David Sterba" <dsterba@suse.cz>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Eric Biederman" <ebiederm@xmission.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Jeremy Kerr" <jk@ozlabs.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Mattia Dongili" <malattia@linux.it>,
	"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Brad Warrum" <bwarrum@linux.ibm.com>,
	"Ritu Agarwal" <rituagar@linux.ibm.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Mark Gross" <markgross@kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Eric Van Hensbergen" <ericvh@kernel.org>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	"Dominique Martinet" <asmadeus@codewreck.org>,
	"Christian Schoenebeck" <linux_oss@crudebyte.com>,
	"David Sterba" <dsterba@suse.com>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Ian Kent" <raven@themaw.net>,
	"Luis de Bethencourt" <luisbg@kernel.org>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
	"Chris Mason" <clm@fb.com>, "Josef Bacik" <josef@toxicpanda.com>,
	"Xiubo Li" <xiubli@redhat.com>,
	"Ilya Dryomov" <idryomov@gmail.com>,
	"Jan Harkes" <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, "Joel Becker" <jlbec@evilplan.org>,
	"Christoph Hellwig" <hch@lst.de>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Gao Xiang" <xiang@kernel.org>, "Chao Yu" <chao@kernel.org>,
	"Yue Hu" <huyue2@coolpad.com>,
	"Jeffle Xu" <jefflexu@linux.alibaba.com>,
	"Namjae Jeon" <linkinjeon@kernel.org>,
	"Sungjong Seo" <sj1557.seo@samsung.com>,
	"Jan Kara" <jack@suse.com>,
	"Andreas Dilger" <adilger.kernel@dilger.ca>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"OGAWA Hirofumi" <hirofumi@mail.parknet.co.jp>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Bob Peterson" <rpeterso@redhat.com>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Muchun Song" <muchun.song@linux.dev>, "Jan Kara" <jack@suse.cz>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Dave Kleikamp" <shaggy@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Trond Myklebust" <trond.myklebust@hammerspace.com>,
	"Anna Schumaker" <anna@kernel.org>,
	"Chuck Lever" <chuck.lever@oracle.com>,
	"Neil Brown" <neilb@suse.de>,
	"Olga Kornievskaia" <kolga@netapp.com>,
	"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Anton Altaparmakov" <anton@tuxera.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Bob Copeland" <me@bobcopeland.com>,
	"Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Iurii Zaikin" <yzaikin@google.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Anders Larsen" <al@alarsen.net>,
	"Steve French" <sfrench@samba.org>,
	"Paulo Alcantara" <pc@manguebit.com>,
	"Ronnie Sahlberg" <lsahlber@redhat.com>,
	"Shyam Prasad N" <sprasad@microsoft.com>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	"Phillip Lougher" <phillip@squashfs.org.uk>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Evgeniy Dushistov" <dushistov@mail.ru>,
	"Chandan Babu R" <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <jth@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"John Johansen" <john.johansen@canonical.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Eric Paris" <eparis@parisplace.org>,
	"Kent Overstreet" <kent.overstreet@linux.dev>,
	"Brian Foster" <bfoster@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-usb@vger.kernel.org, v9fs@lists.linux.dev,
	linux-afs@lists.infradead.org, autofs@vger.kernel.org,
	linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org,
	codalist@coda.cs.cmu.edu, linux-efi@vger.kernel.org,
	linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, gfs2@lists.linux.dev,
	linux-um@lists.infradead.org, linux-mtd@lists.infradead.org,
	jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org,
	linux-nilfs@vger.kernel.org,
	linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev,
	ocfs2-devel@lists.linux.dev,
	linux-karma-devel@lists.sourceforge.net,
	devel@lists.orangefs.org, linux-unionfs@vger.kernel.org,
	linux-hardening@vger.kernel.org, reiserfs-devel@vger.kernel.org,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
	selinux@vger.kernel.org, linux-bcachefs@vger.kernel.org
Subject: [PATCH v2 01/89] fs: new accessor methods for atime and mtime
Date: Wed,  4 Oct 2023 14:52:37 -0400	[thread overview]
Message-ID: <20231004185239.80830-1-jlayton@kernel.org> (raw)
In-Reply-To: <20231004185221.80802-1-jlayton@kernel.org>

Recently, we converted the ctime accesses in the kernel to use new
accessor functions. Linus recently pointed out though that if we add
accessors for the atime and mtime, then that would allow us to
seamlessly change how these timestamps are stored in the inode.

Add new accessor functions for the atime and mtime that mirror the
accessors for the ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/libfs.c         | 41 ++++++++++++++++------
 include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 37f2d34ee090..abe2b5a40ba1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -541,7 +541,8 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -582,7 +583,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 */
 	root->i_ino = 1;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
+	simple_inode_init_ts(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -638,8 +639,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,8 +674,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -709,9 +710,10 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct inode *newino = d_inode(new_dentry);
 
-	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
 	if (new_dir != old_dir)
-		new_dir->i_mtime = inode_set_ctime_current(new_dir);
+		inode_set_mtime_to_ts(new_dir,
+				      inode_set_ctime_current(new_dir));
 	inode_set_ctime_current(d_inode(old_dentry));
 	if (newino)
 		inode_set_ctime_current(newino);
@@ -926,7 +928,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	 */
 	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -952,7 +954,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 			goto out;
 		}
 		inode->i_mode = S_IFREG | files->mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1520,7 +1522,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
@@ -1912,3 +1914,20 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 	return direct_written + buffered_written;
 }
 EXPORT_SYMBOL_GPL(direct_write_fallback);
+
+/**
+ * simple_inode_init_ts - initialize the timestamps for a new inode
+ * @inode: inode to be initialized
+ *
+ * When a new inode is created, most filesystems set the timestamps to the
+ * current time. Add a helper to do this.
+ */
+struct timespec64 simple_inode_init_ts(struct inode *inode)
+{
+	struct timespec64 ts = inode_set_ctime_current(inode);
+
+	inode_set_atime_to_ts(inode, ts);
+	inode_set_mtime_to_ts(inode, ts);
+	return ts;
+}
+EXPORT_SYMBOL(simple_inode_init_ts);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b8c6a9d52ec..3ca610d42176 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1515,24 +1515,81 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
 struct timespec64 current_time(struct inode *inode);
 struct timespec64 inode_set_ctime_current(struct inode *inode);
 
-/**
- * inode_get_ctime - fetch the current ctime from the inode
- * @inode: inode from which to fetch ctime
- *
- * Grab the current ctime from the inode and return it.
- */
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+	return inode->i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+	return inode->i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+	return inode->i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_atime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+	return inode->i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_mtime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
 	return inode->__i_ctime;
 }
 
-/**
- * inode_set_ctime_to_ts - set the ctime in the inode
- * @inode: inode in which to set the ctime
- * @ts: value to set in the ctime field
- *
- * Set the ctime in @inode to @ts
- */
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
@@ -1557,6 +1614,8 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 	return inode_set_ctime_to_ts(inode, ts);
 }
 
+struct timespec64 simple_inode_init_ts(struct inode *inode);
+
 /*
  * Snapshotting support.
  */
-- 
2.41.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Jeff Layton <jlayton@kernel.org>
To: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"David Sterba" <dsterba@suse.cz>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Eric Biederman" <ebiederm@xmission.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Jeremy Kerr" <jk@ozlabs.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Mattia Dongili" <malattia@linux.it>,
	"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Brad Warrum" <bwarrum@linux.ibm.com>,
	"Ritu Agarwal" <rituagar@linux.ibm.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Mark Gross" <markgross@kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Eric Van Hensbergen" <ericvh@kernel.org>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	"Dominique Martinet" <asmadeus@codewreck.org>,
	"Christian Schoenebeck" <linux_oss@crudebyte.com>,
	"David Sterba" <dsterba@suse.com>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Ian Kent" <raven@themaw.net>,
	"Luis de Bethencourt" <luisbg@kernel.org>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
	"Chris Mason" <clm@fb.com>, "Josef Bacik" <josef@toxicpanda.com>,
	"Xiubo Li" <xiubli@redhat.com>,
	"Ilya Dryomov" <idryomov@gmail.com>,
	"Jan Harkes" <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, "Joel Becker" <jlbec@evilplan.org>,
	"Christoph Hellwig" <hch@lst.de>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Gao Xiang" <xiang@kernel.org>, "Chao Yu" <chao@kernel.org>,
	"Yue Hu" <huyue2@coolpad.com>,
	"Jeffle Xu" <jefflexu@linux.alibaba.com>,
	"Namjae Jeon" <linkinjeon@kernel.org>,
	"Sungjong Seo" <sj1557.seo@samsung.com>,
	"Jan Kara" <jack@suse.com>,
	"Andreas Dilger" <adilger.kernel@dilger.ca>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"OGAWA Hirofumi" <hirofumi@mail.parknet.co.jp>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Bob Peterson" <rpeterso@redhat.com>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Muchun Song" <muchun.song@linux.dev>, "Jan Kara" <jack@suse.cz>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Dave Kleikamp" <shaggy@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Trond Myklebust" <trond.myklebust@hammerspace.com>,
	"Anna Schumaker" <anna@kernel.org>,
	"Chuck Lever" <chuck.lever@oracle.com>,
	"Neil Brown" <neilb@suse.de>,
	"Olga Kornievskaia" <kolga@netapp.com>,
	"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Anton Altaparmakov" <anton@tuxera.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Bob Copeland" <me@bobcopeland.com>,
	"Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Iurii Zaikin" <yzaikin@google.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Anders Larsen" <al@alarsen.net>,
	"Steve French" <sfrench@samba.org>,
	"Paulo Alcantara" <pc@manguebit.com>,
	"Ronnie Sahlberg" <lsahlber@redhat.com>,
	"Shyam Prasad N" <sprasad@microsoft.com>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	"Phillip Lougher" <phillip@squashfs.org.uk>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Evgeniy Dushistov" <dushistov@mail.ru>,
	"Chandan Babu R" <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <jth@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"John Johansen" <john.johansen@canonical.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Eric Paris" <eparis@parisplace.org>,
	"Kent Overstreet" <kent.overstreet@linux.dev>,
	"Brian Foster" <bfoster@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-usb@vger.kernel.org, v9fs@lists.linux.dev,
	linux-afs@lists.infradead.org, autofs@vger.kernel.org,
	linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org,
	codalist@coda.cs.cmu.edu, linux-efi@vger.kernel.org,
	linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, gfs2@lists.linux.dev,
	linux-um@lists.infradead.org, linux-mtd@lists.infradead.org,
	jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org,
	linux-nilfs@vger.kernel.org,
	linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev,
	ocfs2-devel@lists.linux.dev,
	linux-karma-devel@lists.sourceforge.net,
	devel@lists.orangefs.org, linux-unionfs@vger.kernel.org,
	linux-hardening@vger.kernel.org, reiserfs-devel@vger.kernel.org,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
	selinux@vger.kernel.org, linux-bcachefs@vger.kernel.org
Subject: [PATCH v2 01/89] fs: new accessor methods for atime and mtime
Date: Wed,  4 Oct 2023 14:52:37 -0400	[thread overview]
Message-ID: <20231004185239.80830-1-jlayton@kernel.org> (raw)
In-Reply-To: <20231004185221.80802-1-jlayton@kernel.org>

Recently, we converted the ctime accesses in the kernel to use new
accessor functions. Linus recently pointed out though that if we add
accessors for the atime and mtime, then that would allow us to
seamlessly change how these timestamps are stored in the inode.

Add new accessor functions for the atime and mtime that mirror the
accessors for the ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/libfs.c         | 41 ++++++++++++++++------
 include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 37f2d34ee090..abe2b5a40ba1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -541,7 +541,8 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -582,7 +583,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 */
 	root->i_ino = 1;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
+	simple_inode_init_ts(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -638,8 +639,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,8 +674,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -709,9 +710,10 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct inode *newino = d_inode(new_dentry);
 
-	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
 	if (new_dir != old_dir)
-		new_dir->i_mtime = inode_set_ctime_current(new_dir);
+		inode_set_mtime_to_ts(new_dir,
+				      inode_set_ctime_current(new_dir));
 	inode_set_ctime_current(d_inode(old_dentry));
 	if (newino)
 		inode_set_ctime_current(newino);
@@ -926,7 +928,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	 */
 	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -952,7 +954,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 			goto out;
 		}
 		inode->i_mode = S_IFREG | files->mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1520,7 +1522,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
@@ -1912,3 +1914,20 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 	return direct_written + buffered_written;
 }
 EXPORT_SYMBOL_GPL(direct_write_fallback);
+
+/**
+ * simple_inode_init_ts - initialize the timestamps for a new inode
+ * @inode: inode to be initialized
+ *
+ * When a new inode is created, most filesystems set the timestamps to the
+ * current time. Add a helper to do this.
+ */
+struct timespec64 simple_inode_init_ts(struct inode *inode)
+{
+	struct timespec64 ts = inode_set_ctime_current(inode);
+
+	inode_set_atime_to_ts(inode, ts);
+	inode_set_mtime_to_ts(inode, ts);
+	return ts;
+}
+EXPORT_SYMBOL(simple_inode_init_ts);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b8c6a9d52ec..3ca610d42176 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1515,24 +1515,81 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
 struct timespec64 current_time(struct inode *inode);
 struct timespec64 inode_set_ctime_current(struct inode *inode);
 
-/**
- * inode_get_ctime - fetch the current ctime from the inode
- * @inode: inode from which to fetch ctime
- *
- * Grab the current ctime from the inode and return it.
- */
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+	return inode->i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+	return inode->i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+	return inode->i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_atime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+	return inode->i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_mtime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
 	return inode->__i_ctime;
 }
 
-/**
- * inode_set_ctime_to_ts - set the ctime in the inode
- * @inode: inode in which to set the ctime
- * @ts: value to set in the ctime field
- *
- * Set the ctime in @inode to @ts
- */
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
@@ -1557,6 +1614,8 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 	return inode_set_ctime_to_ts(inode, ts);
 }
 
+struct timespec64 simple_inode_init_ts(struct inode *inode);
+
 /*
  * Snapshotting support.
  */
-- 
2.41.0


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

WARNING: multiple messages have this Message-ID (diff)
From: Jeff Layton <jlayton@kernel.org>
To: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"David Sterba" <dsterba@suse.cz>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Eric Biederman" <ebiederm@xmission.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Jeremy Kerr" <jk@ozlabs.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Mattia Dongili" <malattia@linux.it>,
	"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Brad Warrum" <bwarrum@linux.ibm.com>,
	"Ritu Agarwal" <rituagar@linux.ibm.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Mark Gross" <markgross@kernel.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Eric Van Hensbergen" <ericvh@kernel.org>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	"Dominique Martinet" <asmadeus@codewreck.org>,
	"Christian Schoenebeck" <linux_oss@crudebyte.com>,
	"David Sterba" <dsterba@suse.com>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Ian Kent" <raven@themaw.net>,
	"Luis de Bethencourt" <luisbg@kernel.org>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Tigran A. Aivazian" <aivazian.tigran@gmail.com>,
	"Chris Mason" <clm@fb.com>, "Josef Bacik" <josef@toxicpanda.com>,
	"Xiubo Li" <xiubli@redhat.com>,
	"Ilya Dryomov" <idryomov@gmail.com>,
	"Jan Harkes" <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, "Joel Becker" <jlbec@evilplan.org>,
	"Christoph Hellwig" <hch@lst.de>,
	"Nicolas Pitre" <nico@fluxnic.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Gao Xiang" <xiang@kernel.org>, "Chao Yu" <chao@kernel.org>,
	"Yue Hu" <huyue2@coolpad.com>,
	"Jeffle Xu" <jefflexu@linux.alibaba.com>,
	"Namjae Jeon" <linkinjeon@kernel.org>,
	"Sungjong Seo" <sj1557.seo@samsung.com>,
	"Jan Kara" <jack@suse.com>,
	"Andreas Dilger" <adilger.kernel@dilger.ca>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"OGAWA Hirofumi" <hirofumi@mail.parknet.co.jp>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Bob Peterson" <rpeterso@redhat.com>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
	"Mike Kravetz" <mike.kravetz@oracle.com>,
	"Muchun Song" <muchun.song@linux.dev>, "Jan Kara" <jack@suse.cz>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Dave Kleikamp" <shaggy@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Trond Myklebust" <trond.myklebust@hammerspace.com>,
	"Anna Schumaker" <anna@kernel.org>,
	"Chuck Lever" <chuck.lever@oracle.com>,
	"Neil Brown" <neilb@suse.de>,
	"Olga Kornievskaia" <kolga@netapp.com>,
	"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Anton Altaparmakov" <anton@tuxera.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Bob Copeland" <me@bobcopeland.com>,
	"Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Iurii Zaikin" <yzaikin@google.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Anders Larsen" <al@alarsen.net>,
	"Steve French" <sfrench@samba.org>,
	"Paulo Alcantara" <pc@manguebit.com>,
	"Ronnie Sahlberg" <lsahlber@redhat.com>,
	"Shyam Prasad N" <sprasad@microsoft.com>,
	"Sergey Senozhatsky" <senozhatsky@chromium.org>,
	"Phillip Lougher" <phillip@squashfs.org.uk>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Evgeniy Dushistov" <dushistov@mail.ru>,
	"Chandan Babu R" <chandan.babu@oracle.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <jth@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"John Johansen" <john.johansen@canonical.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Eric Paris" <eparis@parisplace.org>,
	"Kent Overstreet" <kent.overstreet@linux.dev>,
	"Brian Foster" <bfoster@redhat.com>
Cc: jfs-discussion@lists.sourceforge.net, linux-efi@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, gfs2@lists.linux.dev,
	linux-mm@kvack.org, linux-mtd@lists.infradead.org,
	linux-hardening@vger.kernel.org, linux-afs@lists.infradead.org,
	linux-s390@vger.kernel.org, linux-nilfs@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-unionfs@vger.kernel.org,
	codalist@coda.cs.cmu.edu, linux-bcachefs@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-ext4@vger.kernel.org,
	devel@lists.orangefs.org, linux-trace-kernel@vger.kernel.org,
	linux-cifs@vger.kernel.org, selinux@vger.kernel.org,
	apparmor@lists.ubuntu.com, autofs@vger.kernel.org,
	linux-um@lists.infradead.org, reiserfs-devel@vger.kernel.org,
	ocfs2-devel@lists.linux.dev, ceph-devel@vger.kernel.org,
	linux-nfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net,
	linuxppc-dev@lists.ozlabs.org, v9fs@lists.linux.dev,
	linux-usb@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourcef orge.net,
	linux-xfs@vger.kernel.org, linux-security-module@vger.kernel.org,
	netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	bpf@vger.kernel.org, ntfs3@lists.linux.dev,
	linux-erofs@lists.ozlabs.org,
	linux-karma-devel@lists.sourceforge.net,
	linux-btrfs@vger.kernel.org
Subject: [PATCH v2 01/89] fs: new accessor methods for atime and mtime
Date: Wed,  4 Oct 2023 14:52:37 -0400	[thread overview]
Message-ID: <20231004185239.80830-1-jlayton@kernel.org> (raw)
In-Reply-To: <20231004185221.80802-1-jlayton@kernel.org>

Recently, we converted the ctime accesses in the kernel to use new
accessor functions. Linus recently pointed out though that if we add
accessors for the atime and mtime, then that would allow us to
seamlessly change how these timestamps are stored in the inode.

Add new accessor functions for the atime and mtime that mirror the
accessors for the ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/libfs.c         | 41 ++++++++++++++++------
 include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 37f2d34ee090..abe2b5a40ba1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -541,7 +541,8 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -582,7 +583,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 */
 	root->i_ino = 1;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
+	simple_inode_init_ts(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -638,8 +639,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,8 +674,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -709,9 +710,10 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct inode *newino = d_inode(new_dentry);
 
-	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
 	if (new_dir != old_dir)
-		new_dir->i_mtime = inode_set_ctime_current(new_dir);
+		inode_set_mtime_to_ts(new_dir,
+				      inode_set_ctime_current(new_dir));
 	inode_set_ctime_current(d_inode(old_dentry));
 	if (newino)
 		inode_set_ctime_current(newino);
@@ -926,7 +928,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	 */
 	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -952,7 +954,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 			goto out;
 		}
 		inode->i_mode = S_IFREG | files->mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1520,7 +1522,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
@@ -1912,3 +1914,20 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 	return direct_written + buffered_written;
 }
 EXPORT_SYMBOL_GPL(direct_write_fallback);
+
+/**
+ * simple_inode_init_ts - initialize the timestamps for a new inode
+ * @inode: inode to be initialized
+ *
+ * When a new inode is created, most filesystems set the timestamps to the
+ * current time. Add a helper to do this.
+ */
+struct timespec64 simple_inode_init_ts(struct inode *inode)
+{
+	struct timespec64 ts = inode_set_ctime_current(inode);
+
+	inode_set_atime_to_ts(inode, ts);
+	inode_set_mtime_to_ts(inode, ts);
+	return ts;
+}
+EXPORT_SYMBOL(simple_inode_init_ts);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b8c6a9d52ec..3ca610d42176 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1515,24 +1515,81 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
 struct timespec64 current_time(struct inode *inode);
 struct timespec64 inode_set_ctime_current(struct inode *inode);
 
-/**
- * inode_get_ctime - fetch the current ctime from the inode
- * @inode: inode from which to fetch ctime
- *
- * Grab the current ctime from the inode and return it.
- */
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+	return inode->i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+	return inode->i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+	return inode->i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_atime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+	return inode->i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_mtime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
 	return inode->__i_ctime;
 }
 
-/**
- * inode_set_ctime_to_ts - set the ctime in the inode
- * @inode: inode in which to set the ctime
- * @ts: value to set in the ctime field
- *
- * Set the ctime in @inode to @ts
- */
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
@@ -1557,6 +1614,8 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 	return inode_set_ctime_to_ts(inode, ts);
 }
 
+struct timespec64 simple_inode_init_ts(struct inode *inode);
+
 /*
  * Snapshotting support.
  */
-- 
2.41.0


  parent reply	other threads:[~2023-10-04 18:52 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
2023-10-04 18:52 ` Jeff Layton
2023-10-04 18:52 ` Jeff Layton
2023-10-04 18:52 ` Jeff Layton
2023-10-04 18:52 ` [f2fs-dev] " Jeff Layton
2023-10-04 18:51 ` [PATCH v2 03/89] spufs: convert to new timestamp accessors Jeff Layton
2023-10-04 18:51   ` Jeff Layton
2023-10-04 18:51   ` [PATCH v2 04/89] hypfs: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 05/89] android: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 06/89] char: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 07/89] qib: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 08/89] ibmasm: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 09/89] misc: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 10/89] x86: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 11/89] tty: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 12/89] function: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 13/89] legacy: " Jeff Layton
2023-10-04 18:51   ` [PATCH v2 14/89] usb: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 15/89] 9p: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 16/89] adfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 17/89] affs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 18/89] afs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 19/89] autofs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 20/89] bcachefs: " Jeff Layton
2023-10-05 12:08     ` Brian Foster
2023-10-04 18:52   ` [PATCH v2 21/89] befs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 22/89] bfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 23/89] btrfs: " Jeff Layton
2023-10-09 16:53     ` David Sterba
2023-10-04 18:52   ` [PATCH v2 24/89] ceph: " Jeff Layton
2023-10-07  1:25     ` Xiubo Li
2023-10-04 18:52   ` [PATCH v2 25/89] coda: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 26/89] configfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 27/89] cramfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 28/89] debugfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 29/89] devpts: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 30/89] efivarfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 31/89] efs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 32/89] erofs: " Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52   ` [PATCH v2 33/89] exfat: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 34/89] ext2: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 35/89] ext4: " Jeff Layton
2023-10-04 18:52   ` [f2fs-dev] [PATCH v2 36/89] f2fs: " Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52   ` [PATCH v2 37/89] fat: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 38/89] freevxfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 39/89] fuse: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 40/89] gfs2: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 41/89] hfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 42/89] hfsplus: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 43/89] hostfs: " Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52   ` [PATCH v2 44/89] hpfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 45/89] hugetlbfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 46/89] isofs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 47/89] jffs2: " Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52   ` [PATCH v2 48/89] jfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 49/89] kernfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 50/89] minix: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 51/89] nfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 52/89] nfsd: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 53/89] nilfs2: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 54/89] ntfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 55/89] ntfs3: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 56/89] ocfs2: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 57/89] omfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 58/89] openpromfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 59/89] orangefs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 60/89] overlayfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 61/89] proc: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 62/89] pstore: " Jeff Layton
2023-10-04 19:07     ` Kees Cook
2023-10-04 18:52   ` [PATCH v2 63/89] qnx4: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 64/89] qnx6: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 65/89] ramfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 66/89] reiserfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 67/89] romfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 68/89] client: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 69/89] server: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 70/89] squashfs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 71/89] sysv: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 72/89] tracefs: " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 73/89] ubifs: " Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52   ` [PATCH v2 74/89] udf: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 75/89] ufs: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 76/89] vboxsf: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 77/89] xfs: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 78/89] zonefs: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 79/89] linux: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 80/89] ipc: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 81/89] bpf: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 82/89] mm: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 83/89] sunrpc: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 84/89] apparmor: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 85/89] selinux: " Jeff Layton
2023-10-04 18:53   ` [PATCH v2 86/89] security: " Jeff Layton
2023-10-04 18:52 ` Jeff Layton [this message]
2023-10-04 18:52   ` [PATCH v2 01/89] fs: new accessor methods for atime and mtime Jeff Layton
2023-10-04 18:52   ` Jeff Layton
2023-10-04 18:52   ` Jeff Layton
2023-10-04 18:52   ` [f2fs-dev] " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52     ` Jeff Layton
2023-10-04 18:52     ` [f2fs-dev] " Jeff Layton
2023-10-09 16:09 ` [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Christian Brauner
2023-10-09 16:09   ` Christian Brauner
2023-10-09 16:09   ` Christian Brauner
2023-10-09 16:09   ` Christian Brauner
2023-10-09 16:09   ` Christian Brauner
2023-10-09 16:09   ` [f2fs-dev] " Christian Brauner
2023-11-01  3:41 [PATCH v2,01/89] fs: new accessor methods for " Yuezhang.Mo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231004185239.80830-1-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=agordeev@linux.ibm.com \
    --cc=agruenba@redhat.com \
    --cc=aivazian.tigran@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=al@alarsen.net \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=amir73il@gmail.com \
    --cc=andrii@kernel.org \
    --cc=anna@kernel.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=anton@tuxera.com \
    --cc=apparmor@lists.ubuntu.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arve@android.com \
    --cc=asmadeus@codewreck.org \
    --cc=ast@kernel.org \
    --cc=autofs@vger.kernel.org \
    --cc=bfoster@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=bwarrum@linux.ibm.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=chandan.babu@oracle.com \
    --cc=chao@kernel.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=chuck.lever@oracle.com \
    --cc=clm@fb.com \
    --cc=cmllamas@google.com \
    --cc=coda@cs.cmu.edu \
    --cc=codalist@coda.cs.cmu.edu \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=devel@lists.orangefs.org \
    --cc=dhowells@redhat.com \
    --cc=djwong@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=dushistov@mail.ru \
    --cc=dwmw2@infradead.org \
    --cc=ebiederm@xmission.com \
    --cc=edumazet@google.com \
    --cc=eparis@parisplace.org \
    --cc=ericvh@kernel.org \
    --cc=gfs2@lists.linux.dev \
    --cc=gor@linux.ibm.com \
    --cc=gpiccoli@igalia.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haoluo@google.com \
    --cc=hca@linux.ibm.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=hdegoede@redhat.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=hubcap@omnibond.com \
    --cc=hughd@google.com \
    --cc=huyue2@coolpad.com \
    --cc=idryomov@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=jaharkes@cs.cmu.edu \
    --cc=jefflexu@linux.alibaba.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jgg@ziepe.ca \
    --cc=jirislaby@kernel.org \
    --cc=jk@ozlabs.org \
    --cc=jlbec@evilplan.org \
    --cc=jmorris@namei.org \
    --cc=joel@joelfernandes.org \
    --cc=johannes@sipsolutions.net \
    --cc=john.fastabend@gmail.com \
    --cc=john.johansen@canonical.com \
    --cc=jolsa@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=jth@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kent.overstreet@linux.dev \
    --cc=kolga@netapp.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-karma-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lsahlber@redhat.com \
    --cc=lucho@ionkov.net \
    --cc=luisbg@kernel.org \
    --cc=maco@android.com \
    --cc=malattia@linux.it \
    --cc=marc.dionne@auristor.com \
    --cc=mark@fasheh.com \
    --cc=markgross@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=martin@omnibond.com \
    --cc=mcgrof@kernel.org \
    --cc=me@bobcopeland.com \
    --cc=mhiramat@kernel.org \
    --cc=mike.kravetz@oracle.com \
    --cc=miklos@szeredi.hu \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=mpe@ellerman.id.au \
    --cc=muchun.song@linux.dev \
    --cc=naohiro.aota@wdc.com \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=nico@fluxnic.net \
    --cc=npiggin@gmail.com \
    --cc=ntfs3@lists.linux.dev \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=pc@manguebit.com \
    --cc=phillip@squashfs.org.uk \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=raven@themaw.net \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=rituagar@linux.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=rpeterso@redhat.com \
    --cc=salah.triki@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sdf@google.com \
    --cc=selinux@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=serge@hallyn.com \
    --cc=sfrench@samba.org \
    --cc=shaggy@kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=song@kernel.org \
    --cc=sprasad@microsoft.com \
    --cc=stephen.smalley.work@gmail.com \
    --cc=surenb@google.com \
    --cc=svens@linux.ibm.com \
    --cc=tj@kernel.org \
    --cc=tkjos@android.com \
    --cc=tom@talpey.com \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=trond.myklebust@hammerspace.com \
    --cc=tytso@mit.edu \
    --cc=v9fs@lists.linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiang@kernel.org \
    --cc=xiubli@redhat.com \
    --cc=yonghong.song@linux.dev \
    --cc=yzaikin@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.