linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 34/89] ext2: convert to new timestamp accessors
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
@ 2023-10-04 18:52   ` Jeff Layton
  2023-10-04 18:52   ` [PATCH v2 35/89] ext4: " Jeff Layton
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, linux-fsdevel, linux-kernel; +Cc: linux-ext4

Convert to using the new inode timestamp accessor functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ext2/dir.c    |  6 +++---
 fs/ext2/ialloc.c |  2 +-
 fs/ext2/inode.c  | 13 ++++++-------
 fs/ext2/super.c  |  2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index b335f17f682f..c7900868171b 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -468,7 +468,7 @@ int ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
 	ext2_set_de_type(de, inode);
 	ext2_commit_chunk(page, pos, len);
 	if (update_times)
-		dir->i_mtime = inode_set_ctime_current(dir);
+		inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 	EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
 	mark_inode_dirty(dir);
 	return ext2_handle_dirsync(dir);
@@ -555,7 +555,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
 	de->inode = cpu_to_le32(inode->i_ino);
 	ext2_set_de_type (de, inode);
 	ext2_commit_chunk(page, pos, rec_len);
-	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 	EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
 	mark_inode_dirty(dir);
 	err = ext2_handle_dirsync(dir);
@@ -606,7 +606,7 @@ int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page)
 		pde->rec_len = ext2_rec_len_to_disk(to - from);
 	dir->inode = 0;
 	ext2_commit_chunk(page, pos, to - from);
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
 	mark_inode_dirty(inode);
 	return ext2_handle_dirsync(inode);
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index c24d0de95a83..fdf63e9c6e7c 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -546,7 +546,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode,
 
 	inode->i_ino = ino;
 	inode->i_blocks = 0;
-	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	memset(ei->i_data, 0, sizeof(ei->i_data));
 	ei->i_flags =
 		ext2_mask_flags(mode, EXT2_I(dir)->i_flags & EXT2_FL_INHERITED);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 314b415ee518..464faf6c217e 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1291,7 +1291,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize)
 	__ext2_truncate_blocks(inode, newsize);
 	filemap_invalidate_unlock(inode->i_mapping);
 
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	if (inode_needs_sync(inode)) {
 		sync_mapping_buffers(inode->i_mapping);
 		sync_inode_metadata(inode, 1);
@@ -1412,10 +1412,9 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	i_gid_write(inode, i_gid);
 	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
 	inode->i_size = le32_to_cpu(raw_inode->i_size);
-	inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
+	inode_set_atime(inode, (signed)le32_to_cpu(raw_inode->i_atime), 0);
 	inode_set_ctime(inode, (signed)le32_to_cpu(raw_inode->i_ctime), 0);
-	inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime);
-	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 0;
+	inode_set_mtime(inode, (signed)le32_to_cpu(raw_inode->i_mtime), 0);
 	ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
 	/* We now have enough fields to check if the inode was active or not.
 	 * This is needed because nfsd might try to access dead inodes
@@ -1544,9 +1543,9 @@ static int __ext2_write_inode(struct inode *inode, int do_sync)
 	}
 	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
 	raw_inode->i_size = cpu_to_le32(inode->i_size);
-	raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
-	raw_inode->i_ctime = cpu_to_le32(inode_get_ctime(inode).tv_sec);
-	raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
+	raw_inode->i_atime = cpu_to_le32(inode_get_atime_sec(inode));
+	raw_inode->i_ctime = cpu_to_le32(inode_get_ctime_sec(inode));
+	raw_inode->i_mtime = cpu_to_le32(inode_get_mtime_sec(inode));
 
 	raw_inode->i_blocks = cpu_to_le32(inode->i_blocks);
 	raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index aaf3e3e88cb2..645ee6142f69 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1572,7 +1572,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type,
 	if (inode->i_size < off+len-towrite)
 		i_size_write(inode, off+len-towrite);
 	inode_inc_iversion(inode);
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	mark_inode_dirty(inode);
 	return len - towrite;
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 35/89] ext4: convert to new timestamp accessors
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
  2023-10-04 18:52   ` [PATCH v2 34/89] ext2: convert to new timestamp accessors Jeff Layton
@ 2023-10-04 18:52   ` Jeff Layton
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, linux-fsdevel, linux-kernel; +Cc: linux-ext4

Convert to using the new inode timestamp accessor functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ext4/ext4.h    | 20 +++++++++++++++-----
 fs/ext4/extents.c | 11 ++++++-----
 fs/ext4/ialloc.c  |  4 ++--
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   | 19 ++++++++++---------
 fs/ext4/ioctl.c   | 13 +++++++++++--
 fs/ext4/namei.c   | 10 +++++-----
 fs/ext4/super.c   |  2 +-
 fs/ext4/xattr.c   |  8 ++++----
 9 files changed, 56 insertions(+), 35 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 380c5a267d27..180b8c5fe021 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -891,10 +891,13 @@ do {										\
 		(raw_inode)->xtime = cpu_to_le32(clamp_t(int32_t, (ts).tv_sec, S32_MIN, S32_MAX));	\
 } while (0)
 
-#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)				\
-	EXT4_INODE_SET_XTIME_VAL(xtime, inode, raw_inode, (inode)->xtime)
+#define EXT4_INODE_SET_ATIME(inode, raw_inode)						\
+	EXT4_INODE_SET_XTIME_VAL(i_atime, inode, raw_inode, inode_get_atime(inode))
 
-#define EXT4_INODE_SET_CTIME(inode, raw_inode)					\
+#define EXT4_INODE_SET_MTIME(inode, raw_inode)						\
+	EXT4_INODE_SET_XTIME_VAL(i_mtime, inode, raw_inode, inode_get_mtime(inode))
+
+#define EXT4_INODE_SET_CTIME(inode, raw_inode)						\
 	EXT4_INODE_SET_XTIME_VAL(i_ctime, inode, raw_inode, inode_get_ctime(inode))
 
 #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode)				\
@@ -910,9 +913,16 @@ do {										\
 			.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime)	\
 		})
 
-#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)				\
+#define EXT4_INODE_GET_ATIME(inode, raw_inode)					\
+do {										\
+	inode_set_atime_to_ts(inode,						\
+		EXT4_INODE_GET_XTIME_VAL(i_atime, inode, raw_inode));		\
+} while (0)
+
+#define EXT4_INODE_GET_MTIME(inode, raw_inode)					\
 do {										\
-	(inode)->xtime = EXT4_INODE_GET_XTIME_VAL(xtime, inode, raw_inode);	\
+	inode_set_mtime_to_ts(inode,						\
+		EXT4_INODE_GET_XTIME_VAL(i_mtime, inode, raw_inode));		\
 } while (0)
 
 #define EXT4_INODE_GET_CTIME(inode, raw_inode)					\
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 202c76996b62..4c4176ee1749 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4481,7 +4481,8 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 			if (epos > new_size)
 				epos = new_size;
 			if (ext4_update_inode_size(inode, epos) & 0x1)
-				inode->i_mtime = inode_get_ctime(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_get_ctime(inode));
 		}
 		ret2 = ext4_mark_inode_dirty(handle, inode);
 		ext4_update_inode_fsync_trans(handle, inode, 1);
@@ -4617,7 +4618,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 
 		/* Now release the pages and zero block aligned part of pages */
 		truncate_pagecache_range(inode, start, end - 1);
-		inode->i_mtime = inode_set_ctime_current(inode);
+		inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 
 		ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 					     flags);
@@ -4642,7 +4643,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 		goto out_mutex;
 	}
 
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	if (new_size)
 		ext4_update_inode_size(inode, new_size);
 	ret = ext4_mark_inode_dirty(handle, inode);
@@ -5378,7 +5379,7 @@ static int ext4_collapse_range(struct file *file, loff_t offset, loff_t len)
 	up_write(&EXT4_I(inode)->i_data_sem);
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret = ext4_mark_inode_dirty(handle, inode);
 	ext4_update_inode_fsync_trans(handle, inode, 1);
 
@@ -5488,7 +5489,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len)
 	/* Expand file to avoid data loss if there is error while shifting */
 	inode->i_size += len;
 	EXT4_I(inode)->i_disksize += len;
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret = ext4_mark_inode_dirty(handle, inode);
 	if (ret)
 		goto out_stop;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index b65058d972f9..e9bbb1da2d0a 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1250,8 +1250,8 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
 	inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
 	/* This is the optimal IO size (for stat), not the fs block size */
 	inode->i_blocks = 0;
-	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
-	ei->i_crtime = inode->i_mtime;
+	simple_inode_init_ts(inode);
+	ei->i_crtime = inode_get_mtime(inode);
 
 	memset(ei->i_data, 0, sizeof(ei->i_data));
 	ei->i_dir_start_lookup = 0;
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 012d9259ff53..9a84a5f9fef4 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1037,7 +1037,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
 	 * happen is that the times are slightly out of date
 	 * and/or different from the directory change time.
 	 */
-	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 	ext4_update_dx_flag(dir);
 	inode_inc_iversion(dir);
 	return 1;
@@ -1991,7 +1991,7 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline)
 		ext4_orphan_del(handle, inode);
 
 	if (err == 0) {
-		inode->i_mtime = inode_set_ctime_current(inode);
+		inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 		err = ext4_mark_inode_dirty(handle, inode);
 		if (IS_SYNC(inode))
 			ext4_handle_sync(handle);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 4ce35f1c8b0a..08cb5c0e0d51 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4020,7 +4020,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
 
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(ret2))
 		ret = ret2;
@@ -4180,7 +4180,7 @@ int ext4_truncate(struct inode *inode)
 	if (inode->i_nlink)
 		ext4_orphan_del(handle, inode);
 
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	err2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(err2 && !err))
 		err = err2;
@@ -4284,8 +4284,8 @@ static int ext4_fill_raw_inode(struct inode *inode, struct ext4_inode *raw_inode
 	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
 
 	EXT4_INODE_SET_CTIME(inode, raw_inode);
-	EXT4_INODE_SET_XTIME(i_mtime, inode, raw_inode);
-	EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode);
+	EXT4_INODE_SET_MTIME(inode, raw_inode);
+	EXT4_INODE_SET_ATIME(inode, raw_inode);
 	EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode);
 
 	raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
@@ -4893,8 +4893,8 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 	}
 
 	EXT4_INODE_GET_CTIME(inode, raw_inode);
-	EXT4_INODE_GET_XTIME(i_mtime, inode, raw_inode);
-	EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
+	EXT4_INODE_GET_ATIME(inode, raw_inode);
+	EXT4_INODE_GET_MTIME(inode, raw_inode);
 	EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
 
 	if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
@@ -5019,8 +5019,8 @@ static void __ext4_update_other_inode_time(struct super_block *sb,
 
 		spin_lock(&ei->i_raw_lock);
 		EXT4_INODE_SET_CTIME(inode, raw_inode);
-		EXT4_INODE_SET_XTIME(i_mtime, inode, raw_inode);
-		EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode);
+		EXT4_INODE_SET_MTIME(inode, raw_inode);
+		EXT4_INODE_SET_ATIME(inode, raw_inode);
 		ext4_inode_csum_set(inode, raw_inode, ei);
 		spin_unlock(&ei->i_raw_lock);
 		trace_ext4_other_inode_update_time(inode, orig_ino);
@@ -5413,7 +5413,8 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 			 * update c/mtime in shrink case below
 			 */
 			if (!shrink)
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 
 			if (shrink)
 				ext4_fc_track_range(handle, inode,
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 0bfe2ce589e2..4f931f80cb34 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -312,13 +312,22 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
 	struct ext4_inode_info *ei1;
 	struct ext4_inode_info *ei2;
 	unsigned long tmp;
+	struct timespec64 ts1, ts2;
 
 	ei1 = EXT4_I(inode1);
 	ei2 = EXT4_I(inode2);
 
 	swap(inode1->i_version, inode2->i_version);
-	swap(inode1->i_atime, inode2->i_atime);
-	swap(inode1->i_mtime, inode2->i_mtime);
+
+	ts1 = inode_get_atime(inode1);
+	ts2 = inode_get_atime(inode2);
+	inode_set_atime_to_ts(inode1, ts2);
+	inode_set_atime_to_ts(inode2, ts1);
+
+	ts1 = inode_get_mtime(inode1);
+	ts2 = inode_get_mtime(inode2);
+	inode_set_mtime_to_ts(inode1, ts2);
+	inode_set_mtime_to_ts(inode2, ts1);
 
 	memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data));
 	tmp = ei1->i_flags & EXT4_FL_SHOULD_SWAP;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index bbda587f76b8..057d74467293 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2207,7 +2207,7 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
 	 * happen is that the times are slightly out of date
 	 * and/or different from the directory change time.
 	 */
-	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 	ext4_update_dx_flag(dir);
 	inode_inc_iversion(dir);
 	err2 = ext4_mark_inode_dirty(handle, dir);
@@ -3202,7 +3202,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
 	 * recovery. */
 	inode->i_size = 0;
 	ext4_orphan_add(handle, inode);
-	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 	inode_set_ctime_current(inode);
 	retval = ext4_mark_inode_dirty(handle, inode);
 	if (retval)
@@ -3277,7 +3277,7 @@ int __ext4_unlink(struct inode *dir, const struct qstr *d_name,
 		retval = ext4_delete_entry(handle, dir, de, bh);
 		if (retval)
 			goto out_handle;
-		dir->i_mtime = inode_set_ctime_current(dir);
+		inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 		ext4_update_dx_flag(dir);
 		retval = ext4_mark_inode_dirty(handle, dir);
 		if (retval)
@@ -3648,7 +3648,7 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
 	if (ext4_has_feature_filetype(ent->dir->i_sb))
 		ent->de->file_type = file_type;
 	inode_inc_iversion(ent->dir);
-	ent->dir->i_mtime = inode_set_ctime_current(ent->dir);
+	inode_set_mtime_to_ts(ent->dir, inode_set_ctime_current(ent->dir));
 	retval = ext4_mark_inode_dirty(handle, ent->dir);
 	BUFFER_TRACE(ent->bh, "call ext4_handle_dirty_metadata");
 	if (!ent->inlined) {
@@ -3963,7 +3963,7 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		ext4_dec_count(new.inode);
 		inode_set_ctime_current(new.inode);
 	}
-	old.dir->i_mtime = inode_set_ctime_current(old.dir);
+	inode_set_mtime_to_ts(old.dir, inode_set_ctime_current(old.dir));
 	ext4_update_dx_flag(old.dir);
 	if (old.dir_bh) {
 		retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f37fb009bd99..3165426784a9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -7136,7 +7136,7 @@ static int ext4_quota_off(struct super_block *sb, int type)
 	}
 	EXT4_I(inode)->i_flags &= ~(EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL);
 	inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
-	inode->i_mtime = inode_set_ctime_current(inode);
+	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	err = ext4_mark_inode_dirty(handle, inode);
 	ext4_journal_stop(handle);
 out_unlock:
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 92ba28cebac6..b9467ff8d4e9 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -356,7 +356,7 @@ ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size)
 
 static u64 ext4_xattr_inode_get_ref(struct inode *ea_inode)
 {
-	return ((u64) inode_get_ctime(ea_inode).tv_sec << 32) |
+	return ((u64) inode_get_ctime_sec(ea_inode) << 32) |
 		(u32) inode_peek_iversion_raw(ea_inode);
 }
 
@@ -368,12 +368,12 @@ static void ext4_xattr_inode_set_ref(struct inode *ea_inode, u64 ref_count)
 
 static u32 ext4_xattr_inode_get_hash(struct inode *ea_inode)
 {
-	return (u32)ea_inode->i_atime.tv_sec;
+	return (u32) inode_get_atime_sec(ea_inode);
 }
 
 static void ext4_xattr_inode_set_hash(struct inode *ea_inode, u32 hash)
 {
-	ea_inode->i_atime.tv_sec = hash;
+	inode_set_atime(ea_inode, hash, 0);
 }
 
 /*
@@ -418,7 +418,7 @@ static int ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t size)
 	return ret;
 }
 
-#define EXT4_XATTR_INODE_GET_PARENT(inode) ((__u32)(inode)->i_mtime.tv_sec)
+#define EXT4_XATTR_INODE_GET_PARENT(inode) ((__u32)(inode_get_mtime_sec(inode)))
 
 static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
 				 u32 ea_inode_hash, struct inode **ea_inode)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime
@ 2023-10-04 18:52 Jeff Layton
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian, Chris Mason,
	Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
	Joel Becker, Christoph Hellwig, Nicolas Pitre, Rafael J. Wysocki,
	Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger, Jaegeuk Kim,
	OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi, Bob Peterson,
	Andreas Gruenbacher, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Mikulas Patocka, Mike Kravetz, Muchun Song,
	Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg, Luis Chamberlain,
	Iurii Zaikin, Tony Luck, Guilherme G. Piccoli, Anders Larsen,
	Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Sergey Senozhatsky, Phillip Lougher, Steven Rostedt,
	Masami Hiramatsu, Evgeniy Dushistov, Chandan Babu R,
	Darrick J. Wong, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, Kent Overstreet,
	Brian Foster
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, linux-ntfs-dev,
	ntfs3, ocfs2-devel, linux-karma-devel, devel, linux-unionfs,
	linux-hardening, reiserfs-devel, linux-cifs, samba-technical,
	linux-trace-kernel, linux-xfs, bpf, netdev, apparmor,
	linux-security-module, selinux, linux-bcachefs

v2:
- bugfix in mtime handling
- incorporate _sec and _nsec accessor functions (Chuck Lever)
- move i_generation to plug hole after changing timestamps (Amir Goldstein)

While working on the multigrain timestamp changes, Linus suggested
adding some similar wrappers for accessing the atime and mtime that we
have for the ctime. With that, we could then move to using discrete
integers instead of struct timespec64 in struct inode and shrink it.

This patch implements this. Linus suggested using macros for the new
accessors, but the existing ctime wrappers were static inlines and since
there are only 3 different timestamps, I didn't see that trying to
fiddle with macros would gain us anything (other than less verbosity in
fs.h).

The second to last patch makes the conversion to discrete integers,
which shaves 8 bytes off of struct inode on my x86_64 kernel. The last
patch reshuffles things a little to keep the i_lock in the same
cacheline as the fields it protects.

About 75% of this conversion was done with coccinelle, with the rest
done by hand.

I think we probably ought to try to get everything but the last two
patches into v6.7 (though we could consider those too if we're feeling
lucky).

Jeff Layton (89):
  fs: new accessor methods for atime and mtime
  fs: convert core infrastructure to new timestamp accessors
  spufs: convert to new timestamp accessors
  hypfs: convert to new timestamp accessors
  android: convert to new timestamp accessors
  char: convert to new timestamp accessors
  qib: convert to new timestamp accessors
  ibmasm: convert to new timestamp accessors
  misc: convert to new timestamp accessors
  x86: convert to new timestamp accessors
  tty: convert to new timestamp accessors
  function: convert to new timestamp accessors
  legacy: convert to new timestamp accessors
  usb: convert to new timestamp accessors
  9p: convert to new timestamp accessors
  adfs: convert to new timestamp accessors
  affs: convert to new timestamp accessors
  afs: convert to new timestamp accessors
  autofs: convert to new timestamp accessors
  bcachefs: convert to new timestamp accessors
  befs: convert to new timestamp accessors
  bfs: convert to new timestamp accessors
  btrfs: convert to new timestamp accessors
  ceph: convert to new timestamp accessors
  coda: convert to new timestamp accessors
  configfs: convert to new timestamp accessors
  cramfs: convert to new timestamp accessors
  debugfs: convert to new timestamp accessors
  devpts: convert to new timestamp accessors
  efivarfs: convert to new timestamp accessors
  efs: convert to new timestamp accessors
  erofs: convert to new timestamp accessors
  exfat: convert to new timestamp accessors
  ext2: convert to new timestamp accessors
  ext4: convert to new timestamp accessors
  f2fs: convert to new timestamp accessors
  fat: convert to new timestamp accessors
  freevxfs: convert to new timestamp accessors
  fuse: convert to new timestamp accessors
  gfs2: convert to new timestamp accessors
  hfs: convert to new timestamp accessors
  hfsplus: convert to new timestamp accessors
  hostfs: convert to new timestamp accessors
  hpfs: convert to new timestamp accessors
  hugetlbfs: convert to new timestamp accessors
  isofs: convert to new timestamp accessors
  jffs2: convert to new timestamp accessors
  jfs: convert to new timestamp accessors
  kernfs: convert to new timestamp accessors
  minix: convert to new timestamp accessors
  nfs: convert to new timestamp accessors
  nfsd: convert to new timestamp accessors
  nilfs2: convert to new timestamp accessors
  ntfs: convert to new timestamp accessors
  ntfs3: convert to new timestamp accessors
  ocfs2: convert to new timestamp accessors
  omfs: convert to new timestamp accessors
  openpromfs: convert to new timestamp accessors
  orangefs: convert to new timestamp accessors
  overlayfs: convert to new timestamp accessors
  proc: convert to new timestamp accessors
  pstore: convert to new timestamp accessors
  qnx4: convert to new timestamp accessors
  qnx6: convert to new timestamp accessors
  ramfs: convert to new timestamp accessors
  reiserfs: convert to new timestamp accessors
  romfs: convert to new timestamp accessors
  client: convert to new timestamp accessors
  server: convert to new timestamp accessors
  squashfs: convert to new timestamp accessors
  sysv: convert to new timestamp accessors
  tracefs: convert to new timestamp accessors
  ubifs: convert to new timestamp accessors
  udf: convert to new timestamp accessors
  ufs: convert to new timestamp accessors
  vboxsf: convert to new timestamp accessors
  xfs: convert to new timestamp accessors
  zonefs: convert to new timestamp accessors
  linux: convert to new timestamp accessors
  ipc: convert to new timestamp accessors
  bpf: convert to new timestamp accessors
  mm: convert to new timestamp accessors
  sunrpc: convert to new timestamp accessors
  apparmor: convert to new timestamp accessors
  selinux: convert to new timestamp accessors
  security: convert to new timestamp accessors
  fs: rename inode i_atime and i_mtime fields
  fs: switch timespec64 fields in inode to discrete integers
  fs: move i_generation into new hole created after timestamp conversion

 arch/powerpc/platforms/cell/spufs/inode.c |   2 +-
 arch/s390/hypfs/inode.c                   |   4 +-
 drivers/android/binderfs.c                |   8 +-
 drivers/char/sonypi.c                     |   2 +-
 drivers/infiniband/hw/qib/qib_fs.c        |   4 +-
 drivers/misc/ibmasm/ibmasmfs.c            |   2 +-
 drivers/misc/ibmvmc.c                     |   2 +-
 drivers/platform/x86/sony-laptop.c        |   2 +-
 drivers/tty/tty_io.c                      |  10 +-
 drivers/usb/core/devio.c                  |  26 +++--
 drivers/usb/gadget/function/f_fs.c        |   4 +-
 drivers/usb/gadget/legacy/inode.c         |   2 +-
 fs/9p/vfs_inode.c                         |   6 +-
 fs/9p/vfs_inode_dotl.c                    |  16 +--
 fs/adfs/inode.c                           |  13 ++-
 fs/affs/amigaffs.c                        |   4 +-
 fs/affs/inode.c                           |  17 ++-
 fs/afs/dynroot.c                          |   2 +-
 fs/afs/inode.c                            |   8 +-
 fs/afs/write.c                            |   2 +-
 fs/attr.c                                 |   4 +-
 fs/autofs/inode.c                         |   2 +-
 fs/autofs/root.c                          |   6 +-
 fs/bad_inode.c                            |   2 +-
 fs/bcachefs/fs.c                          |  12 +--
 fs/befs/linuxvfs.c                        |  10 +-
 fs/bfs/dir.c                              |   9 +-
 fs/bfs/inode.c                            |  12 +--
 fs/binfmt_misc.c                          |   2 +-
 fs/btrfs/delayed-inode.c                  |  20 ++--
 fs/btrfs/file.c                           |  18 ++--
 fs/btrfs/inode.c                          |  43 ++++----
 fs/btrfs/reflink.c                        |   2 +-
 fs/btrfs/transaction.c                    |   3 +-
 fs/btrfs/tree-log.c                       |  12 +--
 fs/ceph/addr.c                            |  10 +-
 fs/ceph/caps.c                            |   4 +-
 fs/ceph/file.c                            |   2 +-
 fs/ceph/inode.c                           |  64 ++++++------
 fs/ceph/mds_client.c                      |   8 +-
 fs/ceph/snap.c                            |   4 +-
 fs/coda/coda_linux.c                      |   6 +-
 fs/coda/dir.c                             |   2 +-
 fs/coda/file.c                            |   2 +-
 fs/configfs/inode.c                       |   8 +-
 fs/cramfs/inode.c                         |   4 +-
 fs/debugfs/inode.c                        |   2 +-
 fs/devpts/inode.c                         |   6 +-
 fs/efivarfs/file.c                        |   2 +-
 fs/efivarfs/inode.c                       |   2 +-
 fs/efs/inode.c                            |   5 +-
 fs/erofs/inode.c                          |   3 +-
 fs/exfat/exfat_fs.h                       |   1 +
 fs/exfat/file.c                           |   7 +-
 fs/exfat/inode.c                          |  31 +++---
 fs/exfat/misc.c                           |   8 ++
 fs/exfat/namei.c                          |  31 +++---
 fs/exfat/super.c                          |   4 +-
 fs/ext2/dir.c                             |   6 +-
 fs/ext2/ialloc.c                          |   2 +-
 fs/ext2/inode.c                           |  13 ++-
 fs/ext2/super.c                           |   2 +-
 fs/ext4/ext4.h                            |  20 +++-
 fs/ext4/extents.c                         |  11 +-
 fs/ext4/ialloc.c                          |   4 +-
 fs/ext4/inline.c                          |   4 +-
 fs/ext4/inode.c                           |  19 ++--
 fs/ext4/ioctl.c                           |  13 ++-
 fs/ext4/namei.c                           |  10 +-
 fs/ext4/super.c                           |   2 +-
 fs/ext4/xattr.c                           |   8 +-
 fs/f2fs/dir.c                             |   6 +-
 fs/f2fs/f2fs.h                            |  10 +-
 fs/f2fs/file.c                            |  14 +--
 fs/f2fs/inline.c                          |   2 +-
 fs/f2fs/inode.c                           |  24 ++---
 fs/f2fs/namei.c                           |   4 +-
 fs/f2fs/recovery.c                        |   8 +-
 fs/f2fs/super.c                           |   2 +-
 fs/fat/inode.c                            |  25 +++--
 fs/fat/misc.c                             |   6 +-
 fs/freevxfs/vxfs_inode.c                  |   6 +-
 fs/fuse/control.c                         |   2 +-
 fs/fuse/dir.c                             |  10 +-
 fs/fuse/inode.c                           |  29 +++---
 fs/fuse/readdir.c                         |   6 +-
 fs/gfs2/bmap.c                            |  10 +-
 fs/gfs2/dir.c                             |  10 +-
 fs/gfs2/glops.c                           |  11 +-
 fs/gfs2/inode.c                           |   7 +-
 fs/gfs2/quota.c                           |   2 +-
 fs/gfs2/super.c                           |  12 +--
 fs/hfs/catalog.c                          |   8 +-
 fs/hfs/inode.c                            |  16 +--
 fs/hfs/sysdep.c                           |  10 +-
 fs/hfsplus/catalog.c                      |   8 +-
 fs/hfsplus/inode.c                        |  22 ++--
 fs/hostfs/hostfs_kern.c                   |  12 ++-
 fs/hpfs/dir.c                             |  12 ++-
 fs/hpfs/inode.c                           |  16 +--
 fs/hpfs/namei.c                           |  22 ++--
 fs/hpfs/super.c                           |  10 +-
 fs/hugetlbfs/inode.c                      |  10 +-
 fs/inode.c                                |  35 ++++---
 fs/isofs/inode.c                          |   4 +-
 fs/isofs/rock.c                           |  18 ++--
 fs/jffs2/dir.c                            |  35 ++++---
 fs/jffs2/file.c                           |   4 +-
 fs/jffs2/fs.c                             |  20 ++--
 fs/jffs2/os-linux.h                       |   4 +-
 fs/jfs/inode.c                            |   2 +-
 fs/jfs/jfs_imap.c                         |  20 ++--
 fs/jfs/jfs_inode.c                        |   4 +-
 fs/jfs/namei.c                            |  20 ++--
 fs/jfs/super.c                            |   2 +-
 fs/kernfs/inode.c                         |   6 +-
 fs/libfs.c                                |  41 ++++++--
 fs/minix/bitmap.c                         |   2 +-
 fs/minix/dir.c                            |   6 +-
 fs/minix/inode.c                          |  17 ++-
 fs/minix/itree_common.c                   |   2 +-
 fs/nfs/callback_proc.c                    |   2 +-
 fs/nfs/fscache.h                          |   4 +-
 fs/nfs/inode.c                            |  30 +++---
 fs/nfsd/blocklayout.c                     |   3 +-
 fs/nfsd/nfs3proc.c                        |   4 +-
 fs/nfsd/nfs4proc.c                        |   8 +-
 fs/nfsd/nfsctl.c                          |   2 +-
 fs/nfsd/vfs.c                             |   2 +-
 fs/nilfs2/dir.c                           |   6 +-
 fs/nilfs2/inode.c                         |  20 ++--
 fs/nsfs.c                                 |   2 +-
 fs/ntfs/inode.c                           |  25 ++---
 fs/ntfs/mft.c                             |   2 +-
 fs/ntfs3/file.c                           |   6 +-
 fs/ntfs3/frecord.c                        |  11 +-
 fs/ntfs3/inode.c                          |  25 +++--
 fs/ntfs3/namei.c                          |   4 +-
 fs/ocfs2/acl.c                            |   4 +-
 fs/ocfs2/alloc.c                          |   6 +-
 fs/ocfs2/aops.c                           |   6 +-
 fs/ocfs2/dir.c                            |   9 +-
 fs/ocfs2/dlmfs/dlmfs.c                    |   4 +-
 fs/ocfs2/dlmglue.c                        |  29 +++---
 fs/ocfs2/file.c                           |  30 +++---
 fs/ocfs2/inode.c                          |  28 ++---
 fs/ocfs2/move_extents.c                   |   4 +-
 fs/ocfs2/namei.c                          |  16 +--
 fs/ocfs2/refcounttree.c                   |  12 +--
 fs/ocfs2/xattr.c                          |   4 +-
 fs/omfs/inode.c                           |  12 +--
 fs/openpromfs/inode.c                     |   4 +-
 fs/orangefs/orangefs-utils.c              |  16 +--
 fs/overlayfs/file.c                       |   9 +-
 fs/overlayfs/inode.c                      |   3 +-
 fs/overlayfs/util.c                       |   4 +-
 fs/pipe.c                                 |   2 +-
 fs/proc/base.c                            |   2 +-
 fs/proc/inode.c                           |   2 +-
 fs/proc/proc_sysctl.c                     |   2 +-
 fs/proc/self.c                            |   2 +-
 fs/proc/thread_self.c                     |   2 +-
 fs/pstore/inode.c                         |   5 +-
 fs/qnx4/inode.c                           |   6 +-
 fs/qnx6/inode.c                           |   6 +-
 fs/ramfs/inode.c                          |   7 +-
 fs/reiserfs/inode.c                       |  26 ++---
 fs/reiserfs/namei.c                       |   8 +-
 fs/reiserfs/stree.c                       |   5 +-
 fs/reiserfs/super.c                       |   2 +-
 fs/romfs/super.c                          |   3 +-
 fs/smb/client/file.c                      |  18 ++--
 fs/smb/client/fscache.h                   |   6 +-
 fs/smb/client/inode.c                     |  17 ++-
 fs/smb/client/smb2ops.c                   |   6 +-
 fs/smb/server/smb2pdu.c                   |   8 +-
 fs/squashfs/inode.c                       |   6 +-
 fs/stack.c                                |   4 +-
 fs/stat.c                                 |   4 +-
 fs/sysv/dir.c                             |   6 +-
 fs/sysv/ialloc.c                          |   2 +-
 fs/sysv/inode.c                           |  12 +--
 fs/sysv/itree.c                           |   2 +-
 fs/tracefs/inode.c                        |   2 +-
 fs/ubifs/debug.c                          |  12 +--
 fs/ubifs/dir.c                            |  23 +++--
 fs/ubifs/file.c                           |  16 +--
 fs/ubifs/journal.c                        |  12 +--
 fs/ubifs/super.c                          |   8 +-
 fs/udf/ialloc.c                           |   4 +-
 fs/udf/inode.c                            |  38 ++++---
 fs/udf/namei.c                            |  16 +--
 fs/ufs/dir.c                              |   6 +-
 fs/ufs/ialloc.c                           |   2 +-
 fs/ufs/inode.c                            |  42 ++++----
 fs/vboxsf/utils.c                         |  15 +--
 fs/xfs/libxfs/xfs_inode_buf.c             |  10 +-
 fs/xfs/libxfs/xfs_rtbitmap.c              |   6 +-
 fs/xfs/libxfs/xfs_trans_inode.c           |   2 +-
 fs/xfs/xfs_bmap_util.c                    |   7 +-
 fs/xfs/xfs_inode.c                        |   4 +-
 fs/xfs/xfs_inode_item.c                   |   4 +-
 fs/xfs/xfs_iops.c                         |   8 +-
 fs/xfs/xfs_itable.c                       |  12 +--
 fs/xfs/xfs_rtalloc.c                      |  30 +++---
 fs/zonefs/super.c                         |  10 +-
 include/linux/fs.h                        | 120 +++++++++++++++++-----
 include/linux/fs_stack.h                  |   6 +-
 ipc/mqueue.c                              |  19 ++--
 kernel/bpf/inode.c                        |   5 +-
 mm/shmem.c                                |  20 ++--
 net/sunrpc/rpc_pipe.c                     |   2 +-
 security/apparmor/apparmorfs.c            |   7 +-
 security/apparmor/policy_unpack.c         |   4 +-
 security/inode.c                          |   2 +-
 security/selinux/selinuxfs.c              |   2 +-
 216 files changed, 1220 insertions(+), 1000 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 01/89] fs: new accessor methods for atime and mtime
  2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
@ 2023-10-04 18:52 ` Jeff Layton
  2023-10-04 18:52   ` [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors Jeff Layton
  2023-10-09 16:09 ` [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Christian Brauner
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian, Chris Mason,
	Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
	Joel Becker, Christoph Hellwig, Nicolas Pitre, Rafael J. Wysocki,
	Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger, Jaegeuk Kim,
	OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi, Bob Peterson,
	Andreas Gruenbacher, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Mikulas Patocka, Mike Kravetz, Muchun Song,
	Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg, Luis Chamberlain,
	Iurii Zaikin, Tony Luck, Guilherme G. Piccoli, Anders Larsen,
	Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Sergey Senozhatsky, Phillip Lougher, Steven Rostedt,
	Masami Hiramatsu, Evgeniy Dushistov, Chandan Babu R,
	Darrick J. Wong, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, Kent Overstreet,
	Brian Foster
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, linux-ntfs-dev,
	ntfs3, ocfs2-devel, linux-karma-devel, devel, linux-unionfs,
	linux-hardening, reiserfs-devel, linux-cifs, samba-technical,
	linux-trace-kernel, linux-xfs, bpf, netdev, apparmor,
	linux-security-module, selinux, linux-bcachefs

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors
  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
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian, Chris Mason,
	Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes, coda,
	Joel Becker, Christoph Hellwig, Nicolas Pitre, Rafael J. Wysocki,
	Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger, Jaegeuk Kim,
	OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi, Bob Peterson,
	Andreas Gruenbacher, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Mikulas Patocka, Mike Kravetz, Muchun Song,
	Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg, Luis Chamberlain,
	Iurii Zaikin, Tony Luck, Guilherme G. Piccoli, Anders Larsen,
	Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Sergey Senozhatsky, Phillip Lougher, Steven Rostedt,
	Masami Hiramatsu, Evgeniy Dushistov, Chandan Babu R,
	Darrick J. Wong, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, Kent Overstreet,
	Brian Foster
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs, linux-ntfs-dev,
	ntfs3, ocfs2-devel, linux-karma-devel, devel, linux-unionfs,
	linux-hardening, reiserfs-devel, linux-cifs, samba-technical,
	linux-trace-kernel, linux-xfs, bpf, netdev, apparmor,
	linux-security-module, selinux, linux-bcachefs

Convert the core vfs code to use the new timestamp accessor functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/attr.c        |  4 ++--
 fs/bad_inode.c   |  2 +-
 fs/binfmt_misc.c |  2 +-
 fs/inode.c       | 35 +++++++++++++++++++++--------------
 fs/nsfs.c        |  2 +-
 fs/pipe.c        |  2 +-
 fs/stack.c       |  4 ++--
 fs/stat.c        |  4 ++--
 8 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index a8ae5f6d9b16..bdf5deb06ea9 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -308,9 +308,9 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode,
 	i_uid_update(idmap, attr, inode);
 	i_gid_update(idmap, attr, inode);
 	if (ia_valid & ATTR_ATIME)
-		inode->i_atime = attr->ia_atime;
+		inode_set_atime_to_ts(inode, attr->ia_atime);
 	if (ia_valid & ATTR_MTIME)
-		inode->i_mtime = attr->ia_mtime;
+		inode_set_mtime_to_ts(inode, attr->ia_mtime);
 	if (ia_valid & ATTR_CTIME)
 		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 83f9566c973b..316d88da2ce1 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -208,7 +208,7 @@ void make_bad_inode(struct inode *inode)
 	remove_inode_hash(inode);
 
 	inode->i_mode = S_IFREG;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &bad_inode_ops;	
 	inode->i_opflags &= ~IOP_XATTR;
 	inode->i_fop = &bad_file_ops;	
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index e0108d17b085..5d2be9b0a0a5 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -547,7 +547,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
 	if (inode) {
 		inode->i_ino = get_next_ino();
 		inode->i_mode = mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 	}
 	return inode;
 }
diff --git a/fs/inode.c b/fs/inode.c
index 3bb6193f436c..4f8984b97df0 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1837,27 +1837,29 @@ EXPORT_SYMBOL(bmap);
 static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
 			     struct timespec64 now)
 {
-	struct timespec64 ctime;
+	struct timespec64 atime, mtime, ctime;
 
 	if (!(mnt->mnt_flags & MNT_RELATIME))
 		return 1;
 	/*
 	 * Is mtime younger than or equal to atime? If yes, update atime:
 	 */
-	if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0)
+	atime = inode_get_atime(inode);
+	mtime = inode_get_mtime(inode);
+	if (timespec64_compare(&mtime, &atime) >= 0)
 		return 1;
 	/*
 	 * Is ctime younger than or equal to atime? If yes, update atime:
 	 */
 	ctime = inode_get_ctime(inode);
-	if (timespec64_compare(&ctime, &inode->i_atime) >= 0)
+	if (timespec64_compare(&ctime, &atime) >= 0)
 		return 1;
 
 	/*
 	 * Is the previous atime value older than a day? If yes,
 	 * update atime:
 	 */
-	if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60)
+	if ((long)(now.tv_sec - atime.tv_sec) >= 24*60*60)
 		return 1;
 	/*
 	 * Good, we can skip the atime update:
@@ -1888,12 +1890,13 @@ int inode_update_timestamps(struct inode *inode, int flags)
 
 	if (flags & (S_MTIME|S_CTIME|S_VERSION)) {
 		struct timespec64 ctime = inode_get_ctime(inode);
+		struct timespec64 mtime = inode_get_mtime(inode);
 
 		now = inode_set_ctime_current(inode);
 		if (!timespec64_equal(&now, &ctime))
 			updated |= S_CTIME;
-		if (!timespec64_equal(&now, &inode->i_mtime)) {
-			inode->i_mtime = now;
+		if (!timespec64_equal(&now, &mtime)) {
+			inode_set_mtime_to_ts(inode, now);
 			updated |= S_MTIME;
 		}
 		if (IS_I_VERSION(inode) && inode_maybe_inc_iversion(inode, updated))
@@ -1903,8 +1906,10 @@ int inode_update_timestamps(struct inode *inode, int flags)
 	}
 
 	if (flags & S_ATIME) {
-		if (!timespec64_equal(&now, &inode->i_atime)) {
-			inode->i_atime = now;
+		struct timespec64 atime = inode_get_atime(inode);
+
+		if (!timespec64_equal(&now, &atime)) {
+			inode_set_atime_to_ts(inode, now);
 			updated |= S_ATIME;
 		}
 	}
@@ -1963,7 +1968,7 @@ EXPORT_SYMBOL(inode_update_time);
 bool atime_needs_update(const struct path *path, struct inode *inode)
 {
 	struct vfsmount *mnt = path->mnt;
-	struct timespec64 now;
+	struct timespec64 now, atime;
 
 	if (inode->i_flags & S_NOATIME)
 		return false;
@@ -1989,7 +1994,8 @@ bool atime_needs_update(const struct path *path, struct inode *inode)
 	if (!relatime_need_update(mnt, inode, now))
 		return false;
 
-	if (timespec64_equal(&inode->i_atime, &now))
+	atime = inode_get_atime(inode);
+	if (timespec64_equal(&atime, &now))
 		return false;
 
 	return true;
@@ -2106,17 +2112,18 @@ static int inode_needs_update_time(struct inode *inode)
 {
 	int sync_it = 0;
 	struct timespec64 now = current_time(inode);
-	struct timespec64 ctime;
+	struct timespec64 ts;
 
 	/* First try to exhaust all avenues to not sync */
 	if (IS_NOCMTIME(inode))
 		return 0;
 
-	if (!timespec64_equal(&inode->i_mtime, &now))
+	ts = inode_get_mtime(inode);
+	if (!timespec64_equal(&ts, &now))
 		sync_it = S_MTIME;
 
-	ctime = inode_get_ctime(inode);
-	if (!timespec64_equal(&ctime, &now))
+	ts = inode_get_ctime(inode);
+	if (!timespec64_equal(&ts, &now))
 		sync_it |= S_CTIME;
 
 	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 647a22433bd8..9a4b228d42fa 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -84,7 +84,7 @@ static int __ns_get_path(struct path *path, struct ns_common *ns)
 		return -ENOMEM;
 	}
 	inode->i_ino = ns->inum;
-	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_flags |= S_IMMUTABLE;
 	inode->i_mode = S_IFREG | S_IRUGO;
 	inode->i_fop = &ns_file_operations;
diff --git a/fs/pipe.c b/fs/pipe.c
index 485e3be8903c..8916c455a469 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -908,7 +908,7 @@ static struct inode * get_pipe_inode(void)
 	inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR;
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 
 	return inode;
 
diff --git a/fs/stack.c b/fs/stack.c
index b5e01bdb5f5f..f18920119944 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -66,8 +66,8 @@ void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
 	dest->i_uid = src->i_uid;
 	dest->i_gid = src->i_gid;
 	dest->i_rdev = src->i_rdev;
-	dest->i_atime = src->i_atime;
-	dest->i_mtime = src->i_mtime;
+	inode_set_atime_to_ts(dest, inode_get_atime(src));
+	inode_set_mtime_to_ts(dest, inode_get_mtime(src));
 	inode_set_ctime_to_ts(dest, inode_get_ctime(src));
 	dest->i_blkbits = src->i_blkbits;
 	dest->i_flags = src->i_flags;
diff --git a/fs/stat.c b/fs/stat.c
index d43a5cc1bfa4..24bb0209e459 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -57,8 +57,8 @@ void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask,
 	stat->gid = vfsgid_into_kgid(vfsgid);
 	stat->rdev = inode->i_rdev;
 	stat->size = i_size_read(inode);
-	stat->atime = inode->i_atime;
-	stat->mtime = inode->i_mtime;
+	stat->atime = inode_get_atime(inode);
+	stat->mtime = inode_get_mtime(inode);
 	stat->ctime = inode_get_ctime(inode);
 	stat->blksize = i_blocksize(inode);
 	stat->blocks = inode->i_blocks;
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime
  2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
  2023-10-04 18:52 ` [PATCH v2 01/89] fs: new accessor methods for atime and mtime Jeff Layton
@ 2023-10-09 16:09 ` Christian Brauner
  2 siblings, 0 replies; 6+ messages in thread
From: Christian Brauner @ 2023-10-09 16:09 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Alexander Viro, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, arve, Todd Kjos, Martijn Coenen,
	Joel Fernandes, Carlos Llamas, Suren Baghdasaryan, Mattia Dongili,
	Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky, Brad Warrum,
	Ritu Agarwal, Hans de Goede, ilpo.jarvinen, Mark Gross,
	Jiri Slaby, Eric Van Hensbergen, Latchesar Ionkov,
	Dominique Martinet, Christian Schoenebeck, David Sterba,
	David Howells, Marc Dionne, Ian Kent, Luis de Bethencourt,
	Salah Triki, Tigran A. Aivazian, Chris Mason, Josef Bacik,
	Xiubo Li, Ilya Dryomov, Jan Harkes, coda, Joel Becker,
	Christoph Hellwig, Nicolas Pitre, Rafael J. Wysocki,
	Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger, Jaegeuk Kim,
	OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi, Bob Peterson,
	Andreas Gruenbacher, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Mikulas Patocka, Mike Kravetz, Muchun Song,
	Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg, Luis Chamberlain,
	Iurii Zaikin, Tony Luck, Guilherme G. Piccoli, Anders Larsen,
	Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Sergey Senozhatsky, Phillip Lougher, Steven Rostedt,
	Masami Hiramatsu, Evgeniy Dushistov, Chandan Babu R,
	Darrick J. Wong, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, Kent Overstreet,
	Brian Foster, linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev,
	linux-s390, platform-driver-x86, linux-rdma, linux-serial,
	linux-usb, v9fs, linux-afs, autofs, linux-btrfs, ceph-devel,
	codalist, linux-efi, linux-erofs, linux-ext4, linux-f2fs-devel,
	gfs2, linux-um, linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux, linux-bcachefs

On Wed, Oct 04, 2023 at 02:52:21PM -0400, Jeff Layton wrote:
> v2:
> - bugfix in mtime handling
> - incorporate _sec and _nsec accessor functions (Chuck Lever)
> - move i_generation to plug hole after changing timestamps (Amir Goldstein)
> 
> While working on the multigrain timestamp changes, Linus suggested
> adding some similar wrappers for accessing the atime and mtime that we
> have for the ctime. With that, we could then move to using discrete
> integers instead of struct timespec64 in struct inode and shrink it.
> 
> This patch implements this. Linus suggested using macros for the new
> accessors, but the existing ctime wrappers were static inlines and since
> there are only 3 different timestamps, I didn't see that trying to
> fiddle with macros would gain us anything (other than less verbosity in
> fs.h).
> 
> [...]

This was applied on top of -next but vfs.ctime is now based on v6.6-rc3
as stable tag otherwise this is too much of a moving target with other
stuff in -next. Anything that had to be dropped and requires fixups
should just be explained in the pr. The sooner this sees some -next, the
better, I think.

---

Applied to the vfs.ctime branch of the vfs/vfs.git tree.
Patches in the vfs.ctime branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.ctime

[01/86] fs: new accessor methods for atime and mtime
        https://git.kernel.org/vfs/vfs/c/22f45fee808d
[02/86] fs: convert core infrastructure to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6ac95fb71485
[03/86] spufs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/9953073d5f20
[04/86] hypfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/1d64bfe22112
[05/86] android: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a8a74b6b4f2c
[06/86] char: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/671ffa0775a7
[07/86] qib: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ebd5458f3b52
[08/86] ibmasm: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/1d4257d57a41
[09/86] misc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/d4bf8378b9cb
[10/86] x86: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/070601b1e496
[11/86] tty: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5c9f26b87bed
[12/86] function: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/092f46404245
[13/86] legacy: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5c51d80e51d0
[14/86] usb: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/4707a33afd6f
[15/86] 9p: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/20fc454b4493
[16/86] adfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3e8d59046f6d
[17/86] affs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/60d4d0d37086
[18/86] afs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6471772aa6fe
[19/86] autofs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3eaad981548b
[20/86] befs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/21d0433caf69
[21/86] bfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/06e502c123a6
[22/86] btrfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/f62049d7838d
[23/86] ceph: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ac7750d84e38
[24/86] coda: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5c4bf2507baa
[25/86] configfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3b930e187f16
[26/86] cramfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/bb0bf9d3bda8
[27/86] debugfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/7dc950e659d6
[28/86] devpts: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a1eb5c26d5a1
[29/86] efivarfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/17b5652aa824
[30/86] efs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a3cfbea29e7d
[31/86] erofs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/2beccde96d66
[32/86] exfat: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/522f3c42c9e7
[33/86] ext2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/07be81fce412
[34/86] ext4: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/2ff285d78c4d
[35/86] f2fs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/c495130561ae
[36/86] fat: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/e57260ae3226
[37/86] freevxfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a83513cd029e
[38/86] fuse: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5f1e57582b4e
[39/86] gfs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a5f1a9296668
[40/86] hfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/7ee8d53576e9
[41/86] hfsplus: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/2179ad3569f6
[42/86] hostfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/c3e1be490207
[43/86] hpfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/e08a2ea26b41
[44/86] hugetlbfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a9701db0ca64
[45/86] isofs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/362d327da07e
[46/86] jffs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/36a8a5a63218
[47/86] jfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/acd529413de5
[48/86] kernfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/05acde68936b
[49/86] minix: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/34c1ca111ec1
[50/86] nfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/77e808456854
[51/86] nfsd: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a800ed7ebbbf
[52/86] nilfs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/4ddc9518c2fa
[53/86] ntfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/0d15c2118b1a
[54/86] ntfs3: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/82f8d5fde753
[55/86] ocfs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/45251ebaca70
[56/86] omfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/e7c1ff814326
[57/86] openpromfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/cb62db1d3c61
[58/86] orangefs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/68e257a49aed
[59/86] overlayfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/d482d98dc1bd
[60/86] proc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/8c8afe8a25fa
[61/86] pstore: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/b0be548328a2
[62/86] qnx4: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/c28589f2d838
[63/86] qnx6: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ae0f3d29e728
[64/86] ramfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6315fd97a8fc
[65/86] reiserfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/8eceb9b75a5b
[66/86] romfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6d3dd456da31
[67/86] client: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/b14d4c14f51b
[68/86] server: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/bec3d7ffcecd
[69/86] squashfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/d7d5ff75af52
[70/86] sysv: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/39f012d8743e
[71/86] tracefs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/22ada3856de8
[72/86] ubifs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/af8b66e1d4b7
[73/86] udf: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/1da45142f95a
[74/86] ufs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/41c46d3bb9b3
[75/86] vboxsf: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/cc36ec7935eb
[76/86] xfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ee3be90b2ba7
[77/86] zonefs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/8c798cc16b17
[78/86] linux: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/dd53b64b6f51
[79/86] ipc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/f132b3723b71
[80/86] bpf: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/448a018f67a3
[81/86] mm: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/b6f5b3d5ffc9
[82/86] sunrpc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/fc9db028b8d7
[83/86] apparmor: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/794ef2a745ec
[84/86] selinux: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3d57ee3686d7
[85/86] security: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/71f6d9ebaf43
[86/86] fs: rename inode i_atime and i_mtime fields
        https://git.kernel.org/vfs/vfs/c/fea0e8fc7829

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-09 16:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
     [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
2023-10-04 18:52   ` [PATCH v2 34/89] ext2: convert to new timestamp accessors Jeff Layton
2023-10-04 18:52   ` [PATCH v2 35/89] ext4: " Jeff Layton
2023-10-04 18:52 ` [PATCH v2 01/89] fs: new accessor methods for atime and mtime Jeff Layton
2023-10-04 18:52   ` [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors Jeff Layton
2023-10-09 16:09 ` [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).