All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write
       [not found] <20230705185755.579053-1-jlayton@kernel.org>
@ 2023-07-05 19:00 ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 02/92] bfs: update ctime in addition to mtime when adding entries Jeff Layton
                     ` (87 more replies)
  0 siblings, 88 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Brad Warrum, Ritu Agarwal, Arnd Bergmann,
	Greg Kroah-Hartman
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

POSIX says:

"Upon successful completion, where nbyte is greater than 0, write()
 shall mark for update the last data modification and last file status
 change timestamps of the file..."

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 drivers/misc/ibmvmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
index cbaf6d35e854..d7c7f0305257 100644
--- a/drivers/misc/ibmvmc.c
+++ b/drivers/misc/ibmvmc.c
@@ -1124,7 +1124,7 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
 		goto out;
 
 	inode = file_inode(file);
-	inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode->i_ctime = current_time(inode);
 	mark_inode_dirty(inode);
 
 	dev_dbg(adapter->dev, "write: file = 0x%lx, count = 0x%lx\n",
-- 
2.41.0


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

* [PATCH v2 02/92] bfs: update ctime in addition to mtime when adding entries
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                     ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Tigran A. Aivazian
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

When adding entries to a directory, POSIX generally requires that the
ctime be updated alongside the mtime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/bfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 040d5140e426..d2e8a2a56b05 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -294,7 +294,7 @@ static int bfs_add_entry(struct inode *dir, const struct qstr *child, int ino)
 					dir->i_size += BFS_DIRENT_SIZE;
 					dir->i_ctime = current_time(dir);
 				}
-				dir->i_mtime = current_time(dir);
+				dir->i_mtime = dir->i_ctime = current_time(dir);
 				mark_inode_dirty(dir);
 				de->ino = cpu_to_le16((u16)ino);
 				for (i = 0; i < BFS_NAMELEN; i++)
-- 
2.41.0


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

* [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 02/92] bfs: update ctime in addition to mtime when adding entries Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 04/92] exfat: ensure that ctime is updated whenever the mtime is Jeff Layton
                     ` (85 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Jeremy Kerr, Ard Biesheuvel
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-efi

POSIX says:

"Upon successful completion, where nbyte is greater than 0, write()
 shall mark for update the last data modification and last file status
 change timestamps of the file..."

Add the missing ctime update.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/efivarfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index d57ee15874f9..375576111dc3 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -51,7 +51,7 @@ static ssize_t efivarfs_file_write(struct file *file,
 	} else {
 		inode_lock(inode);
 		i_size_write(inode, datasize + sizeof(attributes));
-		inode->i_mtime = current_time(inode);
+		inode->i_mtime = inode->i_ctime = current_time(inode);
 		inode_unlock(inode);
 	}
 
-- 
2.41.0


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

* [PATCH v2 04/92] exfat: ensure that ctime is updated whenever the mtime is
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 02/92] bfs: update ctime in addition to mtime when adding entries Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 05/92] apparmor: update ctime whenever the mtime changes on an inode Jeff Layton
                     ` (84 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Namjae Jeon, Sungjong Seo
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

When removing entries from a directory, the ctime must also be updated
alongside the mtime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/exfat/namei.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index e0ff9d156f6f..d9b46fa36bff 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -817,7 +817,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
 	ei->dir.dir = DIR_DELETED;
 
 	inode_inc_iversion(dir);
-	dir->i_mtime = dir->i_atime = current_time(dir);
+	dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
 	exfat_truncate_atime(&dir->i_atime);
 	if (IS_DIRSYNC(dir))
 		exfat_sync_inode(dir);
@@ -825,7 +825,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
 		mark_inode_dirty(dir);
 
 	clear_nlink(inode);
-	inode->i_mtime = inode->i_atime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	exfat_unhash_inode(inode);
 	exfat_d_version_set(dentry, inode_query_iversion(dir));
@@ -979,7 +979,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
 	ei->dir.dir = DIR_DELETED;
 
 	inode_inc_iversion(dir);
-	dir->i_mtime = dir->i_atime = current_time(dir);
+	dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
 	exfat_truncate_atime(&dir->i_atime);
 	if (IS_DIRSYNC(dir))
 		exfat_sync_inode(dir);
@@ -988,7 +988,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
 	drop_nlink(dir);
 
 	clear_nlink(inode);
-	inode->i_mtime = inode->i_atime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	exfat_unhash_inode(inode);
 	exfat_d_version_set(dentry, inode_query_iversion(dir));
-- 
2.41.0


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

* [PATCH v2 05/92] apparmor: update ctime whenever the mtime changes on an inode
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (2 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 04/92] exfat: ensure that ctime is updated whenever the mtime is Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
                     ` (83 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, apparmor,
	linux-security-module

In general, when updating the mtime on an inode, one must also update
the ctime. Add the missing ctime updates.

Acked-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 security/apparmor/apparmorfs.c    |  7 +++++--
 security/apparmor/policy_unpack.c | 11 +++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 8e634fde35a5..3d0d370d6ffd 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1554,8 +1554,11 @@ void __aafs_profile_migrate_dents(struct aa_profile *old,
 
 	for (i = 0; i < AAFS_PROF_SIZEOF; i++) {
 		new->dents[i] = old->dents[i];
-		if (new->dents[i])
-			new->dents[i]->d_inode->i_mtime = current_time(new->dents[i]->d_inode);
+		if (new->dents[i]) {
+			struct inode *inode = d_inode(new->dents[i]);
+
+			inode->i_mtime = inode->i_ctime = current_time(inode);
+		}
 		old->dents[i] = NULL;
 	}
 }
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index 694fb7a09962..ed180722a833 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -86,10 +86,13 @@ void __aa_loaddata_update(struct aa_loaddata *data, long revision)
 
 	data->revision = revision;
 	if ((data->dents[AAFS_LOADDATA_REVISION])) {
-		d_inode(data->dents[AAFS_LOADDATA_DIR])->i_mtime =
-			current_time(d_inode(data->dents[AAFS_LOADDATA_DIR]));
-		d_inode(data->dents[AAFS_LOADDATA_REVISION])->i_mtime =
-			current_time(d_inode(data->dents[AAFS_LOADDATA_REVISION]));
+		struct inode *inode;
+
+		inode = d_inode(data->dents[AAFS_LOADDATA_DIR]);
+		inode->i_mtime = inode->i_ctime = current_time(inode);
+
+		inode = d_inode(data->dents[AAFS_LOADDATA_REVISION]);
+		inode->i_mtime = inode->i_ctime = current_time(inode);
 	}
 }
 
-- 
2.41.0


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

* [PATCH v2 06/92] cifs: update the ctime on a partial page write
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (3 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 05/92] apparmor: update ctime whenever the mtime changes on an inode Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
       [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
  2023-07-06 15:26     ` Steve French
  2023-07-05 19:00   ` [PATCH v2 09/92] btrfs: convert to simple_rename_timestamp Jeff Layton
                     ` (82 subsequent siblings)
  87 siblings, 2 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Steve French, Paulo Alcantara,
	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

POSIX says:

    "Upon successful completion, where nbyte is greater than 0, write()
     shall mark for update the last data modification and last file status
     change timestamps of the file..."

Add the missing ctime update.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/smb/client/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 879bc8e6555c..0a5fe8d5314b 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
 					   write_data, to - from, &offset);
 		cifsFileInfo_put(open_file);
 		/* Does mm or vfs already set times? */
-		inode->i_atime = inode->i_mtime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
 		if ((bytes_written > 0) && (offset))
 			rc = 0;
 		else if (bytes_written < 0)
-- 
2.41.0


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

* [PATCH v2 09/92] btrfs: convert to simple_rename_timestamp
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (4 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00     ` Jeff Layton
                     ` (81 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Chris Mason, Josef Bacik, David Sterba
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-btrfs

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/btrfs/inode.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 601fdc956484..521c08b8ad04 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8778,7 +8778,6 @@ static int btrfs_rename_exchange(struct inode *old_dir,
 	struct btrfs_root *dest = BTRFS_I(new_dir)->root;
 	struct inode *new_inode = new_dentry->d_inode;
 	struct inode *old_inode = old_dentry->d_inode;
-	struct timespec64 ctime = current_time(old_inode);
 	struct btrfs_rename_ctx old_rename_ctx;
 	struct btrfs_rename_ctx new_rename_ctx;
 	u64 old_ino = btrfs_ino(BTRFS_I(old_inode));
@@ -8909,12 +8908,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
 	inode_inc_iversion(new_dir);
 	inode_inc_iversion(old_inode);
 	inode_inc_iversion(new_inode);
-	old_dir->i_mtime = ctime;
-	old_dir->i_ctime = ctime;
-	new_dir->i_mtime = ctime;
-	new_dir->i_ctime = ctime;
-	old_inode->i_ctime = ctime;
-	new_inode->i_ctime = ctime;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	if (old_dentry->d_parent != new_dentry->d_parent) {
 		btrfs_record_unlink_dir(trans, BTRFS_I(old_dir),
@@ -9178,11 +9172,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
 	inode_inc_iversion(old_dir);
 	inode_inc_iversion(new_dir);
 	inode_inc_iversion(old_inode);
-	old_dir->i_mtime = current_time(old_dir);
-	old_dir->i_ctime = old_dir->i_mtime;
-	new_dir->i_mtime = old_dir->i_mtime;
-	new_dir->i_ctime = old_dir->i_mtime;
-	old_inode->i_ctime = old_dir->i_mtime;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	if (old_dentry->d_parent != new_dentry->d_parent)
 		btrfs_record_unlink_dir(trans, BTRFS_I(old_dir),
@@ -9204,7 +9194,6 @@ static int btrfs_rename(struct mnt_idmap *idmap,
 
 	if (new_inode) {
 		inode_inc_iversion(new_inode);
-		new_inode->i_ctime = current_time(new_inode);
 		if (unlikely(btrfs_ino(BTRFS_I(new_inode)) ==
 			     BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
 			ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry);
-- 
2.41.0


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

* [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:00     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ubifs/dir.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index ef0499edc248..7ec25310bd8a 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 * Like most other Unix systems, set the @i_ctime for inodes on a
 	 * rename.
 	 */
-	time = current_time(old_dir);
-	old_inode->i_ctime = time;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	/* We must adjust parent link count when renaming directories */
 	if (is_dir) {
@@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 	old_dir->i_size -= old_sz;
 	ubifs_inode(old_dir)->ui_size = old_dir->i_size;
-	old_dir->i_mtime = old_dir->i_ctime = time;
-	new_dir->i_mtime = new_dir->i_ctime = time;
 
 	/*
 	 * And finally, if we unlinked a direntry which happened to have the
 	 * same name as the moved direntry, we have to decrement @i_nlink of
-	 * the unlinked inode and change its ctime.
+	 * the unlinked inode.
 	 */
 	if (unlink) {
 		/*
@@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 			clear_nlink(new_inode);
 		else
 			drop_nlink(new_inode);
-		new_inode->i_ctime = time;
 	} else {
 		new_dir->i_size += new_sz;
 		ubifs_inode(new_dir)->ui_size = new_dir->i_size;
@@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
 	struct inode *fst_inode = d_inode(old_dentry);
 	struct inode *snd_inode = d_inode(new_dentry);
-	struct timespec64 time;
 	int err;
 	struct fscrypt_name fst_nm, snd_nm;
 
@@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 
 	lock_4_inodes(old_dir, new_dir, NULL, NULL);
 
-	time = current_time(old_dir);
-	fst_inode->i_ctime = time;
-	snd_inode->i_ctime = time;
-	old_dir->i_mtime = old_dir->i_ctime = time;
-	new_dir->i_mtime = new_dir->i_ctime = time;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	if (old_dir != new_dir) {
 		if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
-- 
2.41.0


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

* [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp
@ 2023-07-05 19:00     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ubifs/dir.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index ef0499edc248..7ec25310bd8a 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 * Like most other Unix systems, set the @i_ctime for inodes on a
 	 * rename.
 	 */
-	time = current_time(old_dir);
-	old_inode->i_ctime = time;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	/* We must adjust parent link count when renaming directories */
 	if (is_dir) {
@@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 	old_dir->i_size -= old_sz;
 	ubifs_inode(old_dir)->ui_size = old_dir->i_size;
-	old_dir->i_mtime = old_dir->i_ctime = time;
-	new_dir->i_mtime = new_dir->i_ctime = time;
 
 	/*
 	 * And finally, if we unlinked a direntry which happened to have the
 	 * same name as the moved direntry, we have to decrement @i_nlink of
-	 * the unlinked inode and change its ctime.
+	 * the unlinked inode.
 	 */
 	if (unlink) {
 		/*
@@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 			clear_nlink(new_inode);
 		else
 			drop_nlink(new_inode);
-		new_inode->i_ctime = time;
 	} else {
 		new_dir->i_size += new_sz;
 		ubifs_inode(new_dir)->ui_size = new_dir->i_size;
@@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
 	struct inode *fst_inode = d_inode(old_dentry);
 	struct inode *snd_inode = d_inode(new_dentry);
-	struct timespec64 time;
 	int err;
 	struct fscrypt_name fst_nm, snd_nm;
 
@@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 
 	lock_4_inodes(old_dir, new_dir, NULL, NULL);
 
-	time = current_time(old_dir);
-	fst_inode->i_ctime = time;
-	snd_inode->i_ctime = time;
-	old_dir->i_mtime = old_dir->i_ctime = time;
-	new_dir->i_mtime = new_dir->i_ctime = time;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	if (old_dir != new_dir) {
 		if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
-- 
2.41.0


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

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

* [PATCH v2 11/92] shmem: convert to simple_rename_timestamp
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (6 preceding siblings ...)
  2023-07-05 19:00     ` Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:33     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 12/92] exfat: " Jeff Layton
                     ` (79 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Hugh Dickins, Andrew Morton
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mm

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 mm/shmem.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 0f45e72a5ca7..1693134959c5 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3306,9 +3306,7 @@ static int shmem_rename2(struct mnt_idmap *idmap,
 
 	old_dir->i_size -= BOGO_DIRENT_SIZE;
 	new_dir->i_size += BOGO_DIRENT_SIZE;
-	old_dir->i_ctime = old_dir->i_mtime =
-	new_dir->i_ctime = new_dir->i_mtime =
-	inode->i_ctime = current_time(old_dir);
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 	inode_inc_iversion(old_dir);
 	inode_inc_iversion(new_dir);
 	return 0;
-- 
2.41.0


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

* [PATCH v2 12/92] exfat: convert to simple_rename_timestamp
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (7 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 11/92] shmem: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:39     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 13/92] ntfs3: " Jeff Layton
                     ` (78 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Namjae Jeon, Sungjong Seo
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/exfat/namei.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index d9b46fa36bff..e91022ff80ef 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -1312,8 +1312,8 @@ static int exfat_rename(struct mnt_idmap *idmap,
 		goto unlock;
 
 	inode_inc_iversion(new_dir);
-	new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime =
-		EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
+	EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
 	exfat_truncate_atime(&new_dir->i_atime);
 	if (IS_DIRSYNC(new_dir))
 		exfat_sync_inode(new_dir);
@@ -1336,7 +1336,6 @@ static int exfat_rename(struct mnt_idmap *idmap,
 	}
 
 	inode_inc_iversion(old_dir);
-	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
 	if (IS_DIRSYNC(old_dir))
 		exfat_sync_inode(old_dir);
 	else
-- 
2.41.0


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

* [PATCH v2 13/92] ntfs3: convert to simple_rename_timestamp
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (8 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 12/92] exfat: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:40     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 14/92] reiserfs: " Jeff Layton
                     ` (77 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Konstantin Komarov
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ntfs3

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ntfs3/namei.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index 70f8c859e0ad..bfd986699f9e 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -324,14 +324,11 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
 		/* Restore after failed rename failed too. */
 		_ntfs_bad_inode(inode);
 	} else if (!err) {
-		inode->i_ctime = dir->i_ctime = dir->i_mtime =
-			current_time(dir);
+		simple_rename_timestamp(dir, dentry, new_dir, new_dentry);
 		mark_inode_dirty(inode);
 		mark_inode_dirty(dir);
-		if (dir != new_dir) {
-			new_dir->i_mtime = new_dir->i_ctime = dir->i_ctime;
+		if (dir != new_dir)
 			mark_inode_dirty(new_dir);
-		}
 
 		if (IS_DIRSYNC(dir))
 			ntfs_sync_inode(dir);
-- 
2.41.0


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

* [PATCH v2 14/92] reiserfs: convert to simple_rename_timestamp
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (9 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 13/92] ntfs3: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:32     ` Jan Kara
  2023-07-05 19:00     ` Jeff Layton
                     ` (76 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, reiserfs-devel

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/reiserfs/namei.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 52240cc891cf..405ac59eb2dd 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1325,7 +1325,6 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
 	int jbegin_count;
 	umode_t old_inode_mode;
 	unsigned long savelink = 1;
-	struct timespec64 ctime;
 
 	if (flags & ~RENAME_NOREPLACE)
 		return -EINVAL;
@@ -1576,14 +1575,11 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
 
 	mark_de_hidden(old_de.de_deh + old_de.de_entry_num);
 	journal_mark_dirty(&th, old_de.de_bh);
-	ctime = current_time(old_dir);
-	old_dir->i_ctime = old_dir->i_mtime = ctime;
-	new_dir->i_ctime = new_dir->i_mtime = ctime;
 	/*
 	 * thanks to Alex Adriaanse <alex_a@caltech.edu> for patch
 	 * which adds ctime update of renamed object
 	 */
-	old_inode->i_ctime = ctime;
+	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
 
 	if (new_dentry_inode) {
 		/* adjust link number of the victim */
@@ -1592,7 +1588,6 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
 		} else {
 			drop_nlink(new_dentry_inode);
 		}
-		new_dentry_inode->i_ctime = ctime;
 		savelink = new_dentry_inode->i_nlink;
 	}
 
-- 
2.41.0


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

* [PATCH v2 15/92] spufs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:00     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Jeremy Kerr, Arnd Bergmann, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linuxppc-dev

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index ea807aa0c31a..38c5be34c895 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -86,7 +86,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
 	inode->i_mode = mode;
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 out:
 	return inode;
 }
-- 
2.41.0


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

* [PATCH v2 15/92] spufs: convert to ctime accessor functions
@ 2023-07-05 19:00     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Jeremy Kerr, Arnd Bergmann, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy
  Cc: linux-fsdevel, linuxppc-dev, Jan Kara, Al Viro, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index ea807aa0c31a..38c5be34c895 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -86,7 +86,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
 	inode->i_mode = mode;
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 out:
 	return inode;
 }
-- 
2.41.0


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

* [PATCH v2 16/92] s390: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (11 preceding siblings ...)
  2023-07-05 19:00     ` Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-12 12:56     ` Alexander Gordeev
  2023-07-05 19:00   ` [PATCH v2 17/92] binderfs: " Jeff Layton
                     ` (74 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-s390

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 arch/s390/hypfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index ee919bfc8186..5feef8da406b 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -53,7 +53,7 @@ static void hypfs_update_update(struct super_block *sb)
 	struct inode *inode = d_inode(sb_info->update_file);
 
 	sb_info->last_update = ktime_get_seconds();
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 }
 
 /* directory tree removal functions */
@@ -101,7 +101,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)
 		ret->i_mode = mode;
 		ret->i_uid = hypfs_info->uid;
 		ret->i_gid = hypfs_info->gid;
-		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
+		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
 		if (S_ISDIR(mode))
 			set_nlink(ret, 2);
 	}
-- 
2.41.0


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

* [PATCH v2 17/92] binderfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (12 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 16/92] s390: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 18/92] infiniband: " Jeff Layton
                     ` (73 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Greg Kroah-Hartman, Arve Hjønnevåg,
	Todd Kjos, Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 drivers/android/binderfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 76e7d6676657..faebe9f5412a 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -153,7 +153,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
 		goto err;
 
 	inode->i_ino = minor + INODE_OFFSET;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	init_special_inode(inode, S_IFCHR | 0600,
 			   MKDEV(MAJOR(binderfs_dev), minor));
 	inode->i_fop = &binder_fops;
@@ -432,7 +432,7 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
 	}
 
 	inode->i_ino = SECOND_INODE;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	init_special_inode(inode, S_IFCHR | 0600,
 			   MKDEV(MAJOR(binderfs_dev), minor));
 	inode->i_fop = &binder_ctl_fops;
@@ -474,7 +474,7 @@ static struct inode *binderfs_make_inode(struct super_block *sb, int mode)
 	if (ret) {
 		ret->i_ino = iunique(sb, BINDERFS_MAX_MINOR + INODE_OFFSET);
 		ret->i_mode = mode;
-		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
+		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
 	}
 	return ret;
 }
@@ -703,7 +703,7 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	inode->i_ino = FIRST_INODE;
 	inode->i_fop = &simple_dir_operations;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_op = &binderfs_dir_inode_operations;
 	set_nlink(inode, 2);
 
-- 
2.41.0


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

* [PATCH v2 18/92] infiniband: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (13 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 17/92] binderfs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 19/92] ibm: " Jeff Layton
                     ` (72 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-rdma

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 drivers/infiniband/hw/qib/qib_fs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index a973905afd13..ed7d4b02f45a 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -64,9 +64,8 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
 	inode->i_uid = GLOBAL_ROOT_UID;
 	inode->i_gid = GLOBAL_ROOT_GID;
 	inode->i_blocks = 0;
-	inode->i_atime = current_time(inode);
+	inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_mtime = inode->i_atime;
-	inode->i_ctime = inode->i_atime;
 	inode->i_private = data;
 	if (S_ISDIR(mode)) {
 		inode->i_op = &simple_dir_inode_operations;
-- 
2.41.0


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

* [PATCH v2 19/92] ibm: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (14 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 18/92] infiniband: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:41     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 20/92] usb: " Jeff Layton
                     ` (71 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Arnd Bergmann, Greg Kroah-Hartman,
	Brad Warrum, Ritu Agarwal
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 drivers/misc/ibmasm/ibmasmfs.c | 2 +-
 drivers/misc/ibmvmc.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 35fec1bf1b3d..5867af9f592c 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -139,7 +139,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
 	if (ret) {
 		ret->i_ino = get_next_ino();
 		ret->i_mode = mode;
-		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
+		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
 	}
 	return ret;
 }
diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
index d7c7f0305257..2101eb12bcba 100644
--- a/drivers/misc/ibmvmc.c
+++ b/drivers/misc/ibmvmc.c
@@ -1124,7 +1124,7 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
 		goto out;
 
 	inode = file_inode(file);
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	dev_dbg(adapter->dev, "write: file = 0x%lx, count = 0x%lx\n",
-- 
2.41.0


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

* [PATCH v2 20/92] usb: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (15 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 19/92] ibm: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 21/92] 9p: " Jeff Layton
                     ` (70 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Greg Kroah-Hartman
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-usb

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 drivers/usb/core/devio.c           | 16 ++++++++--------
 drivers/usb/gadget/function/f_fs.c |  3 +--
 drivers/usb/gadget/legacy/inode.c  |  3 +--
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 1a16a8bdea60..4f68f6ef3cc1 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -2642,21 +2642,21 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		snoop(&dev->dev, "%s: CONTROL\n", __func__);
 		ret = proc_control(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_BULK:
 		snoop(&dev->dev, "%s: BULK\n", __func__);
 		ret = proc_bulk(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_RESETEP:
 		snoop(&dev->dev, "%s: RESETEP\n", __func__);
 		ret = proc_resetep(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_RESET:
@@ -2668,7 +2668,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__);
 		ret = proc_clearhalt(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_GETDRIVER:
@@ -2695,7 +2695,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
 		ret = proc_submiturb(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 #ifdef CONFIG_COMPAT
@@ -2703,14 +2703,14 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		snoop(&dev->dev, "%s: CONTROL32\n", __func__);
 		ret = proc_control_compat(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_BULK32:
 		snoop(&dev->dev, "%s: BULK32\n", __func__);
 		ret = proc_bulk_compat(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_DISCSIGNAL32:
@@ -2722,7 +2722,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
 		snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
 		ret = proc_submiturb_compat(ps, p);
 		if (ret >= 0)
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		break;
 
 	case USBDEVFS_IOCTL32:
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index f41a385a5c42..6e9ef35a43a7 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1377,7 +1377,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
 	inode = new_inode(sb);
 
 	if (inode) {
-		struct timespec64 ts = current_time(inode);
+		struct timespec64 ts = inode_set_ctime_current(inode);
 
 		inode->i_ino	 = get_next_ino();
 		inode->i_mode    = perms->mode;
@@ -1385,7 +1385,6 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
 		inode->i_gid     = perms->gid;
 		inode->i_atime   = ts;
 		inode->i_mtime   = ts;
-		inode->i_ctime   = ts;
 		inode->i_private = data;
 		if (fops)
 			inode->i_fop = fops;
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 28249d0bf062..ce9e31f3d26b 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1969,8 +1969,7 @@ gadgetfs_make_inode (struct super_block *sb,
 		inode->i_mode = mode;
 		inode->i_uid = make_kuid(&init_user_ns, default_uid);
 		inode->i_gid = make_kgid(&init_user_ns, default_gid);
-		inode->i_atime = inode->i_mtime = inode->i_ctime
-				= current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inode->i_private = data;
 		inode->i_fop = fops;
 	}
-- 
2.41.0


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

* [PATCH v2 21/92] 9p: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (16 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 20/92] usb: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 22/92] adfs: " Jeff Layton
                     ` (69 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Eric Van Hensbergen, Latchesar Ionkov,
	Dominique Martinet, Christian Schoenebeck
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, v9fs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/9p/vfs_inode.c      | 4 ++--
 fs/9p/vfs_inode_dotl.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 36b466e35887..16d85e6033a3 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -261,7 +261,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
 	inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
 	inode->i_blocks = 0;
 	inode->i_rdev = rdev;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_mapping->a_ops = &v9fs_addr_operations;
 	inode->i_private = NULL;
 
@@ -1158,7 +1158,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
 
 	inode->i_atime.tv_sec = stat->atime;
 	inode->i_mtime.tv_sec = stat->mtime;
-	inode->i_ctime.tv_sec = stat->mtime;
+	inode_set_ctime(inode, stat->mtime, 0);
 
 	inode->i_uid = v9ses->dfltuid;
 	inode->i_gid = v9ses->dfltgid;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 5361cd2d7996..464ea73d1bf8 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -646,8 +646,8 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
 		inode->i_atime.tv_nsec = stat->st_atime_nsec;
 		inode->i_mtime.tv_sec = stat->st_mtime_sec;
 		inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
-		inode->i_ctime.tv_sec = stat->st_ctime_sec;
-		inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
+		inode_set_ctime(inode, stat->st_ctime_sec,
+				stat->st_ctime_nsec);
 		inode->i_uid = stat->st_uid;
 		inode->i_gid = stat->st_gid;
 		set_nlink(inode, stat->st_nlink);
@@ -669,8 +669,8 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
 			inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
 		}
 		if (stat->st_result_mask & P9_STATS_CTIME) {
-			inode->i_ctime.tv_sec = stat->st_ctime_sec;
-			inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
+			inode_set_ctime(inode, stat->st_ctime_sec,
+					stat->st_ctime_nsec);
 		}
 		if (stat->st_result_mask & P9_STATS_UID)
 			inode->i_uid = stat->st_uid;
-- 
2.41.0


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

* [PATCH v2 22/92] adfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (17 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 21/92] 9p: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 23/92] affs: " Jeff Layton
                     ` (68 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/adfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index c3ac613d0975..20963002578a 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -270,7 +270,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
 	inode->i_mode	 = adfs_atts2mode(sb, inode);
 	adfs_adfs2unix_time(&inode->i_mtime, inode);
 	inode->i_atime = inode->i_mtime;
-	inode->i_ctime = inode->i_mtime;
+	inode_set_ctime_to_ts(inode, inode->i_mtime);
 
 	if (S_ISDIR(inode->i_mode)) {
 		inode->i_op	= &adfs_dir_inode_operations;
@@ -331,7 +331,7 @@ adfs_notify_change(struct mnt_idmap *idmap, struct dentry *dentry,
 	if (ia_valid & ATTR_ATIME)
 		inode->i_atime = attr->ia_atime;
 	if (ia_valid & ATTR_CTIME)
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
 		ADFS_I(inode)->attr = adfs_mode2atts(sb, inode, attr->ia_mode);
 		inode->i_mode = adfs_atts2mode(sb, inode);
-- 
2.41.0


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

* [PATCH v2 23/92] affs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (18 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 22/92] adfs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 24/92] afs: " Jeff Layton
                     ` (67 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, David Sterba
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: David Sterba <dsterba@suse.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/affs/amigaffs.c |  6 +++---
 fs/affs/inode.c    | 16 ++++++++--------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 29f11e10a7c7..7ba93efc1143 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -60,7 +60,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
 	mark_buffer_dirty_inode(dir_bh, dir);
 	affs_brelse(dir_bh);
 
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	inode_inc_iversion(dir);
 	mark_inode_dirty(dir);
 
@@ -114,7 +114,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh)
 
 	affs_brelse(bh);
 
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	inode_inc_iversion(dir);
 	mark_inode_dirty(dir);
 
@@ -315,7 +315,7 @@ affs_remove_header(struct dentry *dentry)
 	else
 		clear_nlink(inode);
 	affs_unlock_link(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 done:
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 27f77a52c5c8..060746c63151 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -149,13 +149,13 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
 		break;
 	}
 
-	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec
-		       = (be32_to_cpu(tail->change.days) * 86400LL +
-		         be32_to_cpu(tail->change.mins) * 60 +
-			 be32_to_cpu(tail->change.ticks) / 50 +
-			 AFFS_EPOCH_DELTA) +
-			 sys_tz.tz_minuteswest * 60;
-	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0;
+	inode->i_mtime.tv_sec = inode->i_atime.tv_sec =
+		inode_set_ctime(inode,
+				(be32_to_cpu(tail->change.days) * 86400LL +
+				 be32_to_cpu(tail->change.mins) * 60 +
+				 be32_to_cpu(tail->change.ticks) / 50 + AFFS_EPOCH_DELTA)
+				+ sys_tz.tz_minuteswest * 60, 0).tv_sec;
+	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0;
 	affs_brelse(bh);
 	unlock_new_inode(inode);
 	return inode;
@@ -314,7 +314,7 @@ affs_new_inode(struct inode *dir)
 	inode->i_gid     = current_fsgid();
 	inode->i_ino     = block;
 	set_nlink(inode, 1);
-	inode->i_mtime   = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime   = inode->i_atime = inode_set_ctime_current(inode);
 	atomic_set(&AFFS_I(inode)->i_opencnt, 0);
 	AFFS_I(inode)->i_blkcnt = 0;
 	AFFS_I(inode)->i_lc = NULL;
-- 
2.41.0


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

* [PATCH v2 24/92] afs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (19 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 23/92] affs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 25/92] fs: " Jeff Layton
                     ` (66 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, David Howells, Marc Dionne
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-afs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/afs/dynroot.c | 2 +-
 fs/afs/inode.c   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c
index d7d9402ff718..95bcbd7654d1 100644
--- a/fs/afs/dynroot.c
+++ b/fs/afs/dynroot.c
@@ -88,7 +88,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
 	set_nlink(inode, 2);
 	inode->i_uid		= GLOBAL_ROOT_UID;
 	inode->i_gid		= GLOBAL_ROOT_GID;
-	inode->i_ctime = inode->i_atime = inode->i_mtime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_blocks		= 0;
 	inode->i_generation	= 0;
 
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 866bab860a88..6b636f43f548 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -90,7 +90,7 @@ static int afs_inode_init_from_status(struct afs_operation *op,
 	vnode->status = *status;
 
 	t = status->mtime_client;
-	inode->i_ctime = t;
+	inode_set_ctime_to_ts(inode, t);
 	inode->i_mtime = t;
 	inode->i_atime = t;
 	inode->i_flags |= S_NOATIME;
@@ -206,7 +206,7 @@ static void afs_apply_status(struct afs_operation *op,
 	t = status->mtime_client;
 	inode->i_mtime = t;
 	if (vp->update_ctime)
-		inode->i_ctime = op->ctime;
+		inode_set_ctime_to_ts(inode, op->ctime);
 
 	if (vnode->status.data_version != status->data_version)
 		data_changed = true;
@@ -252,7 +252,7 @@ static void afs_apply_status(struct afs_operation *op,
 		vnode->netfs.remote_i_size = status->size;
 		if (change_size) {
 			afs_set_i_size(vnode, status->size);
-			inode->i_ctime = t;
+			inode_set_ctime_to_ts(inode, t);
 			inode->i_atime = t;
 		}
 	}
-- 
2.41.0


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

* [PATCH v2 25/92] fs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (20 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 24/92] afs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 26/92] autofs: " Jeff Layton
                     ` (65 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Alexander Viro, Eric Biederman, Kees Cook
  Cc: Jan Kara, linux-fsdevel, linux-kernel, linux-mm

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/attr.c        |  2 +-
 fs/bad_inode.c   |  3 +--
 fs/binfmt_misc.c |  3 +--
 fs/inode.c       | 10 +++++++---
 fs/nsfs.c        |  2 +-
 fs/pipe.c        |  2 +-
 fs/posix_acl.c   |  2 +-
 fs/stack.c       |  2 +-
 fs/stat.c        |  2 +-
 9 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index d60dc1edb526..599f6d14c0ed 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -312,7 +312,7 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode,
 	if (ia_valid & ATTR_MTIME)
 		inode->i_mtime = attr->ia_mtime;
 	if (ia_valid & ATTR_CTIME)
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 		if (!in_group_or_capable(idmap, inode,
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index db649487d58c..6e21f7412a85 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -209,8 +209,7 @@ void make_bad_inode(struct inode *inode)
 	remove_inode_hash(inode);
 
 	inode->i_mode = S_IFREG;
-	inode->i_atime = inode->i_mtime = inode->i_ctime =
-		current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(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 bb202ad369d5..e0108d17b085 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -547,8 +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->i_ctime =
-			current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	}
 	return inode;
 }
diff --git a/fs/inode.c b/fs/inode.c
index 21b026d95b51..32e08c3fa9ff 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1851,6 +1851,7 @@ EXPORT_SYMBOL(bmap);
 static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
 			     struct timespec64 now)
 {
+	struct timespec64 ctime;
 
 	if (!(mnt->mnt_flags & MNT_RELATIME))
 		return 1;
@@ -1862,7 +1863,8 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
 	/*
 	 * Is ctime younger than or equal to atime? If yes, update atime:
 	 */
-	if (timespec64_compare(&inode->i_ctime, &inode->i_atime) >= 0)
+	ctime = inode_get_ctime(inode);
+	if (timespec64_compare(&ctime, &inode->i_atime) >= 0)
 		return 1;
 
 	/*
@@ -1885,7 +1887,7 @@ int generic_update_time(struct inode *inode, struct timespec64 *time, int flags)
 		if (flags & S_ATIME)
 			inode->i_atime = *time;
 		if (flags & S_CTIME)
-			inode->i_ctime = *time;
+			inode_set_ctime_to_ts(inode, *time);
 		if (flags & S_MTIME)
 			inode->i_mtime = *time;
 
@@ -2071,6 +2073,7 @@ EXPORT_SYMBOL(file_remove_privs);
 static int inode_needs_update_time(struct inode *inode, struct timespec64 *now)
 {
 	int sync_it = 0;
+	struct timespec64 ctime;
 
 	/* First try to exhaust all avenues to not sync */
 	if (IS_NOCMTIME(inode))
@@ -2079,7 +2082,8 @@ static int inode_needs_update_time(struct inode *inode, struct timespec64 *now)
 	if (!timespec64_equal(&inode->i_mtime, now))
 		sync_it = S_MTIME;
 
-	if (!timespec64_equal(&inode->i_ctime, now))
+	ctime = inode_get_ctime(inode);
+	if (!timespec64_equal(&ctime, 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 f602a96a1afe..647a22433bd8 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->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(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 2d88f73f585a..174682103669 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -899,7 +899,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->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 
 	return inode;
 
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 7fa1b738bbab..a05fe94970ce 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -1027,7 +1027,7 @@ int simple_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 			return error;
 	}
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (IS_I_VERSION(inode))
 		inode_inc_iversion(inode);
 	set_cached_acl(inode, type, acl);
diff --git a/fs/stack.c b/fs/stack.c
index c9830924eb12..b5e01bdb5f5f 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -68,7 +68,7 @@ void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
 	dest->i_rdev = src->i_rdev;
 	dest->i_atime = src->i_atime;
 	dest->i_mtime = src->i_mtime;
-	dest->i_ctime = src->i_ctime;
+	inode_set_ctime_to_ts(dest, inode_get_ctime(src));
 	dest->i_blkbits = src->i_blkbits;
 	dest->i_flags = src->i_flags;
 	set_nlink(dest, src->i_nlink);
diff --git a/fs/stat.c b/fs/stat.c
index 7c238da22ef0..8c2b30af19f5 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -58,7 +58,7 @@ void generic_fillattr(struct mnt_idmap *idmap, struct inode *inode,
 	stat->size = i_size_read(inode);
 	stat->atime = inode->i_atime;
 	stat->mtime = inode->i_mtime;
-	stat->ctime = inode->i_ctime;
+	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] 208+ messages in thread

* [PATCH v2 26/92] autofs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (21 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 25/92] fs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 27/92] befs: " Jeff Layton
                     ` (64 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Ian Kent
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, autofs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Ian Kent <raven@themaw.net>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/autofs/inode.c | 2 +-
 fs/autofs/root.c  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index affa70360b1f..2b49662ed237 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -370,7 +370,7 @@ struct inode *autofs_get_inode(struct super_block *sb, umode_t mode)
 		inode->i_uid = d_inode(sb->s_root)->i_uid;
 		inode->i_gid = d_inode(sb->s_root)->i_gid;
 	}
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_ino = get_next_ino();
 
 	if (S_ISDIR(mode)) {
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 93046c9dc461..512b9a26c63d 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -600,7 +600,7 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
 	p_ino = autofs_dentry_ino(dentry->d_parent);
 	p_ino->count++;
 
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	return 0;
 }
@@ -633,7 +633,7 @@ static int autofs_dir_unlink(struct inode *dir, struct dentry *dentry)
 	d_inode(dentry)->i_size = 0;
 	clear_nlink(d_inode(dentry));
 
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	spin_lock(&sbi->lookup_lock);
 	__autofs_add_expiring(dentry);
@@ -749,7 +749,7 @@ static int autofs_dir_mkdir(struct mnt_idmap *idmap,
 	p_ino = autofs_dentry_ino(dentry->d_parent);
 	p_ino->count++;
 	inc_nlink(dir);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	return 0;
 }
-- 
2.41.0


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

* [PATCH v2 27/92] befs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (22 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 26/92] autofs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 28/92] bfs: " Jeff Layton
                     ` (63 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Luis de Bethencourt, Salah Triki
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/befs/linuxvfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index eee9237386e2..9a16a51fbb88 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -363,7 +363,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
 	inode->i_mtime.tv_sec =
 	    fs64_to_cpu(sb, raw_inode->last_modified_time) >> 16;
 	inode->i_mtime.tv_nsec = 0;   /* lower 16 bits are not a time */
-	inode->i_ctime = inode->i_mtime;
+	inode_set_ctime_to_ts(inode, inode->i_mtime);
 	inode->i_atime = inode->i_mtime;
 
 	befs_ino->i_inode_num = fsrun_to_cpu(sb, raw_inode->inode_num);
-- 
2.41.0


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

* [PATCH v2 28/92] bfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (23 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 27/92] befs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:44     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 29/92] btrfs: " Jeff Layton
                     ` (62 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Tigran A. Aivazian
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/bfs/dir.c   | 16 ++++++++--------
 fs/bfs/inode.c |  5 ++---
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index d2e8a2a56b05..12b8af04dcb3 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -97,7 +97,7 @@ static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
 	set_bit(ino, info->si_imap);
 	info->si_freei--;
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_blocks = 0;
 	inode->i_op = &bfs_file_inops;
 	inode->i_fop = &bfs_file_operations;
@@ -158,7 +158,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
 		return err;
 	}
 	inc_nlink(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	ihold(inode);
 	d_instantiate(new, inode);
@@ -187,9 +187,9 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
 	}
 	de->ino = 0;
 	mark_buffer_dirty_inode(bh, dir);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	inode_dec_link_count(inode);
 	error = 0;
 
@@ -240,10 +240,10 @@ static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 			goto end_rename;
 	}
 	old_de->ino = 0;
-	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
+	old_dir->i_mtime = inode_set_ctime_current(old_dir);
 	mark_inode_dirty(old_dir);
 	if (new_inode) {
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		inode_dec_link_count(new_inode);
 	}
 	mark_buffer_dirty_inode(old_bh, old_dir);
@@ -292,9 +292,9 @@ static int bfs_add_entry(struct inode *dir, const struct qstr *child, int ino)
 				pos = (block - sblock) * BFS_BSIZE + off;
 				if (pos >= dir->i_size) {
 					dir->i_size += BFS_DIRENT_SIZE;
-					dir->i_ctime = current_time(dir);
+					inode_set_ctime_current(dir);
 				}
-				dir->i_mtime = dir->i_ctime = current_time(dir);
+				dir->i_mtime = inode_set_ctime_current(dir);
 				mark_inode_dirty(dir);
 				de->ino = cpu_to_le16((u16)ino);
 				for (i = 0; i < BFS_NAMELEN; i++)
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 1926bec2c850..e6a76ae9eb44 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -82,10 +82,9 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
 	inode->i_blocks = BFS_FILEBLOCKS(di);
 	inode->i_atime.tv_sec =  le32_to_cpu(di->i_atime);
 	inode->i_mtime.tv_sec =  le32_to_cpu(di->i_mtime);
-	inode->i_ctime.tv_sec =  le32_to_cpu(di->i_ctime);
+	inode_set_ctime(inode, le32_to_cpu(di->i_ctime), 0);
 	inode->i_atime.tv_nsec = 0;
 	inode->i_mtime.tv_nsec = 0;
-	inode->i_ctime.tv_nsec = 0;
 
 	brelse(bh);
 	unlock_new_inode(inode);
@@ -143,7 +142,7 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 	di->i_nlink = cpu_to_le32(inode->i_nlink);
 	di->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
 	di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
-	di->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
+	di->i_ctime = cpu_to_le32(inode_get_ctime(inode).tv_sec);
 	i_sblock = BFS_I(inode)->i_sblock;
 	di->i_sblock = cpu_to_le32(i_sblock);
 	di->i_eblock = cpu_to_le32(BFS_I(inode)->i_eblock);
-- 
2.41.0


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

* [PATCH v2 29/92] btrfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (24 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 28/92] bfs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:51     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 30/92] ceph: " Jeff Layton
                     ` (61 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Chris Mason, Josef Bacik, David Sterba
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-btrfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/btrfs/delayed-inode.c |  8 ++++----
 fs/btrfs/file.c          | 21 +++++++++------------
 fs/btrfs/inode.c         | 39 ++++++++++++++++-----------------------
 fs/btrfs/ioctl.c         |  2 +-
 fs/btrfs/reflink.c       |  3 +--
 fs/btrfs/transaction.c   |  3 +--
 fs/btrfs/tree-log.c      |  4 ++--
 fs/btrfs/xattr.c         |  4 ++--
 8 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index c0a6a1784697..e2753d228037 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1808,9 +1808,9 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
 				      inode->i_mtime.tv_nsec);
 
 	btrfs_set_stack_timespec_sec(&inode_item->ctime,
-				     inode->i_ctime.tv_sec);
+				     inode_get_ctime(inode).tv_sec);
 	btrfs_set_stack_timespec_nsec(&inode_item->ctime,
-				      inode->i_ctime.tv_nsec);
+				      inode_get_ctime(inode).tv_nsec);
 
 	btrfs_set_stack_timespec_sec(&inode_item->otime,
 				     BTRFS_I(inode)->i_otime.tv_sec);
@@ -1861,8 +1861,8 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
 	inode->i_mtime.tv_sec = btrfs_stack_timespec_sec(&inode_item->mtime);
 	inode->i_mtime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->mtime);
 
-	inode->i_ctime.tv_sec = btrfs_stack_timespec_sec(&inode_item->ctime);
-	inode->i_ctime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->ctime);
+	inode_set_ctime(inode, btrfs_stack_timespec_sec(&inode_item->ctime),
+			btrfs_stack_timespec_nsec(&inode_item->ctime));
 
 	BTRFS_I(inode)->i_otime.tv_sec =
 		btrfs_stack_timespec_sec(&inode_item->otime);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index fd03e689a6be..d7a9ece7a40b 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1108,7 +1108,7 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode)
 
 static void update_time_for_write(struct inode *inode)
 {
-	struct timespec64 now;
+	struct timespec64 now, ctime;
 
 	if (IS_NOCMTIME(inode))
 		return;
@@ -1117,8 +1117,9 @@ static void update_time_for_write(struct inode *inode)
 	if (!timespec64_equal(&inode->i_mtime, &now))
 		inode->i_mtime = now;
 
-	if (!timespec64_equal(&inode->i_ctime, &now))
-		inode->i_ctime = now;
+	ctime = inode_get_ctime(inode);
+	if (!timespec64_equal(&ctime, &now))
+		inode_set_ctime_to_ts(inode, now);
 
 	if (IS_I_VERSION(inode))
 		inode_inc_iversion(inode);
@@ -2459,10 +2460,8 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
 		 */
 		inode_inc_iversion(&inode->vfs_inode);
 
-		if (!extent_info || extent_info->update_times) {
-			inode->vfs_inode.i_mtime = current_time(&inode->vfs_inode);
-			inode->vfs_inode.i_ctime = inode->vfs_inode.i_mtime;
-		}
+		if (!extent_info || extent_info->update_times)
+			inode->vfs_inode.i_mtime = inode_set_ctime_current(&inode->vfs_inode);
 
 		ret = btrfs_update_inode(trans, root, inode);
 		if (ret)
@@ -2703,8 +2702,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 
 	ASSERT(trans != NULL);
 	inode_inc_iversion(inode);
-	inode->i_mtime = current_time(inode);
-	inode->i_ctime = inode->i_mtime;
+	inode->i_mtime = inode_set_ctime_current(inode);
 	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
 	updated_inode = true;
 	btrfs_end_transaction(trans);
@@ -2721,11 +2719,10 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 		 * for detecting, at fsync time, if the inode isn't yet in the
 		 * log tree or it's there but not up to date.
 		 */
-		struct timespec64 now = current_time(inode);
+		struct timespec64 now = inode_set_ctime_current(inode);
 
 		inode_inc_iversion(inode);
 		inode->i_mtime = now;
-		inode->i_ctime = now;
 		trans = btrfs_start_transaction(root, 1);
 		if (IS_ERR(trans)) {
 			ret = PTR_ERR(trans);
@@ -2796,7 +2793,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
 	if (IS_ERR(trans))
 		return PTR_ERR(trans);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	i_size_write(inode, end);
 	btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
 	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 521c08b8ad04..daa47a2238bd 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3901,8 +3901,8 @@ static int btrfs_read_locked_inode(struct inode *inode,
 	inode->i_mtime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->mtime);
 	inode->i_mtime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->mtime);
 
-	inode->i_ctime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->ctime);
-	inode->i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->ctime);
+	inode_set_ctime(inode, btrfs_timespec_sec(leaf, &inode_item->ctime),
+			btrfs_timespec_nsec(leaf, &inode_item->ctime));
 
 	BTRFS_I(inode)->i_otime.tv_sec =
 		btrfs_timespec_sec(leaf, &inode_item->otime);
@@ -4073,9 +4073,9 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
 				      inode->i_mtime.tv_nsec);
 
 	btrfs_set_token_timespec_sec(&token, &item->ctime,
-				     inode->i_ctime.tv_sec);
+				     inode_get_ctime(inode).tv_sec);
 	btrfs_set_token_timespec_nsec(&token, &item->ctime,
-				      inode->i_ctime.tv_nsec);
+				      inode_get_ctime(inode).tv_nsec);
 
 	btrfs_set_token_timespec_sec(&token, &item->otime,
 				     BTRFS_I(inode)->i_otime.tv_sec);
@@ -4273,9 +4273,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 	btrfs_i_size_write(dir, dir->vfs_inode.i_size - name->len * 2);
 	inode_inc_iversion(&inode->vfs_inode);
 	inode_inc_iversion(&dir->vfs_inode);
-	inode->vfs_inode.i_ctime = current_time(&inode->vfs_inode);
-	dir->vfs_inode.i_mtime = inode->vfs_inode.i_ctime;
-	dir->vfs_inode.i_ctime = inode->vfs_inode.i_ctime;
+	inode_set_ctime_current(&inode->vfs_inode);
+	dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
 	ret = btrfs_update_inode(trans, root, dir);
 out:
 	return ret;
@@ -4448,8 +4447,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 
 	btrfs_i_size_write(dir, dir->vfs_inode.i_size - fname.disk_name.len * 2);
 	inode_inc_iversion(&dir->vfs_inode);
-	dir->vfs_inode.i_mtime = current_time(&dir->vfs_inode);
-	dir->vfs_inode.i_ctime = dir->vfs_inode.i_mtime;
+	dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
 	ret = btrfs_update_inode_fallback(trans, root, dir);
 	if (ret)
 		btrfs_abort_transaction(trans, ret);
@@ -5091,8 +5089,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
 	if (newsize != oldsize) {
 		inode_inc_iversion(inode);
 		if (!(mask & (ATTR_CTIME | ATTR_MTIME))) {
-			inode->i_mtime = current_time(inode);
-			inode->i_ctime = inode->i_mtime;
+			inode->i_mtime = inode_set_ctime_current(inode);
 		}
 	}
 
@@ -5736,9 +5733,8 @@ static struct inode *new_simple_dir(struct super_block *s,
 	inode->i_opflags &= ~IOP_XATTR;
 	inode->i_fop = &simple_dir_operations;
 	inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
-	inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_atime = inode->i_mtime;
-	inode->i_ctime = inode->i_mtime;
 	BTRFS_I(inode)->i_otime = inode->i_mtime;
 
 	return inode;
@@ -6075,7 +6071,7 @@ static int btrfs_update_time(struct inode *inode, struct timespec64 *now,
 	if (flags & S_VERSION)
 		dirty |= inode_maybe_inc_iversion(inode, dirty);
 	if (flags & S_CTIME)
-		inode->i_ctime = *now;
+		inode_set_ctime_to_ts(inode, *now);
 	if (flags & S_MTIME)
 		inode->i_mtime = *now;
 	if (flags & S_ATIME)
@@ -6378,9 +6374,8 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
 		goto discard;
 	}
 
-	inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_atime = inode->i_mtime;
-	inode->i_ctime = inode->i_mtime;
 	BTRFS_I(inode)->i_otime = inode->i_mtime;
 
 	/*
@@ -6545,12 +6540,10 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
 	 * log replay procedure is responsible for setting them to their correct
 	 * values (the ones it had when the fsync was done).
 	 */
-	if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) {
-		struct timespec64 now = current_time(&parent_inode->vfs_inode);
+	if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags))
+		parent_inode->vfs_inode.i_mtime =
+			inode_set_ctime_current(&parent_inode->vfs_inode);
 
-		parent_inode->vfs_inode.i_mtime = now;
-		parent_inode->vfs_inode.i_ctime = now;
-	}
 	ret = btrfs_update_inode(trans, root, parent_inode);
 	if (ret)
 		btrfs_abort_transaction(trans, ret);
@@ -6690,7 +6683,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 	BTRFS_I(inode)->dir_index = 0ULL;
 	inc_nlink(inode);
 	inode_inc_iversion(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ihold(inode);
 	set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
 
@@ -9733,7 +9726,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
 		*alloc_hint = ins.objectid + ins.offset;
 
 		inode_inc_iversion(inode);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
 		if (!(mode & FALLOC_FL_KEEP_SIZE) &&
 		    (actual_len > inode->i_size) &&
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a895d105464b..a18ee7b5a166 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -384,7 +384,7 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
 	binode->flags = binode_flags;
 	btrfs_sync_inode_flags_to_i_flags(inode);
 	inode_inc_iversion(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
 
  out_end_trans:
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 0474bbe39da7..65d2bd6910f2 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -30,8 +30,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
 
 	inode_inc_iversion(inode);
 	if (!no_time_update) {
-		inode->i_mtime = current_time(inode);
-		inode->i_ctime = inode->i_mtime;
+		inode->i_mtime = inode_set_ctime_current(inode);
 	}
 	/*
 	 * We round up to the block size at eof when determining which
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index e7cfc992e02a..d8d20ea5a41f 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1831,8 +1831,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 
 	btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size +
 						  fname.disk_name.len * 2);
-	parent_inode->i_mtime = current_time(parent_inode);
-	parent_inode->i_ctime = parent_inode->i_mtime;
+	parent_inode->i_mtime = inode_set_ctime_current(parent_inode);
 	ret = btrfs_update_inode_fallback(trans, parent_root, BTRFS_I(parent_inode));
 	if (ret) {
 		btrfs_abort_transaction(trans, ret);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 365a1cc0a3c3..ffcff7188170 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4148,9 +4148,9 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
 				      inode->i_mtime.tv_nsec);
 
 	btrfs_set_token_timespec_sec(&token, &item->ctime,
-				     inode->i_ctime.tv_sec);
+				     inode_get_ctime(inode).tv_sec);
 	btrfs_set_token_timespec_nsec(&token, &item->ctime,
-				      inode->i_ctime.tv_nsec);
+				      inode_get_ctime(inode).tv_nsec);
 
 	/*
 	 * We do not need to set the nbytes field, in fact during a fast fsync
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index fc4b20c2688a..96828a13dd43 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -264,7 +264,7 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name,
 		goto out;
 
 	inode_inc_iversion(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
 	if (ret)
 		btrfs_abort_transaction(trans, ret);
@@ -407,7 +407,7 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
 	ret = btrfs_set_prop(trans, inode, name, value, size, flags);
 	if (!ret) {
 		inode_inc_iversion(inode);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
 		if (ret)
 			btrfs_abort_transaction(trans, ret);
-- 
2.41.0


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

* [PATCH v2 30/92] ceph: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (25 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 29/92] btrfs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:53     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 31/92] coda: " Jeff Layton
                     ` (60 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Xiubo Li, Ilya Dryomov
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ceph-devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/acl.c   |  2 +-
 fs/ceph/caps.c  |  2 +-
 fs/ceph/inode.c | 17 ++++++++++-------
 fs/ceph/snap.c  |  2 +-
 fs/ceph/xattr.c |  2 +-
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 6945a938d396..c91b293267d7 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -93,7 +93,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 	char *value = NULL;
 	struct iattr newattrs;
 	struct inode *inode = d_inode(dentry);
-	struct timespec64 old_ctime = inode->i_ctime;
+	struct timespec64 old_ctime = inode_get_ctime(inode);
 	umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
 
 	if (ceph_snap(inode) != CEPH_NOSNAP) {
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index e2bb0d0072da..09cd6d334604 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1400,7 +1400,7 @@ static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap,
 
 	arg->mtime = inode->i_mtime;
 	arg->atime = inode->i_atime;
-	arg->ctime = inode->i_ctime;
+	arg->ctime = inode_get_ctime(inode);
 	arg->btime = ci->i_btime;
 	arg->change_attr = inode_peek_iversion_raw(inode);
 
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 8e5f41d45283..bcdb1a0beccf 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -100,7 +100,7 @@ struct inode *ceph_get_snapdir(struct inode *parent)
 	inode->i_uid = parent->i_uid;
 	inode->i_gid = parent->i_gid;
 	inode->i_mtime = parent->i_mtime;
-	inode->i_ctime = parent->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(parent));
 	inode->i_atime = parent->i_atime;
 	ci->i_rbytes = 0;
 	ci->i_btime = ceph_inode(parent)->i_btime;
@@ -688,6 +688,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,
 			 struct timespec64 *mtime, struct timespec64 *atime)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
+	struct timespec64 ictime = inode_get_ctime(inode);
 	int warn = 0;
 
 	if (issued & (CEPH_CAP_FILE_EXCL|
@@ -696,11 +697,12 @@ void ceph_fill_file_time(struct inode *inode, int issued,
 		      CEPH_CAP_AUTH_EXCL|
 		      CEPH_CAP_XATTR_EXCL)) {
 		if (ci->i_version == 0 ||
-		    timespec64_compare(ctime, &inode->i_ctime) > 0) {
+		    timespec64_compare(ctime, &ictime) > 0) {
 			dout("ctime %lld.%09ld -> %lld.%09ld inc w/ cap\n",
-			     inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+			     inode_get_ctime(inode).tv_sec,
+			     inode_get_ctime(inode).tv_nsec,
 			     ctime->tv_sec, ctime->tv_nsec);
-			inode->i_ctime = *ctime;
+			inode_set_ctime_to_ts(inode, *ctime);
 		}
 		if (ci->i_version == 0 ||
 		    ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) {
@@ -738,7 +740,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,
 	} else {
 		/* we have no write|excl caps; whatever the MDS says is true */
 		if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) {
-			inode->i_ctime = *ctime;
+			inode_set_ctime_to_ts(inode, *ctime);
 			inode->i_mtime = *mtime;
 			inode->i_atime = *atime;
 			ci->i_time_warp_seq = time_warp_seq;
@@ -2166,7 +2168,8 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
 		bool only = (ia_valid & (ATTR_SIZE|ATTR_MTIME|ATTR_ATIME|
 					 ATTR_MODE|ATTR_UID|ATTR_GID)) == 0;
 		dout("setattr %p ctime %lld.%ld -> %lld.%ld (%s)\n", inode,
-		     inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+		     inode_get_ctime(inode).tv_sec,
+		     inode_get_ctime(inode).tv_nsec,
 		     attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec,
 		     only ? "ctime only" : "ignored");
 		if (only) {
@@ -2191,7 +2194,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
 	if (dirtied) {
 		inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied,
 							   &prealloc_cf);
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 		inode_inc_iversion_raw(inode);
 	}
 
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index 343d738448dc..c9920ade15f5 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -660,7 +660,7 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
 	capsnap->size = i_size_read(inode);
 	capsnap->mtime = inode->i_mtime;
 	capsnap->atime = inode->i_atime;
-	capsnap->ctime = inode->i_ctime;
+	capsnap->ctime = inode_get_ctime(inode);
 	capsnap->btime = ci->i_btime;
 	capsnap->change_attr = inode_peek_iversion_raw(inode);
 	capsnap->time_warp_seq = ci->i_time_warp_seq;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 806183959c47..1cbd84cc82a8 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -1238,7 +1238,7 @@ int __ceph_setxattr(struct inode *inode, const char *name,
 		dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL,
 					       &prealloc_cf);
 		ci->i_xattrs.dirty = true;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 	}
 
 	spin_unlock(&ci->i_ceph_lock);
-- 
2.41.0


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

* [PATCH v2 31/92] coda: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (26 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 30/92] ceph: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:54     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 32/92] configfs: " Jeff Layton
                     ` (59 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Jan Harkes, coda
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, codalist

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/coda/coda_linux.c | 3 ++-
 fs/coda/dir.c        | 2 +-
 fs/coda/file.c       | 2 +-
 fs/coda/inode.c      | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index 903ca8fa4b9b..ae023853a98f 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -127,7 +127,8 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
 	if (attr->va_mtime.tv_sec != -1)
 		inode->i_mtime = coda_to_timespec64(attr->va_mtime);
         if (attr->va_ctime.tv_sec != -1)
-		inode->i_ctime = coda_to_timespec64(attr->va_ctime);
+		inode_set_ctime_to_ts(inode,
+				      coda_to_timespec64(attr->va_ctime));
 }
 
 
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 8450b1bd354b..1d4f40048efc 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -111,7 +111,7 @@ static inline void coda_dir_update_mtime(struct inode *dir)
 	/* optimistically we can also act as if our nose bleeds. The
 	 * granularity of the mtime is coarse anyways so we might actually be
 	 * right most of the time. Note: we only do this for directories. */
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 #endif
 }
 
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 12b26bd13564..42346618b4ed 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -84,7 +84,7 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
 	ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos, 0);
 	coda_inode->i_size = file_inode(host_file)->i_size;
 	coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
-	coda_inode->i_mtime = coda_inode->i_ctime = current_time(coda_inode);
+	coda_inode->i_mtime = inode_set_ctime_current(coda_inode);
 	inode_unlock(coda_inode);
 	file_end_write(host_file);
 
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index d661e6cf17ac..3e64679c1620 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -269,7 +269,7 @@ int coda_setattr(struct mnt_idmap *idmap, struct dentry *de,
 
 	memset(&vattr, 0, sizeof(vattr)); 
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	coda_iattr_to_vattr(iattr, &vattr);
 	vattr.va_type = C_VNON; /* cannot set type */
 
-- 
2.41.0


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

* [PATCH v2 32/92] configfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (27 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 31/92] coda: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:54     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 33/92] cramfs: " Jeff Layton
                     ` (58 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Joel Becker, Christoph Hellwig
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/configfs/inode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 1c15edbe70ff..fbdcb3582926 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -88,8 +88,7 @@ int configfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 static inline void set_default_inode_attr(struct inode * inode, umode_t mode)
 {
 	inode->i_mode = mode;
-	inode->i_atime = inode->i_mtime =
-		inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 }
 
 static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
@@ -99,7 +98,7 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
 	inode->i_gid = iattr->ia_gid;
 	inode->i_atime = iattr->ia_atime;
 	inode->i_mtime = iattr->ia_mtime;
-	inode->i_ctime = iattr->ia_ctime;
+	inode_set_ctime_to_ts(inode, iattr->ia_ctime);
 }
 
 struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent *sd,
@@ -172,7 +171,7 @@ struct inode *configfs_create(struct dentry *dentry, umode_t mode)
 		return ERR_PTR(-ENOMEM);
 
 	p_inode = d_inode(dentry->d_parent);
-	p_inode->i_mtime = p_inode->i_ctime = current_time(p_inode);
+	p_inode->i_mtime = inode_set_ctime_current(p_inode);
 	configfs_set_inode_lock_class(sd, inode);
 	return inode;
 }
-- 
2.41.0


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

* [PATCH v2 33/92] cramfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (28 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 32/92] configfs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:55     ` Jan Kara
  2023-07-05 19:00   ` [PATCH v2 34/92] debugfs: " Jeff Layton
                     ` (57 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Nicolas Pitre
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/cramfs/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 27c6597aa1be..e755b2223936 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -133,7 +133,8 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
 	}
 
 	/* Struct copy intentional */
-	inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime;
+	inode->i_mtime = inode->i_atime = inode_set_ctime_to_ts(inode,
+								zerotime);
 	/* inode->i_nlink is left 1 - arguably wrong for directories,
 	   but it's the best we can do without reading the directory
 	   contents.  1 yields the right result in GNU find, even
-- 
2.41.0


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

* [PATCH v2 34/92] debugfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (29 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 33/92] cramfs: " Jeff Layton
@ 2023-07-05 19:00   ` Jeff Layton
  2023-07-06 10:55     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 35/92] devpts: " Jeff Layton
                     ` (56 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:00 UTC (permalink / raw)
  To: Christian Brauner, Greg Kroah-Hartman, Rafael J. Wysocki
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/debugfs/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 3f81f73c241a..83e57e9f9fa0 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -72,8 +72,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb)
 	struct inode *inode = new_inode(sb);
 	if (inode) {
 		inode->i_ino = get_next_ino();
-		inode->i_atime = inode->i_mtime =
-			inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	}
 	return inode;
 }
-- 
2.41.0


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

* [PATCH v2 35/92] devpts: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (30 preceding siblings ...)
  2023-07-05 19:00   ` [PATCH v2 34/92] debugfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 10:56     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 36/92] ecryptfs: " Jeff Layton
                     ` (55 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/devpts/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index fe3db0eda8e4..5ede89880911 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -338,7 +338,7 @@ static int mknod_ptmx(struct super_block *sb)
 	}
 
 	inode->i_ino = 2;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 
 	mode = S_IFCHR|opts->ptmxmode;
 	init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
@@ -451,7 +451,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
 	if (!inode)
 		goto fail;
 	inode->i_ino = 1;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
@@ -560,7 +560,7 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
 	inode->i_ino = index + 3;
 	inode->i_uid = opts->setuid ? opts->uid : current_fsuid();
 	inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	init_special_inode(inode, S_IFCHR|opts->mode, MKDEV(UNIX98_PTY_SLAVE_MAJOR, index));
 
 	sprintf(s, "%d", index);
-- 
2.41.0


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

* [PATCH v2 36/92] ecryptfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (31 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 35/92] devpts: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 10:56     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 37/92] efivarfs: " Jeff Layton
                     ` (54 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Tyler Hicks
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ecryptfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ecryptfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 83274915ba6d..b491bb239c8f 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -148,7 +148,7 @@ static int ecryptfs_do_unlink(struct inode *dir, struct dentry *dentry,
 	}
 	fsstack_copy_attr_times(dir, lower_dir);
 	set_nlink(inode, ecryptfs_inode_to_lower(inode)->i_nlink);
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 out_unlock:
 	dput(lower_dentry);
 	inode_unlock(lower_dir);
-- 
2.41.0


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

* [PATCH v2 37/92] efivarfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (32 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 36/92] ecryptfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 10:57     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 38/92] efs: " Jeff Layton
                     ` (53 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Jeremy Kerr, Ard Biesheuvel
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-efi

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/efivarfs/file.c  | 2 +-
 fs/efivarfs/inode.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index 375576111dc3..59b52718a3a2 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -51,7 +51,7 @@ static ssize_t efivarfs_file_write(struct file *file,
 	} else {
 		inode_lock(inode);
 		i_size_write(inode, datasize + sizeof(attributes));
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		inode_unlock(inode);
 	}
 
diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index b973a2c03dde..db9231f0e77b 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -25,7 +25,7 @@ struct inode *efivarfs_get_inode(struct super_block *sb,
 	if (inode) {
 		inode->i_ino = get_next_ino();
 		inode->i_mode = mode;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inode->i_flags = is_removable ? 0 : S_IMMUTABLE;
 		switch (mode & S_IFMT) {
 		case S_IFREG:
-- 
2.41.0


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

* [PATCH v2 38/92] efs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (33 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 37/92] efivarfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 10:57     ` Jan Kara
  2023-07-05 19:01     ` Jeff Layton
                     ` (52 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/efs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index 3ba94bb005a6..3789d22ba501 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -105,8 +105,8 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
 	inode->i_size  = be32_to_cpu(efs_inode->di_size);
 	inode->i_atime.tv_sec = be32_to_cpu(efs_inode->di_atime);
 	inode->i_mtime.tv_sec = be32_to_cpu(efs_inode->di_mtime);
-	inode->i_ctime.tv_sec = be32_to_cpu(efs_inode->di_ctime);
-	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0;
+	inode_set_ctime(inode, be32_to_cpu(efs_inode->di_ctime), 0);
+	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 0;
 
 	/* this is the number of blocks in the file */
 	if (inode->i_size == 0) {
-- 
2.41.0


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

* [PATCH v2 39/92] erofs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:01     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu
  Cc: linux-fsdevel, linux-erofs, Jan Kara, Al Viro, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Gao Xiang <xiang@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/erofs/inode.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index d70b12b81507..806374d866d1 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -105,8 +105,8 @@ static void *erofs_read_inode(struct erofs_buf *buf,
 		set_nlink(inode, le32_to_cpu(die->i_nlink));
 
 		/* extended inode has its own timestamp */
-		inode->i_ctime.tv_sec = le64_to_cpu(die->i_mtime);
-		inode->i_ctime.tv_nsec = le32_to_cpu(die->i_mtime_nsec);
+		inode_set_ctime(inode, le64_to_cpu(die->i_mtime),
+				le32_to_cpu(die->i_mtime_nsec));
 
 		inode->i_size = le64_to_cpu(die->i_size);
 
@@ -148,8 +148,7 @@ static void *erofs_read_inode(struct erofs_buf *buf,
 		set_nlink(inode, le16_to_cpu(dic->i_nlink));
 
 		/* use build time for compact inodes */
-		inode->i_ctime.tv_sec = sbi->build_time;
-		inode->i_ctime.tv_nsec = sbi->build_time_nsec;
+		inode_set_ctime(inode, sbi->build_time, sbi->build_time_nsec);
 
 		inode->i_size = le32_to_cpu(dic->i_size);
 		if (erofs_inode_is_data_compressed(vi->datalayout))
@@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
 		vi->chunkbits = sb->s_blocksize_bits +
 			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
 	}
-	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
-	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
-	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
-	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
+	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
+	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
+	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
+	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;
 
 	inode->i_flags &= ~S_DAX;
 	if (test_opt(&sbi->opt, DAX_ALWAYS) && S_ISREG(inode->i_mode) &&
-- 
2.41.0


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

* [PATCH v2 39/92] erofs: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-erofs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Gao Xiang <xiang@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/erofs/inode.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index d70b12b81507..806374d866d1 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -105,8 +105,8 @@ static void *erofs_read_inode(struct erofs_buf *buf,
 		set_nlink(inode, le32_to_cpu(die->i_nlink));
 
 		/* extended inode has its own timestamp */
-		inode->i_ctime.tv_sec = le64_to_cpu(die->i_mtime);
-		inode->i_ctime.tv_nsec = le32_to_cpu(die->i_mtime_nsec);
+		inode_set_ctime(inode, le64_to_cpu(die->i_mtime),
+				le32_to_cpu(die->i_mtime_nsec));
 
 		inode->i_size = le64_to_cpu(die->i_size);
 
@@ -148,8 +148,7 @@ static void *erofs_read_inode(struct erofs_buf *buf,
 		set_nlink(inode, le16_to_cpu(dic->i_nlink));
 
 		/* use build time for compact inodes */
-		inode->i_ctime.tv_sec = sbi->build_time;
-		inode->i_ctime.tv_nsec = sbi->build_time_nsec;
+		inode_set_ctime(inode, sbi->build_time, sbi->build_time_nsec);
 
 		inode->i_size = le32_to_cpu(dic->i_size);
 		if (erofs_inode_is_data_compressed(vi->datalayout))
@@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
 		vi->chunkbits = sb->s_blocksize_bits +
 			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
 	}
-	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
-	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
-	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
-	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
+	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
+	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
+	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
+	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;
 
 	inode->i_flags &= ~S_DAX;
 	if (test_opt(&sbi->opt, DAX_ALWAYS) && S_ISREG(inode->i_mode) &&
-- 
2.41.0


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

* [PATCH v2 40/92] exfat: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (35 preceding siblings ...)
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 11:01     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 41/92] ext2: " Jeff Layton
                     ` (50 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Namjae Jeon, Sungjong Seo
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/exfat/file.c  |  4 ++--
 fs/exfat/inode.c |  6 +++---
 fs/exfat/namei.c | 21 +++++++++------------
 fs/exfat/super.c |  3 +--
 4 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 3cbd270e0cba..f40ecfeee3a4 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -22,7 +22,7 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
 	if (err)
 		return err;
 
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	if (!IS_SYNC(inode))
@@ -290,7 +290,7 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 	}
 
 	if (attr->ia_valid & ATTR_SIZE)
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 
 	setattr_copy(&nop_mnt_idmap, inode, attr);
 	exfat_truncate_atime(&inode->i_atime);
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 481dd338f2b8..13329baeafbc 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -355,7 +355,7 @@ static void exfat_write_failed(struct address_space *mapping, loff_t to)
 
 	if (to > i_size_read(inode)) {
 		truncate_pagecache(inode, i_size_read(inode));
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		exfat_truncate(inode);
 	}
 }
@@ -398,7 +398,7 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,
 		exfat_write_failed(mapping, pos+len);
 
 	if (!(err < 0) && !(ei->attr & ATTR_ARCHIVE)) {
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		ei->attr |= ATTR_ARCHIVE;
 		mark_inode_dirty(inode);
 	}
@@ -577,7 +577,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
 
 	inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9;
 	inode->i_mtime = info->mtime;
-	inode->i_ctime = info->mtime;
+	inode_set_ctime_to_ts(inode, info->mtime);
 	ei->i_crtime = info->crtime;
 	inode->i_atime = info->atime;
 
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index e91022ff80ef..c007de6ac1c7 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -569,7 +569,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
 		goto unlock;
 
 	inode_inc_iversion(dir);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	if (IS_DIRSYNC(dir))
 		exfat_sync_inode(dir);
 	else
@@ -582,8 +582,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
 		goto unlock;
 
 	inode_inc_iversion(inode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime =
-		EXFAT_I(inode)->i_crtime = current_time(inode);
+	inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
@@ -817,7 +816,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
 	ei->dir.dir = DIR_DELETED;
 
 	inode_inc_iversion(dir);
-	dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
 	exfat_truncate_atime(&dir->i_atime);
 	if (IS_DIRSYNC(dir))
 		exfat_sync_inode(dir);
@@ -825,7 +824,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
 		mark_inode_dirty(dir);
 
 	clear_nlink(inode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	exfat_unhash_inode(inode);
 	exfat_d_version_set(dentry, inode_query_iversion(dir));
@@ -852,7 +851,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 		goto unlock;
 
 	inode_inc_iversion(dir);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	if (IS_DIRSYNC(dir))
 		exfat_sync_inode(dir);
 	else
@@ -866,8 +865,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 		goto unlock;
 
 	inode_inc_iversion(inode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime =
-		EXFAT_I(inode)->i_crtime = current_time(inode);
+	inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
@@ -979,7 +977,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
 	ei->dir.dir = DIR_DELETED;
 
 	inode_inc_iversion(dir);
-	dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
 	exfat_truncate_atime(&dir->i_atime);
 	if (IS_DIRSYNC(dir))
 		exfat_sync_inode(dir);
@@ -988,7 +986,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
 	drop_nlink(dir);
 
 	clear_nlink(inode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	exfat_unhash_inode(inode);
 	exfat_d_version_set(dentry, inode_query_iversion(dir));
@@ -1353,8 +1351,7 @@ static int exfat_rename(struct mnt_idmap *idmap,
 			exfat_warn(sb, "abnormal access to an inode dropped");
 			WARN_ON(new_inode->i_nlink == 0);
 		}
-		new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
-			current_time(new_inode);
+		EXFAT_I(new_inode)->i_crtime = inode_set_ctime_current(new_inode);
 	}
 
 unlock:
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 8c32460e031e..8e0ca4b0fc8f 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -379,8 +379,7 @@ static int exfat_read_root(struct inode *inode)
 	ei->i_size_ondisk = i_size_read(inode);
 
 	exfat_save_attr(inode, ATTR_SUBDIR);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
-		current_time(inode);
+	inode->i_mtime = inode->i_atime = ei->i_crtime = inode_set_ctime_current(inode);
 	exfat_truncate_atime(&inode->i_atime);
 	return 0;
 }
-- 
2.41.0


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

* [PATCH v2 41/92] ext2: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (36 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 40/92] exfat: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 11:03     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 42/92] ext4: " Jeff Layton
                     ` (49 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Jan Kara
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-ext4

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ext2/acl.c    |  2 +-
 fs/ext2/dir.c    |  6 +++---
 fs/ext2/ialloc.c |  2 +-
 fs/ext2/inode.c  | 10 +++++-----
 fs/ext2/ioctl.c  |  4 ++--
 fs/ext2/namei.c  |  8 ++++----
 fs/ext2/super.c  |  2 +-
 fs/ext2/xattr.c  |  2 +-
 8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 82b17d7fc93f..7e54c31589c7 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -237,7 +237,7 @@ ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 	error = __ext2_set_acl(inode, acl, type);
 	if (!error && update_mode) {
 		inode->i_mode = mode;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		mark_inode_dirty(inode);
 	}
 	return error;
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 42db804794bd..b335f17f682f 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 = dir->i_ctime = current_time(dir);
+		dir->i_mtime = 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 = dir->i_ctime = current_time(dir);
+	dir->i_mtime = 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_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = 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 34cd5dc1da23..c24d0de95a83 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->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(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 75983215c7a1..1259995977d2 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -595,7 +595,7 @@ static void ext2_splice_branch(struct inode *inode,
 	if (where->bh)
 		mark_buffer_dirty_inode(where->bh, inode);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 }
 
@@ -1287,7 +1287,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->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (inode_needs_sync(inode)) {
 		sync_mapping_buffers(inode->i_mapping);
 		sync_inode_metadata(inode, 1);
@@ -1409,9 +1409,9 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	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->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime);
+	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 = inode->i_ctime.tv_nsec = 0;
+	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 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
@@ -1541,7 +1541,7 @@ 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->i_ctime.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_blocks = cpu_to_le32(inode->i_blocks);
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index cc87d413eb43..44e04484e570 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -44,7 +44,7 @@ int ext2_fileattr_set(struct mnt_idmap *idmap,
 		(fa->flags & EXT2_FL_USER_MODIFIABLE);
 
 	ext2_set_inode_flags(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	return 0;
@@ -77,7 +77,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		}
 
 		inode_lock(inode);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		inode->i_generation = generation;
 		inode_unlock(inode);
 
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 937dd8f60f96..059517068adc 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -211,7 +211,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
 	if (err)
 		return err;
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_link_count(inode);
 	ihold(inode);
 
@@ -291,7 +291,7 @@ static int ext2_unlink(struct inode *dir, struct dentry *dentry)
 	if (err)
 		goto out;
 
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	inode_dec_link_count(inode);
 	err = 0;
 out:
@@ -367,7 +367,7 @@ static int ext2_rename (struct mnt_idmap * idmap,
 		ext2_put_page(new_page, new_de);
 		if (err)
 			goto out_dir;
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		if (dir_de)
 			drop_nlink(new_inode);
 		inode_dec_link_count(new_inode);
@@ -383,7 +383,7 @@ static int ext2_rename (struct mnt_idmap * idmap,
 	 * Like most other Unix systems, set the ctime for inodes on a
  	 * rename.
 	 */
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 	mark_inode_dirty(old_inode);
 
 	err = ext2_delete_entry(old_de, old_page);
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 2959afc7541c..aaf3e3e88cb2 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->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	return len - towrite;
 }
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 8906ba479aaf..1c9187188d68 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -773,7 +773,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
 
 	/* Update the inode. */
 	EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (IS_SYNC(inode)) {
 		error = sync_inode_metadata(inode, 1);
 		/* In case sync failed due to ENOSPC the inode was actually
-- 
2.41.0


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

* [PATCH v2 42/92] ext4: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (37 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 41/92] ext2: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 12:36     ` Jan Kara
  2023-07-05 19:01     ` Jeff Layton
                     ` (48 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Theodore Ts'o, Andreas Dilger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-ext4

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ext4/acl.c     |  2 +-
 fs/ext4/ext4.h    | 21 +++++++++++++++++++++
 fs/ext4/extents.c | 12 ++++++------
 fs/ext4/ialloc.c  |  2 +-
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   | 16 +++++++---------
 fs/ext4/ioctl.c   |  9 +++++----
 fs/ext4/namei.c   | 26 ++++++++++++--------------
 fs/ext4/super.c   |  2 +-
 fs/ext4/xattr.c   |  6 +++---
 10 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 27fcbddfb148..3bffe862f954 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -259,7 +259,7 @@ ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 	error = __ext4_set_acl(handle, inode, type, acl, 0 /* xattr_flags */);
 	if (!error && update_mode) {
 		inode->i_mode = mode;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		error = ext4_mark_inode_dirty(handle, inode);
 	}
 out_stop:
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0a2d55faa095..d502b930431b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3823,6 +3823,27 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
 	return buffer_uptodate(bh);
 }
 
+static inline void ext4_inode_set_ctime(struct inode *inode, struct ext4_inode *raw_inode)
+{
+	struct timespec64 ctime = inode_get_ctime(inode);
+
+	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra)) {
+		raw_inode->i_ctime = cpu_to_le32(ctime.tv_sec);
+		raw_inode->i_ctime_extra = ext4_encode_extra_time(&ctime);
+	} else {
+		raw_inode->i_ctime = cpu_to_le32(clamp_t(int32_t, ctime.tv_sec, S32_MIN, S32_MAX));
+	}
+}
+
+static inline void ext4_inode_get_ctime(struct inode *inode, const struct ext4_inode *raw_inode)
+{
+	struct timespec64 ctime = { .tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime) };
+
+	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra))
+		ext4_decode_extra_time(&ctime, raw_inode->i_ctime_extra);
+	inode_set_ctime(inode, ctime.tv_sec, ctime.tv_nsec);
+}
+
 #endif	/* __KERNEL__ */
 
 #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e4115d338f10..202c76996b62 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4476,12 +4476,12 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 		map.m_lblk += ret;
 		map.m_len = len = len - ret;
 		epos = (loff_t)map.m_lblk << inode->i_blkbits;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		if (new_size) {
 			if (epos > new_size)
 				epos = new_size;
 			if (ext4_update_inode_size(inode, epos) & 0x1)
-				inode->i_mtime = inode->i_ctime;
+				inode->i_mtime = inode_get_ctime(inode);
 		}
 		ret2 = ext4_mark_inode_dirty(handle, inode);
 		ext4_update_inode_fsync_trans(handle, inode, 1);
@@ -4617,7 +4617,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->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 
 		ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 					     flags);
@@ -4642,7 +4642,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 		goto out_mutex;
 	}
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (new_size)
 		ext4_update_inode_size(inode, new_size);
 	ret = ext4_mark_inode_dirty(handle, inode);
@@ -5378,7 +5378,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->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	ret = ext4_mark_inode_dirty(handle, inode);
 	ext4_update_inode_fsync_trans(handle, inode, 1);
 
@@ -5488,7 +5488,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->i_ctime = current_time(inode);
+	inode->i_mtime = 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 754f961cd9fd..48abef5f23e7 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1250,7 +1250,7 @@ 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->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	ei->i_crtime = inode->i_mtime;
 
 	memset(ei->i_data, 0, sizeof(ei->i_data));
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index a4b7e4bc32d4..003861037374 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 = dir->i_ctime = current_time(dir);
+	dir->i_mtime = 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->i_ctime = current_time(inode);
+		inode->i_mtime = 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 3d253e250871..bbc57954dfd3 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3986,7 +3986,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->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	ret2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(ret2))
 		ret = ret2;
@@ -4146,7 +4146,7 @@ int ext4_truncate(struct inode *inode)
 	if (inode->i_nlink)
 		ext4_orphan_del(handle, inode);
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	err2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(err2 && !err))
 		err = err2;
@@ -4249,7 +4249,7 @@ 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_XTIME(i_ctime, inode, raw_inode);
+	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_EINODE_SET_XTIME(i_crtime, ei, raw_inode);
@@ -4858,7 +4858,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 		}
 	}
 
-	EXT4_INODE_GET_XTIME(i_ctime, inode, raw_inode);
+	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_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
@@ -4981,7 +4981,7 @@ static void __ext4_update_other_inode_time(struct super_block *sb,
 		spin_unlock(&inode->i_lock);
 
 		spin_lock(&ei->i_raw_lock);
-		EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
+		ext4_inode_get_ctime(inode, raw_inode);
 		EXT4_INODE_SET_XTIME(i_mtime, inode, raw_inode);
 		EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode);
 		ext4_inode_csum_set(inode, raw_inode, ei);
@@ -5376,10 +5376,8 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 			 * Update c/mtime on truncate up, ext4_truncate() will
 			 * update c/mtime in shrink case below
 			 */
-			if (!shrink) {
-				inode->i_mtime = current_time(inode);
-				inode->i_ctime = inode->i_mtime;
-			}
+			if (!shrink)
+				inode->i_mtime = 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 331859511f80..b0349f451863 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -449,7 +449,8 @@ static long swap_inode_boot_loader(struct super_block *sb,
 	diff = size - size_bl;
 	swap_inode_data(inode, inode_bl);
 
-	inode->i_ctime = inode_bl->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
+	inode_set_ctime_current(inode_bl);
 	inode_inc_iversion(inode);
 
 	inode->i_generation = get_random_u32();
@@ -663,7 +664,7 @@ static int ext4_ioctl_setflags(struct inode *inode,
 
 	ext4_set_inode_flags(inode, false);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_iversion(inode);
 
 	err = ext4_mark_iloc_dirty(handle, inode, &iloc);
@@ -774,7 +775,7 @@ static int ext4_ioctl_setproject(struct inode *inode, __u32 projid)
 	}
 
 	EXT4_I(inode)->i_projid = kprojid;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_iversion(inode);
 out_dirty:
 	rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
@@ -1266,7 +1267,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		}
 		err = ext4_reserve_inode_write(handle, inode, &iloc);
 		if (err == 0) {
-			inode->i_ctime = current_time(inode);
+			inode_set_ctime_current(inode);
 			inode_inc_iversion(inode);
 			inode->i_generation = generation;
 			err = ext4_mark_iloc_dirty(handle, inode, &iloc);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 0caf6c730ce3..07f6d96ebc60 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2203,7 +2203,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 = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	ext4_update_dx_flag(dir);
 	inode_inc_iversion(dir);
 	err2 = ext4_mark_inode_dirty(handle, dir);
@@ -3197,7 +3197,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
 	 * recovery. */
 	inode->i_size = 0;
 	ext4_orphan_add(handle, inode);
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_ctime_current(inode);
 	retval = ext4_mark_inode_dirty(handle, inode);
 	if (retval)
 		goto end_rmdir;
@@ -3271,7 +3272,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_ctime = dir->i_mtime = current_time(dir);
+		dir->i_mtime = inode_set_ctime_current(dir);
 		ext4_update_dx_flag(dir);
 		retval = ext4_mark_inode_dirty(handle, dir);
 		if (retval)
@@ -3286,7 +3287,7 @@ int __ext4_unlink(struct inode *dir, const struct qstr *d_name,
 		drop_nlink(inode);
 	if (!inode->i_nlink)
 		ext4_orphan_add(handle, inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	retval = ext4_mark_inode_dirty(handle, inode);
 	if (dentry && !retval)
 		ext4_fc_track_unlink(handle, dentry);
@@ -3463,7 +3464,7 @@ int __ext4_link(struct inode *dir, struct inode *inode, struct dentry *dentry)
 	if (IS_DIRSYNC(dir))
 		ext4_handle_sync(handle);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ext4_inc_count(inode);
 	ihold(inode);
 
@@ -3641,8 +3642,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_ctime = ent->dir->i_mtime =
-		current_time(ent->dir);
+	ent->dir->i_mtime = 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) {
@@ -3941,7 +3941,7 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	old.inode->i_ctime = current_time(old.inode);
+	inode_set_ctime_current(old.inode);
 	retval = ext4_mark_inode_dirty(handle, old.inode);
 	if (unlikely(retval))
 		goto end_rename;
@@ -3955,9 +3955,9 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 
 	if (new.inode) {
 		ext4_dec_count(new.inode);
-		new.inode->i_ctime = current_time(new.inode);
+		inode_set_ctime_current(new.inode);
 	}
-	old.dir->i_ctime = old.dir->i_mtime = current_time(old.dir);
+	old.dir->i_mtime = inode_set_ctime_current(old.inode);
 	ext4_update_dx_flag(old.dir);
 	if (old.dir_bh) {
 		retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino);
@@ -4053,7 +4053,6 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	};
 	u8 new_file_type;
 	int retval;
-	struct timespec64 ctime;
 
 	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
 	     !projid_eq(EXT4_I(new_dir)->i_projid,
@@ -4147,9 +4146,8 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	ctime = current_time(old.inode);
-	old.inode->i_ctime = ctime;
-	new.inode->i_ctime = ctime;
+	inode_set_ctime_current(old.inode);
+	inode_set_ctime_current(new.inode);
 	retval = ext4_mark_inode_dirty(handle, old.inode);
 	if (unlikely(retval))
 		goto end_rename;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c94ebf704616..b54c70e1a74e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -7103,7 +7103,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->i_ctime = current_time(inode);
+	inode->i_mtime = 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 321e3a888c20..dbe54cddda3d 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -356,13 +356,13 @@ 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)ea_inode->i_ctime.tv_sec << 32) |
+	return ((u64) inode_get_ctime(ea_inode).tv_sec << 32) |
 		(u32) inode_peek_iversion_raw(ea_inode);
 }
 
 static void ext4_xattr_inode_set_ref(struct inode *ea_inode, u64 ref_count)
 {
-	ea_inode->i_ctime.tv_sec = (u32)(ref_count >> 32);
+	inode_set_ctime(ea_inode, (u32)(ref_count >> 32), 0);
 	inode_set_iversion_raw(ea_inode, ref_count & 0xffffffff);
 }
 
@@ -2459,7 +2459,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 	}
 	if (!error) {
 		ext4_xattr_update_super_block(handle, inode->i_sb);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		inode_inc_iversion(inode);
 		if (!value)
 			no_expand = 0;
-- 
2.41.0


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

* [f2fs-dev] [PATCH v2 43/92] f2fs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:01     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Jaegeuk Kim, Chao Yu
  Cc: linux-fsdevel, linux-f2fs-devel, Jan Kara, Al Viro, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/f2fs/dir.c      |  8 ++++----
 fs/f2fs/f2fs.h     |  4 +++-
 fs/f2fs/file.c     | 20 ++++++++++----------
 fs/f2fs/inline.c   |  2 +-
 fs/f2fs/inode.c    | 10 +++++-----
 fs/f2fs/namei.c    | 12 ++++++------
 fs/f2fs/recovery.c |  4 ++--
 fs/f2fs/super.c    |  2 +-
 fs/f2fs/xattr.c    |  2 +-
 9 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index d635c58cf5a3..8aa29fe2e87b 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -455,7 +455,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
 	de->file_type = fs_umode_to_ftype(inode->i_mode);
 	set_page_dirty(page);
 
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 	f2fs_put_page(page, 1);
 }
@@ -609,7 +609,7 @@ void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,
 			f2fs_i_links_write(dir, true);
 		clear_inode_flag(inode, FI_NEW_INODE);
 	}
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 
 	if (F2FS_I(dir)->i_current_depth != current_depth)
@@ -858,7 +858,7 @@ void f2fs_drop_nlink(struct inode *dir, struct inode *inode)
 
 	if (S_ISDIR(inode->i_mode))
 		f2fs_i_links_write(dir, false);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 
 	f2fs_i_links_write(inode, false);
 	if (S_ISDIR(inode->i_mode)) {
@@ -919,7 +919,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
 	}
 	f2fs_put_page(page, 1);
 
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 
 	if (inode)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c7cb2177b252..e18272ae3119 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3303,9 +3303,11 @@ static inline void clear_file(struct inode *inode, int type)
 
 static inline bool f2fs_is_time_consistent(struct inode *inode)
 {
+	struct timespec64 ctime = inode_get_ctime(inode);
+
 	if (!timespec64_equal(F2FS_I(inode)->i_disk_time, &inode->i_atime))
 		return false;
-	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &inode->i_ctime))
+	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &ctime))
 		return false;
 	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 2, &inode->i_mtime))
 		return false;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 093039dee992..b018800223c4 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -794,7 +794,7 @@ int f2fs_truncate(struct inode *inode)
 	if (err)
 		return err;
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, false);
 	return 0;
 }
@@ -905,7 +905,7 @@ static void __setattr_copy(struct mnt_idmap *idmap,
 	if (ia_valid & ATTR_MTIME)
 		inode->i_mtime = attr->ia_mtime;
 	if (ia_valid & ATTR_CTIME)
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 		vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
@@ -1008,7 +1008,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 			return err;
 
 		spin_lock(&F2FS_I(inode)->i_size_lock);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		F2FS_I(inode)->last_disk_size = i_size_read(inode);
 		spin_unlock(&F2FS_I(inode)->i_size_lock);
 	}
@@ -1835,7 +1835,7 @@ static long f2fs_fallocate(struct file *file, int mode,
 	}
 
 	if (!ret) {
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		f2fs_mark_inode_dirty_sync(inode, false);
 		f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 	}
@@ -1937,7 +1937,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 	else
 		clear_inode_flag(inode, FI_PROJ_INHERIT);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	f2fs_set_inode_flags(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 	return 0;
@@ -2874,10 +2874,10 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 	if (ret)
 		goto out_unlock;
 
-	src->i_mtime = src->i_ctime = current_time(src);
+	src->i_mtime = inode_set_ctime_current(src);
 	f2fs_mark_inode_dirty_sync(src, false);
 	if (src != dst) {
-		dst->i_mtime = dst->i_ctime = current_time(dst);
+		dst->i_mtime = inode_set_ctime_current(dst);
 		f2fs_mark_inode_dirty_sync(dst, false);
 	}
 	f2fs_update_time(sbi, REQ_TIME);
@@ -3073,7 +3073,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)
 		goto out_unlock;
 
 	fi->i_projid = kprojid;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 out_unlock:
 	f2fs_unlock_op(sbi);
@@ -3511,7 +3511,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
 	}
 
 	set_inode_flag(inode, FI_COMPRESS_RELEASED);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 
 	f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
@@ -3710,7 +3710,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
 
 	if (ret >= 0) {
 		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		f2fs_mark_inode_dirty_sync(inode, true);
 	}
 unlock_inode:
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 4638fee16a91..88fc9208ffa7 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -698,7 +698,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
 	set_page_dirty(page);
 	f2fs_put_page(page, 1);
 
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 
 	if (inode)
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 09e986b050c6..c1c2ba9f28e5 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -403,7 +403,7 @@ static void init_idisk_time(struct inode *inode)
 	struct f2fs_inode_info *fi = F2FS_I(inode);
 
 	fi->i_disk_time[0] = inode->i_atime;
-	fi->i_disk_time[1] = inode->i_ctime;
+	fi->i_disk_time[1] = inode_get_ctime(inode);
 	fi->i_disk_time[2] = inode->i_mtime;
 }
 
@@ -434,10 +434,10 @@ static int do_read_inode(struct inode *inode)
 	inode->i_blocks = SECTOR_FROM_BLOCK(le64_to_cpu(ri->i_blocks) - 1);
 
 	inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime);
-	inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime);
+	inode_set_ctime(inode, le64_to_cpu(ri->i_ctime),
+			le32_to_cpu(ri->i_ctime_nsec));
 	inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime);
 	inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
 	inode->i_generation = le32_to_cpu(ri->i_generation);
 	if (S_ISDIR(inode->i_mode))
@@ -714,10 +714,10 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
 	set_raw_inline(inode, ri);
 
 	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
-	ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
+	ri->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
 	ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
 	ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
-	ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	ri->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	if (S_ISDIR(inode->i_mode))
 		ri->i_current_depth =
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index bee0568888da..193b22a2d6bf 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -243,7 +243,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
 
 	inode->i_ino = ino;
 	inode->i_blocks = 0;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	F2FS_I(inode)->i_crtime = inode->i_mtime;
 	inode->i_generation = get_random_u32();
 
@@ -420,7 +420,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
 
 	f2fs_balance_fs(sbi, true);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ihold(inode);
 
 	set_inode_flag(inode, FI_INC_LINK);
@@ -1052,7 +1052,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		f2fs_set_link(new_dir, new_entry, new_page, old_inode);
 		new_page = NULL;
 
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		f2fs_down_write(&F2FS_I(new_inode)->i_sem);
 		if (old_dir_entry)
 			f2fs_i_links_write(new_inode, false);
@@ -1086,7 +1086,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
 
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 	f2fs_mark_inode_dirty_sync(old_inode, false);
 
 	f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
@@ -1251,7 +1251,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
 
-	old_dir->i_ctime = current_time(old_dir);
+	inode_set_ctime_current(old_dir);
 	if (old_nlink) {
 		f2fs_down_write(&F2FS_I(old_dir)->i_sem);
 		f2fs_i_links_write(old_dir, old_nlink > 0);
@@ -1270,7 +1270,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 		f2fs_i_pino_write(new_inode, old_dir->i_ino);
 	f2fs_up_write(&F2FS_I(new_inode)->i_sem);
 
-	new_dir->i_ctime = current_time(new_dir);
+	inode_set_ctime_current(new_dir);
 	if (new_nlink) {
 		f2fs_down_write(&F2FS_I(new_dir)->i_sem);
 		f2fs_i_links_write(new_dir, new_nlink > 0);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 4e7d4ceeb084..b8637e88d94f 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -321,10 +321,10 @@ static int recover_inode(struct inode *inode, struct page *page)
 
 	f2fs_i_size_write(inode, le64_to_cpu(raw->i_size));
 	inode->i_atime.tv_sec = le64_to_cpu(raw->i_atime);
-	inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime);
+	inode_set_ctime(inode, le64_to_cpu(raw->i_ctime),
+			le32_to_cpu(raw->i_ctime_nsec));
 	inode->i_mtime.tv_sec = le64_to_cpu(raw->i_mtime);
 	inode->i_atime.tv_nsec = le32_to_cpu(raw->i_atime_nsec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
 
 	F2FS_I(inode)->i_advise = raw->i_advise;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ca31163da00a..28aeffc0048c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2703,7 +2703,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
 
 	if (len == towrite)
 		return err;
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, false);
 	return len - towrite;
 }
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 476b186b90a6..4ae93e1df421 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -764,7 +764,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 same:
 	if (is_inode_flag_set(inode, FI_ACL_MODE)) {
 		inode->i_mode = F2FS_I(inode)->i_acl_mode;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		clear_inode_flag(inode, FI_ACL_MODE);
 	}
 
-- 
2.41.0



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

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

* [PATCH v2 43/92] f2fs: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Jaegeuk Kim, Chao Yu
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-f2fs-devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/f2fs/dir.c      |  8 ++++----
 fs/f2fs/f2fs.h     |  4 +++-
 fs/f2fs/file.c     | 20 ++++++++++----------
 fs/f2fs/inline.c   |  2 +-
 fs/f2fs/inode.c    | 10 +++++-----
 fs/f2fs/namei.c    | 12 ++++++------
 fs/f2fs/recovery.c |  4 ++--
 fs/f2fs/super.c    |  2 +-
 fs/f2fs/xattr.c    |  2 +-
 9 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index d635c58cf5a3..8aa29fe2e87b 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -455,7 +455,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
 	de->file_type = fs_umode_to_ftype(inode->i_mode);
 	set_page_dirty(page);
 
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 	f2fs_put_page(page, 1);
 }
@@ -609,7 +609,7 @@ void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,
 			f2fs_i_links_write(dir, true);
 		clear_inode_flag(inode, FI_NEW_INODE);
 	}
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 
 	if (F2FS_I(dir)->i_current_depth != current_depth)
@@ -858,7 +858,7 @@ void f2fs_drop_nlink(struct inode *dir, struct inode *inode)
 
 	if (S_ISDIR(inode->i_mode))
 		f2fs_i_links_write(dir, false);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 
 	f2fs_i_links_write(inode, false);
 	if (S_ISDIR(inode->i_mode)) {
@@ -919,7 +919,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
 	}
 	f2fs_put_page(page, 1);
 
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 
 	if (inode)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c7cb2177b252..e18272ae3119 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3303,9 +3303,11 @@ static inline void clear_file(struct inode *inode, int type)
 
 static inline bool f2fs_is_time_consistent(struct inode *inode)
 {
+	struct timespec64 ctime = inode_get_ctime(inode);
+
 	if (!timespec64_equal(F2FS_I(inode)->i_disk_time, &inode->i_atime))
 		return false;
-	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &inode->i_ctime))
+	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &ctime))
 		return false;
 	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 2, &inode->i_mtime))
 		return false;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 093039dee992..b018800223c4 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -794,7 +794,7 @@ int f2fs_truncate(struct inode *inode)
 	if (err)
 		return err;
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, false);
 	return 0;
 }
@@ -905,7 +905,7 @@ static void __setattr_copy(struct mnt_idmap *idmap,
 	if (ia_valid & ATTR_MTIME)
 		inode->i_mtime = attr->ia_mtime;
 	if (ia_valid & ATTR_CTIME)
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 		vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
@@ -1008,7 +1008,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 			return err;
 
 		spin_lock(&F2FS_I(inode)->i_size_lock);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		F2FS_I(inode)->last_disk_size = i_size_read(inode);
 		spin_unlock(&F2FS_I(inode)->i_size_lock);
 	}
@@ -1835,7 +1835,7 @@ static long f2fs_fallocate(struct file *file, int mode,
 	}
 
 	if (!ret) {
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		f2fs_mark_inode_dirty_sync(inode, false);
 		f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 	}
@@ -1937,7 +1937,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 	else
 		clear_inode_flag(inode, FI_PROJ_INHERIT);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	f2fs_set_inode_flags(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 	return 0;
@@ -2874,10 +2874,10 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 	if (ret)
 		goto out_unlock;
 
-	src->i_mtime = src->i_ctime = current_time(src);
+	src->i_mtime = inode_set_ctime_current(src);
 	f2fs_mark_inode_dirty_sync(src, false);
 	if (src != dst) {
-		dst->i_mtime = dst->i_ctime = current_time(dst);
+		dst->i_mtime = inode_set_ctime_current(dst);
 		f2fs_mark_inode_dirty_sync(dst, false);
 	}
 	f2fs_update_time(sbi, REQ_TIME);
@@ -3073,7 +3073,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)
 		goto out_unlock;
 
 	fi->i_projid = kprojid;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 out_unlock:
 	f2fs_unlock_op(sbi);
@@ -3511,7 +3511,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
 	}
 
 	set_inode_flag(inode, FI_COMPRESS_RELEASED);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 
 	f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
@@ -3710,7 +3710,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
 
 	if (ret >= 0) {
 		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		f2fs_mark_inode_dirty_sync(inode, true);
 	}
 unlock_inode:
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 4638fee16a91..88fc9208ffa7 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -698,7 +698,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
 	set_page_dirty(page);
 	f2fs_put_page(page, 1);
 
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	f2fs_mark_inode_dirty_sync(dir, false);
 
 	if (inode)
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 09e986b050c6..c1c2ba9f28e5 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -403,7 +403,7 @@ static void init_idisk_time(struct inode *inode)
 	struct f2fs_inode_info *fi = F2FS_I(inode);
 
 	fi->i_disk_time[0] = inode->i_atime;
-	fi->i_disk_time[1] = inode->i_ctime;
+	fi->i_disk_time[1] = inode_get_ctime(inode);
 	fi->i_disk_time[2] = inode->i_mtime;
 }
 
@@ -434,10 +434,10 @@ static int do_read_inode(struct inode *inode)
 	inode->i_blocks = SECTOR_FROM_BLOCK(le64_to_cpu(ri->i_blocks) - 1);
 
 	inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime);
-	inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime);
+	inode_set_ctime(inode, le64_to_cpu(ri->i_ctime),
+			le32_to_cpu(ri->i_ctime_nsec));
 	inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime);
 	inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
 	inode->i_generation = le32_to_cpu(ri->i_generation);
 	if (S_ISDIR(inode->i_mode))
@@ -714,10 +714,10 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
 	set_raw_inline(inode, ri);
 
 	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
-	ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
+	ri->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
 	ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
 	ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
-	ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	ri->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	if (S_ISDIR(inode->i_mode))
 		ri->i_current_depth =
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index bee0568888da..193b22a2d6bf 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -243,7 +243,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
 
 	inode->i_ino = ino;
 	inode->i_blocks = 0;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	F2FS_I(inode)->i_crtime = inode->i_mtime;
 	inode->i_generation = get_random_u32();
 
@@ -420,7 +420,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
 
 	f2fs_balance_fs(sbi, true);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ihold(inode);
 
 	set_inode_flag(inode, FI_INC_LINK);
@@ -1052,7 +1052,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		f2fs_set_link(new_dir, new_entry, new_page, old_inode);
 		new_page = NULL;
 
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		f2fs_down_write(&F2FS_I(new_inode)->i_sem);
 		if (old_dir_entry)
 			f2fs_i_links_write(new_inode, false);
@@ -1086,7 +1086,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
 
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 	f2fs_mark_inode_dirty_sync(old_inode, false);
 
 	f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
@@ -1251,7 +1251,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
 
-	old_dir->i_ctime = current_time(old_dir);
+	inode_set_ctime_current(old_dir);
 	if (old_nlink) {
 		f2fs_down_write(&F2FS_I(old_dir)->i_sem);
 		f2fs_i_links_write(old_dir, old_nlink > 0);
@@ -1270,7 +1270,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 		f2fs_i_pino_write(new_inode, old_dir->i_ino);
 	f2fs_up_write(&F2FS_I(new_inode)->i_sem);
 
-	new_dir->i_ctime = current_time(new_dir);
+	inode_set_ctime_current(new_dir);
 	if (new_nlink) {
 		f2fs_down_write(&F2FS_I(new_dir)->i_sem);
 		f2fs_i_links_write(new_dir, new_nlink > 0);
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 4e7d4ceeb084..b8637e88d94f 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -321,10 +321,10 @@ static int recover_inode(struct inode *inode, struct page *page)
 
 	f2fs_i_size_write(inode, le64_to_cpu(raw->i_size));
 	inode->i_atime.tv_sec = le64_to_cpu(raw->i_atime);
-	inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime);
+	inode_set_ctime(inode, le64_to_cpu(raw->i_ctime),
+			le32_to_cpu(raw->i_ctime_nsec));
 	inode->i_mtime.tv_sec = le64_to_cpu(raw->i_mtime);
 	inode->i_atime.tv_nsec = le32_to_cpu(raw->i_atime_nsec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
 
 	F2FS_I(inode)->i_advise = raw->i_advise;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ca31163da00a..28aeffc0048c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2703,7 +2703,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
 
 	if (len == towrite)
 		return err;
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	f2fs_mark_inode_dirty_sync(inode, false);
 	return len - towrite;
 }
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 476b186b90a6..4ae93e1df421 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -764,7 +764,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 same:
 	if (is_inode_flag_set(inode, FI_ACL_MODE)) {
 		inode->i_mode = F2FS_I(inode)->i_acl_mode;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		clear_inode_flag(inode, FI_ACL_MODE);
 	}
 
-- 
2.41.0


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

* [PATCH v2 44/92] fat: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (39 preceding siblings ...)
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06  1:54     ` OGAWA Hirofumi
  2023-07-05 19:01   ` [PATCH v2 45/92] freevxfs: " Jeff Layton
                     ` (46 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, OGAWA Hirofumi
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/fat/inode.c | 7 ++++---
 fs/fat/misc.c  | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index d99b8549ec8f..2be40ff8a74f 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -562,7 +562,7 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
 			   & ~((loff_t)sbi->cluster_size - 1)) >> 9;
 
 	fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
-	inode->i_ctime = inode->i_mtime;
+	inode_set_ctime_to_ts(inode, inode->i_mtime);
 	if (sbi->options.isvfat) {
 		fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0);
 		fat_time_fat2unix(sbi, &MSDOS_I(inode)->i_crtime, de->ctime,
@@ -1407,8 +1407,9 @@ static int fat_read_root(struct inode *inode)
 	MSDOS_I(inode)->mmu_private = inode->i_size;
 
 	fat_save_attrs(inode, ATTR_DIR);
-	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0;
-	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0;
+	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode_set_ctime(inode,
+									0, 0).tv_sec;
+	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0;
 	set_nlink(inode, fat_subdirs(inode)+2);
 
 	return 0;
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 7e5d6ae305f2..67006ea08db6 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -332,7 +332,8 @@ int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags)
 	 * but ctime updates are ignored.
 	 */
 	if (flags & S_MTIME)
-		inode->i_mtime = inode->i_ctime = fat_truncate_mtime(sbi, now);
+		inode->i_mtime = inode_set_ctime_to_ts(inode,
+						       fat_truncate_mtime(sbi, now));
 
 	return 0;
 }
-- 
2.41.0


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

* [PATCH v2 45/92] freevxfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (40 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 44/92] fat: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 11:19     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 46/92] fuse: " Jeff Layton
                     ` (45 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Christoph Hellwig
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/freevxfs/vxfs_inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index ceb6a12649ba..ac5d43b164b5 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -110,10 +110,9 @@ static inline void dip2vip_cpy(struct vxfs_sb_info *sbi,
 	inode->i_size = vip->vii_size;
 
 	inode->i_atime.tv_sec = vip->vii_atime;
-	inode->i_ctime.tv_sec = vip->vii_ctime;
+	inode_set_ctime(inode, vip->vii_ctime, 0);
 	inode->i_mtime.tv_sec = vip->vii_mtime;
 	inode->i_atime.tv_nsec = 0;
-	inode->i_ctime.tv_nsec = 0;
 	inode->i_mtime.tv_nsec = 0;
 
 	inode->i_blocks = vip->vii_blocks;
-- 
2.41.0


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

* [PATCH v2 46/92] fuse: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (41 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 45/92] freevxfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 11:20     ` Jan Kara
  2023-07-05 19:01     ` [Cluster-devel] " Jeff Layton
                     ` (44 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Miklos Szeredi
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/fuse/control.c |  2 +-
 fs/fuse/dir.c     |  8 ++++----
 fs/fuse/inode.c   | 16 ++++++++--------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 247ef4f76761..ab62e4624256 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -235,7 +235,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
 	inode->i_mode = mode;
 	inode->i_uid = fc->user_id;
 	inode->i_gid = fc->group_id;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	/* setting ->i_op to NULL is not allowed */
 	if (iop)
 		inode->i_op = iop;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index f67bef9d83c4..672245ee0394 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -933,7 +933,7 @@ void fuse_flush_time_update(struct inode *inode)
 static void fuse_update_ctime_in_cache(struct inode *inode)
 {
 	if (!IS_NOCMTIME(inode)) {
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		mark_inode_dirty_sync(inode);
 		fuse_flush_time_update(inode);
 	}
@@ -1715,8 +1715,8 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
 	inarg.mtimensec = inode->i_mtime.tv_nsec;
 	if (fm->fc->minor >= 23) {
 		inarg.valid |= FATTR_CTIME;
-		inarg.ctime = inode->i_ctime.tv_sec;
-		inarg.ctimensec = inode->i_ctime.tv_nsec;
+		inarg.ctime = inode_get_ctime(inode).tv_sec;
+		inarg.ctimensec = inode_get_ctime(inode).tv_nsec;
 	}
 	if (ff) {
 		inarg.valid |= FATTR_FH;
@@ -1857,7 +1857,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
 		if (attr->ia_valid & ATTR_MTIME)
 			inode->i_mtime = attr->ia_mtime;
 		if (attr->ia_valid & ATTR_CTIME)
-			inode->i_ctime = attr->ia_ctime;
+			inode_set_ctime_to_ts(inode, attr->ia_ctime);
 		/* FIXME: clear I_DIRTY_SYNC? */
 	}
 
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index f19d748890f0..549358ffea8b 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -194,8 +194,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
 		inode->i_mtime.tv_nsec  = attr->mtimensec;
 	}
 	if (!(cache_mask & STATX_CTIME)) {
-		inode->i_ctime.tv_sec   = attr->ctime;
-		inode->i_ctime.tv_nsec  = attr->ctimensec;
+		inode_set_ctime(inode, attr->ctime, attr->ctimensec);
 	}
 
 	if (attr->blksize != 0)
@@ -259,8 +258,8 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
 		attr->mtimensec = inode->i_mtime.tv_nsec;
 	}
 	if (cache_mask & STATX_CTIME) {
-		attr->ctime = inode->i_ctime.tv_sec;
-		attr->ctimensec = inode->i_ctime.tv_nsec;
+		attr->ctime = inode_get_ctime(inode).tv_sec;
+		attr->ctimensec = inode_get_ctime(inode).tv_nsec;
 	}
 
 	if ((attr_version != 0 && fi->attr_version > attr_version) ||
@@ -318,8 +317,7 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr,
 	inode->i_size = attr->size;
 	inode->i_mtime.tv_sec  = attr->mtime;
 	inode->i_mtime.tv_nsec = attr->mtimensec;
-	inode->i_ctime.tv_sec  = attr->ctime;
-	inode->i_ctime.tv_nsec = attr->ctimensec;
+	inode_set_ctime(inode, attr->ctime, attr->ctimensec);
 	if (S_ISREG(inode->i_mode)) {
 		fuse_init_common(inode);
 		fuse_init_file_inode(inode, attr->flags);
@@ -1401,16 +1399,18 @@ EXPORT_SYMBOL_GPL(fuse_dev_free);
 static void fuse_fill_attr_from_inode(struct fuse_attr *attr,
 				      const struct fuse_inode *fi)
 {
+	struct timespec64 ctime = inode_get_ctime(&fi->inode);
+
 	*attr = (struct fuse_attr){
 		.ino		= fi->inode.i_ino,
 		.size		= fi->inode.i_size,
 		.blocks		= fi->inode.i_blocks,
 		.atime		= fi->inode.i_atime.tv_sec,
 		.mtime		= fi->inode.i_mtime.tv_sec,
-		.ctime		= fi->inode.i_ctime.tv_sec,
+		.ctime		= ctime.tv_sec,
 		.atimensec	= fi->inode.i_atime.tv_nsec,
 		.mtimensec	= fi->inode.i_mtime.tv_nsec,
-		.ctimensec	= fi->inode.i_ctime.tv_nsec,
+		.ctimensec	= ctime.tv_nsec,
 		.mode		= fi->inode.i_mode,
 		.nlink		= fi->inode.i_nlink,
 		.uid		= fi->inode.i_uid.val,
-- 
2.41.0


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

* [PATCH v2 47/92] gfs2: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:01     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Bob Peterson, Andreas Gruenbacher
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, cluster-devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/gfs2/acl.c   |  2 +-
 fs/gfs2/bmap.c  | 11 +++++------
 fs/gfs2/dir.c   | 15 ++++++++-------
 fs/gfs2/file.c  |  2 +-
 fs/gfs2/glops.c |  4 ++--
 fs/gfs2/inode.c |  8 ++++----
 fs/gfs2/super.c |  4 ++--
 fs/gfs2/xattr.c |  8 ++++----
 8 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index a392aa0f041d..443640e6fb9c 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -142,7 +142,7 @@ int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 
 	ret = __gfs2_set_acl(inode, acl, type);
 	if (!ret && mode != inode->i_mode) {
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		inode->i_mode = mode;
 		mark_inode_dirty(inode);
 	}
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 8d611fbcf0bd..45ea63f7167d 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1386,7 +1386,7 @@ static int trunc_start(struct inode *inode, u64 newsize)
 		ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG;
 
 	i_size_write(inode, newsize);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	gfs2_dinode_out(ip, dibh->b_data);
 
 	if (journaled)
@@ -1583,8 +1583,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
 
 			/* Every transaction boundary, we rewrite the dinode
 			   to keep its di_blocks current in case of failure. */
-			ip->i_inode.i_mtime = ip->i_inode.i_ctime =
-				current_time(&ip->i_inode);
+			ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 			gfs2_trans_add_meta(ip->i_gl, dibh);
 			gfs2_dinode_out(ip, dibh->b_data);
 			brelse(dibh);
@@ -1950,7 +1949,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
 		gfs2_statfs_change(sdp, 0, +btotal, 0);
 		gfs2_quota_change(ip, -(s64)btotal, ip->i_inode.i_uid,
 				  ip->i_inode.i_gid);
-		ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+		ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 		gfs2_trans_add_meta(ip->i_gl, dibh);
 		gfs2_dinode_out(ip, dibh->b_data);
 		up_write(&ip->i_rw_mutex);
@@ -1993,7 +1992,7 @@ static int trunc_end(struct gfs2_inode *ip)
 		gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
 		gfs2_ordered_del_inode(ip);
 	}
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG;
 
 	gfs2_trans_add_meta(ip->i_gl, dibh);
@@ -2094,7 +2093,7 @@ static int do_grow(struct inode *inode, u64 size)
 		goto do_end_trans;
 
 	truncate_setsize(inode, size);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	gfs2_trans_add_meta(ip->i_gl, dibh);
 	gfs2_dinode_out(ip, dibh->b_data);
 	brelse(dibh);
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 54a6d17b8c25..1a2afa88f8be 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -130,7 +130,7 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
 	memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
 	if (ip->i_inode.i_size < offset + size)
 		i_size_write(&ip->i_inode, offset + size);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	gfs2_dinode_out(ip, dibh->b_data);
 
 	brelse(dibh);
@@ -227,7 +227,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
 
 	if (ip->i_inode.i_size < offset + copied)
 		i_size_write(&ip->i_inode, offset + copied);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 
 	gfs2_trans_add_meta(ip->i_gl, dibh);
 	gfs2_dinode_out(ip, dibh->b_data);
@@ -1814,7 +1814,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
 			gfs2_inum_out(nip, dent);
 			dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode));
 			dent->de_rahead = cpu_to_be16(gfs2_inode_ra_len(nip));
-			tv = current_time(&ip->i_inode);
+			tv = inode_set_ctime_current(&ip->i_inode);
 			if (ip->i_diskflags & GFS2_DIF_EXHASH) {
 				leaf = (struct gfs2_leaf *)bh->b_data;
 				be16_add_cpu(&leaf->lf_entries, 1);
@@ -1825,7 +1825,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
 			da->bh = NULL;
 			brelse(bh);
 			ip->i_entries++;
-			ip->i_inode.i_mtime = ip->i_inode.i_ctime = tv;
+			ip->i_inode.i_mtime = tv;
 			if (S_ISDIR(nip->i_inode.i_mode))
 				inc_nlink(&ip->i_inode);
 			mark_inode_dirty(inode);
@@ -1876,7 +1876,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
 	const struct qstr *name = &dentry->d_name;
 	struct gfs2_dirent *dent, *prev = NULL;
 	struct buffer_head *bh;
-	struct timespec64 tv = current_time(&dip->i_inode);
+	struct timespec64 tv;
 
 	/* Returns _either_ the entry (if its first in block) or the
 	   previous entry otherwise */
@@ -1896,6 +1896,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
 	}
 
 	dirent_del(dip, bh, prev, dent);
+	tv = inode_set_ctime_current(&dip->i_inode);
 	if (dip->i_diskflags & GFS2_DIF_EXHASH) {
 		struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
 		u16 entries = be16_to_cpu(leaf->lf_entries);
@@ -1910,7 +1911,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
 	if (!dip->i_entries)
 		gfs2_consist_inode(dip);
 	dip->i_entries--;
-	dip->i_inode.i_mtime = dip->i_inode.i_ctime = tv;
+	dip->i_inode.i_mtime =  tv;
 	if (d_is_dir(dentry))
 		drop_nlink(&dip->i_inode);
 	mark_inode_dirty(&dip->i_inode);
@@ -1951,7 +1952,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
 	dent->de_type = cpu_to_be16(new_type);
 	brelse(bh);
 
-	dip->i_inode.i_mtime = dip->i_inode.i_ctime = current_time(&dip->i_inode);
+	dip->i_inode.i_mtime = inode_set_ctime_current(&dip->i_inode);
 	mark_inode_dirty_sync(&dip->i_inode);
 	return 0;
 }
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 1bf3c4453516..ecbfbc6df621 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -260,7 +260,7 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
 	error = gfs2_meta_inode_buffer(ip, &bh);
 	if (error)
 		goto out_trans_end;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	gfs2_trans_add_meta(ip->i_gl, bh);
 	ip->i_diskflags = new_flags;
 	gfs2_dinode_out(ip, bh->b_data);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 54319328b16b..aecdac3cfbe1 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -437,8 +437,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
 		inode->i_atime = atime;
 	inode->i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
 	inode->i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
-	inode->i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
-	inode->i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
+	inode_set_ctime(inode, be64_to_cpu(str->di_ctime),
+			be32_to_cpu(str->di_ctime_nsec));
 
 	ip->i_goal = be64_to_cpu(str->di_goal_meta);
 	ip->i_generation = be64_to_cpu(str->di_generation);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 17c994a0c0d0..2ded6c813f20 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -690,7 +690,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
 	set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
 	inode->i_rdev = dev;
 	inode->i_size = size;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	munge_mode_uid_gid(dip, inode);
 	check_and_update_goal(dip);
 	ip->i_goal = dip->i_goal;
@@ -1029,7 +1029,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
 
 	gfs2_trans_add_meta(ip->i_gl, dibh);
 	inc_nlink(&ip->i_inode);
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	ihold(inode);
 	d_instantiate(dentry, inode);
 	mark_inode_dirty(inode);
@@ -1114,7 +1114,7 @@ static int gfs2_unlink_inode(struct gfs2_inode *dip,
 		return error;
 
 	ip->i_entries = 0;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (S_ISDIR(inode->i_mode))
 		clear_nlink(inode);
 	else
@@ -1371,7 +1371,7 @@ static int update_moved_ino(struct gfs2_inode *ip, struct gfs2_inode *ndip,
 	if (dir_rename)
 		return gfs2_dir_mvino(ip, &gfs2_qdotdot, ndip, DT_DIR);
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	mark_inode_dirty_sync(&ip->i_inode);
 	return 0;
 }
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 9f4d5d6549ee..ec0296b35dfe 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -412,7 +412,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
 	str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(inode));
 	str->di_atime = cpu_to_be64(inode->i_atime.tv_sec);
 	str->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec);
-	str->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec);
+	str->di_ctime = cpu_to_be64(inode_get_ctime(inode).tv_sec);
 
 	str->di_goal_meta = cpu_to_be64(ip->i_goal);
 	str->di_goal_data = cpu_to_be64(ip->i_goal);
@@ -429,7 +429,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
 	str->di_eattr = cpu_to_be64(ip->i_eattr);
 	str->di_atime_nsec = cpu_to_be32(inode->i_atime.tv_nsec);
 	str->di_mtime_nsec = cpu_to_be32(inode->i_mtime.tv_nsec);
-	str->di_ctime_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
+	str->di_ctime_nsec = cpu_to_be32(inode_get_ctime(inode).tv_nsec);
 }
 
 /**
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 93b36d026bb4..4fea70c0fe3d 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -311,7 +311,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
 		ea->ea_num_ptrs = 0;
 	}
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 	gfs2_trans_end(sdp);
@@ -763,7 +763,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
 	if (error)
 		goto out_end_trans;
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 out_end_trans:
@@ -888,7 +888,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
 	if (es->es_el)
 		ea_set_remove_stuffed(ip, es->es_el);
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 	gfs2_trans_end(GFS2_SB(&ip->i_inode));
@@ -1106,7 +1106,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
 		ea->ea_type = GFS2_EATYPE_UNUSED;
 	}
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 	gfs2_trans_end(GFS2_SB(&ip->i_inode));
-- 
2.41.0


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

* [Cluster-devel] [PATCH v2 47/92] gfs2: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: cluster-devel.redhat.com

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/gfs2/acl.c   |  2 +-
 fs/gfs2/bmap.c  | 11 +++++------
 fs/gfs2/dir.c   | 15 ++++++++-------
 fs/gfs2/file.c  |  2 +-
 fs/gfs2/glops.c |  4 ++--
 fs/gfs2/inode.c |  8 ++++----
 fs/gfs2/super.c |  4 ++--
 fs/gfs2/xattr.c |  8 ++++----
 8 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index a392aa0f041d..443640e6fb9c 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -142,7 +142,7 @@ int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 
 	ret = __gfs2_set_acl(inode, acl, type);
 	if (!ret && mode != inode->i_mode) {
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		inode->i_mode = mode;
 		mark_inode_dirty(inode);
 	}
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 8d611fbcf0bd..45ea63f7167d 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1386,7 +1386,7 @@ static int trunc_start(struct inode *inode, u64 newsize)
 		ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG;
 
 	i_size_write(inode, newsize);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	gfs2_dinode_out(ip, dibh->b_data);
 
 	if (journaled)
@@ -1583,8 +1583,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
 
 			/* Every transaction boundary, we rewrite the dinode
 			   to keep its di_blocks current in case of failure. */
-			ip->i_inode.i_mtime = ip->i_inode.i_ctime =
-				current_time(&ip->i_inode);
+			ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 			gfs2_trans_add_meta(ip->i_gl, dibh);
 			gfs2_dinode_out(ip, dibh->b_data);
 			brelse(dibh);
@@ -1950,7 +1949,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
 		gfs2_statfs_change(sdp, 0, +btotal, 0);
 		gfs2_quota_change(ip, -(s64)btotal, ip->i_inode.i_uid,
 				  ip->i_inode.i_gid);
-		ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+		ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 		gfs2_trans_add_meta(ip->i_gl, dibh);
 		gfs2_dinode_out(ip, dibh->b_data);
 		up_write(&ip->i_rw_mutex);
@@ -1993,7 +1992,7 @@ static int trunc_end(struct gfs2_inode *ip)
 		gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
 		gfs2_ordered_del_inode(ip);
 	}
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG;
 
 	gfs2_trans_add_meta(ip->i_gl, dibh);
@@ -2094,7 +2093,7 @@ static int do_grow(struct inode *inode, u64 size)
 		goto do_end_trans;
 
 	truncate_setsize(inode, size);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	gfs2_trans_add_meta(ip->i_gl, dibh);
 	gfs2_dinode_out(ip, dibh->b_data);
 	brelse(dibh);
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 54a6d17b8c25..1a2afa88f8be 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -130,7 +130,7 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
 	memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
 	if (ip->i_inode.i_size < offset + size)
 		i_size_write(&ip->i_inode, offset + size);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 	gfs2_dinode_out(ip, dibh->b_data);
 
 	brelse(dibh);
@@ -227,7 +227,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
 
 	if (ip->i_inode.i_size < offset + copied)
 		i_size_write(&ip->i_inode, offset + copied);
-	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
 
 	gfs2_trans_add_meta(ip->i_gl, dibh);
 	gfs2_dinode_out(ip, dibh->b_data);
@@ -1814,7 +1814,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
 			gfs2_inum_out(nip, dent);
 			dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode));
 			dent->de_rahead = cpu_to_be16(gfs2_inode_ra_len(nip));
-			tv = current_time(&ip->i_inode);
+			tv = inode_set_ctime_current(&ip->i_inode);
 			if (ip->i_diskflags & GFS2_DIF_EXHASH) {
 				leaf = (struct gfs2_leaf *)bh->b_data;
 				be16_add_cpu(&leaf->lf_entries, 1);
@@ -1825,7 +1825,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
 			da->bh = NULL;
 			brelse(bh);
 			ip->i_entries++;
-			ip->i_inode.i_mtime = ip->i_inode.i_ctime = tv;
+			ip->i_inode.i_mtime = tv;
 			if (S_ISDIR(nip->i_inode.i_mode))
 				inc_nlink(&ip->i_inode);
 			mark_inode_dirty(inode);
@@ -1876,7 +1876,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
 	const struct qstr *name = &dentry->d_name;
 	struct gfs2_dirent *dent, *prev = NULL;
 	struct buffer_head *bh;
-	struct timespec64 tv = current_time(&dip->i_inode);
+	struct timespec64 tv;
 
 	/* Returns _either_ the entry (if its first in block) or the
 	   previous entry otherwise */
@@ -1896,6 +1896,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
 	}
 
 	dirent_del(dip, bh, prev, dent);
+	tv = inode_set_ctime_current(&dip->i_inode);
 	if (dip->i_diskflags & GFS2_DIF_EXHASH) {
 		struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
 		u16 entries = be16_to_cpu(leaf->lf_entries);
@@ -1910,7 +1911,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
 	if (!dip->i_entries)
 		gfs2_consist_inode(dip);
 	dip->i_entries--;
-	dip->i_inode.i_mtime = dip->i_inode.i_ctime = tv;
+	dip->i_inode.i_mtime =  tv;
 	if (d_is_dir(dentry))
 		drop_nlink(&dip->i_inode);
 	mark_inode_dirty(&dip->i_inode);
@@ -1951,7 +1952,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
 	dent->de_type = cpu_to_be16(new_type);
 	brelse(bh);
 
-	dip->i_inode.i_mtime = dip->i_inode.i_ctime = current_time(&dip->i_inode);
+	dip->i_inode.i_mtime = inode_set_ctime_current(&dip->i_inode);
 	mark_inode_dirty_sync(&dip->i_inode);
 	return 0;
 }
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 1bf3c4453516..ecbfbc6df621 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -260,7 +260,7 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
 	error = gfs2_meta_inode_buffer(ip, &bh);
 	if (error)
 		goto out_trans_end;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	gfs2_trans_add_meta(ip->i_gl, bh);
 	ip->i_diskflags = new_flags;
 	gfs2_dinode_out(ip, bh->b_data);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 54319328b16b..aecdac3cfbe1 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -437,8 +437,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
 		inode->i_atime = atime;
 	inode->i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
 	inode->i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
-	inode->i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
-	inode->i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
+	inode_set_ctime(inode, be64_to_cpu(str->di_ctime),
+			be32_to_cpu(str->di_ctime_nsec));
 
 	ip->i_goal = be64_to_cpu(str->di_goal_meta);
 	ip->i_generation = be64_to_cpu(str->di_generation);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 17c994a0c0d0..2ded6c813f20 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -690,7 +690,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
 	set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
 	inode->i_rdev = dev;
 	inode->i_size = size;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	munge_mode_uid_gid(dip, inode);
 	check_and_update_goal(dip);
 	ip->i_goal = dip->i_goal;
@@ -1029,7 +1029,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
 
 	gfs2_trans_add_meta(ip->i_gl, dibh);
 	inc_nlink(&ip->i_inode);
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	ihold(inode);
 	d_instantiate(dentry, inode);
 	mark_inode_dirty(inode);
@@ -1114,7 +1114,7 @@ static int gfs2_unlink_inode(struct gfs2_inode *dip,
 		return error;
 
 	ip->i_entries = 0;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (S_ISDIR(inode->i_mode))
 		clear_nlink(inode);
 	else
@@ -1371,7 +1371,7 @@ static int update_moved_ino(struct gfs2_inode *ip, struct gfs2_inode *ndip,
 	if (dir_rename)
 		return gfs2_dir_mvino(ip, &gfs2_qdotdot, ndip, DT_DIR);
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	mark_inode_dirty_sync(&ip->i_inode);
 	return 0;
 }
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 9f4d5d6549ee..ec0296b35dfe 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -412,7 +412,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
 	str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(inode));
 	str->di_atime = cpu_to_be64(inode->i_atime.tv_sec);
 	str->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec);
-	str->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec);
+	str->di_ctime = cpu_to_be64(inode_get_ctime(inode).tv_sec);
 
 	str->di_goal_meta = cpu_to_be64(ip->i_goal);
 	str->di_goal_data = cpu_to_be64(ip->i_goal);
@@ -429,7 +429,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
 	str->di_eattr = cpu_to_be64(ip->i_eattr);
 	str->di_atime_nsec = cpu_to_be32(inode->i_atime.tv_nsec);
 	str->di_mtime_nsec = cpu_to_be32(inode->i_mtime.tv_nsec);
-	str->di_ctime_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
+	str->di_ctime_nsec = cpu_to_be32(inode_get_ctime(inode).tv_nsec);
 }
 
 /**
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 93b36d026bb4..4fea70c0fe3d 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -311,7 +311,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
 		ea->ea_num_ptrs = 0;
 	}
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 	gfs2_trans_end(sdp);
@@ -763,7 +763,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
 	if (error)
 		goto out_end_trans;
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 out_end_trans:
@@ -888,7 +888,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
 	if (es->es_el)
 		ea_set_remove_stuffed(ip, es->es_el);
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 	gfs2_trans_end(GFS2_SB(&ip->i_inode));
@@ -1106,7 +1106,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
 		ea->ea_type = GFS2_EATYPE_UNUSED;
 	}
 
-	ip->i_inode.i_ctime = current_time(&ip->i_inode);
+	inode_set_ctime_current(&ip->i_inode);
 	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
 
 	gfs2_trans_end(GFS2_SB(&ip->i_inode));
-- 
2.41.0


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

* [PATCH v2 48/92] hfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (43 preceding siblings ...)
  2023-07-05 19:01     ` [Cluster-devel] " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 12:50     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 49/92] hfsplus: " Jeff Layton
                     ` (42 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/hfs/catalog.c |  8 ++++----
 fs/hfs/dir.c     |  2 +-
 fs/hfs/inode.c   | 13 ++++++-------
 fs/hfs/sysdep.c  |  4 +++-
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index d365bf0b8c77..632c226a3972 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -133,7 +133,7 @@ int hfs_cat_create(u32 cnid, struct inode *dir, const struct qstr *str, struct i
 		goto err1;
 
 	dir->i_size++;
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	hfs_find_exit(&fd);
 	return 0;
@@ -269,7 +269,7 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, const struct qstr *str)
 	}
 
 	dir->i_size--;
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	res = 0;
 out:
@@ -337,7 +337,7 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
 	if (err)
 		goto out;
 	dst_dir->i_size++;
-	dst_dir->i_mtime = dst_dir->i_ctime = current_time(dst_dir);
+	dst_dir->i_mtime = inode_set_ctime_current(dst_dir);
 	mark_inode_dirty(dst_dir);
 
 	/* finally remove the old entry */
@@ -349,7 +349,7 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
 	if (err)
 		goto out;
 	src_dir->i_size--;
-	src_dir->i_mtime = src_dir->i_ctime = current_time(src_dir);
+	src_dir->i_mtime = inode_set_ctime_current(src_dir);
 	mark_inode_dirty(src_dir);
 
 	type = entry.type;
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 3e1e3dcf0b48..b75c26045df4 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -263,7 +263,7 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
 	if (res)
 		return res;
 	clear_nlink(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	hfs_delete_inode(inode);
 	mark_inode_dirty(inode);
 	return 0;
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 441d7fc952e3..ee349b72cfb3 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -200,7 +200,7 @@ struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	set_nlink(inode, 1);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	HFS_I(inode)->flags = 0;
 	HFS_I(inode)->rsrc_inode = NULL;
 	HFS_I(inode)->fs_blocks = 0;
@@ -355,8 +355,8 @@ static int hfs_read_inode(struct inode *inode, void *data)
 			inode->i_mode |= S_IWUGO;
 		inode->i_mode &= ~hsb->s_file_umask;
 		inode->i_mode |= S_IFREG;
-		inode->i_ctime = inode->i_atime = inode->i_mtime =
-				hfs_m_to_utime(rec->file.MdDat);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode,
+									hfs_m_to_utime(rec->file.MdDat));
 		inode->i_op = &hfs_file_inode_operations;
 		inode->i_fop = &hfs_file_operations;
 		inode->i_mapping->a_ops = &hfs_aops;
@@ -366,8 +366,8 @@ static int hfs_read_inode(struct inode *inode, void *data)
 		inode->i_size = be16_to_cpu(rec->dir.Val) + 2;
 		HFS_I(inode)->fs_blocks = 0;
 		inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
-		inode->i_ctime = inode->i_atime = inode->i_mtime =
-				hfs_m_to_utime(rec->dir.MdDat);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode,
+									hfs_m_to_utime(rec->dir.MdDat));
 		inode->i_op = &hfs_dir_inode_operations;
 		inode->i_fop = &hfs_dir_operations;
 		break;
@@ -654,8 +654,7 @@ int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 
 		truncate_setsize(inode, attr->ia_size);
 		hfs_file_truncate(inode);
-		inode->i_atime = inode->i_mtime = inode->i_ctime =
-						  current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	}
 
 	setattr_copy(&nop_mnt_idmap, inode, attr);
diff --git a/fs/hfs/sysdep.c b/fs/hfs/sysdep.c
index 2875961fdc10..dc27d418fbcd 100644
--- a/fs/hfs/sysdep.c
+++ b/fs/hfs/sysdep.c
@@ -28,7 +28,9 @@ static int hfs_revalidate_dentry(struct dentry *dentry, unsigned int flags)
 	/* fix up inode on a timezone change */
 	diff = sys_tz.tz_minuteswest * 60 - HFS_I(inode)->tz_secondswest;
 	if (diff) {
-		inode->i_ctime.tv_sec += diff;
+		struct timespec64 ctime = inode_get_ctime(inode);
+
+		inode_set_ctime(inode, ctime.tv_sec + diff, ctime.tv_nsec);
 		inode->i_atime.tv_sec += diff;
 		inode->i_mtime.tv_sec += diff;
 		HFS_I(inode)->tz_secondswest += diff;
-- 
2.41.0


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

* [PATCH v2 49/92] hfsplus: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (44 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 48/92] hfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 12:49     ` Jan Kara
  2023-07-05 19:01     ` Jeff Layton
                     ` (41 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/hfsplus/catalog.c |  8 ++++----
 fs/hfsplus/dir.c     |  6 +++---
 fs/hfsplus/inode.c   | 16 +++++++++-------
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index 35472cba750e..e71ae2537eaa 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -312,7 +312,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
 	dir->i_size++;
 	if (S_ISDIR(inode->i_mode))
 		hfsplus_subfolders_inc(dir);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY);
 
 	hfs_find_exit(&fd);
@@ -417,7 +417,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str)
 	dir->i_size--;
 	if (type == HFSPLUS_FOLDER)
 		hfsplus_subfolders_dec(dir);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY);
 
 	if (type == HFSPLUS_FILE || type == HFSPLUS_FOLDER) {
@@ -494,7 +494,7 @@ int hfsplus_rename_cat(u32 cnid,
 	dst_dir->i_size++;
 	if (type == HFSPLUS_FOLDER)
 		hfsplus_subfolders_inc(dst_dir);
-	dst_dir->i_mtime = dst_dir->i_ctime = current_time(dst_dir);
+	dst_dir->i_mtime = inode_set_ctime_current(dst_dir);
 
 	/* finally remove the old entry */
 	err = hfsplus_cat_build_key(sb, src_fd.search_key,
@@ -511,7 +511,7 @@ int hfsplus_rename_cat(u32 cnid,
 	src_dir->i_size--;
 	if (type == HFSPLUS_FOLDER)
 		hfsplus_subfolders_dec(src_dir);
-	src_dir->i_mtime = src_dir->i_ctime = current_time(src_dir);
+	src_dir->i_mtime = inode_set_ctime_current(src_dir);
 
 	/* remove old thread entry */
 	hfsplus_cat_build_key_with_cnid(sb, src_fd.search_key, cnid);
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 56fb5f1312e7..f5c4b3e31a1c 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -346,7 +346,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
 	inc_nlink(inode);
 	hfsplus_instantiate(dst_dentry, inode, cnid);
 	ihold(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	sbi->file_count++;
 	hfsplus_mark_mdb_dirty(dst_dir->i_sb);
@@ -405,7 +405,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
 			hfsplus_delete_inode(inode);
 	} else
 		sbi->file_count--;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 out:
 	mutex_unlock(&sbi->vh_mutex);
@@ -426,7 +426,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
 	if (res)
 		goto out;
 	clear_nlink(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	hfsplus_delete_inode(inode);
 	mark_inode_dirty(inode);
 out:
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 7d1a675e037d..40c61ab4a918 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -267,7 +267,7 @@ static int hfsplus_setattr(struct mnt_idmap *idmap,
 		}
 		truncate_setsize(inode, attr->ia_size);
 		hfsplus_file_truncate(inode);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 	}
 
 	setattr_copy(&nop_mnt_idmap, inode, attr);
@@ -392,7 +392,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
 	inode->i_ino = sbi->next_cnid++;
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 	set_nlink(inode, 1);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 
 	hip = HFSPLUS_I(inode);
 	INIT_LIST_HEAD(&hip->open_dir_list);
@@ -523,7 +523,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
 		inode->i_size = 2 + be32_to_cpu(folder->valence);
 		inode->i_atime = hfsp_mt2ut(folder->access_date);
 		inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
-		inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date);
+		inode_set_ctime_to_ts(inode,
+				      hfsp_mt2ut(folder->attribute_mod_date));
 		HFSPLUS_I(inode)->create_date = folder->create_date;
 		HFSPLUS_I(inode)->fs_blocks = 0;
 		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
@@ -564,7 +565,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
 		}
 		inode->i_atime = hfsp_mt2ut(file->access_date);
 		inode->i_mtime = hfsp_mt2ut(file->content_mod_date);
-		inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
+		inode_set_ctime_to_ts(inode,
+				      hfsp_mt2ut(file->attribute_mod_date));
 		HFSPLUS_I(inode)->create_date = file->create_date;
 	} else {
 		pr_err("bad catalog entry used to create inode\n");
@@ -609,7 +611,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
 		hfsplus_cat_set_perms(inode, &folder->permissions);
 		folder->access_date = hfsp_ut2mt(inode->i_atime);
 		folder->content_mod_date = hfsp_ut2mt(inode->i_mtime);
-		folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
+		folder->attribute_mod_date = hfsp_ut2mt(inode_get_ctime(inode));
 		folder->valence = cpu_to_be32(inode->i_size - 2);
 		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
 			folder->subfolders =
@@ -644,7 +646,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
 			file->flags &= cpu_to_be16(~HFSPLUS_FILE_LOCKED);
 		file->access_date = hfsp_ut2mt(inode->i_atime);
 		file->content_mod_date = hfsp_ut2mt(inode->i_mtime);
-		file->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
+		file->attribute_mod_date = hfsp_ut2mt(inode_get_ctime(inode));
 		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
 					 sizeof(struct hfsplus_cat_file));
 	}
@@ -700,7 +702,7 @@ int hfsplus_fileattr_set(struct mnt_idmap *idmap,
 	else
 		hip->userflags &= ~HFSPLUS_FLG_NODUMP;
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	return 0;
-- 
2.41.0


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

* [PATCH v2 50/92] hostfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:01     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Richard Weinberger, Anton Ivanov, Johannes Berg
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-um

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/hostfs/hostfs_kern.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 46387090eb76..182af84a9c12 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -517,8 +517,7 @@ static int hostfs_inode_update(struct inode *ino, const struct hostfs_stat *st)
 		(struct timespec64){ st->atime.tv_sec, st->atime.tv_nsec };
 	ino->i_mtime =
 		(struct timespec64){ st->mtime.tv_sec, st->mtime.tv_nsec };
-	ino->i_ctime =
-		(struct timespec64){ st->ctime.tv_sec, st->ctime.tv_nsec };
+	inode_set_ctime_to_ts(ino, &st->ctime);
 	ino->i_size = st->size;
 	ino->i_blocks = st->blocks;
 	return 0;
-- 
2.41.0


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

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

* [PATCH v2 50/92] hostfs: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Richard Weinberger, Anton Ivanov, Johannes Berg
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-um

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/hostfs/hostfs_kern.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 46387090eb76..182af84a9c12 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -517,8 +517,7 @@ static int hostfs_inode_update(struct inode *ino, const struct hostfs_stat *st)
 		(struct timespec64){ st->atime.tv_sec, st->atime.tv_nsec };
 	ino->i_mtime =
 		(struct timespec64){ st->mtime.tv_sec, st->mtime.tv_nsec };
-	ino->i_ctime =
-		(struct timespec64){ st->ctime.tv_sec, st->ctime.tv_nsec };
+	inode_set_ctime_to_ts(ino, &st->ctime);
 	ino->i_size = st->size;
 	ino->i_blocks = st->blocks;
 	return 0;
-- 
2.41.0


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

* [PATCH v2 51/92] hpfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (46 preceding siblings ...)
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 12:47     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 52/92] hugetlbfs: " Jeff Layton
                     ` (39 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Mikulas Patocka
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/hpfs/dir.c   |  8 ++++----
 fs/hpfs/inode.c |  6 +++---
 fs/hpfs/namei.c | 26 +++++++++++++++-----------
 fs/hpfs/super.c |  5 +++--
 4 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index f32f15669996..f36566d61215 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -277,10 +277,10 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 	 * inode.
 	 */
 
-	if (!result->i_ctime.tv_sec) {
-		if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date))))
-			result->i_ctime.tv_sec = 1;
-		result->i_ctime.tv_nsec = 0;
+	if (!inode_get_ctime(result).tv_sec) {
+		time64_t csec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date));
+
+		inode_set_ctime(result, csec ? csec : 1, 0);
 		result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date));
 		result->i_mtime.tv_nsec = 0;
 		result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date));
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index e50e92a42432..479166378bae 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -36,7 +36,7 @@ void hpfs_init_inode(struct inode *i)
 	hpfs_inode->i_rddir_off = NULL;
 	hpfs_inode->i_dirty = 0;
 
-	i->i_ctime.tv_sec = i->i_ctime.tv_nsec = 0;
+	inode_set_ctime(i, 0, 0);
 	i->i_mtime.tv_sec = i->i_mtime.tv_nsec = 0;
 	i->i_atime.tv_sec = i->i_atime.tv_nsec = 0;
 }
@@ -232,7 +232,7 @@ void hpfs_write_inode_nolock(struct inode *i)
 	if (de) {
 		de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
 		de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
-		de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
+		de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, inode_get_ctime(i).tv_sec));
 		de->read_only = !(i->i_mode & 0222);
 		de->ea_size = cpu_to_le32(hpfs_inode->i_ea_size);
 		hpfs_mark_4buffers_dirty(&qbh);
@@ -242,7 +242,7 @@ void hpfs_write_inode_nolock(struct inode *i)
 		if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) {
 			de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
 			de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
-			de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
+			de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, inode_get_ctime(i).tv_sec));
 			de->read_only = !(i->i_mode & 0222);
 			de->ea_size = cpu_to_le32(/*hpfs_inode->i_ea_size*/0);
 			de->file_size = cpu_to_le32(0);
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 69fb40b2c99a..36babb78b510 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -13,10 +13,10 @@ static void hpfs_update_directory_times(struct inode *dir)
 {
 	time64_t t = local_to_gmt(dir->i_sb, local_get_seconds(dir->i_sb));
 	if (t == dir->i_mtime.tv_sec &&
-	    t == dir->i_ctime.tv_sec)
+	    t == inode_get_ctime(dir).tv_sec)
 		return;
-	dir->i_mtime.tv_sec = dir->i_ctime.tv_sec = t;
-	dir->i_mtime.tv_nsec = dir->i_ctime.tv_nsec = 0;
+	dir->i_mtime.tv_sec = inode_set_ctime(dir, t, 0).tv_sec;
+	dir->i_mtime.tv_nsec = 0;
 	hpfs_write_inode_nolock(dir);
 }
 
@@ -59,8 +59,9 @@ static int hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 	result->i_ino = fno;
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
 	hpfs_i(result)->i_dno = dno;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
-	result->i_ctime.tv_nsec = 0; 
+	inode_set_ctime(result,
+			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
+			0);
 	result->i_mtime.tv_nsec = 0; 
 	result->i_atime.tv_nsec = 0; 
 	hpfs_i(result)->i_ea_size = 0;
@@ -167,8 +168,9 @@ static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
 	result->i_fop = &hpfs_file_ops;
 	set_nlink(result, 1);
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
-	result->i_ctime.tv_nsec = 0;
+	inode_set_ctime(result,
+			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
+			0);
 	result->i_mtime.tv_nsec = 0;
 	result->i_atime.tv_nsec = 0;
 	hpfs_i(result)->i_ea_size = 0;
@@ -250,8 +252,9 @@ static int hpfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
 	hpfs_init_inode(result);
 	result->i_ino = fno;
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
-	result->i_ctime.tv_nsec = 0;
+	inode_set_ctime(result,
+			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
+			0);
 	result->i_mtime.tv_nsec = 0;
 	result->i_atime.tv_nsec = 0;
 	hpfs_i(result)->i_ea_size = 0;
@@ -326,8 +329,9 @@ static int hpfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
 	result->i_ino = fno;
 	hpfs_init_inode(result);
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
-	result->i_ctime.tv_nsec = 0;
+	inode_set_ctime(result,
+			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
+			0);
 	result->i_mtime.tv_nsec = 0;
 	result->i_atime.tv_nsec = 0;
 	hpfs_i(result)->i_ea_size = 0;
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 1cb89595b875..758a51564124 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -729,8 +729,9 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
 		root->i_atime.tv_nsec = 0;
 		root->i_mtime.tv_sec = local_to_gmt(s, le32_to_cpu(de->write_date));
 		root->i_mtime.tv_nsec = 0;
-		root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date));
-		root->i_ctime.tv_nsec = 0;
+		inode_set_ctime(root,
+				local_to_gmt(s, le32_to_cpu(de->creation_date)),
+				0);
 		hpfs_i(root)->i_ea_size = le32_to_cpu(de->ea_size);
 		hpfs_i(root)->i_parent_dir = root->i_ino;
 		if (root->i_size == -1)
-- 
2.41.0


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

* [PATCH v2 52/92] hugetlbfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (47 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 51/92] hpfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-05 19:58     ` Mike Kravetz
  2023-07-06 12:40     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 53/92] isofs: " Jeff Layton
                     ` (38 subsequent siblings)
  87 siblings, 2 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Mike Kravetz, Muchun Song
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mm

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/hugetlbfs/inode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7b17ccfa039d..93d3bcfd4fc8 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -887,7 +887,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
 
 	if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size)
 		i_size_write(inode, offset + len);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 out:
 	inode_unlock(inode);
 	return error;
@@ -935,7 +935,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
 		inode->i_mode = S_IFDIR | ctx->mode;
 		inode->i_uid = ctx->uid;
 		inode->i_gid = ctx->gid;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inode->i_op = &hugetlbfs_dir_inode_operations;
 		inode->i_fop = &simple_dir_operations;
 		/* directory inodes start off with i_nlink == 2 (for "." entry) */
@@ -979,7 +979,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
 		lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
 				&hugetlbfs_i_mmap_rwsem_key);
 		inode->i_mapping->a_ops = &hugetlbfs_aops;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inode->i_mapping->private_data = resv_map;
 		info->seals = F_SEAL_SEAL;
 		switch (mode & S_IFMT) {
@@ -1022,7 +1022,7 @@ static int hugetlbfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
 	inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev);
 	if (!inode)
 		return -ENOSPC;
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	d_instantiate(dentry, inode);
 	dget(dentry);/* Extra count - pin the dentry in core */
 	return 0;
@@ -1054,7 +1054,7 @@ static int hugetlbfs_tmpfile(struct mnt_idmap *idmap,
 	inode = hugetlbfs_get_inode(dir->i_sb, dir, mode | S_IFREG, 0);
 	if (!inode)
 		return -ENOSPC;
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	d_tmpfile(file, inode);
 	return finish_open_simple(file, 0);
 }
@@ -1076,7 +1076,7 @@ static int hugetlbfs_symlink(struct mnt_idmap *idmap,
 		} else
 			iput(inode);
 	}
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	return error;
 }
-- 
2.41.0


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

* [PATCH v2 53/92] isofs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (48 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 52/92] hugetlbfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 12:39     ` Jan Kara
  2023-07-05 19:01     ` Jeff Layton
                     ` (37 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Jan Kara; +Cc: Al Viro, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/isofs/inode.c |  8 ++++----
 fs/isofs/rock.c  | 16 +++++++---------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index df9d70588b60..98a78200cff1 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1424,11 +1424,11 @@ static int isofs_read_inode(struct inode *inode, int relocated)
 #endif
 
 	inode->i_mtime.tv_sec =
-	inode->i_atime.tv_sec =
-	inode->i_ctime.tv_sec = iso_date(de->date, high_sierra);
+	inode->i_atime.tv_sec = inode_set_ctime(inode,
+						iso_date(de->date, high_sierra),
+						0).tv_sec;
 	inode->i_mtime.tv_nsec =
-	inode->i_atime.tv_nsec =
-	inode->i_ctime.tv_nsec = 0;
+	inode->i_atime.tv_nsec = 0;
 
 	ei->i_first_extent = (isonum_733(de->extent) +
 			isonum_711(de->ext_attr_length));
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 48f58c6c9e69..348783a70f57 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -421,10 +421,9 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 			/* Rock ridge never appears on a High Sierra disk */
 			cnt = 0;
 			if (rr->u.TF.flags & TF_CREATE) {
-				inode->i_ctime.tv_sec =
-				    iso_date(rr->u.TF.times[cnt++].time,
-					     0);
-				inode->i_ctime.tv_nsec = 0;
+				inode_set_ctime(inode,
+						iso_date(rr->u.TF.times[cnt++].time, 0),
+						0);
 			}
 			if (rr->u.TF.flags & TF_MODIFY) {
 				inode->i_mtime.tv_sec =
@@ -439,10 +438,9 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 				inode->i_atime.tv_nsec = 0;
 			}
 			if (rr->u.TF.flags & TF_ATTRIBUTES) {
-				inode->i_ctime.tv_sec =
-				    iso_date(rr->u.TF.times[cnt++].time,
-					     0);
-				inode->i_ctime.tv_nsec = 0;
+				inode_set_ctime(inode,
+						iso_date(rr->u.TF.times[cnt++].time, 0),
+						0);
 			}
 			break;
 		case SIG('S', 'L'):
@@ -534,7 +532,7 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 			inode->i_size = reloc->i_size;
 			inode->i_blocks = reloc->i_blocks;
 			inode->i_atime = reloc->i_atime;
-			inode->i_ctime = reloc->i_ctime;
+			inode_set_ctime_to_ts(inode, inode_get_ctime(reloc));
 			inode->i_mtime = reloc->i_mtime;
 			iput(reloc);
 			break;
-- 
2.41.0


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

* [PATCH v2 54/92] jffs2: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:01     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, David Woodhouse, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/jffs2/dir.c      | 24 +++++++++++++++---------
 fs/jffs2/file.c     |  3 ++-
 fs/jffs2/fs.c       | 10 +++++-----
 fs/jffs2/os-linux.h |  2 +-
 4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 5075a0a6d594..091ab0eaabbe 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -204,7 +204,8 @@ static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
 	if (ret)
 		goto fail;
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(ri->ctime)));
 
 	jffs2_free_raw_inode(ri);
 
@@ -237,7 +238,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
 	if (dead_f->inocache)
 		set_nlink(d_inode(dentry), dead_f->inocache->pino_nlink);
 	if (!ret)
-		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
 	return ret;
 }
 /***********************************************************************/
@@ -271,7 +272,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
 		set_nlink(d_inode(old_dentry), ++f->inocache->pino_nlink);
 		mutex_unlock(&f->sem);
 		d_instantiate(dentry, d_inode(old_dentry));
-		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
 		ihold(d_inode(old_dentry));
 	}
 	return ret;
@@ -422,7 +423,8 @@ static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
 		goto fail;
 	}
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(rd->mctime)));
 
 	jffs2_free_raw_dirent(rd);
 
@@ -566,7 +568,8 @@ static int jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,
 		goto fail;
 	}
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(rd->mctime)));
 	inc_nlink(dir_i);
 
 	jffs2_free_raw_dirent(rd);
@@ -607,7 +610,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
 	ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,
 			      dentry->d_name.len, f, now);
 	if (!ret) {
-		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
 		clear_nlink(d_inode(dentry));
 		drop_nlink(dir_i);
 	}
@@ -743,7 +746,8 @@ static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
 		goto fail;
 	}
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(rd->mctime)));
 
 	jffs2_free_raw_dirent(rd);
 
@@ -864,14 +868,16 @@ static int jffs2_rename (struct mnt_idmap *idmap,
 		 * caller won't do it on its own since we are returning an error.
 		 */
 		d_invalidate(new_dentry);
-		new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now);
+		new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i,
+							   ITIME(now));
 		return ret;
 	}
 
 	if (d_is_dir(old_dentry))
 		drop_nlink(old_dir_i);
 
-	new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
+	old_dir_i->i_mtime = inode_set_ctime_to_ts(old_dir_i, ITIME(now));
+	new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i, ITIME(now));
 
 	return 0;
 }
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 2345ca3f09ee..11c66793960e 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -317,7 +317,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
 			inode->i_size = pos + writtenlen;
 			inode->i_blocks = (inode->i_size + 511) >> 9;
 
-			inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
+			inode->i_mtime = inode_set_ctime_to_ts(inode,
+							       ITIME(je32_to_cpu(ri->ctime)));
 		}
 	}
 
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 038516bee1ab..0403efab4089 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -115,7 +115,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 	ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
 	ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
 	ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
-	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
+	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode_get_ctime(inode)));
 
 	ri->offset = cpu_to_je32(0);
 	ri->csize = ri->dsize = cpu_to_je32(mdatalen);
@@ -148,7 +148,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 	}
 	/* It worked. Update the inode */
 	inode->i_atime = ITIME(je32_to_cpu(ri->atime));
-	inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
+	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(ri->ctime)));
 	inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
 	inode->i_mode = jemode_to_cpu(ri->mode);
 	i_uid_write(inode, je16_to_cpu(ri->uid));
@@ -284,7 +284,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
 	inode->i_size = je32_to_cpu(latest_node.isize);
 	inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
 	inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
-	inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
+	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(latest_node.ctime)));
 
 	set_nlink(inode, f->inocache->pino_nlink);
 
@@ -388,7 +388,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
 	iattr.ia_gid = inode->i_gid;
 	iattr.ia_atime = inode->i_atime;
 	iattr.ia_mtime = inode->i_mtime;
-	iattr.ia_ctime = inode->i_ctime;
+	iattr.ia_ctime = inode_get_ctime(inode);
 
 	jffs2_do_setattr(inode, &iattr);
 }
@@ -475,7 +475,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
 	inode->i_mode = jemode_to_cpu(ri->mode);
 	i_gid_write(inode, je16_to_cpu(ri->gid));
 	i_uid_write(inode, je16_to_cpu(ri->uid));
-	inode->i_atime = inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
 
 	inode->i_blocks = 0;
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 8da19766c101..50727a1ff931 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -35,7 +35,7 @@ struct kvec;
 #define ITIME(sec) ((struct timespec64){sec, 0})
 #define JFFS2_NOW() JFFS2_CLAMP_TIME(ktime_get_real_seconds())
 #define I_SEC(tv) JFFS2_CLAMP_TIME((tv).tv_sec)
-#define JFFS2_F_I_CTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_ctime)
+#define JFFS2_F_I_CTIME(f) I_SEC(inode_get_ctime(OFNI_EDONI_2SFFJ(f)))
 #define JFFS2_F_I_MTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_mtime)
 #define JFFS2_F_I_ATIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_atime)
 #define sleep_on_spinunlock(wq, s)				\
-- 
2.41.0


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

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

* [PATCH v2 54/92] jffs2: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, David Woodhouse, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/jffs2/dir.c      | 24 +++++++++++++++---------
 fs/jffs2/file.c     |  3 ++-
 fs/jffs2/fs.c       | 10 +++++-----
 fs/jffs2/os-linux.h |  2 +-
 4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 5075a0a6d594..091ab0eaabbe 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -204,7 +204,8 @@ static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
 	if (ret)
 		goto fail;
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(ri->ctime)));
 
 	jffs2_free_raw_inode(ri);
 
@@ -237,7 +238,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
 	if (dead_f->inocache)
 		set_nlink(d_inode(dentry), dead_f->inocache->pino_nlink);
 	if (!ret)
-		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
 	return ret;
 }
 /***********************************************************************/
@@ -271,7 +272,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
 		set_nlink(d_inode(old_dentry), ++f->inocache->pino_nlink);
 		mutex_unlock(&f->sem);
 		d_instantiate(dentry, d_inode(old_dentry));
-		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
 		ihold(d_inode(old_dentry));
 	}
 	return ret;
@@ -422,7 +423,8 @@ static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
 		goto fail;
 	}
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(rd->mctime)));
 
 	jffs2_free_raw_dirent(rd);
 
@@ -566,7 +568,8 @@ static int jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,
 		goto fail;
 	}
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(rd->mctime)));
 	inc_nlink(dir_i);
 
 	jffs2_free_raw_dirent(rd);
@@ -607,7 +610,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
 	ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,
 			      dentry->d_name.len, f, now);
 	if (!ret) {
-		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
 		clear_nlink(d_inode(dentry));
 		drop_nlink(dir_i);
 	}
@@ -743,7 +746,8 @@ static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
 		goto fail;
 	}
 
-	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
+					       ITIME(je32_to_cpu(rd->mctime)));
 
 	jffs2_free_raw_dirent(rd);
 
@@ -864,14 +868,16 @@ static int jffs2_rename (struct mnt_idmap *idmap,
 		 * caller won't do it on its own since we are returning an error.
 		 */
 		d_invalidate(new_dentry);
-		new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now);
+		new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i,
+							   ITIME(now));
 		return ret;
 	}
 
 	if (d_is_dir(old_dentry))
 		drop_nlink(old_dir_i);
 
-	new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
+	old_dir_i->i_mtime = inode_set_ctime_to_ts(old_dir_i, ITIME(now));
+	new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i, ITIME(now));
 
 	return 0;
 }
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 2345ca3f09ee..11c66793960e 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -317,7 +317,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
 			inode->i_size = pos + writtenlen;
 			inode->i_blocks = (inode->i_size + 511) >> 9;
 
-			inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
+			inode->i_mtime = inode_set_ctime_to_ts(inode,
+							       ITIME(je32_to_cpu(ri->ctime)));
 		}
 	}
 
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 038516bee1ab..0403efab4089 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -115,7 +115,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 	ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
 	ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
 	ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
-	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
+	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode_get_ctime(inode)));
 
 	ri->offset = cpu_to_je32(0);
 	ri->csize = ri->dsize = cpu_to_je32(mdatalen);
@@ -148,7 +148,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 	}
 	/* It worked. Update the inode */
 	inode->i_atime = ITIME(je32_to_cpu(ri->atime));
-	inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
+	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(ri->ctime)));
 	inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
 	inode->i_mode = jemode_to_cpu(ri->mode);
 	i_uid_write(inode, je16_to_cpu(ri->uid));
@@ -284,7 +284,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
 	inode->i_size = je32_to_cpu(latest_node.isize);
 	inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
 	inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
-	inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
+	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(latest_node.ctime)));
 
 	set_nlink(inode, f->inocache->pino_nlink);
 
@@ -388,7 +388,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
 	iattr.ia_gid = inode->i_gid;
 	iattr.ia_atime = inode->i_atime;
 	iattr.ia_mtime = inode->i_mtime;
-	iattr.ia_ctime = inode->i_ctime;
+	iattr.ia_ctime = inode_get_ctime(inode);
 
 	jffs2_do_setattr(inode, &iattr);
 }
@@ -475,7 +475,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
 	inode->i_mode = jemode_to_cpu(ri->mode);
 	i_gid_write(inode, je16_to_cpu(ri->gid));
 	i_uid_write(inode, je16_to_cpu(ri->uid));
-	inode->i_atime = inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
 
 	inode->i_blocks = 0;
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 8da19766c101..50727a1ff931 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -35,7 +35,7 @@ struct kvec;
 #define ITIME(sec) ((struct timespec64){sec, 0})
 #define JFFS2_NOW() JFFS2_CLAMP_TIME(ktime_get_real_seconds())
 #define I_SEC(tv) JFFS2_CLAMP_TIME((tv).tv_sec)
-#define JFFS2_F_I_CTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_ctime)
+#define JFFS2_F_I_CTIME(f) I_SEC(inode_get_ctime(OFNI_EDONI_2SFFJ(f)))
 #define JFFS2_F_I_MTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_mtime)
 #define JFFS2_F_I_ATIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_atime)
 #define sleep_on_spinunlock(wq, s)				\
-- 
2.41.0


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

* [PATCH v2 55/92] jfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (50 preceding siblings ...)
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:27     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 56/92] kernfs: " Jeff Layton
                     ` (35 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Dave Kleikamp
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, Dave Kleikamp,
	jfs-discussion

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/jfs/acl.c       |  2 +-
 fs/jfs/inode.c     |  2 +-
 fs/jfs/ioctl.c     |  2 +-
 fs/jfs/jfs_imap.c  |  8 ++++----
 fs/jfs/jfs_inode.c |  4 ++--
 fs/jfs/namei.c     | 24 ++++++++++++------------
 fs/jfs/super.c     |  2 +-
 fs/jfs/xattr.c     |  2 +-
 8 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index fb96f872d207..1de3602c98de 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -116,7 +116,7 @@ int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 	if (!rc) {
 		if (update_mode) {
 			inode->i_mode = mode;
-			inode->i_ctime = current_time(inode);
+			inode_set_ctime_current(inode);
 			mark_inode_dirty(inode);
 		}
 		rc = txCommit(tid, 1, &inode, 0);
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 8ac10e396050..920d58a1566b 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -393,7 +393,7 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
 			break;
 		}
 
-		ip->i_mtime = ip->i_ctime = current_time(ip);
+		ip->i_mtime = inode_set_ctime_current(ip);
 		mark_inode_dirty(ip);
 
 		txCommit(tid, 1, &ip, 0);
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index ed7989bc2db1..f7bd7e8f5be4 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -96,7 +96,7 @@ int jfs_fileattr_set(struct mnt_idmap *idmap,
 	jfs_inode->mode2 = flags;
 
 	jfs_set_inode_flags(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	return 0;
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 390cbfce391f..a40383aa6c84 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -3064,8 +3064,8 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
 	ip->i_atime.tv_nsec = le32_to_cpu(dip->di_atime.tv_nsec);
 	ip->i_mtime.tv_sec = le32_to_cpu(dip->di_mtime.tv_sec);
 	ip->i_mtime.tv_nsec = le32_to_cpu(dip->di_mtime.tv_nsec);
-	ip->i_ctime.tv_sec = le32_to_cpu(dip->di_ctime.tv_sec);
-	ip->i_ctime.tv_nsec = le32_to_cpu(dip->di_ctime.tv_nsec);
+	inode_set_ctime(ip, le32_to_cpu(dip->di_ctime.tv_sec),
+			le32_to_cpu(dip->di_ctime.tv_nsec));
 	ip->i_blocks = LBLK2PBLK(ip->i_sb, le64_to_cpu(dip->di_nblocks));
 	ip->i_generation = le32_to_cpu(dip->di_gen);
 
@@ -3139,8 +3139,8 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip)
 
 	dip->di_atime.tv_sec = cpu_to_le32(ip->i_atime.tv_sec);
 	dip->di_atime.tv_nsec = cpu_to_le32(ip->i_atime.tv_nsec);
-	dip->di_ctime.tv_sec = cpu_to_le32(ip->i_ctime.tv_sec);
-	dip->di_ctime.tv_nsec = cpu_to_le32(ip->i_ctime.tv_nsec);
+	dip->di_ctime.tv_sec = cpu_to_le32(inode_get_ctime(ip).tv_sec);
+	dip->di_ctime.tv_nsec = cpu_to_le32(inode_get_ctime(ip).tv_nsec);
 	dip->di_mtime.tv_sec = cpu_to_le32(ip->i_mtime.tv_sec);
 	dip->di_mtime.tv_nsec = cpu_to_le32(ip->i_mtime.tv_nsec);
 	dip->di_ixpxd = jfs_ip->ixpxd;	/* in-memory pxd's are little-endian */
diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c
index 9e1f02767201..87594efa7f7c 100644
--- a/fs/jfs/jfs_inode.c
+++ b/fs/jfs/jfs_inode.c
@@ -97,8 +97,8 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
 	jfs_inode->mode2 |= inode->i_mode;
 
 	inode->i_blocks = 0;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
-	jfs_inode->otime = inode->i_ctime.tv_sec;
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
+	jfs_inode->otime = inode_get_ctime(inode).tv_sec;
 	inode->i_generation = JFS_SBI(sb)->gengen++;
 
 	jfs_inode->cflag = 0;
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 9b030297aa64..541578126b1a 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -149,7 +149,7 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
 
 	mark_inode_dirty(ip);
 
-	dip->i_ctime = dip->i_mtime = current_time(dip);
+	dip->i_mtime = inode_set_ctime_current(dip);
 
 	mark_inode_dirty(dip);
 
@@ -284,7 +284,7 @@ static int jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,
 
 	/* update parent directory inode */
 	inc_nlink(dip);		/* for '..' from child directory */
-	dip->i_ctime = dip->i_mtime = current_time(dip);
+	dip->i_mtime = inode_set_ctime_current(dip);
 	mark_inode_dirty(dip);
 
 	rc = txCommit(tid, 2, &iplist[0], 0);
@@ -390,7 +390,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
 	/* update parent directory's link count corresponding
 	 * to ".." entry of the target directory deleted
 	 */
-	dip->i_ctime = dip->i_mtime = current_time(dip);
+	dip->i_mtime = inode_set_ctime_current(dip);
 	inode_dec_link_count(dip);
 
 	/*
@@ -512,7 +512,7 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
 
 	ASSERT(ip->i_nlink);
 
-	ip->i_ctime = dip->i_ctime = dip->i_mtime = current_time(ip);
+	dip->i_mtime = inode_set_ctime_to_ts(dip, inode_set_ctime_current(ip));
 	mark_inode_dirty(dip);
 
 	/* update target's inode */
@@ -827,8 +827,8 @@ static int jfs_link(struct dentry *old_dentry,
 
 	/* update object inode */
 	inc_nlink(ip);		/* for new link */
-	ip->i_ctime = current_time(ip);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	inode_set_ctime_current(ip);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	ihold(ip);
 
@@ -1028,7 +1028,7 @@ static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
 
 	mark_inode_dirty(ip);
 
-	dip->i_ctime = dip->i_mtime = current_time(dip);
+	dip->i_mtime = inode_set_ctime_current(dip);
 	mark_inode_dirty(dip);
 	/*
 	 * commit update of parent directory and link object
@@ -1205,7 +1205,7 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 			tblk->xflag |= COMMIT_DELETE;
 			tblk->u.ip = new_ip;
 		} else {
-			new_ip->i_ctime = current_time(new_ip);
+			inode_set_ctime_current(new_ip);
 			mark_inode_dirty(new_ip);
 		}
 	} else {
@@ -1268,10 +1268,10 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	/*
 	 * Update ctime on changed/moved inodes & mark dirty
 	 */
-	old_ip->i_ctime = current_time(old_ip);
+	inode_set_ctime_current(old_ip);
 	mark_inode_dirty(old_ip);
 
-	new_dir->i_ctime = new_dir->i_mtime = current_time(new_dir);
+	new_dir->i_mtime = inode_set_ctime_current(new_dir);
 	mark_inode_dirty(new_dir);
 
 	/* Build list of inodes modified by this transaction */
@@ -1283,7 +1283,7 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 
 	if (old_dir != new_dir) {
 		iplist[ipcount++] = new_dir;
-		old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
+		old_dir->i_mtime = inode_set_ctime_current(old_dir);
 		mark_inode_dirty(old_dir);
 	}
 
@@ -1416,7 +1416,7 @@ static int jfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
 
 	mark_inode_dirty(ip);
 
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	mark_inode_dirty(dir);
 
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index d2f82cb7db1b..2e2f7f6d36a0 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -818,7 +818,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,
 	}
 	if (inode->i_size < off+len-towrite)
 		i_size_write(inode, off+len-towrite);
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	inode_unlock(inode);
 	return len - towrite;
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 931e50018f88..8577ad494e05 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -647,7 +647,7 @@ static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf,
 	if (old_blocks)
 		dquot_free_block(inode, old_blocks);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 
 	return 0;
 }
-- 
2.41.0


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

* [PATCH v2 56/92] kernfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (51 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 55/92] jfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:32     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 57/92] nfs: " Jeff Layton
                     ` (34 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Greg Kroah-Hartman, Tejun Heo, Alexander Viro
  Cc: Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/kernfs/inode.c       |  5 ++---
 fs/libfs.c              | 19 ++++++++++---------
 fs/minix/bitmap.c       |  2 +-
 fs/minix/dir.c          |  6 +++---
 fs/minix/inode.c        | 10 +++++-----
 fs/minix/itree_common.c |  4 ++--
 fs/minix/namei.c        |  6 +++---
 7 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index b22b74d1a115..89a9b4dcf109 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -151,8 +151,7 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)
 static inline void set_default_inode_attr(struct inode *inode, umode_t mode)
 {
 	inode->i_mode = mode;
-	inode->i_atime = inode->i_mtime =
-		inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 }
 
 static inline void set_inode_attr(struct inode *inode,
@@ -162,7 +161,7 @@ static inline void set_inode_attr(struct inode *inode,
 	inode->i_gid = attrs->ia_gid;
 	inode->i_atime = attrs->ia_atime;
 	inode->i_mtime = attrs->ia_mtime;
-	inode->i_ctime = attrs->ia_ctime;
+	inode_set_ctime_to_ts(inode, attrs->ia_ctime);
 }
 
 static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
diff --git a/fs/libfs.c b/fs/libfs.c
index 9ee79668c909..befbef1b4b46 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -523,7 +523,7 @@ void simple_recursive_removal(struct dentry *dentry,
 		while ((child = find_next_child(this, victim)) == NULL) {
 			// kill and ascend
 			// update metadata while it's still locked
-			inode->i_ctime = current_time(inode);
+			inode_set_ctime_current(inode);
 			clear_nlink(inode);
 			inode_unlock(inode);
 			victim = this;
@@ -541,8 +541,7 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_ctime = inode->i_mtime =
-					current_time(inode);
+				inode->i_mtime = inode_set_ctime_current(inode);
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -583,7 +582,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 = root->i_ctime = current_time(root);
+	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -639,7 +638,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_set_ctime_to_ts(dir,
+					     inode_set_ctime_current(inode));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,7 +673,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_set_ctime_to_ts(dir,
+					     inode_set_ctime_current(inode));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -925,7 +926,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->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -951,7 +952,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->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1519,7 +1520,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->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index 870207ba23f1..25c08fbfcb9d 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -251,7 +251,7 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode)
 	}
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 	inode->i_ino = j;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_blocks = 0;
 	memset(&minix_i(inode)->u, 0, sizeof(minix_i(inode)->u));
 	insert_inode_hash(inode);
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index bf9858f76b6a..20f23e6e58ad 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -281,7 +281,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
 		de->inode = inode->i_ino;
 	}
 	dir_commit_chunk(page, pos, sbi->s_dirsize);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	err = minix_handle_dirsync(dir);
 out_put:
@@ -313,7 +313,7 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
 	else
 		de->inode = 0;
 	dir_commit_chunk(page, pos, len);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	return minix_handle_dirsync(inode);
 }
@@ -436,7 +436,7 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page,
 	else
 		de->inode = inode->i_ino;
 	dir_commit_chunk(page, pos, sbi->s_dirsize);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	return minix_handle_dirsync(dir);
 }
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index e9fbb5303a22..3715a3940bd4 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -501,10 +501,11 @@ static struct inode *V1_minix_iget(struct inode *inode)
 	i_gid_write(inode, raw_inode->i_gid);
 	set_nlink(inode, raw_inode->i_nlinks);
 	inode->i_size = raw_inode->i_size;
-	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = raw_inode->i_time;
+	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode_set_ctime(inode,
+									raw_inode->i_time,
+									0).tv_sec;
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_atime.tv_nsec = 0;
-	inode->i_ctime.tv_nsec = 0;
 	inode->i_blocks = 0;
 	for (i = 0; i < 9; i++)
 		minix_inode->u.i1_data[i] = raw_inode->i_zone[i];
@@ -543,10 +544,9 @@ static struct inode *V2_minix_iget(struct inode *inode)
 	inode->i_size = raw_inode->i_size;
 	inode->i_mtime.tv_sec = raw_inode->i_mtime;
 	inode->i_atime.tv_sec = raw_inode->i_atime;
-	inode->i_ctime.tv_sec = raw_inode->i_ctime;
+	inode_set_ctime(inode, raw_inode->i_ctime, 0);
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_atime.tv_nsec = 0;
-	inode->i_ctime.tv_nsec = 0;
 	inode->i_blocks = 0;
 	for (i = 0; i < 10; i++)
 		minix_inode->u.i2_data[i] = raw_inode->i_zone[i];
@@ -622,7 +622,7 @@ static struct buffer_head * V2_minix_update_inode(struct inode * inode)
 	raw_inode->i_size = inode->i_size;
 	raw_inode->i_mtime = inode->i_mtime.tv_sec;
 	raw_inode->i_atime = inode->i_atime.tv_sec;
-	raw_inode->i_ctime = inode->i_ctime.tv_sec;
+	raw_inode->i_ctime = inode_get_ctime(inode).tv_sec;
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
 		raw_inode->i_zone[0] = old_encode_dev(inode->i_rdev);
 	else for (i = 0; i < 10; i++)
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index 446148792f41..ce18ae37c29d 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -131,7 +131,7 @@ static inline int splice_branch(struct inode *inode,
 
 	/* We are done with atomic stuff, now do the rest of housekeeping */
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 
 	/* had we spliced it onto indirect block? */
 	if (where->bh)
@@ -350,7 +350,7 @@ static inline void truncate (struct inode * inode)
 		}
 		first_whole++;
 	}
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 }
 
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 956d5183828d..114084d5636a 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -98,7 +98,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_link_count(inode);
 	ihold(inode);
 	return add_nondir(dentry, inode);
@@ -154,7 +154,7 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry)
 
 	if (err)
 		return err;
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	inode_dec_link_count(inode);
 	return 0;
 }
@@ -218,7 +218,7 @@ static int minix_rename(struct mnt_idmap *idmap,
 		put_page(new_page);
 		if (err)
 			goto out_dir;
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		if (dir_de)
 			drop_nlink(new_inode);
 		inode_dec_link_count(new_inode);
-- 
2.41.0


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

* [PATCH v2 57/92] nfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (52 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 56/92] kernfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:34     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 58/92] nfsd: " Jeff Layton
                     ` (33 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Trond Myklebust, Anna Schumaker
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-nfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfs/callback_proc.c |  2 +-
 fs/nfs/fscache.h       |  4 ++--
 fs/nfs/inode.c         | 20 ++++++++++----------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index c1eda73254e1..6bed1394d748 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -59,7 +59,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
 	res->change_attr = delegation->change_attr;
 	if (nfs_have_writebacks(inode))
 		res->change_attr++;
-	res->ctime = inode->i_ctime;
+	res->ctime = inode_get_ctime(inode);
 	res->mtime = inode->i_mtime;
 	res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
 		args->bitmap[0];
diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
index e1706e736c64..2dc64454492b 100644
--- a/fs/nfs/fscache.h
+++ b/fs/nfs/fscache.h
@@ -116,8 +116,8 @@ static inline void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *
 	memset(auxdata, 0, sizeof(*auxdata));
 	auxdata->mtime_sec  = inode->i_mtime.tv_sec;
 	auxdata->mtime_nsec = inode->i_mtime.tv_nsec;
-	auxdata->ctime_sec  = inode->i_ctime.tv_sec;
-	auxdata->ctime_nsec = inode->i_ctime.tv_nsec;
+	auxdata->ctime_sec  = inode_get_ctime(inode).tv_sec;
+	auxdata->ctime_nsec = inode_get_ctime(inode).tv_nsec;
 
 	if (NFS_SERVER(inode)->nfs_client->rpc_ops->version == 4)
 		auxdata->change_attr = inode_peek_iversion_raw(inode);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 8172dd4135a1..1283fdfa4b0a 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -514,7 +514,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
 
 		memset(&inode->i_atime, 0, sizeof(inode->i_atime));
 		memset(&inode->i_mtime, 0, sizeof(inode->i_mtime));
-		memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
+		inode_set_ctime(inode, 0, 0);
 		inode_set_iversion_raw(inode, 0);
 		inode->i_size = 0;
 		clear_nlink(inode);
@@ -535,7 +535,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
 		else if (fattr_supported & NFS_ATTR_FATTR_MTIME)
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
 		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
-			inode->i_ctime = fattr->ctime;
+			inode_set_ctime_to_ts(inode, fattr->ctime);
 		else if (fattr_supported & NFS_ATTR_FATTR_CTIME)
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CTIME);
 		if (fattr->valid & NFS_ATTR_FATTR_CHANGE)
@@ -731,7 +731,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
 		if ((attr->ia_valid & ATTR_GID) != 0)
 			inode->i_gid = attr->ia_gid;
 		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
-			inode->i_ctime = fattr->ctime;
+			inode_set_ctime_to_ts(inode, fattr->ctime);
 		else
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
 					| NFS_INO_INVALID_CTIME);
@@ -749,7 +749,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME);
 
 		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
-			inode->i_ctime = fattr->ctime;
+			inode_set_ctime_to_ts(inode, fattr->ctime);
 		else
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
 					| NFS_INO_INVALID_CTIME);
@@ -765,7 +765,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
 
 		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
-			inode->i_ctime = fattr->ctime;
+			inode_set_ctime_to_ts(inode, fattr->ctime);
 		else
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
 					| NFS_INO_INVALID_CTIME);
@@ -1444,11 +1444,11 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			nfs_set_cache_invalid(inode, NFS_INO_INVALID_XATTR);
 	}
 	/* If we have atomic WCC data, we may update some attributes */
-	ts = inode->i_ctime;
+	ts = inode_get_ctime(inode);
 	if ((fattr->valid & NFS_ATTR_FATTR_PRECTIME)
 			&& (fattr->valid & NFS_ATTR_FATTR_CTIME)
 			&& timespec64_equal(&ts, &fattr->pre_ctime)) {
-		inode->i_ctime = fattr->ctime;
+		inode_set_ctime_to_ts(inode, fattr->ctime);
 	}
 
 	ts = inode->i_mtime;
@@ -1510,7 +1510,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
 		if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec64_equal(&ts, &fattr->mtime))
 			invalid |= NFS_INO_INVALID_MTIME;
 
-		ts = inode->i_ctime;
+		ts = inode_get_ctime(inode);
 		if ((fattr->valid & NFS_ATTR_FATTR_CTIME) && !timespec64_equal(&ts, &fattr->ctime))
 			invalid |= NFS_INO_INVALID_CTIME;
 
@@ -1997,7 +1997,7 @@ int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fa
 	}
 	if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 &&
 			(fattr->valid & NFS_ATTR_FATTR_PRECTIME) == 0) {
-		fattr->pre_ctime = inode->i_ctime;
+		fattr->pre_ctime = inode_get_ctime(inode);
 		fattr->valid |= NFS_ATTR_FATTR_PRECTIME;
 	}
 	if ((fattr->valid & NFS_ATTR_FATTR_MTIME) != 0 &&
@@ -2190,7 +2190,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 			save_cache_validity & NFS_INO_INVALID_MTIME;
 
 	if (fattr->valid & NFS_ATTR_FATTR_CTIME)
-		inode->i_ctime = fattr->ctime;
+		inode_set_ctime_to_ts(inode, fattr->ctime);
 	else if (fattr_supported & NFS_ATTR_FATTR_CTIME)
 		nfsi->cache_validity |=
 			save_cache_validity & NFS_INO_INVALID_CTIME;
-- 
2.41.0


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

* [PATCH v2 58/92] nfsd: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (53 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 57/92] nfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:34     ` Jan Kara
  2023-07-05 19:01     ` Jeff Layton
                     ` (32 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Chuck Lever, Neil Brown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-nfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/nfsctl.c | 2 +-
 fs/nfsd/vfs.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 1b8b1aab9a15..a53c5660a8c4 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1131,7 +1131,7 @@ static struct inode *nfsd_get_inode(struct super_block *sb, umode_t mode)
 	/* Following advice from simple_fill_super documentation: */
 	inode->i_ino = iunique(sb, NFSD_MaxReserved);
 	inode->i_mode = mode;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	switch (mode & S_IFMT) {
 	case S_IFDIR:
 		inode->i_fop = &simple_dir_operations;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 8a2321d19194..40a68bae88fc 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -520,7 +520,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 
 	nfsd_sanitize_attrs(inode, iap);
 
-	if (check_guard && guardtime != inode->i_ctime.tv_sec)
+	if (check_guard && guardtime != inode_get_ctime(inode).tv_sec)
 		return nfserr_notsync;
 
 	/*
-- 
2.41.0


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

* [PATCH v2 59/92] nilfs2: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Ryusuke Konishi
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-nilfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nilfs2/dir.c   |  6 +++---
 fs/nilfs2/inode.c | 12 ++++++------
 fs/nilfs2/ioctl.c |  2 +-
 fs/nilfs2/namei.c |  8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index decd6471300b..bce734b68f08 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -429,7 +429,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
 	nilfs_set_de_type(de, inode);
 	nilfs_commit_chunk(page, mapping, from, to);
 	nilfs_put_page(page);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 }
 
 /*
@@ -519,7 +519,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
 	de->inode = cpu_to_le64(inode->i_ino);
 	nilfs_set_de_type(de, inode);
 	nilfs_commit_chunk(page, page->mapping, from, to);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	nilfs_mark_inode_dirty(dir);
 	/* OFFSET_CACHE */
 out_put:
@@ -567,7 +567,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
 		pde->rec_len = nilfs_rec_len_to_disk(to - from);
 	dir->inode = 0;
 	nilfs_commit_chunk(page, mapping, from, to);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 out:
 	nilfs_put_page(page);
 	return err;
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index a8ce522ac747..5259b94ca1dc 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -366,7 +366,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
 	atomic64_inc(&root->inodes_count);
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 	inode->i_ino = ino;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 
 	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
 		err = nilfs_bmap_read(ii->i_bmap, NULL);
@@ -450,10 +450,10 @@ int nilfs_read_inode_common(struct inode *inode,
 	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
 	inode->i_size = le64_to_cpu(raw_inode->i_size);
 	inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
-	inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
+	inode_set_ctime(inode, le64_to_cpu(raw_inode->i_ctime),
+			le32_to_cpu(raw_inode->i_ctime_nsec));
 	inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
 	inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
 	if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode))
 		return -EIO; /* this inode is for metadata and corrupted */
@@ -768,9 +768,9 @@ void nilfs_write_inode_common(struct inode *inode,
 	raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));
 	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
 	raw_inode->i_size = cpu_to_le64(inode->i_size);
-	raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
+	raw_inode->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
 	raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
-	raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	raw_inode->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
 
@@ -875,7 +875,7 @@ void nilfs_truncate(struct inode *inode)
 
 	nilfs_truncate_bmap(ii, blkoff);
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 1dfbc0c34513..40ffade49f38 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -149,7 +149,7 @@ int nilfs_fileattr_set(struct mnt_idmap *idmap,
 	NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE);
 
 	nilfs_set_inode_flags(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index c7024da8f1e2..2a4e7f4a8102 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -185,7 +185,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
 	if (err)
 		return err;
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_link_count(inode);
 	ihold(inode);
 
@@ -283,7 +283,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
 	if (err)
 		goto out;
 
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	drop_nlink(inode);
 	err = 0;
 out:
@@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
 			goto out_dir;
 		nilfs_set_link(new_dir, new_de, new_page, old_inode);
 		nilfs_mark_inode_dirty(new_dir);
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		if (dir_de)
 			drop_nlink(new_inode);
 		drop_nlink(new_inode);
@@ -406,7 +406,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 
 	nilfs_delete_entry(old_de, old_page);
 
-- 
2.41.0


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

* [PATCH v2 59/92] nilfs2: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Ryusuke Konishi
  Cc: Al Viro, Jan Kara, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nilfs-u79uwXL29TY76Z2rM5mHXA

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Ryusuke Konishi <konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Jeff Layton <jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 fs/nilfs2/dir.c   |  6 +++---
 fs/nilfs2/inode.c | 12 ++++++------
 fs/nilfs2/ioctl.c |  2 +-
 fs/nilfs2/namei.c |  8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index decd6471300b..bce734b68f08 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -429,7 +429,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
 	nilfs_set_de_type(de, inode);
 	nilfs_commit_chunk(page, mapping, from, to);
 	nilfs_put_page(page);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 }
 
 /*
@@ -519,7 +519,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
 	de->inode = cpu_to_le64(inode->i_ino);
 	nilfs_set_de_type(de, inode);
 	nilfs_commit_chunk(page, page->mapping, from, to);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	nilfs_mark_inode_dirty(dir);
 	/* OFFSET_CACHE */
 out_put:
@@ -567,7 +567,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
 		pde->rec_len = nilfs_rec_len_to_disk(to - from);
 	dir->inode = 0;
 	nilfs_commit_chunk(page, mapping, from, to);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 out:
 	nilfs_put_page(page);
 	return err;
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index a8ce522ac747..5259b94ca1dc 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -366,7 +366,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
 	atomic64_inc(&root->inodes_count);
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 	inode->i_ino = ino;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 
 	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
 		err = nilfs_bmap_read(ii->i_bmap, NULL);
@@ -450,10 +450,10 @@ int nilfs_read_inode_common(struct inode *inode,
 	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
 	inode->i_size = le64_to_cpu(raw_inode->i_size);
 	inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
-	inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
+	inode_set_ctime(inode, le64_to_cpu(raw_inode->i_ctime),
+			le32_to_cpu(raw_inode->i_ctime_nsec));
 	inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
 	inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
 	if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode))
 		return -EIO; /* this inode is for metadata and corrupted */
@@ -768,9 +768,9 @@ void nilfs_write_inode_common(struct inode *inode,
 	raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));
 	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
 	raw_inode->i_size = cpu_to_le64(inode->i_size);
-	raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
+	raw_inode->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
 	raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
-	raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	raw_inode->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
 
@@ -875,7 +875,7 @@ void nilfs_truncate(struct inode *inode)
 
 	nilfs_truncate_bmap(ii, blkoff);
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 1dfbc0c34513..40ffade49f38 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -149,7 +149,7 @@ int nilfs_fileattr_set(struct mnt_idmap *idmap,
 	NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE);
 
 	nilfs_set_inode_flags(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		nilfs_set_transaction_flag(NILFS_TI_SYNC);
 
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index c7024da8f1e2..2a4e7f4a8102 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -185,7 +185,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
 	if (err)
 		return err;
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_link_count(inode);
 	ihold(inode);
 
@@ -283,7 +283,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
 	if (err)
 		goto out;
 
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	drop_nlink(inode);
 	err = 0;
 out:
@@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
 			goto out_dir;
 		nilfs_set_link(new_dir, new_de, new_page, old_inode);
 		nilfs_mark_inode_dirty(new_dir);
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		if (dir_de)
 			drop_nlink(new_inode);
 		drop_nlink(new_inode);
@@ -406,7 +406,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 
 	nilfs_delete_entry(old_de, old_page);
 
-- 
2.41.0


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

* [PATCH v2 60/92] ntfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (55 preceding siblings ...)
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:37     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 61/92] ntfs3: " Jeff Layton
                     ` (30 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Anton Altaparmakov, Namjae Jeon
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-ntfs-dev

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ntfs/inode.c | 15 ++++++++-------
 fs/ntfs/mft.c   |  3 +--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 6c3f38d66579..99ac6ea277c4 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -654,7 +654,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
 	 * always changes, when mtime is changed. ctime can be changed on its
 	 * own, mtime is then not changed, e.g. when a file is renamed.
 	 */
-	vi->i_ctime = ntfs2utc(si->last_mft_change_time);
+	inode_set_ctime_to_ts(vi, ntfs2utc(si->last_mft_change_time));
 	/*
 	 * Last access to the data within the file. Not changed during a rename
 	 * for example but changed whenever the file is written to.
@@ -1218,7 +1218,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
 	vi->i_gid	= base_vi->i_gid;
 	set_nlink(vi, base_vi->i_nlink);
 	vi->i_mtime	= base_vi->i_mtime;
-	vi->i_ctime	= base_vi->i_ctime;
+	inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi));
 	vi->i_atime	= base_vi->i_atime;
 	vi->i_generation = ni->seq_no = base_ni->seq_no;
 
@@ -1484,7 +1484,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
 	vi->i_gid	= base_vi->i_gid;
 	set_nlink(vi, base_vi->i_nlink);
 	vi->i_mtime	= base_vi->i_mtime;
-	vi->i_ctime	= base_vi->i_ctime;
+	inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi));
 	vi->i_atime	= base_vi->i_atime;
 	vi->i_generation = ni->seq_no = base_ni->seq_no;
 	/* Set inode type to zero but preserve permissions. */
@@ -2804,13 +2804,14 @@ int ntfs_truncate(struct inode *vi)
 	 */
 	if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) {
 		struct timespec64 now = current_time(VFS_I(base_ni));
+		struct timespec64 ctime = inode_get_ctime(VFS_I(base_ni));
 		int sync_it = 0;
 
 		if (!timespec64_equal(&VFS_I(base_ni)->i_mtime, &now) ||
-		    !timespec64_equal(&VFS_I(base_ni)->i_ctime, &now))
+		    !timespec64_equal(&ctime, &now))
 			sync_it = 1;
+		inode_set_ctime_to_ts(VFS_I(base_ni), now);
 		VFS_I(base_ni)->i_mtime = now;
-		VFS_I(base_ni)->i_ctime = now;
 
 		if (sync_it)
 			mark_inode_dirty_sync(VFS_I(base_ni));
@@ -2928,7 +2929,7 @@ int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 	if (ia_valid & ATTR_MTIME)
 		vi->i_mtime = attr->ia_mtime;
 	if (ia_valid & ATTR_CTIME)
-		vi->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(vi, attr->ia_ctime);
 	mark_inode_dirty(vi);
 out:
 	return err;
@@ -3004,7 +3005,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
 		si->last_data_change_time = nt;
 		modified = true;
 	}
-	nt = utc2ntfs(vi->i_ctime);
+	nt = utc2ntfs(inode_get_ctime(vi));
 	if (si->last_mft_change_time != nt) {
 		ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, "
 				"new = 0x%llx", vi->i_ino, (long long)
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 0155f106ec34..ad1a8f72da22 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -2682,8 +2682,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
 			vi->i_mode &= ~S_IWUGO;
 
 		/* Set the inode times to the current time. */
-		vi->i_atime = vi->i_mtime = vi->i_ctime =
-			current_time(vi);
+		vi->i_atime = vi->i_mtime = inode_set_ctime_current(vi);
 		/*
 		 * Set the file size to 0, the ntfs inode sizes are set to 0 by
 		 * the call to ntfs_init_big_inode() below.
-- 
2.41.0


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

* [PATCH v2 61/92] ntfs3: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (56 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 60/92] ntfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:47     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 62/92] ocfs2: " Jeff Layton
                     ` (29 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Konstantin Komarov
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ntfs3

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ntfs3/file.c    |  6 +++---
 fs/ntfs3/frecord.c |  3 ++-
 fs/ntfs3/inode.c   | 14 ++++++++------
 fs/ntfs3/namei.c   |  4 ++--
 fs/ntfs3/xattr.c   |  4 ++--
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 1d6c824246c4..12788601dc84 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -342,7 +342,7 @@ static int ntfs_extend(struct inode *inode, loff_t pos, size_t count,
 		err = 0;
 	}
 
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	if (IS_SYNC(inode)) {
@@ -400,7 +400,7 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
 	ni_unlock(ni);
 
 	ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE;
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (!IS_DIRSYNC(inode)) {
 		dirty = 1;
 	} else {
@@ -642,7 +642,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
 		filemap_invalidate_unlock(mapping);
 
 	if (!err) {
-		inode->i_ctime = inode->i_mtime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		mark_inode_dirty(inode);
 	}
 
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 16bd9faa2d28..2b85cb10f0be 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -3265,6 +3265,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 	if (is_rec_inuse(ni->mi.mrec) &&
 	    !(sbi->flags & NTFS_FLAGS_LOG_REPLAYING) && inode->i_nlink) {
 		bool modified = false;
+		struct timespec64 ctime = inode_get_ctime(inode);
 
 		/* Update times in standard attribute. */
 		std = ni_std(ni);
@@ -3280,7 +3281,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 			modified = true;
 		}
 
-		dup.c_time = kernel2nt(&inode->i_ctime);
+		dup.c_time = kernel2nt(&ctime);
 		if (std->c_time != dup.c_time) {
 			std->c_time = dup.c_time;
 			modified = true;
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index dc7e7ab701c6..4123e126c4d0 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -44,6 +44,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 	u64 t64;
 	struct MFT_REC *rec;
 	struct runs_tree *run;
+	struct timespec64 ctime;
 
 	inode->i_op = NULL;
 	/* Setup 'uid' and 'gid' */
@@ -169,7 +170,8 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 		nt2kernel(std5->cr_time, &ni->i_crtime);
 #endif
 		nt2kernel(std5->a_time, &inode->i_atime);
-		nt2kernel(std5->c_time, &inode->i_ctime);
+		ctime = inode_get_ctime(inode);
+		nt2kernel(std5->c_time, &ctime);
 		nt2kernel(std5->m_time, &inode->i_mtime);
 
 		ni->std_fa = std5->fa;
@@ -958,7 +960,7 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 
 	if (err >= 0) {
 		if (!(ni->std_fa & FILE_ATTRIBUTE_ARCHIVE)) {
-			inode->i_ctime = inode->i_mtime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 			ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE;
 			dirty = true;
 		}
@@ -1658,8 +1660,8 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
 	d_instantiate(dentry, inode);
 
 	/* Set original time. inode times (i_ctime) may be changed in ntfs_init_acl. */
-	inode->i_atime = inode->i_mtime = inode->i_ctime = dir->i_mtime =
-		dir->i_ctime = ni->i_crtime;
+	inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode, ni->i_crtime);
+	dir->i_mtime = inode_set_ctime_to_ts(dir, ni->i_crtime);
 
 	mark_inode_dirty(dir);
 	mark_inode_dirty(inode);
@@ -1765,9 +1767,9 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)
 
 	if (!err) {
 		drop_nlink(inode);
-		dir->i_mtime = dir->i_ctime = current_time(dir);
+		dir->i_mtime = inode_set_ctime_current(dir);
 		mark_inode_dirty(dir);
-		inode->i_ctime = dir->i_ctime;
+		inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 		if (inode->i_nlink)
 			mark_inode_dirty(inode);
 	} else if (!ni_remove_name_undo(dir_ni, ni, de, de2, undo_remove)) {
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index bfd986699f9e..ad430d50bd79 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -156,8 +156,8 @@ static int ntfs_link(struct dentry *ode, struct inode *dir, struct dentry *de)
 	err = ntfs_link_inode(inode, de);
 
 	if (!err) {
-		dir->i_ctime = dir->i_mtime = inode->i_ctime =
-			current_time(dir);
+		dir->i_mtime = inode_set_ctime_to_ts(inode,
+						     inode_set_ctime_current(dir));
 		mark_inode_dirty(inode);
 		mark_inode_dirty(dir);
 		d_instantiate(de, inode);
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 023f314e8950..29fd391899e5 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -637,7 +637,7 @@ static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
 	if (!err) {
 		set_cached_acl(inode, type, acl);
 		inode->i_mode = mode;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		mark_inode_dirty(inode);
 	}
 
@@ -924,7 +924,7 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
 			  NULL);
 
 out:
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 
 	return err;
-- 
2.41.0


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

* [PATCH v2 62/92] ocfs2: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (57 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 61/92] ntfs3: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:51     ` Jan Kara
  2023-07-07  3:15     ` Joseph Qi
  2023-07-05 19:01   ` [PATCH v2 63/92] omfs: " Jeff Layton
                     ` (28 subsequent siblings)
  87 siblings, 2 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Mark Fasheh, Joel Becker, Joseph Qi
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ocfs2-devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ocfs2/acl.c          |  6 +++---
 fs/ocfs2/alloc.c        |  6 +++---
 fs/ocfs2/aops.c         |  2 +-
 fs/ocfs2/dir.c          |  8 ++++----
 fs/ocfs2/dlmfs/dlmfs.c  |  4 ++--
 fs/ocfs2/dlmglue.c      |  7 +++++--
 fs/ocfs2/file.c         | 16 +++++++++-------
 fs/ocfs2/inode.c        | 12 ++++++------
 fs/ocfs2/move_extents.c |  6 +++---
 fs/ocfs2/namei.c        | 21 +++++++++++----------
 fs/ocfs2/refcounttree.c | 14 +++++++-------
 fs/ocfs2/xattr.c        |  6 +++---
 12 files changed, 57 insertions(+), 51 deletions(-)

diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 9fd03eaf15f8..e75137a8e7cb 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -191,10 +191,10 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
 	}
 
 	inode->i_mode = new_mode;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	di->i_mode = cpu_to_le16(inode->i_mode);
-	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
-	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ocfs2_update_inode_fsync_trans(handle, inode, 0);
 
 	ocfs2_journal_dirty(handle, di_bh);
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 51c93929a146..aef58f1395c8 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -7436,10 +7436,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
 	}
 
 	inode->i_blocks = ocfs2_inode_sector_count(inode);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 
-	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
-	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 
 	ocfs2_update_inode_fsync_trans(handle, inode, 1);
 	ocfs2_journal_dirty(handle, di_bh);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 8dfc284e85f0..0fdba30740ab 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -2048,7 +2048,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
 		}
 		inode->i_blocks = ocfs2_inode_sector_count(inode);
 		di->i_size = cpu_to_le64((u64)i_size_read(inode));
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
 		di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 		if (handle)
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 694471fc46b8..8b123d543e6e 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1658,7 +1658,7 @@ int __ocfs2_add_entry(handle_t *handle,
 				offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
 
 		if (ocfs2_dirent_would_fit(de, rec_len)) {
-			dir->i_mtime = dir->i_ctime = current_time(dir);
+			dir->i_mtime = inode_set_ctime_current(dir);
 			retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
 			if (retval < 0) {
 				mlog_errno(retval);
@@ -2962,11 +2962,11 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
 	ocfs2_dinode_new_extent_list(dir, di);
 
 	i_size_write(dir, sb->s_blocksize);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	di->i_size = cpu_to_le64(sb->s_blocksize);
-	di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec);
-	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec);
+	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(dir).tv_sec);
+	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(dir).tv_nsec);
 	ocfs2_update_inode_fsync_trans(handle, dir, 1);
 
 	/*
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index ba26c5567cff..81265123ce6c 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -337,7 +337,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
 	if (inode) {
 		inode->i_ino = get_next_ino();
 		inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inc_nlink(inode);
 
 		inode->i_fop = &simple_dir_operations;
@@ -360,7 +360,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
 
 	inode->i_ino = get_next_ino();
 	inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 
 	ip = DLMFS_I(inode);
 	ip->ip_conn = DLMFS_I(parent)->ip_conn;
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index c28bc983a7b1..c3e2961ee5db 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2162,6 +2162,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
 	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
 	struct ocfs2_meta_lvb *lvb;
+	struct timespec64 ctime = inode_get_ctime(inode);
 
 	lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
 
@@ -2185,7 +2186,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
 	lvb->lvb_iatime_packed  =
 		cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime));
 	lvb->lvb_ictime_packed =
-		cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime));
+		cpu_to_be64(ocfs2_pack_timespec(&ctime));
 	lvb->lvb_imtime_packed =
 		cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
 	lvb->lvb_iattr    = cpu_to_be32(oi->ip_attr);
@@ -2208,6 +2209,7 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
 	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
 	struct ocfs2_meta_lvb *lvb;
+	struct timespec64 ctime;
 
 	mlog_meta_lvb(0, lockres);
 
@@ -2238,8 +2240,9 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
 			      be64_to_cpu(lvb->lvb_iatime_packed));
 	ocfs2_unpack_timespec(&inode->i_mtime,
 			      be64_to_cpu(lvb->lvb_imtime_packed));
-	ocfs2_unpack_timespec(&inode->i_ctime,
+	ocfs2_unpack_timespec(&ctime,
 			      be64_to_cpu(lvb->lvb_ictime_packed));
+	inode_set_ctime_to_ts(inode, ctime);
 	spin_unlock(&oi->ip_lock);
 	return 0;
 }
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9e417cd4fd16..e8c78d16e815 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -232,8 +232,10 @@ int ocfs2_should_update_atime(struct inode *inode,
 		return 0;
 
 	if (vfsmnt->mnt_flags & MNT_RELATIME) {
+		struct timespec64 ctime = inode_get_ctime(inode);
+
 		if ((timespec64_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
-		    (timespec64_compare(&inode->i_atime, &inode->i_ctime) <= 0))
+		    (timespec64_compare(&inode->i_atime, &ctime) <= 0))
 			return 1;
 
 		return 0;
@@ -294,7 +296,7 @@ int ocfs2_set_inode_size(handle_t *handle,
 
 	i_size_write(inode, new_i_size);
 	inode->i_blocks = ocfs2_inode_sector_count(inode);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 
 	status = ocfs2_mark_inode_dirty(handle, inode, fe_bh);
 	if (status < 0) {
@@ -415,12 +417,12 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
 	}
 
 	i_size_write(inode, new_i_size);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 
 	di = (struct ocfs2_dinode *) fe_bh->b_data;
 	di->i_size = cpu_to_le64(new_i_size);
-	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
-	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ocfs2_update_inode_fsync_trans(handle, inode, 0);
 
 	ocfs2_journal_dirty(handle, fe_bh);
@@ -819,7 +821,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
 	i_size_write(inode, abs_to);
 	inode->i_blocks = ocfs2_inode_sector_count(inode);
 	di->i_size = cpu_to_le64((u64)i_size_read(inode));
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
 	di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	di->i_mtime_nsec = di->i_ctime_nsec;
@@ -2038,7 +2040,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
 		goto out_inode_unlock;
 	}
 
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
 	if (ret < 0)
 		mlog_errno(ret);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index bb116c39b581..e8771600b930 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -306,8 +306,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
 	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
 	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
 	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
-	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
-	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
+	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
+		        le32_to_cpu(fe->i_ctime_nsec));
 
 	if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
 		mlog(ML_ERROR,
@@ -1314,8 +1314,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
 	fe->i_mode = cpu_to_le16(inode->i_mode);
 	fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
 	fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
-	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
-	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
 	fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 
@@ -1352,8 +1352,8 @@ void ocfs2_refresh_inode(struct inode *inode,
 	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
 	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
 	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
-	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
-	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
+	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
+			le32_to_cpu(fe->i_ctime_nsec));
 
 	spin_unlock(&OCFS2_I(inode)->ip_lock);
 }
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index b1e32ec4a9d4..05d67968a3a9 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -950,9 +950,9 @@ static int ocfs2_move_extents(struct ocfs2_move_extents_context *context)
 	}
 
 	di = (struct ocfs2_dinode *)di_bh->b_data;
-	inode->i_ctime = current_time(inode);
-	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
-	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	inode_set_ctime_current(inode);
+	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ocfs2_update_inode_fsync_trans(handle, inode, 0);
 
 	ocfs2_journal_dirty(handle, di_bh);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 17c52225b87d..e4a684d45308 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -793,10 +793,10 @@ static int ocfs2_link(struct dentry *old_dentry,
 	}
 
 	inc_nlink(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ocfs2_set_links_count(fe, inode->i_nlink);
-	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
-	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ocfs2_journal_dirty(handle, fe_bh);
 
 	err = ocfs2_add_entry(handle, dentry, inode,
@@ -995,7 +995,7 @@ static int ocfs2_unlink(struct inode *dir,
 	ocfs2_set_links_count(fe, inode->i_nlink);
 	ocfs2_journal_dirty(handle, fe_bh);
 
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	if (S_ISDIR(inode->i_mode))
 		drop_nlink(dir);
 
@@ -1537,7 +1537,7 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
 					 new_dir_bh, &target_insert);
 	}
 
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 	mark_inode_dirty(old_inode);
 
 	status = ocfs2_journal_access_di(handle, INODE_CACHE(old_inode),
@@ -1546,8 +1546,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
 	if (status >= 0) {
 		old_di = (struct ocfs2_dinode *) old_inode_bh->b_data;
 
-		old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
-		old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
+		old_di->i_ctime = cpu_to_le64(inode_get_ctime(old_inode).tv_sec);
+		old_di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(old_inode).tv_nsec);
 		ocfs2_journal_dirty(handle, old_inode_bh);
 	} else
 		mlog_errno(status);
@@ -1586,9 +1586,9 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
 
 	if (new_inode) {
 		drop_nlink(new_inode);
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 	}
-	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
+	old_dir->i_mtime = inode_set_ctime_current(old_dir);
 
 	if (update_dot_dot) {
 		status = ocfs2_update_entry(old_inode, handle,
@@ -1610,7 +1610,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
 
 	if (old_dir != new_dir) {
 		/* Keep the same times on both directories.*/
-		new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime;
+		new_dir->i_mtime = inode_set_ctime_to_ts(new_dir,
+							 inode_get_ctime(old_dir));
 
 		/*
 		 * This will also pick up the i_nlink change from the
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 564ab48d03ef..25c8ec3c8c3a 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -3750,9 +3750,9 @@ static int ocfs2_change_ctime(struct inode *inode,
 		goto out_commit;
 	}
 
-	inode->i_ctime = current_time(inode);
-	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
-	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	inode_set_ctime_current(inode);
+	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 
 	ocfs2_journal_dirty(handle, di_bh);
 
@@ -4073,10 +4073,10 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
 		 * we want mtime to appear identical to the source and
 		 * update ctime.
 		 */
-		t_inode->i_ctime = current_time(t_inode);
+		inode_set_ctime_current(t_inode);
 
-		di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec);
-		di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec);
+		di->i_ctime = cpu_to_le64(inode_get_ctime(t_inode).tv_sec);
+		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(t_inode).tv_nsec);
 
 		t_inode->i_mtime = s_inode->i_mtime;
 		di->i_mtime = s_di->i_mtime;
@@ -4456,7 +4456,7 @@ int ocfs2_reflink_update_dest(struct inode *dest,
 	if (newlen > i_size_read(dest))
 		i_size_write(dest, newlen);
 	spin_unlock(&OCFS2_I(dest)->ip_lock);
-	dest->i_ctime = dest->i_mtime = current_time(dest);
+	dest->i_mtime = inode_set_ctime_current(dest);
 
 	ret = ocfs2_mark_inode_dirty(handle, dest, d_bh);
 	if (ret) {
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 4ac77ff6e676..6510ad783c91 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -3421,9 +3421,9 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
 			goto out;
 		}
 
-		inode->i_ctime = current_time(inode);
-		di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
-		di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+		inode_set_ctime_current(inode);
+		di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 		ocfs2_journal_dirty(ctxt->handle, xis->inode_bh);
 	}
 out:
-- 
2.41.0


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

* [PATCH v2 63/92] omfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (58 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 62/92] ocfs2: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:52     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 64/92] openpromfs: " Jeff Layton
                     ` (27 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Bob Copeland
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-karma-devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/omfs/dir.c   | 4 ++--
 fs/omfs/inode.c | 9 ++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index 82cf7e9a665f..6bda275826d6 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -143,7 +143,7 @@ static int omfs_add_link(struct dentry *dentry, struct inode *inode)
 	mark_buffer_dirty(bh);
 	brelse(bh);
 
-	dir->i_ctime = current_time(dir);
+	inode_set_ctime_current(dir);
 
 	/* mark affected inodes dirty to rebuild checksums */
 	mark_inode_dirty(dir);
@@ -399,7 +399,7 @@ static int omfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	if (err)
 		goto out;
 
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 	mark_inode_dirty(old_inode);
 out:
 	return err;
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index c4c79e07efc7..2f8c1882f45c 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -51,7 +51,7 @@ struct inode *omfs_new_inode(struct inode *dir, umode_t mode)
 	inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
 	inode->i_mapping->a_ops = &omfs_aops;
 
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	switch (mode & S_IFMT) {
 	case S_IFDIR:
 		inode->i_op = &omfs_dir_inops;
@@ -134,8 +134,8 @@ static int __omfs_write_inode(struct inode *inode, int wait)
 	oi->i_head.h_magic = OMFS_IMAGIC;
 	oi->i_size = cpu_to_be64(inode->i_size);
 
-	ctime = inode->i_ctime.tv_sec * 1000LL +
-		((inode->i_ctime.tv_nsec + 999)/1000);
+	ctime = inode_get_ctime(inode).tv_sec * 1000LL +
+		((inode_get_ctime(inode).tv_nsec + 999)/1000);
 	oi->i_ctime = cpu_to_be64(ctime);
 
 	omfs_update_checksums(oi);
@@ -232,10 +232,9 @@ struct inode *omfs_iget(struct super_block *sb, ino_t ino)
 
 	inode->i_atime.tv_sec = ctime;
 	inode->i_mtime.tv_sec = ctime;
-	inode->i_ctime.tv_sec = ctime;
+	inode_set_ctime(inode, ctime, nsecs);
 	inode->i_atime.tv_nsec = nsecs;
 	inode->i_mtime.tv_nsec = nsecs;
-	inode->i_ctime.tv_nsec = nsecs;
 
 	inode->i_mapping->a_ops = &omfs_aops;
 
-- 
2.41.0


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

* [PATCH v2 64/92] openpromfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (59 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 63/92] omfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:52     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 65/92] orangefs: " Jeff Layton
                     ` (26 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/openpromfs/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index f0b7f4d51a17..b2457cb97fa0 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -237,7 +237,7 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);
 	if (inode->i_state & I_NEW) {
-		inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 		ent_oi = OP_I(inode);
 		ent_oi->type = ent_type;
 		ent_oi->u = ent_data;
@@ -387,8 +387,7 @@ static int openprom_fill_super(struct super_block *s, struct fs_context *fc)
 		goto out_no_root;
 	}
 
-	root_inode->i_mtime = root_inode->i_atime =
-		root_inode->i_ctime = current_time(root_inode);
+	root_inode->i_mtime = root_inode->i_atime = inode_set_ctime_current(root_inode);
 	root_inode->i_op = &openprom_inode_operations;
 	root_inode->i_fop = &openprom_operations;
 	root_inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
-- 
2.41.0


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

* [PATCH v2 65/92] orangefs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (60 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 64/92] openpromfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:55     ` Jan Kara
  2023-07-06 13:56     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 66/92] overlayfs: " Jeff Layton
                     ` (25 subsequent siblings)
  87 siblings, 2 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Mike Marshall, Martin Brandenburg
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/orangefs/namei.c          | 2 +-
 fs/orangefs/orangefs-utils.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 77518e248cf7..c9dfd5c6a097 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -421,7 +421,7 @@ static int orangefs_rename(struct mnt_idmap *idmap,
 		     ret);
 
 	if (new_dentry->d_inode)
-		new_dentry->d_inode->i_ctime = current_time(new_dentry->d_inode);
+		inode_set_ctime_current(d_inode(new_dentry));
 
 	op_release(new_op);
 	return ret;
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index 46b7dcff18ac..0a9fcfdf552f 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -361,11 +361,11 @@ int orangefs_inode_getattr(struct inode *inode, int flags)
 	    downcall.resp.getattr.attributes.atime;
 	inode->i_mtime.tv_sec = (time64_t)new_op->
 	    downcall.resp.getattr.attributes.mtime;
-	inode->i_ctime.tv_sec = (time64_t)new_op->
-	    downcall.resp.getattr.attributes.ctime;
+	inode_set_ctime(inode,
+			(time64_t)new_op->downcall.resp.getattr.attributes.ctime,
+			0);
 	inode->i_atime.tv_nsec = 0;
 	inode->i_mtime.tv_nsec = 0;
-	inode->i_ctime.tv_nsec = 0;
 
 	/* special case: mark the root inode as sticky */
 	inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) |
-- 
2.41.0


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

* [PATCH v2 66/92] overlayfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (61 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 65/92] orangefs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:58     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 67/92] procfs: " Jeff Layton
                     ` (24 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Miklos Szeredi, Amir Goldstein
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-unionfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/overlayfs/file.c | 7 +++++--
 fs/overlayfs/util.c | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 21245b00722a..7acd3e3fe790 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -239,6 +239,7 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence)
 static void ovl_file_accessed(struct file *file)
 {
 	struct inode *inode, *upperinode;
+	struct timespec64 ctime, uctime;
 
 	if (file->f_flags & O_NOATIME)
 		return;
@@ -249,10 +250,12 @@ static void ovl_file_accessed(struct file *file)
 	if (!upperinode)
 		return;
 
+	ctime = inode_get_ctime(inode);
+	uctime = inode_get_ctime(upperinode);
 	if ((!timespec64_equal(&inode->i_mtime, &upperinode->i_mtime) ||
-	     !timespec64_equal(&inode->i_ctime, &upperinode->i_ctime))) {
+	     !timespec64_equal(&ctime, &uctime))) {
 		inode->i_mtime = upperinode->i_mtime;
-		inode->i_ctime = upperinode->i_ctime;
+		inode_set_ctime_to_ts(inode, inode_get_ctime(upperinode));
 	}
 
 	touch_atime(&file->f_path);
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 7ef9e13c404a..c210b5d496a8 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -1202,6 +1202,6 @@ void ovl_copyattr(struct inode *inode)
 	inode->i_mode = realinode->i_mode;
 	inode->i_atime = realinode->i_atime;
 	inode->i_mtime = realinode->i_mtime;
-	inode->i_ctime = realinode->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(realinode));
 	i_size_write(inode, i_size_read(realinode));
 }
-- 
2.41.0


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

* [PATCH v2 67/92] procfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (62 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 66/92] overlayfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 13:59     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 68/92] pstore: " Jeff Layton
                     ` (23 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Luis Chamberlain, Kees Cook, Iurii Zaikin
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 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 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index eb2e498e3b8d..bbc998fd2a2f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1902,7 +1902,7 @@ struct inode *proc_pid_make_inode(struct super_block *sb,
 	ei = PROC_I(inode);
 	inode->i_mode = mode;
 	inode->i_ino = get_next_ino();
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_op = &proc_def_inode_operations;
 
 	/*
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 67b09a1d9433..532dc9d240f7 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -660,7 +660,7 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
 
 	inode->i_private = de->data;
 	inode->i_ino = de->low_ino;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	PROC_I(inode)->pde = de;
 	if (is_empty_pde(de)) {
 		make_empty_dir_inode(inode);
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 5ea42653126e..6bc10e7e0ff7 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -463,7 +463,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
 	head->count++;
 	spin_unlock(&sysctl_lock);
 
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_mode = table->mode;
 	if (!S_ISDIR(table->mode)) {
 		inode->i_mode |= S_IFREG;
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 72cd69bcaf4a..ecc4da8d265e 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -46,7 +46,7 @@ int proc_setup_self(struct super_block *s)
 		struct inode *inode = new_inode(s);
 		if (inode) {
 			inode->i_ino = self_inum;
-			inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 			inode->i_mode = S_IFLNK | S_IRWXUGO;
 			inode->i_uid = GLOBAL_ROOT_UID;
 			inode->i_gid = GLOBAL_ROOT_GID;
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index a553273fbd41..63ac1f93289f 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -46,7 +46,7 @@ int proc_setup_thread_self(struct super_block *s)
 		struct inode *inode = new_inode(s);
 		if (inode) {
 			inode->i_ino = thread_self_inum;
-			inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 			inode->i_mode = S_IFLNK | S_IRWXUGO;
 			inode->i_uid = GLOBAL_ROOT_UID;
 			inode->i_gid = GLOBAL_ROOT_GID;
-- 
2.41.0


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

* [PATCH v2 68/92] pstore: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (63 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 67/92] procfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:00     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 69/92] qnx4: " Jeff Layton
                     ` (22 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Kees Cook, Tony Luck, Guilherme G. Piccoli
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-hardening

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/pstore/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index ffbadb8b3032..a756af980d0c 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -223,7 +223,7 @@ static struct inode *pstore_get_inode(struct super_block *sb)
 	struct inode *inode = new_inode(sb);
 	if (inode) {
 		inode->i_ino = get_next_ino();
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	}
 	return inode;
 }
@@ -390,7 +390,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
 	inode->i_private = private;
 
 	if (record->time.tv_sec)
-		inode->i_mtime = inode->i_ctime = record->time;
+		inode->i_mtime = inode_set_ctime_to_ts(inode, record->time);
 
 	d_add(dentry, inode);
 
-- 
2.41.0


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

* [PATCH v2 69/92] qnx4: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (64 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 68/92] pstore: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:00     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 70/92] qnx6: " Jeff Layton
                     ` (21 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Anders Larsen
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Anders Larsen <al@alarsen.net>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/qnx4/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 391ea402920d..a7171f5532a1 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -305,8 +305,7 @@ struct inode *qnx4_iget(struct super_block *sb, unsigned long ino)
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_atime.tv_sec   = le32_to_cpu(raw_inode->di_atime);
 	inode->i_atime.tv_nsec = 0;
-	inode->i_ctime.tv_sec   = le32_to_cpu(raw_inode->di_ctime);
-	inode->i_ctime.tv_nsec = 0;
+	inode_set_ctime(inode, le32_to_cpu(raw_inode->di_ctime), 0);
 	inode->i_blocks  = le32_to_cpu(raw_inode->di_first_xtnt.xtnt_size);
 
 	memcpy(qnx4_inode, raw_inode, QNX4_DIR_ENTRY_SIZE);
-- 
2.41.0


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

* [PATCH v2 70/92] qnx6: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (65 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 69/92] qnx4: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:01     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 71/92] ramfs: " Jeff Layton
                     ` (20 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/qnx6/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index 85b2fa3b211c..21f90d519f1a 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -562,8 +562,7 @@ struct inode *qnx6_iget(struct super_block *sb, unsigned ino)
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_atime.tv_sec   = fs32_to_cpu(sbi, raw_inode->di_atime);
 	inode->i_atime.tv_nsec = 0;
-	inode->i_ctime.tv_sec   = fs32_to_cpu(sbi, raw_inode->di_ctime);
-	inode->i_ctime.tv_nsec = 0;
+	inode_set_ctime(inode, fs32_to_cpu(sbi, raw_inode->di_ctime), 0);
 
 	/* calc blocks based on 512 byte blocksize */
 	inode->i_blocks = (inode->i_size + 511) >> 9;
-- 
2.41.0


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

* [PATCH v2 71/92] ramfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (66 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 70/92] qnx6: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:01     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 72/92] reiserfs: " Jeff Layton
                     ` (19 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ramfs/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index fef477c78107..18e8387cab41 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -65,7 +65,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
 		inode->i_mapping->a_ops = &ram_aops;
 		mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER);
 		mapping_set_unevictable(inode->i_mapping);
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		switch (mode & S_IFMT) {
 		default:
 			init_special_inode(inode, mode, dev);
@@ -105,7 +105,7 @@ ramfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
 		d_instantiate(dentry, inode);
 		dget(dentry);	/* Extra count - pin the dentry in core */
 		error = 0;
-		dir->i_mtime = dir->i_ctime = current_time(dir);
+		dir->i_mtime = inode_set_ctime_current(dir);
 	}
 	return error;
 }
@@ -138,7 +138,7 @@ static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
 		if (!error) {
 			d_instantiate(dentry, inode);
 			dget(dentry);
-			dir->i_mtime = dir->i_ctime = current_time(dir);
+			dir->i_mtime = inode_set_ctime_current(dir);
 		} else
 			iput(inode);
 	}
-- 
2.41.0


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

* [PATCH v2 72/92] reiserfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (67 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 71/92] ramfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:03     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 73/92] romfs: " Jeff Layton
                     ` (18 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, reiserfs-devel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/reiserfs/inode.c     | 12 +++++-------
 fs/reiserfs/ioctl.c     |  4 ++--
 fs/reiserfs/namei.c     | 11 ++++++-----
 fs/reiserfs/stree.c     |  4 ++--
 fs/reiserfs/super.c     |  2 +-
 fs/reiserfs/xattr.c     |  5 +++--
 fs/reiserfs/xattr_acl.c |  2 +-
 7 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 77bd3b27059f..86e55d4bb10d 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1259,9 +1259,8 @@ static void init_inode(struct inode *inode, struct treepath *path)
 		inode->i_size = sd_v1_size(sd);
 		inode->i_atime.tv_sec = sd_v1_atime(sd);
 		inode->i_mtime.tv_sec = sd_v1_mtime(sd);
-		inode->i_ctime.tv_sec = sd_v1_ctime(sd);
+		inode_set_ctime(inode, sd_v1_ctime(sd), 0);
 		inode->i_atime.tv_nsec = 0;
-		inode->i_ctime.tv_nsec = 0;
 		inode->i_mtime.tv_nsec = 0;
 
 		inode->i_blocks = sd_v1_blocks(sd);
@@ -1314,8 +1313,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
 		i_gid_write(inode, sd_v2_gid(sd));
 		inode->i_mtime.tv_sec = sd_v2_mtime(sd);
 		inode->i_atime.tv_sec = sd_v2_atime(sd);
-		inode->i_ctime.tv_sec = sd_v2_ctime(sd);
-		inode->i_ctime.tv_nsec = 0;
+		inode_set_ctime(inode, sd_v2_ctime(sd), 0);
 		inode->i_mtime.tv_nsec = 0;
 		inode->i_atime.tv_nsec = 0;
 		inode->i_blocks = sd_v2_blocks(sd);
@@ -1374,7 +1372,7 @@ static void inode2sd(void *sd, struct inode *inode, loff_t size)
 	set_sd_v2_gid(sd_v2, i_gid_read(inode));
 	set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
 	set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
-	set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
+	set_sd_v2_ctime(sd_v2, inode_get_ctime(inode).tv_sec);
 	set_sd_v2_blocks(sd_v2, to_fake_used_blocks(inode, SD_V2_SIZE));
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
 		set_sd_v2_rdev(sd_v2, new_encode_dev(inode->i_rdev));
@@ -1394,7 +1392,7 @@ static void inode2sd_v1(void *sd, struct inode *inode, loff_t size)
 	set_sd_v1_nlink(sd_v1, inode->i_nlink);
 	set_sd_v1_size(sd_v1, size);
 	set_sd_v1_atime(sd_v1, inode->i_atime.tv_sec);
-	set_sd_v1_ctime(sd_v1, inode->i_ctime.tv_sec);
+	set_sd_v1_ctime(sd_v1, inode_get_ctime(inode).tv_sec);
 	set_sd_v1_mtime(sd_v1, inode->i_mtime.tv_sec);
 
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
@@ -1986,7 +1984,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
 
 	/* uid and gid must already be set by the caller for quota init */
 
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_size = i_size;
 	inode->i_blocks = 0;
 	inode->i_bytes = 0;
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 6bf9b54e58ca..dd33f8cc6eda 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -55,7 +55,7 @@ int reiserfs_fileattr_set(struct mnt_idmap *idmap,
 	}
 	sd_attrs_to_i_attrs(flags, inode);
 	REISERFS_I(inode)->i_attrs = flags;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	err = 0;
 unlock:
@@ -107,7 +107,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			err = -EFAULT;
 			goto setversion_out;
 		}
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		mark_inode_dirty(inode);
 setversion_out:
 		mnt_drop_write_file(filp);
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 405ac59eb2dd..9c5704be2435 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -572,7 +572,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
 	}
 
 	dir->i_size += paste_size;
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	if (!S_ISDIR(inode->i_mode) && visible)
 		/* reiserfs_mkdir or reiserfs_rename will do that by itself */
 		reiserfs_update_sd(th, dir);
@@ -966,7 +966,8 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
 			       inode->i_nlink);
 
 	clear_nlink(inode);
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_to_ts(dir,
+					     inode_set_ctime_current(inode));
 	reiserfs_update_sd(&th, inode);
 
 	DEC_DIR_INODE_NLINK(dir)
@@ -1070,11 +1071,11 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
 		inc_nlink(inode);
 		goto end_unlink;
 	}
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	reiserfs_update_sd(&th, inode);
 
 	dir->i_size -= (de.de_entrylen + DEH_SIZE);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	reiserfs_update_sd(&th, dir);
 
 	if (!savelink)
@@ -1250,7 +1251,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
 		return err ? err : retval;
 	}
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	reiserfs_update_sd(&th, inode);
 
 	ihold(inode);
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index ce5003986789..3676e02a0232 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -2004,7 +2004,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
 
 			if (update_timestamps) {
 				inode->i_mtime = current_time(inode);
-				inode->i_ctime = current_time(inode);
+				inode_set_ctime_current(inode);
 			}
 			reiserfs_update_sd(th, inode);
 
@@ -2029,7 +2029,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
 	if (update_timestamps) {
 		/* this is truncate, not file closing */
 		inode->i_mtime = current_time(inode);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 	}
 	reiserfs_update_sd(th, inode);
 
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 929acce6e731..7eaf36b3de12 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -2587,7 +2587,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
 		return err;
 	if (inode->i_size < off + len - towrite)
 		i_size_write(inode, off + len - towrite);
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	return len - towrite;
 }
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 651027967159..6000964c2b80 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -466,12 +466,13 @@ int reiserfs_commit_write(struct file *f, struct page *page,
 static void update_ctime(struct inode *inode)
 {
 	struct timespec64 now = current_time(inode);
+	struct timespec64 ctime = inode_get_ctime(inode);
 
 	if (inode_unhashed(inode) || !inode->i_nlink ||
-	    timespec64_equal(&inode->i_ctime, &now))
+	    timespec64_equal(&ctime, &now))
 		return;
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_to_ts(inode, now);
 	mark_inode_dirty(inode);
 }
 
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 138060452678..064264992b49 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -285,7 +285,7 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
 	if (error == -ENODATA) {
 		error = 0;
 		if (type == ACL_TYPE_ACCESS) {
-			inode->i_ctime = current_time(inode);
+			inode_set_ctime_current(inode);
 			mark_inode_dirty(inode);
 		}
 	}
-- 
2.41.0


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

* [PATCH v2 73/92] romfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (68 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 72/92] reiserfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:04     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: " Jeff Layton
                     ` (17 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/romfs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index c59b230d55b4..961b9d342e0e 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -322,8 +322,8 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
 
 	set_nlink(i, 1);		/* Hard to decide.. */
 	i->i_size = be32_to_cpu(ri.size);
-	i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;
-	i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;
+	i->i_mtime.tv_sec = i->i_atime.tv_sec = inode_set_ctime(i, 0, 0).tv_sec;
+	i->i_mtime.tv_nsec = i->i_atime.tv_nsec = 0;
 
 	/* set up mode and ops */
 	mode = romfs_modemap[nextfh & ROMFH_TYPE];
-- 
2.41.0


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

* [PATCH v2 74/92] smb: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (69 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 73/92] romfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-05 23:01     ` Jeff Layton
  2023-07-06 15:28     ` Steve French
  2023-07-05 19:01   ` [PATCH v2 75/92] squashfs: " Jeff Layton
                     ` (16 subsequent siblings)
  87 siblings, 2 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Steve French, Paulo Alcantara,
	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Namjae Jeon,
	Sergey Senozhatsky
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Tom Talpey <tom@talpey.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/smb/client/file.c    |  4 ++--
 fs/smb/client/fscache.h |  5 +++--
 fs/smb/client/inode.c   | 14 +++++++-------
 fs/smb/client/smb2ops.c |  3 ++-
 fs/smb/server/smb2pdu.c |  8 ++++----
 5 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 0a5fe8d5314b..689058e1b6e6 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
 		    !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
 		    dclose) {
 			if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) {
-				inode->i_ctime = inode->i_mtime = current_time(inode);
+				inode->i_mtime = inode_set_ctime_current(inode);
 			}
 			spin_lock(&cinode->deferred_lock);
 			cifs_add_deferred_close(cfile, dclose);
@@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
 					   write_data, to - from, &offset);
 		cifsFileInfo_put(open_file);
 		/* Does mm or vfs already set times? */
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		if ((bytes_written > 0) && (offset))
 			rc = 0;
 		else if (bytes_written < 0)
diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
index 173999610997..a228964bc2ce 100644
--- a/fs/smb/client/fscache.h
+++ b/fs/smb/client/fscache.h
@@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
 				 struct cifs_fscache_inode_coherency_data *cd)
 {
 	struct cifsInodeInfo *cifsi = CIFS_I(inode);
+	struct timespec64 ctime = inode_get_ctime(inode);
 
 	memset(cd, 0, sizeof(*cd));
 	cd->last_write_time_sec   = cpu_to_le64(cifsi->netfs.inode.i_mtime.tv_sec);
 	cd->last_write_time_nsec  = cpu_to_le32(cifsi->netfs.inode.i_mtime.tv_nsec);
-	cd->last_change_time_sec  = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec);
-	cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec);
+	cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
+	cd->last_change_time_nsec  = cpu_to_le64(ctime.tv_nsec);
 }
 
 
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index c3eeae07e139..218f03dd3f52 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
 	else
 		inode->i_atime = fattr->cf_atime;
 	inode->i_mtime = fattr->cf_mtime;
-	inode->i_ctime = fattr->cf_ctime;
+	inode_set_ctime_to_ts(inode, fattr->cf_ctime);
 	inode->i_rdev = fattr->cf_rdev;
 	cifs_nlink_fattr_to_inode(inode, fattr);
 	inode->i_uid = fattr->cf_uid;
@@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
 		cifs_inode = CIFS_I(inode);
 		cifs_inode->time = 0;	/* will force revalidate to get info
 					   when needed */
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 	}
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	cifs_inode = CIFS_I(dir);
 	CIFS_I(dir)->time = 0;	/* force revalidate of dir as well */
 unlink_out:
@@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
 	 */
 	cifsInode->time = 0;
 
-	d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime =
-		current_time(inode);
+	inode_set_ctime_current(d_inode(direntry));
+	inode->i_mtime = inode_set_ctime_current(inode);
 
 rmdir_exit:
 	free_dentry_path(page);
@@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
 	/* force revalidate to go get info when needed */
 	CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
 
-	source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
-		target_dir->i_mtime = current_time(source_dir);
+	source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
+									  inode_set_ctime_current(target_dir));
 
 cifs_rename_exit:
 	kfree(info_buf_source);
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 87abce010974..3cc3c4a71e32 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
 	if (file_inf.LastWriteTime)
 		inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
 	if (file_inf.ChangeTime)
-		inode->i_ctime = cifs_NTtimeToUnix(file_inf.ChangeTime);
+		inode_set_ctime_to_ts(inode,
+				      cifs_NTtimeToUnix(file_inf.ChangeTime));
 	if (file_inf.LastAccessTime)
 		inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
 
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index cf8822103f50..f9099831c8ff 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
 	file_info->LastAccessTime = cpu_to_le64(time);
 	time = ksmbd_UnixTimeToNT(inode->i_mtime);
 	file_info->LastWriteTime = cpu_to_le64(time);
-	time = ksmbd_UnixTimeToNT(inode->i_ctime);
+	time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
 	file_info->ChangeTime = cpu_to_le64(time);
 	file_info->DosAttributes = fp->f_ci->m_fattr;
 	file_info->Inode = cpu_to_le64(inode->i_ino);
@@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
 		rsp->LastAccessTime = cpu_to_le64(time);
 		time = ksmbd_UnixTimeToNT(inode->i_mtime);
 		rsp->LastWriteTime = cpu_to_le64(time);
-		time = ksmbd_UnixTimeToNT(inode->i_ctime);
+		time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
 		rsp->ChangeTime = cpu_to_le64(time);
 		ksmbd_fd_put(work, fp);
 	} else {
@@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 	if (file_info->ChangeTime)
 		attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
 	else
-		attrs.ia_ctime = inode->i_ctime;
+		attrs.ia_ctime = inode_get_ctime(inode);
 
 	if (file_info->LastWriteTime) {
 		attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime);
@@ -5689,7 +5689,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 			return -EACCES;
 
 		inode_lock(inode);
-		inode->i_ctime = attrs.ia_ctime;
+		inode_set_ctime_to_ts(inode, attrs.ia_ctime);
 		attrs.ia_valid &= ~ATTR_CTIME;
 		rc = notify_change(idmap, dentry, &attrs, NULL);
 		inode_unlock(inode);
-- 
2.41.0


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

* [PATCH v2 75/92] squashfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (70 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:04     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 76/92] sysv: " Jeff Layton
                     ` (15 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Phillip Lougher
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/squashfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 24463145b351..c6e626b00546 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -61,7 +61,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
 	inode->i_ino = le32_to_cpu(sqsh_ino->inode_number);
 	inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime);
 	inode->i_atime.tv_sec = inode->i_mtime.tv_sec;
-	inode->i_ctime.tv_sec = inode->i_mtime.tv_sec;
+	inode_set_ctime(inode, inode->i_mtime.tv_sec, 0);
 	inode->i_mode = le16_to_cpu(sqsh_ino->mode);
 	inode->i_size = 0;
 
-- 
2.41.0


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

* [PATCH v2 76/92] sysv: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (71 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 75/92] squashfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:05     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 77/92] tracefs: " Jeff Layton
                     ` (14 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

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

diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 0140010aa0c3..2f5ead88d00b 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -224,7 +224,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
 	memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
 	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
 	dir_commit_chunk(page, pos, SYSV_DIRSIZE);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	err = sysv_handle_dirsync(dir);
 out_page:
@@ -249,7 +249,7 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
 	}
 	de->inode = 0;
 	dir_commit_chunk(page, pos, SYSV_DIRSIZE);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	return sysv_handle_dirsync(inode);
 }
@@ -346,7 +346,7 @@ int sysv_set_link(struct sysv_dir_entry *de, struct page *page,
 	}
 	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
 	dir_commit_chunk(page, pos, SYSV_DIRSIZE);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	return sysv_handle_dirsync(inode);
 }
diff --git a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
index e732879036ab..6719da5889d9 100644
--- a/fs/sysv/ialloc.c
+++ b/fs/sysv/ialloc.c
@@ -165,7 +165,7 @@ struct inode * sysv_new_inode(const struct inode * dir, umode_t mode)
 	dirty_sb(sb);
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 	inode->i_ino = fs16_to_cpu(sbi, ino);
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_blocks = 0;
 	memset(SYSV_I(inode)->i_data, 0, sizeof(SYSV_I(inode)->i_data));
 	SYSV_I(inode)->i_dir_start_lookup = 0;
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 9e8d4a6fb2f3..0aa3827d8178 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -202,8 +202,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned int ino)
 	inode->i_size = fs32_to_cpu(sbi, raw_inode->i_size);
 	inode->i_atime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_atime);
 	inode->i_mtime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_mtime);
-	inode->i_ctime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_ctime);
-	inode->i_ctime.tv_nsec = 0;
+	inode_set_ctime(inode, fs32_to_cpu(sbi, raw_inode->i_ctime), 0);
 	inode->i_atime.tv_nsec = 0;
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_blocks = 0;
@@ -256,7 +255,7 @@ static int __sysv_write_inode(struct inode *inode, int wait)
 	raw_inode->i_size = cpu_to_fs32(sbi, inode->i_size);
 	raw_inode->i_atime = cpu_to_fs32(sbi, inode->i_atime.tv_sec);
 	raw_inode->i_mtime = cpu_to_fs32(sbi, inode->i_mtime.tv_sec);
-	raw_inode->i_ctime = cpu_to_fs32(sbi, inode->i_ctime.tv_sec);
+	raw_inode->i_ctime = cpu_to_fs32(sbi, inode_get_ctime(inode).tv_sec);
 
 	si = SYSV_I(inode);
 	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index 58d7f43a1371..dba6a2ef26f1 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -183,7 +183,7 @@ static inline int splice_branch(struct inode *inode,
 	*where->p = where->key;
 	write_unlock(&pointers_lock);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 
 	/* had we spliced it onto indirect block? */
 	if (where->bh)
@@ -423,7 +423,7 @@ void sysv_truncate (struct inode * inode)
 		}
 		n++;
 	}
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		sysv_sync_inode (inode);
 	else
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index fcf163fea3ad..d6b73798071b 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -103,7 +103,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir,
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_link_count(inode);
 	ihold(inode);
 
@@ -161,7 +161,7 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry)
 
 	err = sysv_delete_entry(de, page);
 	if (!err) {
-		inode->i_ctime = dir->i_ctime;
+		inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 		inode_dec_link_count(inode);
 	}
 	unmap_and_put_page(page, de);
@@ -230,7 +230,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		unmap_and_put_page(new_page, new_de);
 		if (err)
 			goto out_dir;
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		if (dir_de)
 			drop_nlink(new_inode);
 		inode_dec_link_count(new_inode);
-- 
2.41.0


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

* [PATCH v2 77/92] tracefs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (72 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 76/92] sysv: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:06     ` Jan Kara
  2023-07-06 14:27     ` Steven Rostedt
  2023-07-05 19:01     ` Jeff Layton
                     ` (13 subsequent siblings)
  87 siblings, 2 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Steven Rostedt, Masami Hiramatsu
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-trace-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/tracefs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 57ac8aa4a724..2feb6c58648c 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -132,7 +132,7 @@ static struct inode *tracefs_get_inode(struct super_block *sb)
 	struct inode *inode = new_inode(sb);
 	if (inode) {
 		inode->i_ino = get_next_ino();
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	}
 	return inode;
 }
-- 
2.41.0


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

* [PATCH v2 78/92] ubifs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
@ 2023-07-05 19:01     ` Jeff Layton
  2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
                       ` (86 subsequent siblings)
  87 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ubifs/debug.c   |  4 ++--
 fs/ubifs/dir.c     | 24 +++++++++++-------------
 fs/ubifs/file.c    | 16 +++++++++-------
 fs/ubifs/ioctl.c   |  2 +-
 fs/ubifs/journal.c |  4 ++--
 fs/ubifs/super.c   |  4 ++--
 fs/ubifs/xattr.c   |  6 +++---
 7 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 9c9d3f0e36a4..eef9e527d9ff 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -243,8 +243,8 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
 	       (unsigned int)inode->i_mtime.tv_sec,
 	       (unsigned int)inode->i_mtime.tv_nsec);
 	pr_err("\tctime          %u.%u\n",
-	       (unsigned int)inode->i_ctime.tv_sec,
-	       (unsigned int)inode->i_ctime.tv_nsec);
+	       (unsigned int) inode_get_ctime(inode).tv_sec,
+	       (unsigned int) inode_get_ctime(inode).tv_nsec);
 	pr_err("\tcreat_sqnum    %llu\n", ui->creat_sqnum);
 	pr_err("\txattr_size     %u\n", ui->xattr_size);
 	pr_err("\txattr_cnt      %u\n", ui->xattr_cnt);
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 7ec25310bd8a..3a1ba8ba308a 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -96,8 +96,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
 	inode->i_flags |= S_NOCMTIME;
 
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime =
-			 current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_mapping->nrpages = 0;
 
 	if (!is_xattr) {
@@ -325,7 +324,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
 	mutex_lock(&dir_ui->ui_mutex);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -765,10 +764,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
 
 	inc_nlink(inode);
 	ihold(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -838,11 +837,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
 	}
 
 	lock_2_inodes(dir, inode);
-	inode->i_ctime = current_time(dir);
+	inode_set_ctime_current(inode);
 	drop_nlink(inode);
 	dir->i_size -= sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
 	if (err)
 		goto out_cancel;
@@ -940,12 +939,12 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
 	}
 
 	lock_2_inodes(dir, inode);
-	inode->i_ctime = current_time(dir);
+	inode_set_ctime_current(inode);
 	clear_nlink(inode);
 	drop_nlink(dir);
 	dir->i_size -= sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
 	if (err)
 		goto out_cancel;
@@ -1019,7 +1018,7 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 	inc_nlink(dir);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err) {
 		ubifs_err(c, "cannot create directory, error %d", err);
@@ -1110,7 +1109,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
 	mutex_lock(&dir_ui->ui_mutex);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -1210,7 +1209,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
 	mutex_lock(&dir_ui->ui_mutex);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -1298,7 +1297,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
 			.dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
 	struct ubifs_budget_req wht_req;
-	struct timespec64 time;
 	unsigned int saved_nlink;
 	struct fscrypt_name old_nm, new_nm;
 
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 6738fe43040b..436b27d7c58f 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1092,7 +1092,7 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
 	if (attr->ia_valid & ATTR_MTIME)
 		inode->i_mtime = attr->ia_mtime;
 	if (attr->ia_valid & ATTR_CTIME)
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (attr->ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 
@@ -1192,7 +1192,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
 	mutex_lock(&ui->ui_mutex);
 	ui->ui_size = inode->i_size;
 	/* Truncation changes inode [mc]time */
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	/* Other attributes may be changed at the same time as well */
 	do_attr_changes(inode, attr);
 	err = ubifs_jnl_truncate(c, inode, old_size, new_size);
@@ -1239,7 +1239,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
 	mutex_lock(&ui->ui_mutex);
 	if (attr->ia_valid & ATTR_SIZE) {
 		/* Truncation changes inode [mc]time */
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		/* 'truncate_setsize()' changed @i_size, update @ui_size */
 		ui->ui_size = inode->i_size;
 	}
@@ -1364,8 +1364,10 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 static inline int mctime_update_needed(const struct inode *inode,
 				       const struct timespec64 *now)
 {
+	struct timespec64 ctime = inode_get_ctime(inode);
+
 	if (!timespec64_equal(&inode->i_mtime, now) ||
-	    !timespec64_equal(&inode->i_ctime, now))
+	    !timespec64_equal(&ctime, now))
 		return 1;
 	return 0;
 }
@@ -1396,7 +1398,7 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
 	if (flags & S_ATIME)
 		inode->i_atime = *time;
 	if (flags & S_CTIME)
-		inode->i_ctime = *time;
+		inode_set_ctime_to_ts(inode, *time);
 	if (flags & S_MTIME)
 		inode->i_mtime = *time;
 
@@ -1432,7 +1434,7 @@ static int update_mctime(struct inode *inode)
 			return err;
 
 		mutex_lock(&ui->ui_mutex);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		release = ui->dirty;
 		mark_inode_dirty_sync(inode);
 		mutex_unlock(&ui->ui_mutex);
@@ -1570,7 +1572,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
 		struct ubifs_inode *ui = ubifs_inode(inode);
 
 		mutex_lock(&ui->ui_mutex);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		release = ui->dirty;
 		mark_inode_dirty_sync(inode);
 		mutex_unlock(&ui->ui_mutex);
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 67c5108abd89..d79cabe193c3 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -118,7 +118,7 @@ static int setflags(struct inode *inode, int flags)
 	ui->flags &= ~ioctl2ubifs(UBIFS_SETTABLE_IOCTL_FLAGS);
 	ui->flags |= ioctl2ubifs(flags);
 	ubifs_set_inode_flags(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	release = ui->dirty;
 	mark_inode_dirty_sync(inode);
 	mutex_unlock(&ui->ui_mutex);
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index dc52ac0f4a34..ffc9beee7be6 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -454,8 +454,8 @@ static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
 	ino->creat_sqnum = cpu_to_le64(ui->creat_sqnum);
 	ino->atime_sec  = cpu_to_le64(inode->i_atime.tv_sec);
 	ino->atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
-	ino->ctime_sec  = cpu_to_le64(inode->i_ctime.tv_sec);
-	ino->ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	ino->ctime_sec  = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	ino->ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ino->mtime_sec  = cpu_to_le64(inode->i_mtime.tv_sec);
 	ino->mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	ino->uid   = cpu_to_le32(i_uid_read(inode));
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 32cb14759796..b08fb28d16b5 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -146,8 +146,8 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
 	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);
 	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);
-	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);
+	inode_set_ctime(inode, (int64_t)le64_to_cpu(ino->ctime_sec),
+			le32_to_cpu(ino->ctime_nsec));
 	inode->i_mode = le32_to_cpu(ino->mode);
 	inode->i_size = le64_to_cpu(ino->size);
 
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 349228dd1191..406c82eab513 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -134,7 +134,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
-	host->i_ctime = current_time(host);
+	inode_set_ctime_current(host);
 	host_ui->xattr_cnt += 1;
 	host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
 	host_ui->xattr_size += CALC_XATTR_BYTES(size);
@@ -215,7 +215,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
 	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
-	host->i_ctime = current_time(host);
+	inode_set_ctime_current(host);
 	host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
 	host_ui->xattr_size += CALC_XATTR_BYTES(size);
 
@@ -474,7 +474,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
 		return err;
 
 	mutex_lock(&host_ui->ui_mutex);
-	host->i_ctime = current_time(host);
+	inode_set_ctime_current(host);
 	host_ui->xattr_cnt -= 1;
 	host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
 	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
-- 
2.41.0


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

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

* [PATCH v2 78/92] ubifs: convert to ctime accessor functions
@ 2023-07-05 19:01     ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ubifs/debug.c   |  4 ++--
 fs/ubifs/dir.c     | 24 +++++++++++-------------
 fs/ubifs/file.c    | 16 +++++++++-------
 fs/ubifs/ioctl.c   |  2 +-
 fs/ubifs/journal.c |  4 ++--
 fs/ubifs/super.c   |  4 ++--
 fs/ubifs/xattr.c   |  6 +++---
 7 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 9c9d3f0e36a4..eef9e527d9ff 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -243,8 +243,8 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
 	       (unsigned int)inode->i_mtime.tv_sec,
 	       (unsigned int)inode->i_mtime.tv_nsec);
 	pr_err("\tctime          %u.%u\n",
-	       (unsigned int)inode->i_ctime.tv_sec,
-	       (unsigned int)inode->i_ctime.tv_nsec);
+	       (unsigned int) inode_get_ctime(inode).tv_sec,
+	       (unsigned int) inode_get_ctime(inode).tv_nsec);
 	pr_err("\tcreat_sqnum    %llu\n", ui->creat_sqnum);
 	pr_err("\txattr_size     %u\n", ui->xattr_size);
 	pr_err("\txattr_cnt      %u\n", ui->xattr_cnt);
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 7ec25310bd8a..3a1ba8ba308a 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -96,8 +96,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
 	inode->i_flags |= S_NOCMTIME;
 
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
-	inode->i_mtime = inode->i_atime = inode->i_ctime =
-			 current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_mapping->nrpages = 0;
 
 	if (!is_xattr) {
@@ -325,7 +324,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
 	mutex_lock(&dir_ui->ui_mutex);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -765,10 +764,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
 
 	inc_nlink(inode);
 	ihold(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -838,11 +837,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
 	}
 
 	lock_2_inodes(dir, inode);
-	inode->i_ctime = current_time(dir);
+	inode_set_ctime_current(inode);
 	drop_nlink(inode);
 	dir->i_size -= sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
 	if (err)
 		goto out_cancel;
@@ -940,12 +939,12 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
 	}
 
 	lock_2_inodes(dir, inode);
-	inode->i_ctime = current_time(dir);
+	inode_set_ctime_current(inode);
 	clear_nlink(inode);
 	drop_nlink(dir);
 	dir->i_size -= sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
 	if (err)
 		goto out_cancel;
@@ -1019,7 +1018,7 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 	inc_nlink(dir);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err) {
 		ubifs_err(c, "cannot create directory, error %d", err);
@@ -1110,7 +1109,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
 	mutex_lock(&dir_ui->ui_mutex);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -1210,7 +1209,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
 	mutex_lock(&dir_ui->ui_mutex);
 	dir->i_size += sz_change;
 	dir_ui->ui_size = dir->i_size;
-	dir->i_mtime = dir->i_ctime = inode->i_ctime;
+	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
 	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
 	if (err)
 		goto out_cancel;
@@ -1298,7 +1297,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
 			.dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
 	struct ubifs_budget_req wht_req;
-	struct timespec64 time;
 	unsigned int saved_nlink;
 	struct fscrypt_name old_nm, new_nm;
 
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 6738fe43040b..436b27d7c58f 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1092,7 +1092,7 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
 	if (attr->ia_valid & ATTR_MTIME)
 		inode->i_mtime = attr->ia_mtime;
 	if (attr->ia_valid & ATTR_CTIME)
-		inode->i_ctime = attr->ia_ctime;
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (attr->ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 
@@ -1192,7 +1192,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
 	mutex_lock(&ui->ui_mutex);
 	ui->ui_size = inode->i_size;
 	/* Truncation changes inode [mc]time */
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	/* Other attributes may be changed at the same time as well */
 	do_attr_changes(inode, attr);
 	err = ubifs_jnl_truncate(c, inode, old_size, new_size);
@@ -1239,7 +1239,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
 	mutex_lock(&ui->ui_mutex);
 	if (attr->ia_valid & ATTR_SIZE) {
 		/* Truncation changes inode [mc]time */
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		/* 'truncate_setsize()' changed @i_size, update @ui_size */
 		ui->ui_size = inode->i_size;
 	}
@@ -1364,8 +1364,10 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 static inline int mctime_update_needed(const struct inode *inode,
 				       const struct timespec64 *now)
 {
+	struct timespec64 ctime = inode_get_ctime(inode);
+
 	if (!timespec64_equal(&inode->i_mtime, now) ||
-	    !timespec64_equal(&inode->i_ctime, now))
+	    !timespec64_equal(&ctime, now))
 		return 1;
 	return 0;
 }
@@ -1396,7 +1398,7 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
 	if (flags & S_ATIME)
 		inode->i_atime = *time;
 	if (flags & S_CTIME)
-		inode->i_ctime = *time;
+		inode_set_ctime_to_ts(inode, *time);
 	if (flags & S_MTIME)
 		inode->i_mtime = *time;
 
@@ -1432,7 +1434,7 @@ static int update_mctime(struct inode *inode)
 			return err;
 
 		mutex_lock(&ui->ui_mutex);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		release = ui->dirty;
 		mark_inode_dirty_sync(inode);
 		mutex_unlock(&ui->ui_mutex);
@@ -1570,7 +1572,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
 		struct ubifs_inode *ui = ubifs_inode(inode);
 
 		mutex_lock(&ui->ui_mutex);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 		release = ui->dirty;
 		mark_inode_dirty_sync(inode);
 		mutex_unlock(&ui->ui_mutex);
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 67c5108abd89..d79cabe193c3 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -118,7 +118,7 @@ static int setflags(struct inode *inode, int flags)
 	ui->flags &= ~ioctl2ubifs(UBIFS_SETTABLE_IOCTL_FLAGS);
 	ui->flags |= ioctl2ubifs(flags);
 	ubifs_set_inode_flags(inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	release = ui->dirty;
 	mark_inode_dirty_sync(inode);
 	mutex_unlock(&ui->ui_mutex);
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index dc52ac0f4a34..ffc9beee7be6 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -454,8 +454,8 @@ static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
 	ino->creat_sqnum = cpu_to_le64(ui->creat_sqnum);
 	ino->atime_sec  = cpu_to_le64(inode->i_atime.tv_sec);
 	ino->atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
-	ino->ctime_sec  = cpu_to_le64(inode->i_ctime.tv_sec);
-	ino->ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
+	ino->ctime_sec  = cpu_to_le64(inode_get_ctime(inode).tv_sec);
+	ino->ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
 	ino->mtime_sec  = cpu_to_le64(inode->i_mtime.tv_sec);
 	ino->mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
 	ino->uid   = cpu_to_le32(i_uid_read(inode));
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 32cb14759796..b08fb28d16b5 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -146,8 +146,8 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
 	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);
 	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);
 	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);
-	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);
-	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);
+	inode_set_ctime(inode, (int64_t)le64_to_cpu(ino->ctime_sec),
+			le32_to_cpu(ino->ctime_nsec));
 	inode->i_mode = le32_to_cpu(ino->mode);
 	inode->i_size = le64_to_cpu(ino->size);
 
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 349228dd1191..406c82eab513 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -134,7 +134,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
 	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
-	host->i_ctime = current_time(host);
+	inode_set_ctime_current(host);
 	host_ui->xattr_cnt += 1;
 	host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
 	host_ui->xattr_size += CALC_XATTR_BYTES(size);
@@ -215,7 +215,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
 	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
-	host->i_ctime = current_time(host);
+	inode_set_ctime_current(host);
 	host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
 	host_ui->xattr_size += CALC_XATTR_BYTES(size);
 
@@ -474,7 +474,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
 		return err;
 
 	mutex_lock(&host_ui->ui_mutex);
-	host->i_ctime = current_time(host);
+	inode_set_ctime_current(host);
 	host_ui->xattr_cnt -= 1;
 	host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
 	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
-- 
2.41.0


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

* [PATCH v2 79/92] udf: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (74 preceding siblings ...)
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 12:57     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 80/92] ufs: " Jeff Layton
                     ` (11 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Jan Kara
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/udf/ialloc.c |  2 +-
 fs/udf/inode.c  | 17 ++++++++++-------
 fs/udf/namei.c  | 24 ++++++++++++------------
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 5f7ac8c84798..6b558cbbeb6b 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -100,7 +100,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 		iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
 	else
 		iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	iinfo->i_crtime = inode->i_mtime;
 	if (unlikely(insert_inode_locked(inode) < 0)) {
 		make_bad_inode(inode);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 28cdfc57d946..d089795074e8 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -910,7 +910,7 @@ static int inode_getblk(struct inode *inode, struct udf_map_rq *map)
 	map->oflags = UDF_BLK_NEW | UDF_BLK_MAPPED;
 	iinfo->i_next_alloc_block = map->lblk + 1;
 	iinfo->i_next_alloc_goal = newblocknum + 1;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 
 	if (IS_SYNC(inode))
 		udf_sync_inode(inode);
@@ -1298,7 +1298,7 @@ int udf_setsize(struct inode *inode, loff_t newsize)
 			goto out_unlock;
 	}
 update_time:
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		udf_sync_inode(inode);
 	else
@@ -1329,6 +1329,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
 	int bs = inode->i_sb->s_blocksize;
 	int ret = -EIO;
 	uint32_t uid, gid;
+	struct timespec64 ctime;
 
 reread:
 	if (iloc->partitionReferenceNum >= sbi->s_partitions) {
@@ -1507,7 +1508,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
 
 		udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime);
 		udf_disk_stamp_to_time(&inode->i_mtime, fe->modificationTime);
-		udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime);
+		udf_disk_stamp_to_time(&ctime, fe->attrTime);
+		inode_set_ctime_to_ts(inode, ctime);
 
 		iinfo->i_unique = le64_to_cpu(fe->uniqueID);
 		iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
@@ -1522,7 +1524,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
 		udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime);
 		udf_disk_stamp_to_time(&inode->i_mtime, efe->modificationTime);
 		udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
-		udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime);
+		udf_disk_stamp_to_time(&ctime, efe->attrTime);
+		inode_set_ctime_to_ts(inode, ctime);
 
 		iinfo->i_unique = le64_to_cpu(efe->uniqueID);
 		iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
@@ -1799,7 +1802,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 
 		udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime);
 		udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime);
-		udf_time_to_disk_stamp(&fe->attrTime, inode->i_ctime);
+		udf_time_to_disk_stamp(&fe->attrTime, inode_get_ctime(inode));
 		memset(&(fe->impIdent), 0, sizeof(struct regid));
 		strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER);
 		fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
@@ -1830,12 +1833,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 
 		udf_adjust_time(iinfo, inode->i_atime);
 		udf_adjust_time(iinfo, inode->i_mtime);
-		udf_adjust_time(iinfo, inode->i_ctime);
+		udf_adjust_time(iinfo, inode_get_ctime(inode));
 
 		udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
 		udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);
 		udf_time_to_disk_stamp(&efe->createTime, iinfo->i_crtime);
-		udf_time_to_disk_stamp(&efe->attrTime, inode->i_ctime);
+		udf_time_to_disk_stamp(&efe->attrTime, inode_get_ctime(inode));
 
 		memset(&(efe->impIdent), 0, sizeof(efe->impIdent));
 		strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index a95579b043ab..ae55ab8859b6 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -365,7 +365,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
 	*(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
 		cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL);
 	udf_fiiter_write_fi(&iter, NULL);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	udf_fiiter_release(&iter);
 	udf_add_fid_counter(dir->i_sb, false, 1);
@@ -471,7 +471,7 @@ static int udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 	udf_fiiter_release(&iter);
 	udf_add_fid_counter(dir->i_sb, true, 1);
 	inc_nlink(dir);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	d_instantiate_new(dentry, inode);
 
@@ -523,8 +523,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
 	inode->i_size = 0;
 	inode_dec_link_count(dir);
 	udf_add_fid_counter(dir->i_sb, true, -1);
-	inode->i_ctime = dir->i_ctime = dir->i_mtime =
-						current_time(inode);
+	dir->i_mtime = inode_set_ctime_to_ts(dir,
+					     inode_set_ctime_current(inode));
 	mark_inode_dirty(dir);
 	ret = 0;
 end_rmdir:
@@ -555,11 +555,11 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
 		set_nlink(inode, 1);
 	}
 	udf_fiiter_delete_entry(&iter);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	inode_dec_link_count(inode);
 	udf_add_fid_counter(dir->i_sb, false, -1);
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	ret = 0;
 end_unlink:
 	udf_fiiter_release(&iter);
@@ -746,9 +746,9 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 
 	inc_nlink(inode);
 	udf_add_fid_counter(dir->i_sb, false, 1);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	ihold(inode);
 	d_instantiate(dentry, inode);
@@ -833,7 +833,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 	mark_inode_dirty(old_inode);
 
 	/*
@@ -861,13 +861,13 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	}
 
 	if (new_inode) {
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		inode_dec_link_count(new_inode);
 		udf_add_fid_counter(old_dir->i_sb, S_ISDIR(new_inode->i_mode),
 				    -1);
 	}
-	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
-	new_dir->i_ctime = new_dir->i_mtime = current_time(new_dir);
+	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	new_dir->i_mtime = inode_set_ctime_current(new_dir);
 	mark_inode_dirty(old_dir);
 	mark_inode_dirty(new_dir);
 
-- 
2.41.0


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

* [PATCH v2 80/92] ufs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (75 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 79/92] udf: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:49     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 81/92] vboxsf: " Jeff Layton
                     ` (10 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Evgeniy Dushistov
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ufs/dir.c    |  6 +++---
 fs/ufs/ialloc.c |  2 +-
 fs/ufs/inode.c  | 23 +++++++++++++----------
 fs/ufs/namei.c  |  8 ++++----
 4 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 379d75796a5c..fd57f03b6c93 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -107,7 +107,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
 	ufs_commit_chunk(page, pos, len);
 	ufs_put_page(page);
 	if (update_times)
-		dir->i_mtime = dir->i_ctime = current_time(dir);
+		dir->i_mtime = inode_set_ctime_current(dir);
 	mark_inode_dirty(dir);
 	ufs_handle_dirsync(dir);
 }
@@ -397,7 +397,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
 	ufs_set_de_type(sb, de, inode->i_mode);
 
 	ufs_commit_chunk(page, pos, rec_len);
-	dir->i_mtime = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 
 	mark_inode_dirty(dir);
 	err = ufs_handle_dirsync(dir);
@@ -539,7 +539,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
 		pde->d_reclen = cpu_to_fs16(sb, to - from);
 	dir->d_ino = 0;
 	ufs_commit_chunk(page, pos, to - from);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 	err = ufs_handle_dirsync(inode);
 out:
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 06bd84d555bd..a1e7bd9d1f98 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -292,7 +292,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 	inode->i_blocks = 0;
 	inode->i_generation = 0;
-	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	ufsi->i_flags = UFS_I(dir)->i_flags;
 	ufsi->i_lastfrag = 0;
 	ufsi->i_shadow = 0;
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index a4246c83a8cd..21a4779a2de5 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -296,7 +296,7 @@ ufs_inode_getfrag(struct inode *inode, unsigned index,
 
 	if (new)
 		*new = 1;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	if (IS_SYNC(inode))
 		ufs_sync_inode (inode);
 	mark_inode_dirty(inode);
@@ -378,7 +378,7 @@ ufs_inode_getblock(struct inode *inode, u64 ind_block,
 	mark_buffer_dirty(bh);
 	if (IS_SYNC(inode))
 		sync_dirty_buffer(bh);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 out:
 	brelse (bh);
@@ -580,11 +580,12 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
 
 	inode->i_size = fs64_to_cpu(sb, ufs_inode->ui_size);
 	inode->i_atime.tv_sec = (signed)fs32_to_cpu(sb, ufs_inode->ui_atime.tv_sec);
-	inode->i_ctime.tv_sec = (signed)fs32_to_cpu(sb, ufs_inode->ui_ctime.tv_sec);
+	inode_set_ctime(inode,
+			(signed)fs32_to_cpu(sb, ufs_inode->ui_ctime.tv_sec),
+			0);
 	inode->i_mtime.tv_sec = (signed)fs32_to_cpu(sb, ufs_inode->ui_mtime.tv_sec);
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_atime.tv_nsec = 0;
-	inode->i_ctime.tv_nsec = 0;
 	inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
 	inode->i_generation = fs32_to_cpu(sb, ufs_inode->ui_gen);
 	ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
@@ -626,10 +627,10 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
 
 	inode->i_size = fs64_to_cpu(sb, ufs2_inode->ui_size);
 	inode->i_atime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_atime);
-	inode->i_ctime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_ctime);
+	inode_set_ctime(inode, fs64_to_cpu(sb, ufs2_inode->ui_ctime),
+			fs32_to_cpu(sb, ufs2_inode->ui_ctimensec));
 	inode->i_mtime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_mtime);
 	inode->i_atime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_atimensec);
-	inode->i_ctime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_ctimensec);
 	inode->i_mtime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_mtimensec);
 	inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks);
 	inode->i_generation = fs32_to_cpu(sb, ufs2_inode->ui_gen);
@@ -726,7 +727,8 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
 	ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size);
 	ufs_inode->ui_atime.tv_sec = cpu_to_fs32(sb, inode->i_atime.tv_sec);
 	ufs_inode->ui_atime.tv_usec = 0;
-	ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb, inode->i_ctime.tv_sec);
+	ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb,
+						 inode_get_ctime(inode).tv_sec);
 	ufs_inode->ui_ctime.tv_usec = 0;
 	ufs_inode->ui_mtime.tv_sec = cpu_to_fs32(sb, inode->i_mtime.tv_sec);
 	ufs_inode->ui_mtime.tv_usec = 0;
@@ -770,8 +772,9 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
 	ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size);
 	ufs_inode->ui_atime = cpu_to_fs64(sb, inode->i_atime.tv_sec);
 	ufs_inode->ui_atimensec = cpu_to_fs32(sb, inode->i_atime.tv_nsec);
-	ufs_inode->ui_ctime = cpu_to_fs64(sb, inode->i_ctime.tv_sec);
-	ufs_inode->ui_ctimensec = cpu_to_fs32(sb, inode->i_ctime.tv_nsec);
+	ufs_inode->ui_ctime = cpu_to_fs64(sb, inode_get_ctime(inode).tv_sec);
+	ufs_inode->ui_ctimensec = cpu_to_fs32(sb,
+					      inode_get_ctime(inode).tv_nsec);
 	ufs_inode->ui_mtime = cpu_to_fs64(sb, inode->i_mtime.tv_sec);
 	ufs_inode->ui_mtimensec = cpu_to_fs32(sb, inode->i_mtime.tv_nsec);
 
@@ -1205,7 +1208,7 @@ static int ufs_truncate(struct inode *inode, loff_t size)
 	truncate_setsize(inode, size);
 
 	ufs_truncate_blocks(inode);
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	mark_inode_dirty(inode);
 out:
 	UFSD("EXIT: err %d\n", err);
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 36154b5aca6d..9cad29463791 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -153,7 +153,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
 	struct inode *inode = d_inode(old_dentry);
 	int error;
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_link_count(inode);
 	ihold(inode);
 
@@ -220,7 +220,7 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry)
 	if (err)
 		goto out;
 
-	inode->i_ctime = dir->i_ctime;
+	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
 	inode_dec_link_count(inode);
 	err = 0;
 out:
@@ -282,7 +282,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 		if (!new_de)
 			goto out_dir;
 		ufs_set_link(new_dir, new_de, new_page, old_inode, 1);
-		new_inode->i_ctime = current_time(new_inode);
+		inode_set_ctime_current(new_inode);
 		if (dir_de)
 			drop_nlink(new_inode);
 		inode_dec_link_count(new_inode);
@@ -298,7 +298,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	 * Like most other Unix systems, set the ctime for inodes on a
  	 * rename.
 	 */
-	old_inode->i_ctime = current_time(old_inode);
+	inode_set_ctime_current(old_inode);
 
 	ufs_delete_entry(old_dir, old_de, old_page);
 	mark_inode_dirty(old_inode);
-- 
2.41.0


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

* [PATCH v2 81/92] vboxsf: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (76 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 80/92] ufs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:50     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 82/92] xfs: " Jeff Layton
                     ` (9 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Hans de Goede
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/vboxsf/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
index dd0ae1188e87..576b91d571c5 100644
--- a/fs/vboxsf/utils.c
+++ b/fs/vboxsf/utils.c
@@ -128,8 +128,8 @@ int vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode,
 
 	inode->i_atime = ns_to_timespec64(
 				 info->access_time.ns_relative_to_unix_epoch);
-	inode->i_ctime = ns_to_timespec64(
-				 info->change_time.ns_relative_to_unix_epoch);
+	inode_set_ctime_to_ts(inode,
+			      ns_to_timespec64(info->change_time.ns_relative_to_unix_epoch));
 	inode->i_mtime = ns_to_timespec64(
 			   info->modification_time.ns_relative_to_unix_epoch);
 	return 0;
-- 
2.41.0


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

* [PATCH v2 82/92] xfs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (77 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 81/92] vboxsf: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:52     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 83/92] zonefs: " Jeff Layton
                     ` (8 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Darrick J. Wong
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-xfs

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/xfs/libxfs/xfs_inode_buf.c   | 5 +++--
 fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
 fs/xfs/xfs_acl.c                | 2 +-
 fs/xfs/xfs_bmap_util.c          | 6 ++++--
 fs/xfs/xfs_inode.c              | 3 +--
 fs/xfs/xfs_inode_item.c         | 2 +-
 fs/xfs/xfs_iops.c               | 4 ++--
 fs/xfs/xfs_itable.c             | 4 ++--
 8 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 758aacd8166b..a35781577cad 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -222,7 +222,8 @@ xfs_inode_from_disk(
 	 */
 	inode->i_atime = xfs_inode_from_disk_ts(from, from->di_atime);
 	inode->i_mtime = xfs_inode_from_disk_ts(from, from->di_mtime);
-	inode->i_ctime = xfs_inode_from_disk_ts(from, from->di_ctime);
+	inode_set_ctime_to_ts(inode,
+			      xfs_inode_from_disk_ts(from, from->di_ctime));
 
 	ip->i_disk_size = be64_to_cpu(from->di_size);
 	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
@@ -316,7 +317,7 @@ xfs_inode_to_disk(
 
 	to->di_atime = xfs_inode_to_disk_ts(ip, inode->i_atime);
 	to->di_mtime = xfs_inode_to_disk_ts(ip, inode->i_mtime);
-	to->di_ctime = xfs_inode_to_disk_ts(ip, inode->i_ctime);
+	to->di_ctime = xfs_inode_to_disk_ts(ip, inode_get_ctime(inode));
 	to->di_nlink = cpu_to_be32(inode->i_nlink);
 	to->di_gen = cpu_to_be32(inode->i_generation);
 	to->di_mode = cpu_to_be16(inode->i_mode);
diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
index cb4796b6e693..6b2296ff248a 100644
--- a/fs/xfs/libxfs/xfs_trans_inode.c
+++ b/fs/xfs/libxfs/xfs_trans_inode.c
@@ -67,7 +67,7 @@ xfs_trans_ichgtime(
 	if (flags & XFS_ICHGTIME_MOD)
 		inode->i_mtime = tv;
 	if (flags & XFS_ICHGTIME_CHG)
-		inode->i_ctime = tv;
+		inode_set_ctime_to_ts(inode, tv);
 	if (flags & XFS_ICHGTIME_CREATE)
 		ip->i_crtime = tv;
 }
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 791db7d9c849..6b840301817a 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -233,7 +233,7 @@ xfs_acl_set_mode(
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 	inode->i_mode = mode;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
 	if (xfs_has_wsync(mp))
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index fbb675563208..fcefab687285 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1644,6 +1644,7 @@ xfs_swap_extents(
 	uint64_t		f;
 	int			resblks = 0;
 	unsigned int		flags = 0;
+	struct timespec64	ctime;
 
 	/*
 	 * Lock the inodes against other IO, page faults and truncate to
@@ -1756,8 +1757,9 @@ xfs_swap_extents(
 	 * process that the file was not changed out from
 	 * under it.
 	 */
-	if ((sbp->bs_ctime.tv_sec != VFS_I(ip)->i_ctime.tv_sec) ||
-	    (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) ||
+	ctime = inode_get_ctime(VFS_I(ip));
+	if ((sbp->bs_ctime.tv_sec != ctime.tv_sec) ||
+	    (sbp->bs_ctime.tv_nsec != ctime.tv_nsec) ||
 	    (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
 	    (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
 		error = -EBUSY;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9e62cc500140..360fe83a334f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -843,10 +843,9 @@ xfs_init_new_inode(
 	ip->i_df.if_nextents = 0;
 	ASSERT(ip->i_nblocks == 0);
 
-	tv = current_time(inode);
+	tv = inode_set_ctime_current(inode);
 	inode->i_mtime = tv;
 	inode->i_atime = tv;
-	inode->i_ctime = tv;
 
 	ip->i_extsize = 0;
 	ip->i_diflags = 0;
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 91c847a84e10..127b2410eb20 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -528,7 +528,7 @@ xfs_inode_to_log_dinode(
 	memset(to->di_pad3, 0, sizeof(to->di_pad3));
 	to->di_atime = xfs_inode_to_log_dinode_ts(ip, inode->i_atime);
 	to->di_mtime = xfs_inode_to_log_dinode_ts(ip, inode->i_mtime);
-	to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode->i_ctime);
+	to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode_get_ctime(inode));
 	to->di_nlink = inode->i_nlink;
 	to->di_gen = inode->i_generation;
 	to->di_mode = inode->i_mode;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 24718adb3c16..3a9363953ef2 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -574,7 +574,7 @@ xfs_vn_getattr(
 	stat->ino = ip->i_ino;
 	stat->atime = inode->i_atime;
 	stat->mtime = inode->i_mtime;
-	stat->ctime = inode->i_ctime;
+	stat->ctime = inode_get_ctime(inode);
 	stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
 
 	if (xfs_has_v3inodes(mp)) {
@@ -1055,7 +1055,7 @@ xfs_vn_update_time(
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	if (flags & S_CTIME)
-		inode->i_ctime = *now;
+		inode_set_ctime_to_ts(inode, *now);
 	if (flags & S_MTIME)
 		inode->i_mtime = *now;
 	if (flags & S_ATIME)
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index f225413a993c..c2093cb56092 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -100,8 +100,8 @@ xfs_bulkstat_one_int(
 	buf->bs_atime_nsec = inode->i_atime.tv_nsec;
 	buf->bs_mtime = inode->i_mtime.tv_sec;
 	buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
-	buf->bs_ctime = inode->i_ctime.tv_sec;
-	buf->bs_ctime_nsec = inode->i_ctime.tv_nsec;
+	buf->bs_ctime = inode_get_ctime(inode).tv_sec;
+	buf->bs_ctime_nsec = inode_get_ctime(inode).tv_nsec;
 	buf->bs_gen = inode->i_generation;
 	buf->bs_mode = inode->i_mode;
 
-- 
2.41.0


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

* [PATCH v2 83/92] zonefs: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (78 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 82/92] xfs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:52     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 84/92] linux: " Jeff Layton
                     ` (7 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Damien Le Moal, Naohiro Aota, Johannes Thumshirn
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/zonefs/super.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index bbe44a26a8e5..eaaa23cf6d93 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -658,7 +658,8 @@ static struct inode *zonefs_get_file_inode(struct inode *dir,
 
 	inode->i_ino = ino;
 	inode->i_mode = z->z_mode;
-	inode->i_ctime = inode->i_mtime = inode->i_atime = dir->i_ctime;
+	inode->i_mtime = inode->i_atime = inode_set_ctime_to_ts(inode,
+								inode_get_ctime(dir));
 	inode->i_uid = z->z_uid;
 	inode->i_gid = z->z_gid;
 	inode->i_size = z->z_wpoffset;
@@ -694,7 +695,8 @@ static struct inode *zonefs_get_zgroup_inode(struct super_block *sb,
 	inode->i_ino = ino;
 	inode_init_owner(&nop_mnt_idmap, inode, root, S_IFDIR | 0555);
 	inode->i_size = sbi->s_zgroup[ztype].g_nr_zones;
-	inode->i_ctime = inode->i_mtime = inode->i_atime = root->i_ctime;
+	inode->i_mtime = inode->i_atime = inode_set_ctime_to_ts(inode,
+								inode_get_ctime(root));
 	inode->i_private = &sbi->s_zgroup[ztype];
 	set_nlink(inode, 2);
 
@@ -1317,7 +1319,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 
 	inode->i_ino = bdev_nr_zones(sb->s_bdev);
 	inode->i_mode = S_IFDIR | 0555;
-	inode->i_ctime = inode->i_mtime = inode->i_atime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_op = &zonefs_dir_inode_operations;
 	inode->i_fop = &zonefs_dir_operations;
 	inode->i_size = 2;
-- 
2.41.0


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

* [PATCH v2 84/92] linux: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (79 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 83/92] zonefs: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:53     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 85/92] mqueue: " Jeff Layton
                     ` (6 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 include/linux/fs_stack.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index 54210a42c30d..010d39d0dc1c 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -24,7 +24,7 @@ static inline void fsstack_copy_attr_times(struct inode *dest,
 {
 	dest->i_atime = src->i_atime;
 	dest->i_mtime = src->i_mtime;
-	dest->i_ctime = src->i_ctime;
+	inode_set_ctime_to_ts(dest, inode_get_ctime(src));
 }
 
 #endif /* _LINUX_FS_STACK_H */
-- 
2.41.0


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

* [PATCH v2 85/92] mqueue: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (80 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 84/92] linux: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:54     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 86/92] bpf: " Jeff Layton
                     ` (5 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner; +Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 ipc/mqueue.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 71881bddad25..ba8215ed663a 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -302,7 +302,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
 	inode->i_mode = mode;
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
-	inode->i_mtime = inode->i_ctime = inode->i_atime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 
 	if (S_ISREG(mode)) {
 		struct mqueue_inode_info *info;
@@ -596,7 +596,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg)
 
 	put_ipc_ns(ipc_ns);
 	dir->i_size += DIRENT_SIZE;
-	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
+	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
 
 	d_instantiate(dentry, inode);
 	dget(dentry);
@@ -618,7 +618,7 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
+	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
 	dir->i_size -= DIRENT_SIZE;
 	drop_nlink(inode);
 	dput(dentry);
@@ -635,7 +635,8 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
 static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
 				size_t count, loff_t *off)
 {
-	struct mqueue_inode_info *info = MQUEUE_I(file_inode(filp));
+	struct inode *inode = file_inode(filp);
+	struct mqueue_inode_info *info = MQUEUE_I(inode);
 	char buffer[FILENT_SIZE];
 	ssize_t ret;
 
@@ -656,7 +657,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
 	if (ret <= 0)
 		return ret;
 
-	file_inode(filp)->i_atime = file_inode(filp)->i_ctime = current_time(file_inode(filp));
+	inode->i_atime = inode_set_ctime_current(inode);
 	return ret;
 }
 
@@ -1162,8 +1163,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
 				goto out_unlock;
 			__do_notify(info);
 		}
-		inode->i_atime = inode->i_mtime = inode->i_ctime =
-				current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	}
 out_unlock:
 	spin_unlock(&info->lock);
@@ -1257,8 +1257,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
 
 		msg_ptr = msg_get(info);
 
-		inode->i_atime = inode->i_mtime = inode->i_ctime =
-				current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 
 		/* There is now free space in queue. */
 		pipelined_receive(&wake_q, info);
@@ -1396,7 +1395,7 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
 	if (notification == NULL) {
 		if (info->notify_owner == task_tgid(current)) {
 			remove_notification(info);
-			inode->i_atime = inode->i_ctime = current_time(inode);
+			inode->i_atime = inode_set_ctime_current(inode);
 		}
 	} else if (info->notify_owner != NULL) {
 		ret = -EBUSY;
@@ -1422,7 +1421,7 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
 
 		info->notify_owner = get_pid(task_tgid(current));
 		info->notify_user_ns = get_user_ns(current_user_ns());
-		inode->i_atime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode_set_ctime_current(inode);
 	}
 	spin_unlock(&info->lock);
 out_fput:
@@ -1485,7 +1484,7 @@ static int do_mq_getsetattr(int mqdes, struct mq_attr *new, struct mq_attr *old)
 			f.file->f_flags &= ~O_NONBLOCK;
 		spin_unlock(&f.file->f_lock);
 
-		inode->i_atime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode_set_ctime_current(inode);
 	}
 
 	spin_unlock(&info->lock);
-- 
2.41.0


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

* [PATCH v2 86/92] bpf: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (81 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 85/92] mqueue: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:55     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 87/92] shmem: " Jeff Layton
                     ` (4 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, bpf

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 kernel/bpf/inode.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 4174f76133df..99d0625b6c82 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -118,9 +118,8 @@ static struct inode *bpf_get_inode(struct super_block *sb,
 		return ERR_PTR(-ENOSPC);
 
 	inode->i_ino = get_next_ino();
-	inode->i_atime = current_time(inode);
+	inode->i_atime = inode_set_ctime_current(inode);
 	inode->i_mtime = inode->i_atime;
-	inode->i_ctime = inode->i_atime;
 
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 
@@ -148,8 +147,7 @@ static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
 	d_instantiate(dentry, inode);
 	dget(dentry);
 
-	dir->i_mtime = current_time(dir);
-	dir->i_ctime = dir->i_mtime;
+	dir->i_mtime = inode_set_ctime_current(dir);
 }
 
 static int bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
-- 
2.41.0


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

* [PATCH v2 87/92] shmem: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (82 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 86/92] bpf: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:56     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 88/92] sunrpc: " Jeff Layton
                     ` (3 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Hugh Dickins, Andrew Morton
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mm

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 mm/shmem.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 1693134959c5..51aaaf479437 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1064,7 +1064,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
 void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
 {
 	shmem_undo_range(inode, lstart, lend, false);
-	inode->i_ctime = inode->i_mtime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	inode_inc_iversion(inode);
 }
 EXPORT_SYMBOL_GPL(shmem_truncate_range);
@@ -1161,9 +1161,9 @@ static int shmem_setattr(struct mnt_idmap *idmap,
 	if (attr->ia_valid & ATTR_MODE)
 		error = posix_acl_chmod(idmap, dentry, inode->i_mode);
 	if (!error && update_ctime) {
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		if (update_mtime)
-			inode->i_mtime = inode->i_ctime;
+			inode->i_mtime = inode_get_ctime(inode);
 		inode_inc_iversion(inode);
 	}
 	return error;
@@ -2394,7 +2394,7 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap, struct super_block
 		inode->i_ino = ino;
 		inode_init_owner(idmap, inode, dir, mode);
 		inode->i_blocks = 0;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 		inode->i_generation = get_random_u32();
 		info = SHMEM_I(inode);
 		memset(info, 0, (char *)inode - (char *)info);
@@ -3110,7 +3110,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
 			goto out_iput;
 
 		dir->i_size += BOGO_DIRENT_SIZE;
-		dir->i_ctime = dir->i_mtime = current_time(dir);
+		dir->i_mtime = inode_set_ctime_current(dir);
 		inode_inc_iversion(dir);
 		d_instantiate(dentry, inode);
 		dget(dentry); /* Extra count - pin the dentry in core */
@@ -3193,7 +3193,8 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr
 	}
 
 	dir->i_size += BOGO_DIRENT_SIZE;
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_set_ctime_to_ts(dir,
+					     inode_set_ctime_current(inode));
 	inode_inc_iversion(dir);
 	inc_nlink(inode);
 	ihold(inode);	/* New dentry reference */
@@ -3213,7 +3214,8 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)
 	simple_offset_remove(shmem_get_offset_ctx(dir), dentry);
 
 	dir->i_size -= BOGO_DIRENT_SIZE;
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_set_ctime_to_ts(dir,
+					     inode_set_ctime_current(inode));
 	inode_inc_iversion(dir);
 	drop_nlink(inode);
 	dput(dentry);	/* Undo the count from "create" - this does all the work */
@@ -3360,7 +3362,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
 		folio_put(folio);
 	}
 	dir->i_size += BOGO_DIRENT_SIZE;
-	dir->i_ctime = dir->i_mtime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	inode_inc_iversion(dir);
 	d_instantiate(dentry, inode);
 	dget(dentry);
@@ -3438,7 +3440,7 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap,
 		(fa->flags & SHMEM_FL_USER_MODIFIABLE);
 
 	shmem_set_inode_flags(inode, info->fsflags);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_iversion(inode);
 	return 0;
 }
@@ -3508,7 +3510,7 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
 	name = xattr_full_name(handler, name);
 	err = simple_xattr_set(&info->xattrs, name, value, size, flags, NULL);
 	if (!err) {
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		inode_inc_iversion(inode);
 	}
 	return err;
-- 
2.41.0


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

* [PATCH v2 88/92] sunrpc: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (83 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 87/92] shmem: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:56     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 89/92] apparmor: " Jeff Layton
                     ` (2 subsequent siblings)
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-nfs, netdev

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 net/sunrpc/rpc_pipe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 0b6034fab9ab..f420d8457345 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -472,7 +472,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)
 		return NULL;
 	inode->i_ino = get_next_ino();
 	inode->i_mode = mode;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	switch (mode & S_IFMT) {
 	case S_IFDIR:
 		inode->i_fop = &simple_dir_operations;
-- 
2.41.0


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

* [PATCH v2 89/92] apparmor: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (84 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 88/92] sunrpc: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:57     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 90/92] security: " Jeff Layton
  2023-07-05 19:01   ` [PATCH v2 91/92] selinux: " Jeff Layton
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, apparmor,
	linux-security-module

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 security/apparmor/apparmorfs.c    | 6 +++---
 security/apparmor/policy_unpack.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 3d0d370d6ffd..7dbd0a5aaeeb 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -226,7 +226,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry,
 
 	inode->i_ino = get_next_ino();
 	inode->i_mode = mode;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_private = data;
 	if (S_ISDIR(mode)) {
 		inode->i_op = iops ? iops : &simple_dir_inode_operations;
@@ -1557,7 +1557,7 @@ void __aafs_profile_migrate_dents(struct aa_profile *old,
 		if (new->dents[i]) {
 			struct inode *inode = d_inode(new->dents[i]);
 
-			inode->i_mtime = inode->i_ctime = current_time(inode);
+			inode->i_mtime = inode_set_ctime_current(inode);
 		}
 		old->dents[i] = NULL;
 	}
@@ -2546,7 +2546,7 @@ static int aa_mk_null_file(struct dentry *parent)
 
 	inode->i_ino = get_next_ino();
 	inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO,
 			   MKDEV(MEM_MAJOR, 3));
 	d_instantiate(dentry, inode);
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index ed180722a833..8b8846073e14 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -89,10 +89,10 @@ void __aa_loaddata_update(struct aa_loaddata *data, long revision)
 		struct inode *inode;
 
 		inode = d_inode(data->dents[AAFS_LOADDATA_DIR]);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 
 		inode = d_inode(data->dents[AAFS_LOADDATA_REVISION]);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 	}
 }
 
-- 
2.41.0


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

* [PATCH v2 90/92] security: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (85 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 89/92] apparmor: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:57     ` Jan Kara
  2023-07-05 19:01   ` [PATCH v2 91/92] selinux: " Jeff Layton
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Paul Moore, James Morris, Serge E. Hallyn
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-security-module

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 security/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/inode.c b/security/inode.c
index 6c326939750d..3aa75fffa8c9 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -145,7 +145,7 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
 
 	inode->i_ino = get_next_ino();
 	inode->i_mode = mode;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
 	inode->i_private = data;
 	if (S_ISDIR(mode)) {
 		inode->i_op = &simple_dir_inode_operations;
-- 
2.41.0


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

* [PATCH v2 91/92] selinux: convert to ctime accessor functions
  2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
                     ` (86 preceding siblings ...)
  2023-07-05 19:01   ` [PATCH v2 90/92] security: " Jeff Layton
@ 2023-07-05 19:01   ` Jeff Layton
  2023-07-06 14:57     ` Jan Kara
  87 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 19:01 UTC (permalink / raw)
  To: Christian Brauner, Paul Moore, Stephen Smalley, Eric Paris
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, selinux

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 security/selinux/selinuxfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index bad1f6b685fd..9dafb6ff110d 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1197,7 +1197,7 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
 
 	if (ret) {
 		ret->i_mode = mode;
-		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
+		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
 	}
 	return ret;
 }
-- 
2.41.0


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

* Re: [PATCH v2 52/92] hugetlbfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 52/92] hugetlbfs: " Jeff Layton
@ 2023-07-05 19:58     ` Mike Kravetz
  2023-07-06 12:40     ` Jan Kara
  1 sibling, 0 replies; 208+ messages in thread
From: Mike Kravetz @ 2023-07-05 19:58 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Muchun Song, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-mm

On 07/05/23 15:01, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/hugetlbfs/inode.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Looks straight forward,

Acked-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz

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

* Re: [PATCH v2 74/92] smb: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: " Jeff Layton
@ 2023-07-05 23:01     ` Jeff Layton
  2023-07-06 15:28     ` Steve French
  1 sibling, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-05 23:01 UTC (permalink / raw)
  To: Christian Brauner, Steve French, Paulo Alcantara,
	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Namjae Jeon,
	Sergey Senozhatsky
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-cifs,
	samba-technical

On Wed, 2023-07-05 at 15:01 -0400, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Tom Talpey <tom@talpey.com>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/smb/client/file.c    |  4 ++--
>  fs/smb/client/fscache.h |  5 +++--
>  fs/smb/client/inode.c   | 14 +++++++-------
>  fs/smb/client/smb2ops.c |  3 ++-
>  fs/smb/server/smb2pdu.c |  8 ++++----
>  5 files changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 0a5fe8d5314b..689058e1b6e6 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
>  		    !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
>  		    dclose) {
>  			if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) {
> -				inode->i_ctime = inode->i_mtime = current_time(inode);
> +				inode->i_mtime = inode_set_ctime_current(inode);
>  			}
>  			spin_lock(&cinode->deferred_lock);
>  			cifs_add_deferred_close(cfile, dclose);
> @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
>  					   write_data, to - from, &offset);
>  		cifsFileInfo_put(open_file);
>  		/* Does mm or vfs already set times? */
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		if ((bytes_written > 0) && (offset))
>  			rc = 0;
>  		else if (bytes_written < 0)
> diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
> index 173999610997..a228964bc2ce 100644
> --- a/fs/smb/client/fscache.h
> +++ b/fs/smb/client/fscache.h
> @@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
>  				 struct cifs_fscache_inode_coherency_data *cd)
>  {
>  	struct cifsInodeInfo *cifsi = CIFS_I(inode);
> +	struct timespec64 ctime = inode_get_ctime(inode);
>  
>  	memset(cd, 0, sizeof(*cd));
>  	cd->last_write_time_sec   = cpu_to_le64(cifsi->netfs.inode.i_mtime.tv_sec);
>  	cd->last_write_time_nsec  = cpu_to_le32(cifsi->netfs.inode.i_mtime.tv_nsec);
> -	cd->last_change_time_sec  = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec);
> -	cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec);
> +	cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
> +	cd->last_change_time_nsec  = cpu_to_le64(ctime.tv_nsec);

Tom pointed out that I made a switch to cpu_to_le64 here. That will need
to be fixed before we merge this. I've fixed this in my "ctime-next"
branch for now (and will collect other fixes there).

>  }
>  
>  
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index c3eeae07e139..218f03dd3f52 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
>  	else
>  		inode->i_atime = fattr->cf_atime;
>  	inode->i_mtime = fattr->cf_mtime;
> -	inode->i_ctime = fattr->cf_ctime;
> +	inode_set_ctime_to_ts(inode, fattr->cf_ctime);
>  	inode->i_rdev = fattr->cf_rdev;
>  	cifs_nlink_fattr_to_inode(inode, fattr);
>  	inode->i_uid = fattr->cf_uid;
> @@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>  		cifs_inode = CIFS_I(inode);
>  		cifs_inode->time = 0;	/* will force revalidate to get info
>  					   when needed */
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  	}
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	cifs_inode = CIFS_I(dir);
>  	CIFS_I(dir)->time = 0;	/* force revalidate of dir as well */
>  unlink_out:
> @@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
>  	 */
>  	cifsInode->time = 0;
>  
> -	d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime =
> -		current_time(inode);
> +	inode_set_ctime_current(d_inode(direntry));
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
>  rmdir_exit:
>  	free_dentry_path(page);
> @@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
>  	/* force revalidate to go get info when needed */
>  	CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
>  
> -	source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
> -		target_dir->i_mtime = current_time(source_dir);
> +	source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
> +									  inode_set_ctime_current(target_dir));
>  
>  cifs_rename_exit:
>  	kfree(info_buf_source);
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index 87abce010974..3cc3c4a71e32 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
>  	if (file_inf.LastWriteTime)
>  		inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
>  	if (file_inf.ChangeTime)
> -		inode->i_ctime = cifs_NTtimeToUnix(file_inf.ChangeTime);
> +		inode_set_ctime_to_ts(inode,
> +				      cifs_NTtimeToUnix(file_inf.ChangeTime));
>  	if (file_inf.LastAccessTime)
>  		inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
>  
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index cf8822103f50..f9099831c8ff 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
>  	file_info->LastAccessTime = cpu_to_le64(time);
>  	time = ksmbd_UnixTimeToNT(inode->i_mtime);
>  	file_info->LastWriteTime = cpu_to_le64(time);
> -	time = ksmbd_UnixTimeToNT(inode->i_ctime);
> +	time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
>  	file_info->ChangeTime = cpu_to_le64(time);
>  	file_info->DosAttributes = fp->f_ci->m_fattr;
>  	file_info->Inode = cpu_to_le64(inode->i_ino);
> @@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
>  		rsp->LastAccessTime = cpu_to_le64(time);
>  		time = ksmbd_UnixTimeToNT(inode->i_mtime);
>  		rsp->LastWriteTime = cpu_to_le64(time);
> -		time = ksmbd_UnixTimeToNT(inode->i_ctime);
> +		time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
>  		rsp->ChangeTime = cpu_to_le64(time);
>  		ksmbd_fd_put(work, fp);
>  	} else {
> @@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
>  	if (file_info->ChangeTime)
>  		attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
>  	else
> -		attrs.ia_ctime = inode->i_ctime;
> +		attrs.ia_ctime = inode_get_ctime(inode);
>  
>  	if (file_info->LastWriteTime) {
>  		attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime);
> @@ -5689,7 +5689,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
>  			return -EACCES;
>  
>  		inode_lock(inode);
> -		inode->i_ctime = attrs.ia_ctime;
> +		inode_set_ctime_to_ts(inode, attrs.ia_ctime);
>  		attrs.ia_valid &= ~ATTR_CTIME;
>  		rc = notify_change(idmap, dentry, &attrs, NULL);
>  		inode_unlock(inode);

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 44/92] fat: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 44/92] fat: " Jeff Layton
@ 2023-07-06  1:54     ` OGAWA Hirofumi
  2023-07-06 11:25       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: OGAWA Hirofumi @ 2023-07-06  1:54 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

Jeff Layton <jlayton@kernel.org> writes:

> @@ -1407,8 +1407,9 @@ static int fat_read_root(struct inode *inode)
>  	MSDOS_I(inode)->mmu_private = inode->i_size;
>  
>  	fat_save_attrs(inode, ATTR_DIR);
> -	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0;
> -	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0;
> +	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode_set_ctime(inode,
> +									0, 0).tv_sec;
> +	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0;

Maybe, this should simply be

	inode->i_mtime = inode->i_atime = inode_set_ctime(inode, 0, 0);

?

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

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

* Re: [PATCH v2 06/92] cifs: update the ctime on a partial page write
       [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
@ 2023-07-06  7:11       ` Christian Brauner
  0 siblings, 0 replies; 208+ messages in thread
From: Christian Brauner @ 2023-07-06  7:11 UTC (permalink / raw)
  To: Steve French
  Cc: Jeff Layton, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-cifs, samba-technical

On Wed, Jul 05, 2023 at 11:50:15PM -0500, Steve French wrote:
> this looks useful (although we have a few more serious problems where we
> don't keep the cached mtime/ctime/size for files that have RW or RWH leases
> so can update the mtime/ctime/size from the server version of it which can
> be stale in cases where we are caching writes (with leases).
> 
> Which tree do you want this patch to go through?

Plan is to take it all through the vfs tree.

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

* Re: [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp
  2023-07-05 19:00     ` Jeff Layton
@ 2023-07-06 10:30       ` Jan Kara
  -1 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:30 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Richard Weinberger, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-mtd

On Wed 05-07-23 15:00:35, Jeff Layton wrote:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ubifs/dir.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index ef0499edc248..7ec25310bd8a 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	 * Like most other Unix systems, set the @i_ctime for inodes on a
>  	 * rename.
>  	 */
> -	time = current_time(old_dir);
> -	old_inode->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  
>  	/* We must adjust parent link count when renaming directories */
>  	if (is_dir) {
> @@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  	old_dir->i_size -= old_sz;
>  	ubifs_inode(old_dir)->ui_size = old_dir->i_size;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
>  
>  	/*
>  	 * And finally, if we unlinked a direntry which happened to have the
>  	 * same name as the moved direntry, we have to decrement @i_nlink of
> -	 * the unlinked inode and change its ctime.
> +	 * the unlinked inode.
>  	 */
>  	if (unlink) {
>  		/*
> @@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  			clear_nlink(new_inode);
>  		else
>  			drop_nlink(new_inode);
> -		new_inode->i_ctime = time;
>  	} else {
>  		new_dir->i_size += new_sz;
>  		ubifs_inode(new_dir)->ui_size = new_dir->i_size;
> @@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>  	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
>  	struct inode *fst_inode = d_inode(old_dentry);
>  	struct inode *snd_inode = d_inode(new_dentry);
> -	struct timespec64 time;
>  	int err;
>  	struct fscrypt_name fst_nm, snd_nm;
>  
> @@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  	lock_4_inodes(old_dir, new_dir, NULL, NULL);
>  
> -	time = current_time(old_dir);
> -	fst_inode->i_ctime = time;
> -	snd_inode->i_ctime = time;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  
>  	if (old_dir != new_dir) {
>  		if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp
@ 2023-07-06 10:30       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:30 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Richard Weinberger, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-mtd

On Wed 05-07-23 15:00:35, Jeff Layton wrote:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ubifs/dir.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index ef0499edc248..7ec25310bd8a 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	 * Like most other Unix systems, set the @i_ctime for inodes on a
>  	 * rename.
>  	 */
> -	time = current_time(old_dir);
> -	old_inode->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  
>  	/* We must adjust parent link count when renaming directories */
>  	if (is_dir) {
> @@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  	old_dir->i_size -= old_sz;
>  	ubifs_inode(old_dir)->ui_size = old_dir->i_size;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
>  
>  	/*
>  	 * And finally, if we unlinked a direntry which happened to have the
>  	 * same name as the moved direntry, we have to decrement @i_nlink of
> -	 * the unlinked inode and change its ctime.
> +	 * the unlinked inode.
>  	 */
>  	if (unlink) {
>  		/*
> @@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  			clear_nlink(new_inode);
>  		else
>  			drop_nlink(new_inode);
> -		new_inode->i_ctime = time;
>  	} else {
>  		new_dir->i_size += new_sz;
>  		ubifs_inode(new_dir)->ui_size = new_dir->i_size;
> @@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>  	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
>  	struct inode *fst_inode = d_inode(old_dentry);
>  	struct inode *snd_inode = d_inode(new_dentry);
> -	struct timespec64 time;
>  	int err;
>  	struct fscrypt_name fst_nm, snd_nm;
>  
> @@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  	lock_4_inodes(old_dir, new_dir, NULL, NULL);
>  
> -	time = current_time(old_dir);
> -	fst_inode->i_ctime = time;
> -	snd_inode->i_ctime = time;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  
>  	if (old_dir != new_dir) {
>  		if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

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

* Re: [PATCH v2 14/92] reiserfs: convert to simple_rename_timestamp
  2023-07-05 19:00   ` [PATCH v2 14/92] reiserfs: " Jeff Layton
@ 2023-07-06 10:32     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:32 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, reiserfs-devel

On Wed 05-07-23 15:00:39, Jeff Layton wrote:
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/reiserfs/namei.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
> index 52240cc891cf..405ac59eb2dd 100644
> --- a/fs/reiserfs/namei.c
> +++ b/fs/reiserfs/namei.c
> @@ -1325,7 +1325,6 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
>  	int jbegin_count;
>  	umode_t old_inode_mode;
>  	unsigned long savelink = 1;
> -	struct timespec64 ctime;
>  
>  	if (flags & ~RENAME_NOREPLACE)
>  		return -EINVAL;
> @@ -1576,14 +1575,11 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
>  
>  	mark_de_hidden(old_de.de_deh + old_de.de_entry_num);
>  	journal_mark_dirty(&th, old_de.de_bh);
> -	ctime = current_time(old_dir);
> -	old_dir->i_ctime = old_dir->i_mtime = ctime;
> -	new_dir->i_ctime = new_dir->i_mtime = ctime;
>  	/*
>  	 * thanks to Alex Adriaanse <alex_a@caltech.edu> for patch
>  	 * which adds ctime update of renamed object
>  	 */
> -	old_inode->i_ctime = ctime;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  
>  	if (new_dentry_inode) {
>  		/* adjust link number of the victim */
> @@ -1592,7 +1588,6 @@ static int reiserfs_rename(struct mnt_idmap *idmap,
>  		} else {
>  			drop_nlink(new_dentry_inode);
>  		}
> -		new_dentry_inode->i_ctime = ctime;
>  		savelink = new_dentry_inode->i_nlink;
>  	}
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 11/92] shmem: convert to simple_rename_timestamp
  2023-07-05 19:00   ` [PATCH v2 11/92] shmem: " Jeff Layton
@ 2023-07-06 10:33     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:33 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Hugh Dickins, Andrew Morton, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-mm

On Wed 05-07-23 15:00:36, Jeff Layton wrote:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  mm/shmem.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 0f45e72a5ca7..1693134959c5 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3306,9 +3306,7 @@ static int shmem_rename2(struct mnt_idmap *idmap,
>  
>  	old_dir->i_size -= BOGO_DIRENT_SIZE;
>  	new_dir->i_size += BOGO_DIRENT_SIZE;
> -	old_dir->i_ctime = old_dir->i_mtime =
> -	new_dir->i_ctime = new_dir->i_mtime =
> -	inode->i_ctime = current_time(old_dir);
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  	inode_inc_iversion(old_dir);
>  	inode_inc_iversion(new_dir);
>  	return 0;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 12/92] exfat: convert to simple_rename_timestamp
  2023-07-05 19:00   ` [PATCH v2 12/92] exfat: " Jeff Layton
@ 2023-07-06 10:39     ` Jan Kara
  2023-07-06 11:40       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:39 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Namjae Jeon, Sungjong Seo, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:00:37, Jeff Layton wrote:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/exfat/namei.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index d9b46fa36bff..e91022ff80ef 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -1312,8 +1312,8 @@ static int exfat_rename(struct mnt_idmap *idmap,
>  		goto unlock;
>  
>  	inode_inc_iversion(new_dir);
> -	new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime =
> -		EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
> +	EXFAT_I(new_dir)->i_crtime = current_time(new_dir);

Hum, you loose atime update with this. Not that it would make sense to have
it but it would probably deserve a comment in the changelog.

Also why you use current_time(new_dir) here instead of say inode->i_ctime?

>  	exfat_truncate_atime(&new_dir->i_atime);
>  	if (IS_DIRSYNC(new_dir))
>  		exfat_sync_inode(new_dir);
> @@ -1336,7 +1336,6 @@ static int exfat_rename(struct mnt_idmap *idmap,
>  	}
>  
>  	inode_inc_iversion(old_dir);
> -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
>  	if (IS_DIRSYNC(old_dir))
>  		exfat_sync_inode(old_dir);
>  	else

Also there is:

                new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
                        current_time(new_inode);

in exfat_rename() from which you can remove the ctime update?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 13/92] ntfs3: convert to simple_rename_timestamp
  2023-07-05 19:00   ` [PATCH v2 13/92] ntfs3: " Jeff Layton
@ 2023-07-06 10:40     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:40 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Konstantin Komarov, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, ntfs3

On Wed 05-07-23 15:00:38, Jeff Layton wrote:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ntfs3/namei.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index 70f8c859e0ad..bfd986699f9e 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -324,14 +324,11 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
>  		/* Restore after failed rename failed too. */
>  		_ntfs_bad_inode(inode);
>  	} else if (!err) {
> -		inode->i_ctime = dir->i_ctime = dir->i_mtime =
> -			current_time(dir);
> +		simple_rename_timestamp(dir, dentry, new_dir, new_dentry);
>  		mark_inode_dirty(inode);
>  		mark_inode_dirty(dir);
> -		if (dir != new_dir) {
> -			new_dir->i_mtime = new_dir->i_ctime = dir->i_ctime;
> +		if (dir != new_dir)
>  			mark_inode_dirty(new_dir);
> -		}
>  
>  		if (IS_DIRSYNC(dir))
>  			ntfs_sync_inode(dir);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 19/92] ibm: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 19/92] ibm: " Jeff Layton
@ 2023-07-06 10:41     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:41 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Arnd Bergmann, Greg Kroah-Hartman,
	Brad Warrum, Ritu Agarwal, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel

On Wed 05-07-23 15:00:44, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

									Honza

> ---
>  drivers/misc/ibmasm/ibmasmfs.c | 2 +-
>  drivers/misc/ibmvmc.c          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
> index 35fec1bf1b3d..5867af9f592c 100644
> --- a/drivers/misc/ibmasm/ibmasmfs.c
> +++ b/drivers/misc/ibmasm/ibmasmfs.c
> @@ -139,7 +139,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
>  	if (ret) {
>  		ret->i_ino = get_next_ino();
>  		ret->i_mode = mode;
> -		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
> +		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
>  	}
>  	return ret;
>  }
> diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
> index d7c7f0305257..2101eb12bcba 100644
> --- a/drivers/misc/ibmvmc.c
> +++ b/drivers/misc/ibmvmc.c
> @@ -1124,7 +1124,7 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
>  		goto out;
>  
>  	inode = file_inode(file);
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	dev_dbg(adapter->dev, "write: file = 0x%lx, count = 0x%lx\n",
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 28/92] bfs: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 28/92] bfs: " Jeff Layton
@ 2023-07-06 10:44     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:44 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Tigran A. Aivazian, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:00:53, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/bfs/dir.c   | 16 ++++++++--------
>  fs/bfs/inode.c |  5 ++---
>  2 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
> index d2e8a2a56b05..12b8af04dcb3 100644
> --- a/fs/bfs/dir.c
> +++ b/fs/bfs/dir.c
> @@ -97,7 +97,7 @@ static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
>  	set_bit(ino, info->si_imap);
>  	info->si_freei--;
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_blocks = 0;
>  	inode->i_op = &bfs_file_inops;
>  	inode->i_fop = &bfs_file_operations;
> @@ -158,7 +158,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
>  		return err;
>  	}
>  	inc_nlink(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	ihold(inode);
>  	d_instantiate(new, inode);
> @@ -187,9 +187,9 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
>  	}
>  	de->ino = 0;
>  	mark_buffer_dirty_inode(bh, dir);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  	inode_dec_link_count(inode);
>  	error = 0;
>  
> @@ -240,10 +240,10 @@ static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  			goto end_rename;
>  	}
>  	old_de->ino = 0;
> -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> +	old_dir->i_mtime = inode_set_ctime_current(old_dir);
>  	mark_inode_dirty(old_dir);
>  	if (new_inode) {
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		inode_dec_link_count(new_inode);
>  	}
>  	mark_buffer_dirty_inode(old_bh, old_dir);
> @@ -292,9 +292,9 @@ static int bfs_add_entry(struct inode *dir, const struct qstr *child, int ino)
>  				pos = (block - sblock) * BFS_BSIZE + off;
>  				if (pos >= dir->i_size) {
>  					dir->i_size += BFS_DIRENT_SIZE;
> -					dir->i_ctime = current_time(dir);
> +					inode_set_ctime_current(dir);
>  				}
> -				dir->i_mtime = dir->i_ctime = current_time(dir);
> +				dir->i_mtime = inode_set_ctime_current(dir);
>  				mark_inode_dirty(dir);
>  				de->ino = cpu_to_le16((u16)ino);
>  				for (i = 0; i < BFS_NAMELEN; i++)
> diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
> index 1926bec2c850..e6a76ae9eb44 100644
> --- a/fs/bfs/inode.c
> +++ b/fs/bfs/inode.c
> @@ -82,10 +82,9 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
>  	inode->i_blocks = BFS_FILEBLOCKS(di);
>  	inode->i_atime.tv_sec =  le32_to_cpu(di->i_atime);
>  	inode->i_mtime.tv_sec =  le32_to_cpu(di->i_mtime);
> -	inode->i_ctime.tv_sec =  le32_to_cpu(di->i_ctime);
> +	inode_set_ctime(inode, le32_to_cpu(di->i_ctime), 0);
>  	inode->i_atime.tv_nsec = 0;
>  	inode->i_mtime.tv_nsec = 0;
> -	inode->i_ctime.tv_nsec = 0;
>  
>  	brelse(bh);
>  	unlock_new_inode(inode);
> @@ -143,7 +142,7 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
>  	di->i_nlink = cpu_to_le32(inode->i_nlink);
>  	di->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
>  	di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
> -	di->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
> +	di->i_ctime = cpu_to_le32(inode_get_ctime(inode).tv_sec);
>  	i_sblock = BFS_I(inode)->i_sblock;
>  	di->i_sblock = cpu_to_le32(i_sblock);
>  	di->i_eblock = cpu_to_le32(BFS_I(inode)->i_eblock);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 29/92] btrfs: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 29/92] btrfs: " Jeff Layton
@ 2023-07-06 10:51     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:51 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Chris Mason, Josef Bacik, David Sterba,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-btrfs

On Wed 05-07-23 15:00:54, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/btrfs/delayed-inode.c |  8 ++++----
>  fs/btrfs/file.c          | 21 +++++++++------------
>  fs/btrfs/inode.c         | 39 ++++++++++++++++-----------------------
>  fs/btrfs/ioctl.c         |  2 +-
>  fs/btrfs/reflink.c       |  3 +--
>  fs/btrfs/transaction.c   |  3 +--
>  fs/btrfs/tree-log.c      |  4 ++--
>  fs/btrfs/xattr.c         |  4 ++--
>  8 files changed, 36 insertions(+), 48 deletions(-)
> 
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index c0a6a1784697..e2753d228037 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -1808,9 +1808,9 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
>  				      inode->i_mtime.tv_nsec);
>  
>  	btrfs_set_stack_timespec_sec(&inode_item->ctime,
> -				     inode->i_ctime.tv_sec);
> +				     inode_get_ctime(inode).tv_sec);
>  	btrfs_set_stack_timespec_nsec(&inode_item->ctime,
> -				      inode->i_ctime.tv_nsec);
> +				      inode_get_ctime(inode).tv_nsec);
>  
>  	btrfs_set_stack_timespec_sec(&inode_item->otime,
>  				     BTRFS_I(inode)->i_otime.tv_sec);
> @@ -1861,8 +1861,8 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
>  	inode->i_mtime.tv_sec = btrfs_stack_timespec_sec(&inode_item->mtime);
>  	inode->i_mtime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->mtime);
>  
> -	inode->i_ctime.tv_sec = btrfs_stack_timespec_sec(&inode_item->ctime);
> -	inode->i_ctime.tv_nsec = btrfs_stack_timespec_nsec(&inode_item->ctime);
> +	inode_set_ctime(inode, btrfs_stack_timespec_sec(&inode_item->ctime),
> +			btrfs_stack_timespec_nsec(&inode_item->ctime));
>  
>  	BTRFS_I(inode)->i_otime.tv_sec =
>  		btrfs_stack_timespec_sec(&inode_item->otime);
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index fd03e689a6be..d7a9ece7a40b 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1108,7 +1108,7 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode)
>  
>  static void update_time_for_write(struct inode *inode)
>  {
> -	struct timespec64 now;
> +	struct timespec64 now, ctime;
>  
>  	if (IS_NOCMTIME(inode))
>  		return;
> @@ -1117,8 +1117,9 @@ static void update_time_for_write(struct inode *inode)
>  	if (!timespec64_equal(&inode->i_mtime, &now))
>  		inode->i_mtime = now;
>  
> -	if (!timespec64_equal(&inode->i_ctime, &now))
> -		inode->i_ctime = now;
> +	ctime = inode_get_ctime(inode);
> +	if (!timespec64_equal(&ctime, &now))
> +		inode_set_ctime_to_ts(inode, now);
>  
>  	if (IS_I_VERSION(inode))
>  		inode_inc_iversion(inode);
> @@ -2459,10 +2460,8 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
>  		 */
>  		inode_inc_iversion(&inode->vfs_inode);
>  
> -		if (!extent_info || extent_info->update_times) {
> -			inode->vfs_inode.i_mtime = current_time(&inode->vfs_inode);
> -			inode->vfs_inode.i_ctime = inode->vfs_inode.i_mtime;
> -		}
> +		if (!extent_info || extent_info->update_times)
> +			inode->vfs_inode.i_mtime = inode_set_ctime_current(&inode->vfs_inode);
>  
>  		ret = btrfs_update_inode(trans, root, inode);
>  		if (ret)
> @@ -2703,8 +2702,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
>  
>  	ASSERT(trans != NULL);
>  	inode_inc_iversion(inode);
> -	inode->i_mtime = current_time(inode);
> -	inode->i_ctime = inode->i_mtime;
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
>  	updated_inode = true;
>  	btrfs_end_transaction(trans);
> @@ -2721,11 +2719,10 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
>  		 * for detecting, at fsync time, if the inode isn't yet in the
>  		 * log tree or it's there but not up to date.
>  		 */
> -		struct timespec64 now = current_time(inode);
> +		struct timespec64 now = inode_set_ctime_current(inode);
>  
>  		inode_inc_iversion(inode);
>  		inode->i_mtime = now;
> -		inode->i_ctime = now;
>  		trans = btrfs_start_transaction(root, 1);
>  		if (IS_ERR(trans)) {
>  			ret = PTR_ERR(trans);
> @@ -2796,7 +2793,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
>  	if (IS_ERR(trans))
>  		return PTR_ERR(trans);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	i_size_write(inode, end);
>  	btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
>  	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 521c08b8ad04..daa47a2238bd 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3901,8 +3901,8 @@ static int btrfs_read_locked_inode(struct inode *inode,
>  	inode->i_mtime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->mtime);
>  	inode->i_mtime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->mtime);
>  
> -	inode->i_ctime.tv_sec = btrfs_timespec_sec(leaf, &inode_item->ctime);
> -	inode->i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, &inode_item->ctime);
> +	inode_set_ctime(inode, btrfs_timespec_sec(leaf, &inode_item->ctime),
> +			btrfs_timespec_nsec(leaf, &inode_item->ctime));
>  
>  	BTRFS_I(inode)->i_otime.tv_sec =
>  		btrfs_timespec_sec(leaf, &inode_item->otime);
> @@ -4073,9 +4073,9 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
>  				      inode->i_mtime.tv_nsec);
>  
>  	btrfs_set_token_timespec_sec(&token, &item->ctime,
> -				     inode->i_ctime.tv_sec);
> +				     inode_get_ctime(inode).tv_sec);
>  	btrfs_set_token_timespec_nsec(&token, &item->ctime,
> -				      inode->i_ctime.tv_nsec);
> +				      inode_get_ctime(inode).tv_nsec);
>  
>  	btrfs_set_token_timespec_sec(&token, &item->otime,
>  				     BTRFS_I(inode)->i_otime.tv_sec);
> @@ -4273,9 +4273,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
>  	btrfs_i_size_write(dir, dir->vfs_inode.i_size - name->len * 2);
>  	inode_inc_iversion(&inode->vfs_inode);
>  	inode_inc_iversion(&dir->vfs_inode);
> -	inode->vfs_inode.i_ctime = current_time(&inode->vfs_inode);
> -	dir->vfs_inode.i_mtime = inode->vfs_inode.i_ctime;
> -	dir->vfs_inode.i_ctime = inode->vfs_inode.i_ctime;
> +	inode_set_ctime_current(&inode->vfs_inode);
> +	dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
>  	ret = btrfs_update_inode(trans, root, dir);
>  out:
>  	return ret;
> @@ -4448,8 +4447,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
>  
>  	btrfs_i_size_write(dir, dir->vfs_inode.i_size - fname.disk_name.len * 2);
>  	inode_inc_iversion(&dir->vfs_inode);
> -	dir->vfs_inode.i_mtime = current_time(&dir->vfs_inode);
> -	dir->vfs_inode.i_ctime = dir->vfs_inode.i_mtime;
> +	dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
>  	ret = btrfs_update_inode_fallback(trans, root, dir);
>  	if (ret)
>  		btrfs_abort_transaction(trans, ret);
> @@ -5091,8 +5089,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
>  	if (newsize != oldsize) {
>  		inode_inc_iversion(inode);
>  		if (!(mask & (ATTR_CTIME | ATTR_MTIME))) {
> -			inode->i_mtime = current_time(inode);
> -			inode->i_ctime = inode->i_mtime;
> +			inode->i_mtime = inode_set_ctime_current(inode);
>  		}
>  	}
>  
> @@ -5736,9 +5733,8 @@ static struct inode *new_simple_dir(struct super_block *s,
>  	inode->i_opflags &= ~IOP_XATTR;
>  	inode->i_fop = &simple_dir_operations;
>  	inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
> -	inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	inode->i_atime = inode->i_mtime;
> -	inode->i_ctime = inode->i_mtime;
>  	BTRFS_I(inode)->i_otime = inode->i_mtime;
>  
>  	return inode;
> @@ -6075,7 +6071,7 @@ static int btrfs_update_time(struct inode *inode, struct timespec64 *now,
>  	if (flags & S_VERSION)
>  		dirty |= inode_maybe_inc_iversion(inode, dirty);
>  	if (flags & S_CTIME)
> -		inode->i_ctime = *now;
> +		inode_set_ctime_to_ts(inode, *now);
>  	if (flags & S_MTIME)
>  		inode->i_mtime = *now;
>  	if (flags & S_ATIME)
> @@ -6378,9 +6374,8 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
>  		goto discard;
>  	}
>  
> -	inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	inode->i_atime = inode->i_mtime;
> -	inode->i_ctime = inode->i_mtime;
>  	BTRFS_I(inode)->i_otime = inode->i_mtime;
>  
>  	/*
> @@ -6545,12 +6540,10 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
>  	 * log replay procedure is responsible for setting them to their correct
>  	 * values (the ones it had when the fsync was done).
>  	 */
> -	if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) {
> -		struct timespec64 now = current_time(&parent_inode->vfs_inode);
> +	if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags))
> +		parent_inode->vfs_inode.i_mtime =
> +			inode_set_ctime_current(&parent_inode->vfs_inode);
>  
> -		parent_inode->vfs_inode.i_mtime = now;
> -		parent_inode->vfs_inode.i_ctime = now;
> -	}
>  	ret = btrfs_update_inode(trans, root, parent_inode);
>  	if (ret)
>  		btrfs_abort_transaction(trans, ret);
> @@ -6690,7 +6683,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
>  	BTRFS_I(inode)->dir_index = 0ULL;
>  	inc_nlink(inode);
>  	inode_inc_iversion(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ihold(inode);
>  	set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
>  
> @@ -9733,7 +9726,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
>  		*alloc_hint = ins.objectid + ins.offset;
>  
>  		inode_inc_iversion(inode);
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
>  		if (!(mode & FALLOC_FL_KEEP_SIZE) &&
>  		    (actual_len > inode->i_size) &&
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index a895d105464b..a18ee7b5a166 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -384,7 +384,7 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
>  	binode->flags = binode_flags;
>  	btrfs_sync_inode_flags_to_i_flags(inode);
>  	inode_inc_iversion(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
>  
>   out_end_trans:
> diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
> index 0474bbe39da7..65d2bd6910f2 100644
> --- a/fs/btrfs/reflink.c
> +++ b/fs/btrfs/reflink.c
> @@ -30,8 +30,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
>  
>  	inode_inc_iversion(inode);
>  	if (!no_time_update) {
> -		inode->i_mtime = current_time(inode);
> -		inode->i_ctime = inode->i_mtime;
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  	/*
>  	 * We round up to the block size at eof when determining which
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index e7cfc992e02a..d8d20ea5a41f 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -1831,8 +1831,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
>  
>  	btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size +
>  						  fname.disk_name.len * 2);
> -	parent_inode->i_mtime = current_time(parent_inode);
> -	parent_inode->i_ctime = parent_inode->i_mtime;
> +	parent_inode->i_mtime = inode_set_ctime_current(parent_inode);
>  	ret = btrfs_update_inode_fallback(trans, parent_root, BTRFS_I(parent_inode));
>  	if (ret) {
>  		btrfs_abort_transaction(trans, ret);
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 365a1cc0a3c3..ffcff7188170 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -4148,9 +4148,9 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
>  				      inode->i_mtime.tv_nsec);
>  
>  	btrfs_set_token_timespec_sec(&token, &item->ctime,
> -				     inode->i_ctime.tv_sec);
> +				     inode_get_ctime(inode).tv_sec);
>  	btrfs_set_token_timespec_nsec(&token, &item->ctime,
> -				      inode->i_ctime.tv_nsec);
> +				      inode_get_ctime(inode).tv_nsec);
>  
>  	/*
>  	 * We do not need to set the nbytes field, in fact during a fast fsync
> diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
> index fc4b20c2688a..96828a13dd43 100644
> --- a/fs/btrfs/xattr.c
> +++ b/fs/btrfs/xattr.c
> @@ -264,7 +264,7 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name,
>  		goto out;
>  
>  	inode_inc_iversion(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
>  	if (ret)
>  		btrfs_abort_transaction(trans, ret);
> @@ -407,7 +407,7 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
>  	ret = btrfs_set_prop(trans, inode, name, value, size, flags);
>  	if (!ret) {
>  		inode_inc_iversion(inode);
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
>  		if (ret)
>  			btrfs_abort_transaction(trans, ret);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 30/92] ceph: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 30/92] ceph: " Jeff Layton
@ 2023-07-06 10:53     ` Jan Kara
  2023-07-06 11:47       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:53 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Xiubo Li, Ilya Dryomov, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, ceph-devel

On Wed 05-07-23 15:00:55, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Reviewed-by: Xiubo Li <xiubli@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Just one nit below:

> @@ -688,6 +688,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,
>  			 struct timespec64 *mtime, struct timespec64 *atime)
>  {
>  	struct ceph_inode_info *ci = ceph_inode(inode);
> +	struct timespec64 ictime = inode_get_ctime(inode);
>  	int warn = 0;
>  
>  	if (issued & (CEPH_CAP_FILE_EXCL|
> @@ -696,11 +697,12 @@ void ceph_fill_file_time(struct inode *inode, int issued,
>  		      CEPH_CAP_AUTH_EXCL|
>  		      CEPH_CAP_XATTR_EXCL)) {
>  		if (ci->i_version == 0 ||
> -		    timespec64_compare(ctime, &inode->i_ctime) > 0) {
> +		    timespec64_compare(ctime, &ictime) > 0) {
>  			dout("ctime %lld.%09ld -> %lld.%09ld inc w/ cap\n",
> -			     inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
> +			     inode_get_ctime(inode).tv_sec,
> +			     inode_get_ctime(inode).tv_nsec,

I think here you can use ictime instead of inode_get_ctime(inode).
Otherwise feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>



								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 31/92] coda: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 31/92] coda: " Jeff Layton
@ 2023-07-06 10:54     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:54 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jan Harkes, coda, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, codalist

On Wed 05-07-23 15:00:56, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/coda/coda_linux.c | 3 ++-
>  fs/coda/dir.c        | 2 +-
>  fs/coda/file.c       | 2 +-
>  fs/coda/inode.c      | 2 +-
>  4 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
> index 903ca8fa4b9b..ae023853a98f 100644
> --- a/fs/coda/coda_linux.c
> +++ b/fs/coda/coda_linux.c
> @@ -127,7 +127,8 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
>  	if (attr->va_mtime.tv_sec != -1)
>  		inode->i_mtime = coda_to_timespec64(attr->va_mtime);
>          if (attr->va_ctime.tv_sec != -1)
> -		inode->i_ctime = coda_to_timespec64(attr->va_ctime);
> +		inode_set_ctime_to_ts(inode,
> +				      coda_to_timespec64(attr->va_ctime));
>  }
>  
>  
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index 8450b1bd354b..1d4f40048efc 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -111,7 +111,7 @@ static inline void coda_dir_update_mtime(struct inode *dir)
>  	/* optimistically we can also act as if our nose bleeds. The
>  	 * granularity of the mtime is coarse anyways so we might actually be
>  	 * right most of the time. Note: we only do this for directories. */
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  #endif
>  }
>  
> diff --git a/fs/coda/file.c b/fs/coda/file.c
> index 12b26bd13564..42346618b4ed 100644
> --- a/fs/coda/file.c
> +++ b/fs/coda/file.c
> @@ -84,7 +84,7 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
>  	ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos, 0);
>  	coda_inode->i_size = file_inode(host_file)->i_size;
>  	coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
> -	coda_inode->i_mtime = coda_inode->i_ctime = current_time(coda_inode);
> +	coda_inode->i_mtime = inode_set_ctime_current(coda_inode);
>  	inode_unlock(coda_inode);
>  	file_end_write(host_file);
>  
> diff --git a/fs/coda/inode.c b/fs/coda/inode.c
> index d661e6cf17ac..3e64679c1620 100644
> --- a/fs/coda/inode.c
> +++ b/fs/coda/inode.c
> @@ -269,7 +269,7 @@ int coda_setattr(struct mnt_idmap *idmap, struct dentry *de,
>  
>  	memset(&vattr, 0, sizeof(vattr)); 
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	coda_iattr_to_vattr(iattr, &vattr);
>  	vattr.va_type = C_VNON; /* cannot set type */
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 32/92] configfs: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 32/92] configfs: " Jeff Layton
@ 2023-07-06 10:54     ` Jan Kara
  2023-07-06 22:12       ` Joel Becker
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:54 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Joel Becker, Christoph Hellwig, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:00:57, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/configfs/inode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
> index 1c15edbe70ff..fbdcb3582926 100644
> --- a/fs/configfs/inode.c
> +++ b/fs/configfs/inode.c
> @@ -88,8 +88,7 @@ int configfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  static inline void set_default_inode_attr(struct inode * inode, umode_t mode)
>  {
>  	inode->i_mode = mode;
> -	inode->i_atime = inode->i_mtime =
> -		inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  }
>  
>  static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
> @@ -99,7 +98,7 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
>  	inode->i_gid = iattr->ia_gid;
>  	inode->i_atime = iattr->ia_atime;
>  	inode->i_mtime = iattr->ia_mtime;
> -	inode->i_ctime = iattr->ia_ctime;
> +	inode_set_ctime_to_ts(inode, iattr->ia_ctime);
>  }
>  
>  struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent *sd,
> @@ -172,7 +171,7 @@ struct inode *configfs_create(struct dentry *dentry, umode_t mode)
>  		return ERR_PTR(-ENOMEM);
>  
>  	p_inode = d_inode(dentry->d_parent);
> -	p_inode->i_mtime = p_inode->i_ctime = current_time(p_inode);
> +	p_inode->i_mtime = inode_set_ctime_current(p_inode);
>  	configfs_set_inode_lock_class(sd, inode);
>  	return inode;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 33/92] cramfs: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 33/92] cramfs: " Jeff Layton
@ 2023-07-06 10:55     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:55 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Nicolas Pitre, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:00:58, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Nicolas Pitre <nico@fluxnic.net>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/cramfs/inode.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
> index 27c6597aa1be..e755b2223936 100644
> --- a/fs/cramfs/inode.c
> +++ b/fs/cramfs/inode.c
> @@ -133,7 +133,8 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
>  	}
>  
>  	/* Struct copy intentional */
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime;
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_to_ts(inode,
> +								zerotime);
>  	/* inode->i_nlink is left 1 - arguably wrong for directories,
>  	   but it's the best we can do without reading the directory
>  	   contents.  1 yields the right result in GNU find, even
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 34/92] debugfs: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 34/92] debugfs: " Jeff Layton
@ 2023-07-06 10:55     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:55 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Greg Kroah-Hartman, Rafael J. Wysocki,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:00:59, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/debugfs/inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index 3f81f73c241a..83e57e9f9fa0 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -72,8 +72,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb)
>  	struct inode *inode = new_inode(sb);
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
> -		inode->i_atime = inode->i_mtime =
> -			inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  	return inode;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 35/92] devpts: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 35/92] devpts: " Jeff Layton
@ 2023-07-06 10:56     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:56 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:00, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/devpts/inode.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index fe3db0eda8e4..5ede89880911 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -338,7 +338,7 @@ static int mknod_ptmx(struct super_block *sb)
>  	}
>  
>  	inode->i_ino = 2;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  
>  	mode = S_IFCHR|opts->ptmxmode;
>  	init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
> @@ -451,7 +451,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
>  	if (!inode)
>  		goto fail;
>  	inode->i_ino = 1;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
>  	inode->i_op = &simple_dir_inode_operations;
>  	inode->i_fop = &simple_dir_operations;
> @@ -560,7 +560,7 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
>  	inode->i_ino = index + 3;
>  	inode->i_uid = opts->setuid ? opts->uid : current_fsuid();
>  	inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	init_special_inode(inode, S_IFCHR|opts->mode, MKDEV(UNIX98_PTY_SLAVE_MAJOR, index));
>  
>  	sprintf(s, "%d", index);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 36/92] ecryptfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 36/92] ecryptfs: " Jeff Layton
@ 2023-07-06 10:56     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:56 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Tyler Hicks, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, ecryptfs

On Wed 05-07-23 15:01:01, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ecryptfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 83274915ba6d..b491bb239c8f 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -148,7 +148,7 @@ static int ecryptfs_do_unlink(struct inode *dir, struct dentry *dentry,
>  	}
>  	fsstack_copy_attr_times(dir, lower_dir);
>  	set_nlink(inode, ecryptfs_inode_to_lower(inode)->i_nlink);
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  out_unlock:
>  	dput(lower_dentry);
>  	inode_unlock(lower_dir);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 37/92] efivarfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 37/92] efivarfs: " Jeff Layton
@ 2023-07-06 10:57     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:57 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jeremy Kerr, Ard Biesheuvel, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-efi

On Wed 05-07-23 15:01:02, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/efivarfs/file.c  | 2 +-
>  fs/efivarfs/inode.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
> index 375576111dc3..59b52718a3a2 100644
> --- a/fs/efivarfs/file.c
> +++ b/fs/efivarfs/file.c
> @@ -51,7 +51,7 @@ static ssize_t efivarfs_file_write(struct file *file,
>  	} else {
>  		inode_lock(inode);
>  		i_size_write(inode, datasize + sizeof(attributes));
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		inode_unlock(inode);
>  	}
>  
> diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
> index b973a2c03dde..db9231f0e77b 100644
> --- a/fs/efivarfs/inode.c
> +++ b/fs/efivarfs/inode.c
> @@ -25,7 +25,7 @@ struct inode *efivarfs_get_inode(struct super_block *sb,
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
>  		inode->i_mode = mode;
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		inode->i_flags = is_removable ? 0 : S_IMMUTABLE;
>  		switch (mode & S_IFMT) {
>  		case S_IFREG:
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 38/92] efs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 38/92] efs: " Jeff Layton
@ 2023-07-06 10:57     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 10:57 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:03, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/efs/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/efs/inode.c b/fs/efs/inode.c
> index 3ba94bb005a6..3789d22ba501 100644
> --- a/fs/efs/inode.c
> +++ b/fs/efs/inode.c
> @@ -105,8 +105,8 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
>  	inode->i_size  = be32_to_cpu(efs_inode->di_size);
>  	inode->i_atime.tv_sec = be32_to_cpu(efs_inode->di_atime);
>  	inode->i_mtime.tv_sec = be32_to_cpu(efs_inode->di_mtime);
> -	inode->i_ctime.tv_sec = be32_to_cpu(efs_inode->di_ctime);
> -	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(inode, be32_to_cpu(efs_inode->di_ctime), 0);
> +	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 0;
>  
>  	/* this is the number of blocks in the file */
>  	if (inode->i_size == 0) {
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 39/92] erofs: convert to ctime accessor functions
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-06 11:00       ` Jan Kara
  -1 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:00 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-erofs

On Wed 05-07-23 15:01:04, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Gao Xiang <xiang@kernel.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Just one nit below:

> @@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
>  		vi->chunkbits = sb->s_blocksize_bits +
>  			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
>  	}
> -	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
> -	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
> -	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
> -	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
> +	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
> +	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
> +	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> +	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;

Isn't this just longer way to write:

	inode->i_atime = inode->i_mtime = inode_get_ctime(inode);

?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 39/92] erofs: convert to ctime accessor functions
@ 2023-07-06 11:00       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:00 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jan Kara, linux-kernel, linux-fsdevel, Yue Hu,
	Al Viro, linux-erofs

On Wed 05-07-23 15:01:04, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Gao Xiang <xiang@kernel.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Just one nit below:

> @@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
>  		vi->chunkbits = sb->s_blocksize_bits +
>  			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
>  	}
> -	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
> -	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
> -	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
> -	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
> +	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
> +	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
> +	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> +	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;

Isn't this just longer way to write:

	inode->i_atime = inode->i_mtime = inode_get_ctime(inode);

?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 40/92] exfat: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 40/92] exfat: " Jeff Layton
@ 2023-07-06 11:01     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:01 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Namjae Jeon, Sungjong Seo, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:05, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/exfat/file.c  |  4 ++--
>  fs/exfat/inode.c |  6 +++---
>  fs/exfat/namei.c | 21 +++++++++------------
>  fs/exfat/super.c |  3 +--
>  4 files changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/exfat/file.c b/fs/exfat/file.c
> index 3cbd270e0cba..f40ecfeee3a4 100644
> --- a/fs/exfat/file.c
> +++ b/fs/exfat/file.c
> @@ -22,7 +22,7 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
>  	if (err)
>  		return err;
>  
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	if (!IS_SYNC(inode))
> @@ -290,7 +290,7 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  	}
>  
>  	if (attr->ia_valid & ATTR_SIZE)
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	setattr_copy(&nop_mnt_idmap, inode, attr);
>  	exfat_truncate_atime(&inode->i_atime);
> diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
> index 481dd338f2b8..13329baeafbc 100644
> --- a/fs/exfat/inode.c
> +++ b/fs/exfat/inode.c
> @@ -355,7 +355,7 @@ static void exfat_write_failed(struct address_space *mapping, loff_t to)
>  
>  	if (to > i_size_read(inode)) {
>  		truncate_pagecache(inode, i_size_read(inode));
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		exfat_truncate(inode);
>  	}
>  }
> @@ -398,7 +398,7 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,
>  		exfat_write_failed(mapping, pos+len);
>  
>  	if (!(err < 0) && !(ei->attr & ATTR_ARCHIVE)) {
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		ei->attr |= ATTR_ARCHIVE;
>  		mark_inode_dirty(inode);
>  	}
> @@ -577,7 +577,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
>  
>  	inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9;
>  	inode->i_mtime = info->mtime;
> -	inode->i_ctime = info->mtime;
> +	inode_set_ctime_to_ts(inode, info->mtime);
>  	ei->i_crtime = info->crtime;
>  	inode->i_atime = info->atime;
>  
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index e91022ff80ef..c007de6ac1c7 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -569,7 +569,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
>  		goto unlock;
>  
>  	inode_inc_iversion(dir);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	if (IS_DIRSYNC(dir))
>  		exfat_sync_inode(dir);
>  	else
> @@ -582,8 +582,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
>  		goto unlock;
>  
>  	inode_inc_iversion(inode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime =
> -		EXFAT_I(inode)->i_crtime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
>  	exfat_truncate_atime(&inode->i_atime);
>  	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
>  
> @@ -817,7 +816,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
>  	ei->dir.dir = DIR_DELETED;
>  
>  	inode_inc_iversion(dir);
> -	dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
>  	exfat_truncate_atime(&dir->i_atime);
>  	if (IS_DIRSYNC(dir))
>  		exfat_sync_inode(dir);
> @@ -825,7 +824,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
>  		mark_inode_dirty(dir);
>  
>  	clear_nlink(inode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	exfat_truncate_atime(&inode->i_atime);
>  	exfat_unhash_inode(inode);
>  	exfat_d_version_set(dentry, inode_query_iversion(dir));
> @@ -852,7 +851,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  		goto unlock;
>  
>  	inode_inc_iversion(dir);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	if (IS_DIRSYNC(dir))
>  		exfat_sync_inode(dir);
>  	else
> @@ -866,8 +865,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  		goto unlock;
>  
>  	inode_inc_iversion(inode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime =
> -		EXFAT_I(inode)->i_crtime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
>  	exfat_truncate_atime(&inode->i_atime);
>  	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
>  
> @@ -979,7 +977,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
>  	ei->dir.dir = DIR_DELETED;
>  
>  	inode_inc_iversion(dir);
> -	dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
>  	exfat_truncate_atime(&dir->i_atime);
>  	if (IS_DIRSYNC(dir))
>  		exfat_sync_inode(dir);
> @@ -988,7 +986,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
>  	drop_nlink(dir);
>  
>  	clear_nlink(inode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	exfat_truncate_atime(&inode->i_atime);
>  	exfat_unhash_inode(inode);
>  	exfat_d_version_set(dentry, inode_query_iversion(dir));
> @@ -1353,8 +1351,7 @@ static int exfat_rename(struct mnt_idmap *idmap,
>  			exfat_warn(sb, "abnormal access to an inode dropped");
>  			WARN_ON(new_inode->i_nlink == 0);
>  		}
> -		new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
> -			current_time(new_inode);
> +		EXFAT_I(new_inode)->i_crtime = inode_set_ctime_current(new_inode);
>  	}
>  
>  unlock:
> diff --git a/fs/exfat/super.c b/fs/exfat/super.c
> index 8c32460e031e..8e0ca4b0fc8f 100644
> --- a/fs/exfat/super.c
> +++ b/fs/exfat/super.c
> @@ -379,8 +379,7 @@ static int exfat_read_root(struct inode *inode)
>  	ei->i_size_ondisk = i_size_read(inode);
>  
>  	exfat_save_attr(inode, ATTR_SUBDIR);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
> -		current_time(inode);
> +	inode->i_mtime = inode->i_atime = ei->i_crtime = inode_set_ctime_current(inode);
>  	exfat_truncate_atime(&inode->i_atime);
>  	return 0;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 41/92] ext2: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 41/92] ext2: " Jeff Layton
@ 2023-07-06 11:03     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:03 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jan Kara, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-ext4

On Wed 05-07-23 15:01:06, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext2/acl.c    |  2 +-
>  fs/ext2/dir.c    |  6 +++---
>  fs/ext2/ialloc.c |  2 +-
>  fs/ext2/inode.c  | 10 +++++-----
>  fs/ext2/ioctl.c  |  4 ++--
>  fs/ext2/namei.c  |  8 ++++----
>  fs/ext2/super.c  |  2 +-
>  fs/ext2/xattr.c  |  2 +-
>  8 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
> index 82b17d7fc93f..7e54c31589c7 100644
> --- a/fs/ext2/acl.c
> +++ b/fs/ext2/acl.c
> @@ -237,7 +237,7 @@ ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
>  	error = __ext2_set_acl(inode, acl, type);
>  	if (!error && update_mode) {
>  		inode->i_mode = mode;
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		mark_inode_dirty(inode);
>  	}
>  	return error;
> diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
> index 42db804794bd..b335f17f682f 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 = dir->i_ctime = current_time(dir);
> +		dir->i_mtime = 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 = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = 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_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = 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 34cd5dc1da23..c24d0de95a83 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->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(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 75983215c7a1..1259995977d2 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -595,7 +595,7 @@ static void ext2_splice_branch(struct inode *inode,
>  	if (where->bh)
>  		mark_buffer_dirty_inode(where->bh, inode);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  }
>  
> @@ -1287,7 +1287,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->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	if (inode_needs_sync(inode)) {
>  		sync_mapping_buffers(inode->i_mapping);
>  		sync_inode_metadata(inode, 1);
> @@ -1409,9 +1409,9 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
>  	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->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime);
> +	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 = inode->i_ctime.tv_nsec = 0;
> +	inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 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
> @@ -1541,7 +1541,7 @@ 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->i_ctime.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_blocks = cpu_to_le32(inode->i_blocks);
> diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
> index cc87d413eb43..44e04484e570 100644
> --- a/fs/ext2/ioctl.c
> +++ b/fs/ext2/ioctl.c
> @@ -44,7 +44,7 @@ int ext2_fileattr_set(struct mnt_idmap *idmap,
>  		(fa->flags & EXT2_FL_USER_MODIFIABLE);
>  
>  	ext2_set_inode_flags(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	return 0;
> @@ -77,7 +77,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  		}
>  
>  		inode_lock(inode);
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		inode->i_generation = generation;
>  		inode_unlock(inode);
>  
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 937dd8f60f96..059517068adc 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -211,7 +211,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
>  	if (err)
>  		return err;
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	inode_inc_link_count(inode);
>  	ihold(inode);
>  
> @@ -291,7 +291,7 @@ static int ext2_unlink(struct inode *dir, struct dentry *dentry)
>  	if (err)
>  		goto out;
>  
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  	inode_dec_link_count(inode);
>  	err = 0;
>  out:
> @@ -367,7 +367,7 @@ static int ext2_rename (struct mnt_idmap * idmap,
>  		ext2_put_page(new_page, new_de);
>  		if (err)
>  			goto out_dir;
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		if (dir_de)
>  			drop_nlink(new_inode);
>  		inode_dec_link_count(new_inode);
> @@ -383,7 +383,7 @@ static int ext2_rename (struct mnt_idmap * idmap,
>  	 * Like most other Unix systems, set the ctime for inodes on a
>   	 * rename.
>  	 */
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	mark_inode_dirty(old_inode);
>  
>  	err = ext2_delete_entry(old_de, old_page);
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 2959afc7541c..aaf3e3e88cb2 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->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	return len - towrite;
>  }
> diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
> index 8906ba479aaf..1c9187188d68 100644
> --- a/fs/ext2/xattr.c
> +++ b/fs/ext2/xattr.c
> @@ -773,7 +773,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
>  
>  	/* Update the inode. */
>  	EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode)) {
>  		error = sync_inode_metadata(inode, 1);
>  		/* In case sync failed due to ENOSPC the inode was actually
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 43/92] f2fs: convert to ctime accessor functions
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-06 11:18       ` Jan Kara
  -1 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:18 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jaegeuk Kim, Chao Yu, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-f2fs-devel

On Wed 05-07-23 15:01:08, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/f2fs/dir.c      |  8 ++++----
>  fs/f2fs/f2fs.h     |  4 +++-
>  fs/f2fs/file.c     | 20 ++++++++++----------
>  fs/f2fs/inline.c   |  2 +-
>  fs/f2fs/inode.c    | 10 +++++-----
>  fs/f2fs/namei.c    | 12 ++++++------
>  fs/f2fs/recovery.c |  4 ++--
>  fs/f2fs/super.c    |  2 +-
>  fs/f2fs/xattr.c    |  2 +-
>  9 files changed, 33 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index d635c58cf5a3..8aa29fe2e87b 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -455,7 +455,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
>  	de->file_type = fs_umode_to_ftype(inode->i_mode);
>  	set_page_dirty(page);
>  
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  	f2fs_put_page(page, 1);
>  }
> @@ -609,7 +609,7 @@ void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,
>  			f2fs_i_links_write(dir, true);
>  		clear_inode_flag(inode, FI_NEW_INODE);
>  	}
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  
>  	if (F2FS_I(dir)->i_current_depth != current_depth)
> @@ -858,7 +858,7 @@ void f2fs_drop_nlink(struct inode *dir, struct inode *inode)
>  
>  	if (S_ISDIR(inode->i_mode))
>  		f2fs_i_links_write(dir, false);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  
>  	f2fs_i_links_write(inode, false);
>  	if (S_ISDIR(inode->i_mode)) {
> @@ -919,7 +919,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
>  	}
>  	f2fs_put_page(page, 1);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  
>  	if (inode)
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index c7cb2177b252..e18272ae3119 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3303,9 +3303,11 @@ static inline void clear_file(struct inode *inode, int type)
>  
>  static inline bool f2fs_is_time_consistent(struct inode *inode)
>  {
> +	struct timespec64 ctime = inode_get_ctime(inode);
> +
>  	if (!timespec64_equal(F2FS_I(inode)->i_disk_time, &inode->i_atime))
>  		return false;
> -	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &inode->i_ctime))
> +	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &ctime))
>  		return false;
>  	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 2, &inode->i_mtime))
>  		return false;
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 093039dee992..b018800223c4 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -794,7 +794,7 @@ int f2fs_truncate(struct inode *inode)
>  	if (err)
>  		return err;
>  
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, false);
>  	return 0;
>  }
> @@ -905,7 +905,7 @@ static void __setattr_copy(struct mnt_idmap *idmap,
>  	if (ia_valid & ATTR_MTIME)
>  		inode->i_mtime = attr->ia_mtime;
>  	if (ia_valid & ATTR_CTIME)
> -		inode->i_ctime = attr->ia_ctime;
> +		inode_set_ctime_to_ts(inode, attr->ia_ctime);
>  	if (ia_valid & ATTR_MODE) {
>  		umode_t mode = attr->ia_mode;
>  		vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
> @@ -1008,7 +1008,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  			return err;
>  
>  		spin_lock(&F2FS_I(inode)->i_size_lock);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		F2FS_I(inode)->last_disk_size = i_size_read(inode);
>  		spin_unlock(&F2FS_I(inode)->i_size_lock);
>  	}
> @@ -1835,7 +1835,7 @@ static long f2fs_fallocate(struct file *file, int mode,
>  	}
>  
>  	if (!ret) {
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		f2fs_mark_inode_dirty_sync(inode, false);
>  		f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
>  	}
> @@ -1937,7 +1937,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
>  	else
>  		clear_inode_flag(inode, FI_PROJ_INHERIT);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	f2fs_set_inode_flags(inode);
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  	return 0;
> @@ -2874,10 +2874,10 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
>  	if (ret)
>  		goto out_unlock;
>  
> -	src->i_mtime = src->i_ctime = current_time(src);
> +	src->i_mtime = inode_set_ctime_current(src);
>  	f2fs_mark_inode_dirty_sync(src, false);
>  	if (src != dst) {
> -		dst->i_mtime = dst->i_ctime = current_time(dst);
> +		dst->i_mtime = inode_set_ctime_current(dst);
>  		f2fs_mark_inode_dirty_sync(dst, false);
>  	}
>  	f2fs_update_time(sbi, REQ_TIME);
> @@ -3073,7 +3073,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)
>  		goto out_unlock;
>  
>  	fi->i_projid = kprojid;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  out_unlock:
>  	f2fs_unlock_op(sbi);
> @@ -3511,7 +3511,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>  	}
>  
>  	set_inode_flag(inode, FI_COMPRESS_RELEASED);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  
>  	f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
> @@ -3710,7 +3710,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
>  
>  	if (ret >= 0) {
>  		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		f2fs_mark_inode_dirty_sync(inode, true);
>  	}
>  unlock_inode:
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 4638fee16a91..88fc9208ffa7 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -698,7 +698,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
>  	set_page_dirty(page);
>  	f2fs_put_page(page, 1);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  
>  	if (inode)
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index 09e986b050c6..c1c2ba9f28e5 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -403,7 +403,7 @@ static void init_idisk_time(struct inode *inode)
>  	struct f2fs_inode_info *fi = F2FS_I(inode);
>  
>  	fi->i_disk_time[0] = inode->i_atime;
> -	fi->i_disk_time[1] = inode->i_ctime;
> +	fi->i_disk_time[1] = inode_get_ctime(inode);
>  	fi->i_disk_time[2] = inode->i_mtime;
>  }
>  
> @@ -434,10 +434,10 @@ static int do_read_inode(struct inode *inode)
>  	inode->i_blocks = SECTOR_FROM_BLOCK(le64_to_cpu(ri->i_blocks) - 1);
>  
>  	inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime);
> -	inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime);
> +	inode_set_ctime(inode, le64_to_cpu(ri->i_ctime),
> +			le32_to_cpu(ri->i_ctime_nsec));
>  	inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime);
>  	inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
>  	inode->i_generation = le32_to_cpu(ri->i_generation);
>  	if (S_ISDIR(inode->i_mode))
> @@ -714,10 +714,10 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
>  	set_raw_inline(inode, ri);
>  
>  	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
> -	ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> +	ri->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
>  	ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
>  	ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> -	ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	ri->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  	if (S_ISDIR(inode->i_mode))
>  		ri->i_current_depth =
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index bee0568888da..193b22a2d6bf 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -243,7 +243,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
>  
>  	inode->i_ino = ino;
>  	inode->i_blocks = 0;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	F2FS_I(inode)->i_crtime = inode->i_mtime;
>  	inode->i_generation = get_random_u32();
>  
> @@ -420,7 +420,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
>  
>  	f2fs_balance_fs(sbi, true);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ihold(inode);
>  
>  	set_inode_flag(inode, FI_INC_LINK);
> @@ -1052,7 +1052,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		f2fs_set_link(new_dir, new_entry, new_page, old_inode);
>  		new_page = NULL;
>  
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		f2fs_down_write(&F2FS_I(new_inode)->i_sem);
>  		if (old_dir_entry)
>  			f2fs_i_links_write(new_inode, false);
> @@ -1086,7 +1086,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		f2fs_i_pino_write(old_inode, new_dir->i_ino);
>  	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
>  
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	f2fs_mark_inode_dirty_sync(old_inode, false);
>  
>  	f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
> @@ -1251,7 +1251,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		f2fs_i_pino_write(old_inode, new_dir->i_ino);
>  	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
>  
> -	old_dir->i_ctime = current_time(old_dir);
> +	inode_set_ctime_current(old_dir);
>  	if (old_nlink) {
>  		f2fs_down_write(&F2FS_I(old_dir)->i_sem);
>  		f2fs_i_links_write(old_dir, old_nlink > 0);
> @@ -1270,7 +1270,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		f2fs_i_pino_write(new_inode, old_dir->i_ino);
>  	f2fs_up_write(&F2FS_I(new_inode)->i_sem);
>  
> -	new_dir->i_ctime = current_time(new_dir);
> +	inode_set_ctime_current(new_dir);
>  	if (new_nlink) {
>  		f2fs_down_write(&F2FS_I(new_dir)->i_sem);
>  		f2fs_i_links_write(new_dir, new_nlink > 0);
> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> index 4e7d4ceeb084..b8637e88d94f 100644
> --- a/fs/f2fs/recovery.c
> +++ b/fs/f2fs/recovery.c
> @@ -321,10 +321,10 @@ static int recover_inode(struct inode *inode, struct page *page)
>  
>  	f2fs_i_size_write(inode, le64_to_cpu(raw->i_size));
>  	inode->i_atime.tv_sec = le64_to_cpu(raw->i_atime);
> -	inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime);
> +	inode_set_ctime(inode, le64_to_cpu(raw->i_ctime),
> +			le32_to_cpu(raw->i_ctime_nsec));
>  	inode->i_mtime.tv_sec = le64_to_cpu(raw->i_mtime);
>  	inode->i_atime.tv_nsec = le32_to_cpu(raw->i_atime_nsec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
>  
>  	F2FS_I(inode)->i_advise = raw->i_advise;
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index ca31163da00a..28aeffc0048c 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2703,7 +2703,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
>  
>  	if (len == towrite)
>  		return err;
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, false);
>  	return len - towrite;
>  }
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 476b186b90a6..4ae93e1df421 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -764,7 +764,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
>  same:
>  	if (is_inode_flag_set(inode, FI_ACL_MODE)) {
>  		inode->i_mode = F2FS_I(inode)->i_acl_mode;
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		clear_inode_flag(inode, FI_ACL_MODE);
>  	}
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [f2fs-dev] [PATCH v2 43/92] f2fs: convert to ctime accessor functions
@ 2023-07-06 11:18       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:18 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jan Kara, linux-kernel, linux-f2fs-devel,
	Al Viro, linux-fsdevel, Jaegeuk Kim

On Wed 05-07-23 15:01:08, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/f2fs/dir.c      |  8 ++++----
>  fs/f2fs/f2fs.h     |  4 +++-
>  fs/f2fs/file.c     | 20 ++++++++++----------
>  fs/f2fs/inline.c   |  2 +-
>  fs/f2fs/inode.c    | 10 +++++-----
>  fs/f2fs/namei.c    | 12 ++++++------
>  fs/f2fs/recovery.c |  4 ++--
>  fs/f2fs/super.c    |  2 +-
>  fs/f2fs/xattr.c    |  2 +-
>  9 files changed, 33 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index d635c58cf5a3..8aa29fe2e87b 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -455,7 +455,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
>  	de->file_type = fs_umode_to_ftype(inode->i_mode);
>  	set_page_dirty(page);
>  
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  	f2fs_put_page(page, 1);
>  }
> @@ -609,7 +609,7 @@ void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,
>  			f2fs_i_links_write(dir, true);
>  		clear_inode_flag(inode, FI_NEW_INODE);
>  	}
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  
>  	if (F2FS_I(dir)->i_current_depth != current_depth)
> @@ -858,7 +858,7 @@ void f2fs_drop_nlink(struct inode *dir, struct inode *inode)
>  
>  	if (S_ISDIR(inode->i_mode))
>  		f2fs_i_links_write(dir, false);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  
>  	f2fs_i_links_write(inode, false);
>  	if (S_ISDIR(inode->i_mode)) {
> @@ -919,7 +919,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
>  	}
>  	f2fs_put_page(page, 1);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  
>  	if (inode)
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index c7cb2177b252..e18272ae3119 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3303,9 +3303,11 @@ static inline void clear_file(struct inode *inode, int type)
>  
>  static inline bool f2fs_is_time_consistent(struct inode *inode)
>  {
> +	struct timespec64 ctime = inode_get_ctime(inode);
> +
>  	if (!timespec64_equal(F2FS_I(inode)->i_disk_time, &inode->i_atime))
>  		return false;
> -	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &inode->i_ctime))
> +	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 1, &ctime))
>  		return false;
>  	if (!timespec64_equal(F2FS_I(inode)->i_disk_time + 2, &inode->i_mtime))
>  		return false;
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 093039dee992..b018800223c4 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -794,7 +794,7 @@ int f2fs_truncate(struct inode *inode)
>  	if (err)
>  		return err;
>  
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, false);
>  	return 0;
>  }
> @@ -905,7 +905,7 @@ static void __setattr_copy(struct mnt_idmap *idmap,
>  	if (ia_valid & ATTR_MTIME)
>  		inode->i_mtime = attr->ia_mtime;
>  	if (ia_valid & ATTR_CTIME)
> -		inode->i_ctime = attr->ia_ctime;
> +		inode_set_ctime_to_ts(inode, attr->ia_ctime);
>  	if (ia_valid & ATTR_MODE) {
>  		umode_t mode = attr->ia_mode;
>  		vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
> @@ -1008,7 +1008,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  			return err;
>  
>  		spin_lock(&F2FS_I(inode)->i_size_lock);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		F2FS_I(inode)->last_disk_size = i_size_read(inode);
>  		spin_unlock(&F2FS_I(inode)->i_size_lock);
>  	}
> @@ -1835,7 +1835,7 @@ static long f2fs_fallocate(struct file *file, int mode,
>  	}
>  
>  	if (!ret) {
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		f2fs_mark_inode_dirty_sync(inode, false);
>  		f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
>  	}
> @@ -1937,7 +1937,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
>  	else
>  		clear_inode_flag(inode, FI_PROJ_INHERIT);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	f2fs_set_inode_flags(inode);
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  	return 0;
> @@ -2874,10 +2874,10 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
>  	if (ret)
>  		goto out_unlock;
>  
> -	src->i_mtime = src->i_ctime = current_time(src);
> +	src->i_mtime = inode_set_ctime_current(src);
>  	f2fs_mark_inode_dirty_sync(src, false);
>  	if (src != dst) {
> -		dst->i_mtime = dst->i_ctime = current_time(dst);
> +		dst->i_mtime = inode_set_ctime_current(dst);
>  		f2fs_mark_inode_dirty_sync(dst, false);
>  	}
>  	f2fs_update_time(sbi, REQ_TIME);
> @@ -3073,7 +3073,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)
>  		goto out_unlock;
>  
>  	fi->i_projid = kprojid;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  out_unlock:
>  	f2fs_unlock_op(sbi);
> @@ -3511,7 +3511,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>  	}
>  
>  	set_inode_flag(inode, FI_COMPRESS_RELEASED);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, true);
>  
>  	f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
> @@ -3710,7 +3710,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
>  
>  	if (ret >= 0) {
>  		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		f2fs_mark_inode_dirty_sync(inode, true);
>  	}
>  unlock_inode:
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 4638fee16a91..88fc9208ffa7 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -698,7 +698,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
>  	set_page_dirty(page);
>  	f2fs_put_page(page, 1);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	f2fs_mark_inode_dirty_sync(dir, false);
>  
>  	if (inode)
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index 09e986b050c6..c1c2ba9f28e5 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -403,7 +403,7 @@ static void init_idisk_time(struct inode *inode)
>  	struct f2fs_inode_info *fi = F2FS_I(inode);
>  
>  	fi->i_disk_time[0] = inode->i_atime;
> -	fi->i_disk_time[1] = inode->i_ctime;
> +	fi->i_disk_time[1] = inode_get_ctime(inode);
>  	fi->i_disk_time[2] = inode->i_mtime;
>  }
>  
> @@ -434,10 +434,10 @@ static int do_read_inode(struct inode *inode)
>  	inode->i_blocks = SECTOR_FROM_BLOCK(le64_to_cpu(ri->i_blocks) - 1);
>  
>  	inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime);
> -	inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime);
> +	inode_set_ctime(inode, le64_to_cpu(ri->i_ctime),
> +			le32_to_cpu(ri->i_ctime_nsec));
>  	inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime);
>  	inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
>  	inode->i_generation = le32_to_cpu(ri->i_generation);
>  	if (S_ISDIR(inode->i_mode))
> @@ -714,10 +714,10 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
>  	set_raw_inline(inode, ri);
>  
>  	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
> -	ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> +	ri->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
>  	ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
>  	ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> -	ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	ri->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  	if (S_ISDIR(inode->i_mode))
>  		ri->i_current_depth =
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index bee0568888da..193b22a2d6bf 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -243,7 +243,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
>  
>  	inode->i_ino = ino;
>  	inode->i_blocks = 0;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	F2FS_I(inode)->i_crtime = inode->i_mtime;
>  	inode->i_generation = get_random_u32();
>  
> @@ -420,7 +420,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
>  
>  	f2fs_balance_fs(sbi, true);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ihold(inode);
>  
>  	set_inode_flag(inode, FI_INC_LINK);
> @@ -1052,7 +1052,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		f2fs_set_link(new_dir, new_entry, new_page, old_inode);
>  		new_page = NULL;
>  
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		f2fs_down_write(&F2FS_I(new_inode)->i_sem);
>  		if (old_dir_entry)
>  			f2fs_i_links_write(new_inode, false);
> @@ -1086,7 +1086,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		f2fs_i_pino_write(old_inode, new_dir->i_ino);
>  	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
>  
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	f2fs_mark_inode_dirty_sync(old_inode, false);
>  
>  	f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
> @@ -1251,7 +1251,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		f2fs_i_pino_write(old_inode, new_dir->i_ino);
>  	f2fs_up_write(&F2FS_I(old_inode)->i_sem);
>  
> -	old_dir->i_ctime = current_time(old_dir);
> +	inode_set_ctime_current(old_dir);
>  	if (old_nlink) {
>  		f2fs_down_write(&F2FS_I(old_dir)->i_sem);
>  		f2fs_i_links_write(old_dir, old_nlink > 0);
> @@ -1270,7 +1270,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		f2fs_i_pino_write(new_inode, old_dir->i_ino);
>  	f2fs_up_write(&F2FS_I(new_inode)->i_sem);
>  
> -	new_dir->i_ctime = current_time(new_dir);
> +	inode_set_ctime_current(new_dir);
>  	if (new_nlink) {
>  		f2fs_down_write(&F2FS_I(new_dir)->i_sem);
>  		f2fs_i_links_write(new_dir, new_nlink > 0);
> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> index 4e7d4ceeb084..b8637e88d94f 100644
> --- a/fs/f2fs/recovery.c
> +++ b/fs/f2fs/recovery.c
> @@ -321,10 +321,10 @@ static int recover_inode(struct inode *inode, struct page *page)
>  
>  	f2fs_i_size_write(inode, le64_to_cpu(raw->i_size));
>  	inode->i_atime.tv_sec = le64_to_cpu(raw->i_atime);
> -	inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime);
> +	inode_set_ctime(inode, le64_to_cpu(raw->i_ctime),
> +			le32_to_cpu(raw->i_ctime_nsec));
>  	inode->i_mtime.tv_sec = le64_to_cpu(raw->i_mtime);
>  	inode->i_atime.tv_nsec = le32_to_cpu(raw->i_atime_nsec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(raw->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
>  
>  	F2FS_I(inode)->i_advise = raw->i_advise;
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index ca31163da00a..28aeffc0048c 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2703,7 +2703,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
>  
>  	if (len == towrite)
>  		return err;
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	f2fs_mark_inode_dirty_sync(inode, false);
>  	return len - towrite;
>  }
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 476b186b90a6..4ae93e1df421 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -764,7 +764,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
>  same:
>  	if (is_inode_flag_set(inode, FI_ACL_MODE)) {
>  		inode->i_mode = F2FS_I(inode)->i_acl_mode;
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		clear_inode_flag(inode, FI_ACL_MODE);
>  	}
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


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

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

* Re: [PATCH v2 45/92] freevxfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 45/92] freevxfs: " Jeff Layton
@ 2023-07-06 11:19     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:19 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Christoph Hellwig, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:10, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

									Honza

> ---
>  fs/freevxfs/vxfs_inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
> index ceb6a12649ba..ac5d43b164b5 100644
> --- a/fs/freevxfs/vxfs_inode.c
> +++ b/fs/freevxfs/vxfs_inode.c
> @@ -110,10 +110,9 @@ static inline void dip2vip_cpy(struct vxfs_sb_info *sbi,
>  	inode->i_size = vip->vii_size;
>  
>  	inode->i_atime.tv_sec = vip->vii_atime;
> -	inode->i_ctime.tv_sec = vip->vii_ctime;
> +	inode_set_ctime(inode, vip->vii_ctime, 0);
>  	inode->i_mtime.tv_sec = vip->vii_mtime;
>  	inode->i_atime.tv_nsec = 0;
> -	inode->i_ctime.tv_nsec = 0;
>  	inode->i_mtime.tv_nsec = 0;
>  
>  	inode->i_blocks = vip->vii_blocks;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 46/92] fuse: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 46/92] fuse: " Jeff Layton
@ 2023-07-06 11:20     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 11:20 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Miklos Szeredi, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:11, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/fuse/control.c |  2 +-
>  fs/fuse/dir.c     |  8 ++++----
>  fs/fuse/inode.c   | 16 ++++++++--------
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/fuse/control.c b/fs/fuse/control.c
> index 247ef4f76761..ab62e4624256 100644
> --- a/fs/fuse/control.c
> +++ b/fs/fuse/control.c
> @@ -235,7 +235,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
>  	inode->i_mode = mode;
>  	inode->i_uid = fc->user_id;
>  	inode->i_gid = fc->group_id;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	/* setting ->i_op to NULL is not allowed */
>  	if (iop)
>  		inode->i_op = iop;
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index f67bef9d83c4..672245ee0394 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -933,7 +933,7 @@ void fuse_flush_time_update(struct inode *inode)
>  static void fuse_update_ctime_in_cache(struct inode *inode)
>  {
>  	if (!IS_NOCMTIME(inode)) {
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		mark_inode_dirty_sync(inode);
>  		fuse_flush_time_update(inode);
>  	}
> @@ -1715,8 +1715,8 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
>  	inarg.mtimensec = inode->i_mtime.tv_nsec;
>  	if (fm->fc->minor >= 23) {
>  		inarg.valid |= FATTR_CTIME;
> -		inarg.ctime = inode->i_ctime.tv_sec;
> -		inarg.ctimensec = inode->i_ctime.tv_nsec;
> +		inarg.ctime = inode_get_ctime(inode).tv_sec;
> +		inarg.ctimensec = inode_get_ctime(inode).tv_nsec;
>  	}
>  	if (ff) {
>  		inarg.valid |= FATTR_FH;
> @@ -1857,7 +1857,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
>  		if (attr->ia_valid & ATTR_MTIME)
>  			inode->i_mtime = attr->ia_mtime;
>  		if (attr->ia_valid & ATTR_CTIME)
> -			inode->i_ctime = attr->ia_ctime;
> +			inode_set_ctime_to_ts(inode, attr->ia_ctime);
>  		/* FIXME: clear I_DIRTY_SYNC? */
>  	}
>  
> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index f19d748890f0..549358ffea8b 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -194,8 +194,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
>  		inode->i_mtime.tv_nsec  = attr->mtimensec;
>  	}
>  	if (!(cache_mask & STATX_CTIME)) {
> -		inode->i_ctime.tv_sec   = attr->ctime;
> -		inode->i_ctime.tv_nsec  = attr->ctimensec;
> +		inode_set_ctime(inode, attr->ctime, attr->ctimensec);
>  	}
>  
>  	if (attr->blksize != 0)
> @@ -259,8 +258,8 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
>  		attr->mtimensec = inode->i_mtime.tv_nsec;
>  	}
>  	if (cache_mask & STATX_CTIME) {
> -		attr->ctime = inode->i_ctime.tv_sec;
> -		attr->ctimensec = inode->i_ctime.tv_nsec;
> +		attr->ctime = inode_get_ctime(inode).tv_sec;
> +		attr->ctimensec = inode_get_ctime(inode).tv_nsec;
>  	}
>  
>  	if ((attr_version != 0 && fi->attr_version > attr_version) ||
> @@ -318,8 +317,7 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr,
>  	inode->i_size = attr->size;
>  	inode->i_mtime.tv_sec  = attr->mtime;
>  	inode->i_mtime.tv_nsec = attr->mtimensec;
> -	inode->i_ctime.tv_sec  = attr->ctime;
> -	inode->i_ctime.tv_nsec = attr->ctimensec;
> +	inode_set_ctime(inode, attr->ctime, attr->ctimensec);
>  	if (S_ISREG(inode->i_mode)) {
>  		fuse_init_common(inode);
>  		fuse_init_file_inode(inode, attr->flags);
> @@ -1401,16 +1399,18 @@ EXPORT_SYMBOL_GPL(fuse_dev_free);
>  static void fuse_fill_attr_from_inode(struct fuse_attr *attr,
>  				      const struct fuse_inode *fi)
>  {
> +	struct timespec64 ctime = inode_get_ctime(&fi->inode);
> +
>  	*attr = (struct fuse_attr){
>  		.ino		= fi->inode.i_ino,
>  		.size		= fi->inode.i_size,
>  		.blocks		= fi->inode.i_blocks,
>  		.atime		= fi->inode.i_atime.tv_sec,
>  		.mtime		= fi->inode.i_mtime.tv_sec,
> -		.ctime		= fi->inode.i_ctime.tv_sec,
> +		.ctime		= ctime.tv_sec,
>  		.atimensec	= fi->inode.i_atime.tv_nsec,
>  		.mtimensec	= fi->inode.i_mtime.tv_nsec,
> -		.ctimensec	= fi->inode.i_ctime.tv_nsec,
> +		.ctimensec	= ctime.tv_nsec,
>  		.mode		= fi->inode.i_mode,
>  		.nlink		= fi->inode.i_nlink,
>  		.uid		= fi->inode.i_uid.val,
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 44/92] fat: convert to ctime accessor functions
  2023-07-06  1:54     ` OGAWA Hirofumi
@ 2023-07-06 11:25       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 11:25 UTC (permalink / raw)
  To: OGAWA Hirofumi
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Thu, 2023-07-06 at 10:54 +0900, OGAWA Hirofumi wrote:
> Jeff Layton <jlayton@kernel.org> writes:
> 
> > @@ -1407,8 +1407,9 @@ static int fat_read_root(struct inode *inode)
> >  	MSDOS_I(inode)->mmu_private = inode->i_size;
> >  
> >  	fat_save_attrs(inode, ATTR_DIR);
> > -	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0;
> > -	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0;
> > +	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode_set_ctime(inode,
> > +									0, 0).tv_sec;
> > +	inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0;
> 
> Maybe, this should simply be
> 
> 	inode->i_mtime = inode->i_atime = inode_set_ctime(inode, 0, 0);
> 

Yes, that would be clearer. Chalk that one up to the automated
coccinelle conversion. I've fixed it in my ctime-next branch.

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 15/92] spufs: convert to ctime accessor functions
  2023-07-05 19:00     ` Jeff Layton
@ 2023-07-06 11:34       ` Arnd Bergmann
  -1 siblings, 0 replies; 208+ messages in thread
From: Arnd Bergmann @ 2023-07-06 11:34 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy
  Cc: Alexander Viro, Jan Kara, linux-fsdevel, linux-kernel, linuxppc-dev

On Wed, Jul 5, 2023, at 21:00, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
>
> Acked-by: Jeremy Kerr <jk@ozlabs.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH v2 15/92] spufs: convert to ctime accessor functions
@ 2023-07-06 11:34       ` Arnd Bergmann
  0 siblings, 0 replies; 208+ messages in thread
From: Arnd Bergmann @ 2023-07-06 11:34 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy
  Cc: linux-fsdevel, linuxppc-dev, Jan Kara, Alexander Viro, linux-kernel

On Wed, Jul 5, 2023, at 21:00, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
>
> Acked-by: Jeremy Kerr <jk@ozlabs.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH v2 12/92] exfat: convert to simple_rename_timestamp
  2023-07-06 10:39     ` Jan Kara
@ 2023-07-06 11:40       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 11:40 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Namjae Jeon, Sungjong Seo, Al Viro,
	linux-fsdevel, linux-kernel

On Thu, 2023-07-06 at 12:39 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:00:37, Jeff Layton wrote:
> > A rename potentially involves updating 4 different inode timestamps.
> > Convert to the new simple_rename_timestamp helper function.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  fs/exfat/namei.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> > index d9b46fa36bff..e91022ff80ef 100644
> > --- a/fs/exfat/namei.c
> > +++ b/fs/exfat/namei.c
> > @@ -1312,8 +1312,8 @@ static int exfat_rename(struct mnt_idmap *idmap,
> >  		goto unlock;
> >  
> >  	inode_inc_iversion(new_dir);
> > -	new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime =
> > -		EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
> > +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
> > +	EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
> 
> Hum, you loose atime update with this. Not that it would make sense to have
> it but it would probably deserve a comment in the changelog.
> 
> Also why you use current_time(new_dir) here instead of say inode->i_ctime?
> 

I think the atime update there is a mistake. A rename is not a "read"
operation. I'll note it in the changelog.

The i_crtime in exfat is the creation time (aka btime). I don't think it
matters much which source that ultimately comes from, but now I'm
wondering why it gets set here at all. Does exfat create a new inode
during a rename? If not, then the i_crtime updates here should probably
be removed.


> >  	exfat_truncate_atime(&new_dir->i_atime);
> >  	if (IS_DIRSYNC(new_dir))
> >  		exfat_sync_inode(new_dir);
> > @@ -1336,7 +1336,6 @@ static int exfat_rename(struct mnt_idmap *idmap,
> >  	}
> >  
> >  	inode_inc_iversion(old_dir);
> > -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> >  	if (IS_DIRSYNC(old_dir))
> >  		exfat_sync_inode(old_dir);
> >  	else
> 
> Also there is:
> 
>                 new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
>                         current_time(new_inode);
> 
> in exfat_rename() from which you can remove the ctime update?
> 

Yeah, that should be removed too. I'll fix that in my tree. The i_crtime
update here looks pretty suspicious too, fwiw.

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 30/92] ceph: convert to ctime accessor functions
  2023-07-06 10:53     ` Jan Kara
@ 2023-07-06 11:47       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 11:47 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Xiubo Li, Ilya Dryomov, Al Viro,
	linux-fsdevel, linux-kernel, ceph-devel

On Thu, 2023-07-06 at 12:53 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:00:55, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Reviewed-by: Xiubo Li <xiubli@redhat.com>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Just one nit below:
> 
> > @@ -688,6 +688,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,
> >  			 struct timespec64 *mtime, struct timespec64 *atime)
> >  {
> >  	struct ceph_inode_info *ci = ceph_inode(inode);
> > +	struct timespec64 ictime = inode_get_ctime(inode);
> >  	int warn = 0;
> >  
> >  	if (issued & (CEPH_CAP_FILE_EXCL|
> > @@ -696,11 +697,12 @@ void ceph_fill_file_time(struct inode *inode, int issued,
> >  		      CEPH_CAP_AUTH_EXCL|
> >  		      CEPH_CAP_XATTR_EXCL)) {
> >  		if (ci->i_version == 0 ||
> > -		    timespec64_compare(ctime, &inode->i_ctime) > 0) {
> > +		    timespec64_compare(ctime, &ictime) > 0) {
> >  			dout("ctime %lld.%09ld -> %lld.%09ld inc w/ cap\n",
> > -			     inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
> > +			     inode_get_ctime(inode).tv_sec,
> > +			     inode_get_ctime(inode).tv_nsec,
> 
> I think here you can use ictime instead of inode_get_ctime(inode).
> Otherwise feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 

Thanks. Fixed in my tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 39/92] erofs: convert to ctime accessor functions
  2023-07-06 11:00       ` Jan Kara
@ 2023-07-06 11:53         ` Jeff Layton
  -1 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 11:53 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Al Viro, linux-fsdevel, linux-kernel, linux-erofs

On Thu, 2023-07-06 at 13:00 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:04, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Acked-by: Gao Xiang <xiang@kernel.org>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Just one nit below:
> 
> > @@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
> >  		vi->chunkbits = sb->s_blocksize_bits +
> >  			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
> >  	}
> > -	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
> > -	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
> > -	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
> > -	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
> > +	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
> > +	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
> > +	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> > +	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> 
> Isn't this just longer way to write:
> 
> 	inode->i_atime = inode->i_mtime = inode_get_ctime(inode);
> 
> ?
> 
> 								Honza

Yes. Chalk that one up to coccinelle. Fixed in my tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 39/92] erofs: convert to ctime accessor functions
@ 2023-07-06 11:53         ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 11:53 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, linux-kernel, linux-fsdevel, Yue Hu, Al Viro,
	linux-erofs

On Thu, 2023-07-06 at 13:00 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:04, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Acked-by: Gao Xiang <xiang@kernel.org>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Just one nit below:
> 
> > @@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
> >  		vi->chunkbits = sb->s_blocksize_bits +
> >  			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
> >  	}
> > -	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
> > -	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
> > -	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
> > -	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
> > +	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
> > +	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
> > +	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> > +	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> 
> Isn't this just longer way to write:
> 
> 	inode->i_atime = inode->i_mtime = inode_get_ctime(inode);
> 
> ?
> 
> 								Honza

Yes. Chalk that one up to coccinelle. Fixed in my tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 78/92] ubifs: convert to ctime accessor functions
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-06 12:07       ` Zhihao Cheng
  -1 siblings, 0 replies; 208+ messages in thread
From: Zhihao Cheng @ 2023-07-06 12:07 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

在 2023/7/6 3:01, Jeff Layton 写道:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   fs/ubifs/debug.c   |  4 ++--
>   fs/ubifs/dir.c     | 24 +++++++++++-------------
>   fs/ubifs/file.c    | 16 +++++++++-------
>   fs/ubifs/ioctl.c   |  2 +-
>   fs/ubifs/journal.c |  4 ++--
>   fs/ubifs/super.c   |  4 ++--
>   fs/ubifs/xattr.c   |  6 +++---
>   7 files changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 9c9d3f0e36a4..eef9e527d9ff 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -243,8 +243,8 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>   	       (unsigned int)inode->i_mtime.tv_sec,
>   	       (unsigned int)inode->i_mtime.tv_nsec);
>   	pr_err("\tctime          %u.%u\n",
> -	       (unsigned int)inode->i_ctime.tv_sec,
> -	       (unsigned int)inode->i_ctime.tv_nsec);
> +	       (unsigned int) inode_get_ctime(inode).tv_sec,
> +	       (unsigned int) inode_get_ctime(inode).tv_nsec);
>   	pr_err("\tcreat_sqnum    %llu\n", ui->creat_sqnum);
>   	pr_err("\txattr_size     %u\n", ui->xattr_size);
>   	pr_err("\txattr_cnt      %u\n", ui->xattr_cnt);
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 7ec25310bd8a..3a1ba8ba308a 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -96,8 +96,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
>   	inode->i_flags |= S_NOCMTIME;
>   
>   	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime =
> -			 current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>   	inode->i_mapping->nrpages = 0;
>   
>   	if (!is_xattr) {
> @@ -325,7 +324,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
>   	mutex_lock(&dir_ui->ui_mutex);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -765,10 +764,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
>   
>   	inc_nlink(inode);
>   	ihold(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -838,11 +837,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
>   	}
>   
>   	lock_2_inodes(dir, inode);
> -	inode->i_ctime = current_time(dir);
> +	inode_set_ctime_current(inode);
>   	drop_nlink(inode);
>   	dir->i_size -= sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -940,12 +939,12 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
>   	}
>   
>   	lock_2_inodes(dir, inode);
> -	inode->i_ctime = current_time(dir);
> +	inode_set_ctime_current(inode);
>   	clear_nlink(inode);
>   	drop_nlink(dir);
>   	dir->i_size -= sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -1019,7 +1018,7 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>   	inc_nlink(dir);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err) {
>   		ubifs_err(c, "cannot create directory, error %d", err);
> @@ -1110,7 +1109,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>   	mutex_lock(&dir_ui->ui_mutex);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -1210,7 +1209,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
>   	mutex_lock(&dir_ui->ui_mutex);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -1298,7 +1297,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   	struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
>   			.dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
>   	struct ubifs_budget_req wht_req;
> -	struct timespec64 time;
>   	unsigned int saved_nlink;
>   	struct fscrypt_name old_nm, new_nm;
>   

It would be better to put the change of do_rename in '[PATCH v2 10/92] 
ubifs: convert to simple_rename_timestamp'.

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index 6738fe43040b..436b27d7c58f 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1092,7 +1092,7 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
>   	if (attr->ia_valid & ATTR_MTIME)
>   		inode->i_mtime = attr->ia_mtime;
>   	if (attr->ia_valid & ATTR_CTIME)
> -		inode->i_ctime = attr->ia_ctime;
> +		inode_set_ctime_to_ts(inode, attr->ia_ctime);
>   	if (attr->ia_valid & ATTR_MODE) {
>   		umode_t mode = attr->ia_mode;
>   
> @@ -1192,7 +1192,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
>   	mutex_lock(&ui->ui_mutex);
>   	ui->ui_size = inode->i_size;
>   	/* Truncation changes inode [mc]time */
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>   	/* Other attributes may be changed at the same time as well */
>   	do_attr_changes(inode, attr);
>   	err = ubifs_jnl_truncate(c, inode, old_size, new_size);
> @@ -1239,7 +1239,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
>   	mutex_lock(&ui->ui_mutex);
>   	if (attr->ia_valid & ATTR_SIZE) {
>   		/* Truncation changes inode [mc]time */
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>   		/* 'truncate_setsize()' changed @i_size, update @ui_size */
>   		ui->ui_size = inode->i_size;
>   	}
> @@ -1364,8 +1364,10 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
>   static inline int mctime_update_needed(const struct inode *inode,
>   				       const struct timespec64 *now)
>   {
> +	struct timespec64 ctime = inode_get_ctime(inode);
> +
>   	if (!timespec64_equal(&inode->i_mtime, now) ||
> -	    !timespec64_equal(&inode->i_ctime, now))
> +	    !timespec64_equal(&ctime, now))
>   		return 1;
>   	return 0;
>   }
> @@ -1396,7 +1398,7 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
>   	if (flags & S_ATIME)
>   		inode->i_atime = *time;
>   	if (flags & S_CTIME)
> -		inode->i_ctime = *time;
> +		inode_set_ctime_to_ts(inode, *time);
>   	if (flags & S_MTIME)
>   		inode->i_mtime = *time;
>   
> @@ -1432,7 +1434,7 @@ static int update_mctime(struct inode *inode)
>   			return err;
>   
>   		mutex_lock(&ui->ui_mutex);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>   		release = ui->dirty;
>   		mark_inode_dirty_sync(inode);
>   		mutex_unlock(&ui->ui_mutex);
> @@ -1570,7 +1572,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
>   		struct ubifs_inode *ui = ubifs_inode(inode);
>   
>   		mutex_lock(&ui->ui_mutex);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>   		release = ui->dirty;
>   		mark_inode_dirty_sync(inode);
>   		mutex_unlock(&ui->ui_mutex);
> diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
> index 67c5108abd89..d79cabe193c3 100644
> --- a/fs/ubifs/ioctl.c
> +++ b/fs/ubifs/ioctl.c
> @@ -118,7 +118,7 @@ static int setflags(struct inode *inode, int flags)
>   	ui->flags &= ~ioctl2ubifs(UBIFS_SETTABLE_IOCTL_FLAGS);
>   	ui->flags |= ioctl2ubifs(flags);
>   	ubifs_set_inode_flags(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>   	release = ui->dirty;
>   	mark_inode_dirty_sync(inode);
>   	mutex_unlock(&ui->ui_mutex);
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index dc52ac0f4a34..ffc9beee7be6 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -454,8 +454,8 @@ static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
>   	ino->creat_sqnum = cpu_to_le64(ui->creat_sqnum);
>   	ino->atime_sec  = cpu_to_le64(inode->i_atime.tv_sec);
>   	ino->atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> -	ino->ctime_sec  = cpu_to_le64(inode->i_ctime.tv_sec);
> -	ino->ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	ino->ctime_sec  = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	ino->ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>   	ino->mtime_sec  = cpu_to_le64(inode->i_mtime.tv_sec);
>   	ino->mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>   	ino->uid   = cpu_to_le32(i_uid_read(inode));
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 32cb14759796..b08fb28d16b5 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -146,8 +146,8 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
>   	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);
>   	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);
>   	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);
> -	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);
> +	inode_set_ctime(inode, (int64_t)le64_to_cpu(ino->ctime_sec),
> +			le32_to_cpu(ino->ctime_nsec));
>   	inode->i_mode = le32_to_cpu(ino->mode);
>   	inode->i_size = le64_to_cpu(ino->size);
>   
> diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
> index 349228dd1191..406c82eab513 100644
> --- a/fs/ubifs/xattr.c
> +++ b/fs/ubifs/xattr.c
> @@ -134,7 +134,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
>   	ui->data_len = size;
>   
>   	mutex_lock(&host_ui->ui_mutex);
> -	host->i_ctime = current_time(host);
> +	inode_set_ctime_current(host);
>   	host_ui->xattr_cnt += 1;
>   	host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
>   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
> @@ -215,7 +215,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
>   	ui->data_len = size;
>   
>   	mutex_lock(&host_ui->ui_mutex);
> -	host->i_ctime = current_time(host);
> +	inode_set_ctime_current(host);
>   	host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
>   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
>   
> @@ -474,7 +474,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
>   		return err;
>   
>   	mutex_lock(&host_ui->ui_mutex);
> -	host->i_ctime = current_time(host);
> +	inode_set_ctime_current(host);
>   	host_ui->xattr_cnt -= 1;
>   	host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
>   	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
> 


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

* Re: [PATCH v2 78/92] ubifs: convert to ctime accessor functions
@ 2023-07-06 12:07       ` Zhihao Cheng
  0 siblings, 0 replies; 208+ messages in thread
From: Zhihao Cheng @ 2023-07-06 12:07 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

在 2023/7/6 3:01, Jeff Layton 写道:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   fs/ubifs/debug.c   |  4 ++--
>   fs/ubifs/dir.c     | 24 +++++++++++-------------
>   fs/ubifs/file.c    | 16 +++++++++-------
>   fs/ubifs/ioctl.c   |  2 +-
>   fs/ubifs/journal.c |  4 ++--
>   fs/ubifs/super.c   |  4 ++--
>   fs/ubifs/xattr.c   |  6 +++---
>   7 files changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 9c9d3f0e36a4..eef9e527d9ff 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -243,8 +243,8 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>   	       (unsigned int)inode->i_mtime.tv_sec,
>   	       (unsigned int)inode->i_mtime.tv_nsec);
>   	pr_err("\tctime          %u.%u\n",
> -	       (unsigned int)inode->i_ctime.tv_sec,
> -	       (unsigned int)inode->i_ctime.tv_nsec);
> +	       (unsigned int) inode_get_ctime(inode).tv_sec,
> +	       (unsigned int) inode_get_ctime(inode).tv_nsec);
>   	pr_err("\tcreat_sqnum    %llu\n", ui->creat_sqnum);
>   	pr_err("\txattr_size     %u\n", ui->xattr_size);
>   	pr_err("\txattr_cnt      %u\n", ui->xattr_cnt);
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 7ec25310bd8a..3a1ba8ba308a 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -96,8 +96,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
>   	inode->i_flags |= S_NOCMTIME;
>   
>   	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime =
> -			 current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>   	inode->i_mapping->nrpages = 0;
>   
>   	if (!is_xattr) {
> @@ -325,7 +324,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
>   	mutex_lock(&dir_ui->ui_mutex);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -765,10 +764,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
>   
>   	inc_nlink(inode);
>   	ihold(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -838,11 +837,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
>   	}
>   
>   	lock_2_inodes(dir, inode);
> -	inode->i_ctime = current_time(dir);
> +	inode_set_ctime_current(inode);
>   	drop_nlink(inode);
>   	dir->i_size -= sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -940,12 +939,12 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
>   	}
>   
>   	lock_2_inodes(dir, inode);
> -	inode->i_ctime = current_time(dir);
> +	inode_set_ctime_current(inode);
>   	clear_nlink(inode);
>   	drop_nlink(dir);
>   	dir->i_size -= sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -1019,7 +1018,7 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>   	inc_nlink(dir);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err) {
>   		ubifs_err(c, "cannot create directory, error %d", err);
> @@ -1110,7 +1109,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>   	mutex_lock(&dir_ui->ui_mutex);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -1210,7 +1209,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
>   	mutex_lock(&dir_ui->ui_mutex);
>   	dir->i_size += sz_change;
>   	dir_ui->ui_size = dir->i_size;
> -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
>   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
>   	if (err)
>   		goto out_cancel;
> @@ -1298,7 +1297,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   	struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
>   			.dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
>   	struct ubifs_budget_req wht_req;
> -	struct timespec64 time;
>   	unsigned int saved_nlink;
>   	struct fscrypt_name old_nm, new_nm;
>   

It would be better to put the change of do_rename in '[PATCH v2 10/92] 
ubifs: convert to simple_rename_timestamp'.

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index 6738fe43040b..436b27d7c58f 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1092,7 +1092,7 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
>   	if (attr->ia_valid & ATTR_MTIME)
>   		inode->i_mtime = attr->ia_mtime;
>   	if (attr->ia_valid & ATTR_CTIME)
> -		inode->i_ctime = attr->ia_ctime;
> +		inode_set_ctime_to_ts(inode, attr->ia_ctime);
>   	if (attr->ia_valid & ATTR_MODE) {
>   		umode_t mode = attr->ia_mode;
>   
> @@ -1192,7 +1192,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
>   	mutex_lock(&ui->ui_mutex);
>   	ui->ui_size = inode->i_size;
>   	/* Truncation changes inode [mc]time */
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>   	/* Other attributes may be changed at the same time as well */
>   	do_attr_changes(inode, attr);
>   	err = ubifs_jnl_truncate(c, inode, old_size, new_size);
> @@ -1239,7 +1239,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
>   	mutex_lock(&ui->ui_mutex);
>   	if (attr->ia_valid & ATTR_SIZE) {
>   		/* Truncation changes inode [mc]time */
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>   		/* 'truncate_setsize()' changed @i_size, update @ui_size */
>   		ui->ui_size = inode->i_size;
>   	}
> @@ -1364,8 +1364,10 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
>   static inline int mctime_update_needed(const struct inode *inode,
>   				       const struct timespec64 *now)
>   {
> +	struct timespec64 ctime = inode_get_ctime(inode);
> +
>   	if (!timespec64_equal(&inode->i_mtime, now) ||
> -	    !timespec64_equal(&inode->i_ctime, now))
> +	    !timespec64_equal(&ctime, now))
>   		return 1;
>   	return 0;
>   }
> @@ -1396,7 +1398,7 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
>   	if (flags & S_ATIME)
>   		inode->i_atime = *time;
>   	if (flags & S_CTIME)
> -		inode->i_ctime = *time;
> +		inode_set_ctime_to_ts(inode, *time);
>   	if (flags & S_MTIME)
>   		inode->i_mtime = *time;
>   
> @@ -1432,7 +1434,7 @@ static int update_mctime(struct inode *inode)
>   			return err;
>   
>   		mutex_lock(&ui->ui_mutex);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>   		release = ui->dirty;
>   		mark_inode_dirty_sync(inode);
>   		mutex_unlock(&ui->ui_mutex);
> @@ -1570,7 +1572,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
>   		struct ubifs_inode *ui = ubifs_inode(inode);
>   
>   		mutex_lock(&ui->ui_mutex);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>   		release = ui->dirty;
>   		mark_inode_dirty_sync(inode);
>   		mutex_unlock(&ui->ui_mutex);
> diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
> index 67c5108abd89..d79cabe193c3 100644
> --- a/fs/ubifs/ioctl.c
> +++ b/fs/ubifs/ioctl.c
> @@ -118,7 +118,7 @@ static int setflags(struct inode *inode, int flags)
>   	ui->flags &= ~ioctl2ubifs(UBIFS_SETTABLE_IOCTL_FLAGS);
>   	ui->flags |= ioctl2ubifs(flags);
>   	ubifs_set_inode_flags(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>   	release = ui->dirty;
>   	mark_inode_dirty_sync(inode);
>   	mutex_unlock(&ui->ui_mutex);
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index dc52ac0f4a34..ffc9beee7be6 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -454,8 +454,8 @@ static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
>   	ino->creat_sqnum = cpu_to_le64(ui->creat_sqnum);
>   	ino->atime_sec  = cpu_to_le64(inode->i_atime.tv_sec);
>   	ino->atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> -	ino->ctime_sec  = cpu_to_le64(inode->i_ctime.tv_sec);
> -	ino->ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	ino->ctime_sec  = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	ino->ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>   	ino->mtime_sec  = cpu_to_le64(inode->i_mtime.tv_sec);
>   	ino->mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>   	ino->uid   = cpu_to_le32(i_uid_read(inode));
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 32cb14759796..b08fb28d16b5 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -146,8 +146,8 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
>   	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);
>   	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);
>   	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);
> -	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);
> +	inode_set_ctime(inode, (int64_t)le64_to_cpu(ino->ctime_sec),
> +			le32_to_cpu(ino->ctime_nsec));
>   	inode->i_mode = le32_to_cpu(ino->mode);
>   	inode->i_size = le64_to_cpu(ino->size);
>   
> diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
> index 349228dd1191..406c82eab513 100644
> --- a/fs/ubifs/xattr.c
> +++ b/fs/ubifs/xattr.c
> @@ -134,7 +134,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
>   	ui->data_len = size;
>   
>   	mutex_lock(&host_ui->ui_mutex);
> -	host->i_ctime = current_time(host);
> +	inode_set_ctime_current(host);
>   	host_ui->xattr_cnt += 1;
>   	host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
>   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
> @@ -215,7 +215,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
>   	ui->data_len = size;
>   
>   	mutex_lock(&host_ui->ui_mutex);
> -	host->i_ctime = current_time(host);
> +	inode_set_ctime_current(host);
>   	host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
>   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
>   
> @@ -474,7 +474,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
>   		return err;
>   
>   	mutex_lock(&host_ui->ui_mutex);
> -	host->i_ctime = current_time(host);
> +	inode_set_ctime_current(host);
>   	host_ui->xattr_cnt -= 1;
>   	host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
>   	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
> 


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

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

* Re: [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp
  2023-07-05 19:00     ` Jeff Layton
@ 2023-07-06 12:08       ` Zhihao Cheng
  -1 siblings, 0 replies; 208+ messages in thread
From: Zhihao Cheng @ 2023-07-06 12:08 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

在 2023/7/6 3:00, Jeff Layton 写道:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   fs/ubifs/dir.c | 15 +++------------
>   1 file changed, 3 insertions(+), 12 deletions(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index ef0499edc248..7ec25310bd8a 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   	 * Like most other Unix systems, set the @i_ctime for inodes on a
>   	 * rename.
>   	 */
> -	time = current_time(old_dir);
> -	old_inode->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>   
>   	/* We must adjust parent link count when renaming directories */
>   	if (is_dir) {
> @@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   
>   	old_dir->i_size -= old_sz;
>   	ubifs_inode(old_dir)->ui_size = old_dir->i_size;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
>   
>   	/*
>   	 * And finally, if we unlinked a direntry which happened to have the
>   	 * same name as the moved direntry, we have to decrement @i_nlink of
> -	 * the unlinked inode and change its ctime.
> +	 * the unlinked inode.
>   	 */
>   	if (unlink) {
>   		/*
> @@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   			clear_nlink(new_inode);
>   		else
>   			drop_nlink(new_inode);
> -		new_inode->i_ctime = time;
>   	} else {
>   		new_dir->i_size += new_sz;
>   		ubifs_inode(new_dir)->ui_size = new_dir->i_size;
> @@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>   	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
>   	struct inode *fst_inode = d_inode(old_dentry);
>   	struct inode *snd_inode = d_inode(new_dentry);
> -	struct timespec64 time;
>   	int err;
>   	struct fscrypt_name fst_nm, snd_nm;
>   
> @@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>   
>   	lock_4_inodes(old_dir, new_dir, NULL, NULL);
>   
> -	time = current_time(old_dir);
> -	fst_inode->i_ctime = time;
> -	snd_inode->i_ctime = time;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>   
>   	if (old_dir != new_dir) {
>   		if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
> 


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

* Re: [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp
@ 2023-07-06 12:08       ` Zhihao Cheng
  0 siblings, 0 replies; 208+ messages in thread
From: Zhihao Cheng @ 2023-07-06 12:08 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

在 2023/7/6 3:00, Jeff Layton 写道:
> A rename potentially involves updating 4 different inode timestamps.
> Convert to the new simple_rename_timestamp helper function.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   fs/ubifs/dir.c | 15 +++------------
>   1 file changed, 3 insertions(+), 12 deletions(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index ef0499edc248..7ec25310bd8a 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   	 * Like most other Unix systems, set the @i_ctime for inodes on a
>   	 * rename.
>   	 */
> -	time = current_time(old_dir);
> -	old_inode->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>   
>   	/* We must adjust parent link count when renaming directories */
>   	if (is_dir) {
> @@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   
>   	old_dir->i_size -= old_sz;
>   	ubifs_inode(old_dir)->ui_size = old_dir->i_size;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
>   
>   	/*
>   	 * And finally, if we unlinked a direntry which happened to have the
>   	 * same name as the moved direntry, we have to decrement @i_nlink of
> -	 * the unlinked inode and change its ctime.
> +	 * the unlinked inode.
>   	 */
>   	if (unlink) {
>   		/*
> @@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   			clear_nlink(new_inode);
>   		else
>   			drop_nlink(new_inode);
> -		new_inode->i_ctime = time;
>   	} else {
>   		new_dir->i_size += new_sz;
>   		ubifs_inode(new_dir)->ui_size = new_dir->i_size;
> @@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>   	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
>   	struct inode *fst_inode = d_inode(old_dentry);
>   	struct inode *snd_inode = d_inode(new_dentry);
> -	struct timespec64 time;
>   	int err;
>   	struct fscrypt_name fst_nm, snd_nm;
>   
> @@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>   
>   	lock_4_inodes(old_dir, new_dir, NULL, NULL);
>   
> -	time = current_time(old_dir);
> -	fst_inode->i_ctime = time;
> -	snd_inode->i_ctime = time;
> -	old_dir->i_mtime = old_dir->i_ctime = time;
> -	new_dir->i_mtime = new_dir->i_ctime = time;
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>   
>   	if (old_dir != new_dir) {
>   		if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
> 


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

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

* Re: [PATCH v2 78/92] ubifs: convert to ctime accessor functions
  2023-07-06 12:07       ` Zhihao Cheng
@ 2023-07-06 12:10         ` Jeff Layton
  -1 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 12:10 UTC (permalink / raw)
  To: Zhihao Cheng, Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

On Thu, 2023-07-06 at 20:07 +0800, Zhihao Cheng wrote:
> 在 2023/7/6 3:01, Jeff Layton 写道:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >   fs/ubifs/debug.c   |  4 ++--
> >   fs/ubifs/dir.c     | 24 +++++++++++-------------
> >   fs/ubifs/file.c    | 16 +++++++++-------
> >   fs/ubifs/ioctl.c   |  2 +-
> >   fs/ubifs/journal.c |  4 ++--
> >   fs/ubifs/super.c   |  4 ++--
> >   fs/ubifs/xattr.c   |  6 +++---
> >   7 files changed, 30 insertions(+), 30 deletions(-)
> > 
> > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > index 9c9d3f0e36a4..eef9e527d9ff 100644
> > --- a/fs/ubifs/debug.c
> > +++ b/fs/ubifs/debug.c
> > @@ -243,8 +243,8 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> >   	       (unsigned int)inode->i_mtime.tv_sec,
> >   	       (unsigned int)inode->i_mtime.tv_nsec);
> >   	pr_err("\tctime          %u.%u\n",
> > -	       (unsigned int)inode->i_ctime.tv_sec,
> > -	       (unsigned int)inode->i_ctime.tv_nsec);
> > +	       (unsigned int) inode_get_ctime(inode).tv_sec,
> > +	       (unsigned int) inode_get_ctime(inode).tv_nsec);
> >   	pr_err("\tcreat_sqnum    %llu\n", ui->creat_sqnum);
> >   	pr_err("\txattr_size     %u\n", ui->xattr_size);
> >   	pr_err("\txattr_cnt      %u\n", ui->xattr_cnt);
> > diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> > index 7ec25310bd8a..3a1ba8ba308a 100644
> > --- a/fs/ubifs/dir.c
> > +++ b/fs/ubifs/dir.c
> > @@ -96,8 +96,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
> >   	inode->i_flags |= S_NOCMTIME;
> >   
> >   	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
> > -	inode->i_mtime = inode->i_atime = inode->i_ctime =
> > -			 current_time(inode);
> > +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
> >   	inode->i_mapping->nrpages = 0;
> >   
> >   	if (!is_xattr) {
> > @@ -325,7 +324,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
> >   	mutex_lock(&dir_ui->ui_mutex);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -765,10 +764,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
> >   
> >   	inc_nlink(inode);
> >   	ihold(inode);
> > -	inode->i_ctime = current_time(inode);
> > +	inode_set_ctime_current(inode);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -838,11 +837,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
> >   	}
> >   
> >   	lock_2_inodes(dir, inode);
> > -	inode->i_ctime = current_time(dir);
> > +	inode_set_ctime_current(inode);
> >   	drop_nlink(inode);
> >   	dir->i_size -= sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -940,12 +939,12 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
> >   	}
> >   
> >   	lock_2_inodes(dir, inode);
> > -	inode->i_ctime = current_time(dir);
> > +	inode_set_ctime_current(inode);
> >   	clear_nlink(inode);
> >   	drop_nlink(dir);
> >   	dir->i_size -= sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -1019,7 +1018,7 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> >   	inc_nlink(dir);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err) {
> >   		ubifs_err(c, "cannot create directory, error %d", err);
> > @@ -1110,7 +1109,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> >   	mutex_lock(&dir_ui->ui_mutex);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -1210,7 +1209,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> >   	mutex_lock(&dir_ui->ui_mutex);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -1298,7 +1297,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
> >   	struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
> >   			.dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
> >   	struct ubifs_budget_req wht_req;
> > -	struct timespec64 time;
> >   	unsigned int saved_nlink;
> >   	struct fscrypt_name old_nm, new_nm;
> >   
> 
> It would be better to put the change of do_rename in '[PATCH v2 10/92] 
> ubifs: convert to simple_rename_timestamp'.
> 
> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 

Good catch. I'll fix that up in my tree.

Thanks!

> > diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> > index 6738fe43040b..436b27d7c58f 100644
> > --- a/fs/ubifs/file.c
> > +++ b/fs/ubifs/file.c
> > @@ -1092,7 +1092,7 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
> >   	if (attr->ia_valid & ATTR_MTIME)
> >   		inode->i_mtime = attr->ia_mtime;
> >   	if (attr->ia_valid & ATTR_CTIME)
> > -		inode->i_ctime = attr->ia_ctime;
> > +		inode_set_ctime_to_ts(inode, attr->ia_ctime);
> >   	if (attr->ia_valid & ATTR_MODE) {
> >   		umode_t mode = attr->ia_mode;
> >   
> > @@ -1192,7 +1192,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
> >   	mutex_lock(&ui->ui_mutex);
> >   	ui->ui_size = inode->i_size;
> >   	/* Truncation changes inode [mc]time */
> > -	inode->i_mtime = inode->i_ctime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >   	/* Other attributes may be changed at the same time as well */
> >   	do_attr_changes(inode, attr);
> >   	err = ubifs_jnl_truncate(c, inode, old_size, new_size);
> > @@ -1239,7 +1239,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
> >   	mutex_lock(&ui->ui_mutex);
> >   	if (attr->ia_valid & ATTR_SIZE) {
> >   		/* Truncation changes inode [mc]time */
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >   		/* 'truncate_setsize()' changed @i_size, update @ui_size */
> >   		ui->ui_size = inode->i_size;
> >   	}
> > @@ -1364,8 +1364,10 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
> >   static inline int mctime_update_needed(const struct inode *inode,
> >   				       const struct timespec64 *now)
> >   {
> > +	struct timespec64 ctime = inode_get_ctime(inode);
> > +
> >   	if (!timespec64_equal(&inode->i_mtime, now) ||
> > -	    !timespec64_equal(&inode->i_ctime, now))
> > +	    !timespec64_equal(&ctime, now))
> >   		return 1;
> >   	return 0;
> >   }
> > @@ -1396,7 +1398,7 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
> >   	if (flags & S_ATIME)
> >   		inode->i_atime = *time;
> >   	if (flags & S_CTIME)
> > -		inode->i_ctime = *time;
> > +		inode_set_ctime_to_ts(inode, *time);
> >   	if (flags & S_MTIME)
> >   		inode->i_mtime = *time;
> >   
> > @@ -1432,7 +1434,7 @@ static int update_mctime(struct inode *inode)
> >   			return err;
> >   
> >   		mutex_lock(&ui->ui_mutex);
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >   		release = ui->dirty;
> >   		mark_inode_dirty_sync(inode);
> >   		mutex_unlock(&ui->ui_mutex);
> > @@ -1570,7 +1572,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
> >   		struct ubifs_inode *ui = ubifs_inode(inode);
> >   
> >   		mutex_lock(&ui->ui_mutex);
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >   		release = ui->dirty;
> >   		mark_inode_dirty_sync(inode);
> >   		mutex_unlock(&ui->ui_mutex);
> > diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
> > index 67c5108abd89..d79cabe193c3 100644
> > --- a/fs/ubifs/ioctl.c
> > +++ b/fs/ubifs/ioctl.c
> > @@ -118,7 +118,7 @@ static int setflags(struct inode *inode, int flags)
> >   	ui->flags &= ~ioctl2ubifs(UBIFS_SETTABLE_IOCTL_FLAGS);
> >   	ui->flags |= ioctl2ubifs(flags);
> >   	ubifs_set_inode_flags(inode);
> > -	inode->i_ctime = current_time(inode);
> > +	inode_set_ctime_current(inode);
> >   	release = ui->dirty;
> >   	mark_inode_dirty_sync(inode);
> >   	mutex_unlock(&ui->ui_mutex);
> > diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> > index dc52ac0f4a34..ffc9beee7be6 100644
> > --- a/fs/ubifs/journal.c
> > +++ b/fs/ubifs/journal.c
> > @@ -454,8 +454,8 @@ static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
> >   	ino->creat_sqnum = cpu_to_le64(ui->creat_sqnum);
> >   	ino->atime_sec  = cpu_to_le64(inode->i_atime.tv_sec);
> >   	ino->atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> > -	ino->ctime_sec  = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	ino->ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	ino->ctime_sec  = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	ino->ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >   	ino->mtime_sec  = cpu_to_le64(inode->i_mtime.tv_sec);
> >   	ino->mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
> >   	ino->uid   = cpu_to_le32(i_uid_read(inode));
> > diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> > index 32cb14759796..b08fb28d16b5 100644
> > --- a/fs/ubifs/super.c
> > +++ b/fs/ubifs/super.c
> > @@ -146,8 +146,8 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
> >   	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);
> >   	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);
> >   	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);
> > -	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);
> > -	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);
> > +	inode_set_ctime(inode, (int64_t)le64_to_cpu(ino->ctime_sec),
> > +			le32_to_cpu(ino->ctime_nsec));
> >   	inode->i_mode = le32_to_cpu(ino->mode);
> >   	inode->i_size = le64_to_cpu(ino->size);
> >   
> > diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
> > index 349228dd1191..406c82eab513 100644
> > --- a/fs/ubifs/xattr.c
> > +++ b/fs/ubifs/xattr.c
> > @@ -134,7 +134,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
> >   	ui->data_len = size;
> >   
> >   	mutex_lock(&host_ui->ui_mutex);
> > -	host->i_ctime = current_time(host);
> > +	inode_set_ctime_current(host);
> >   	host_ui->xattr_cnt += 1;
> >   	host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
> >   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
> > @@ -215,7 +215,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
> >   	ui->data_len = size;
> >   
> >   	mutex_lock(&host_ui->ui_mutex);
> > -	host->i_ctime = current_time(host);
> > +	inode_set_ctime_current(host);
> >   	host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
> >   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
> >   
> > @@ -474,7 +474,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
> >   		return err;
> >   
> >   	mutex_lock(&host_ui->ui_mutex);
> > -	host->i_ctime = current_time(host);
> > +	inode_set_ctime_current(host);
> >   	host_ui->xattr_cnt -= 1;
> >   	host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
> >   	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
> > 
> 

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 78/92] ubifs: convert to ctime accessor functions
@ 2023-07-06 12:10         ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 12:10 UTC (permalink / raw)
  To: Zhihao Cheng, Christian Brauner, Richard Weinberger
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

On Thu, 2023-07-06 at 20:07 +0800, Zhihao Cheng wrote:
> 在 2023/7/6 3:01, Jeff Layton 写道:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >   fs/ubifs/debug.c   |  4 ++--
> >   fs/ubifs/dir.c     | 24 +++++++++++-------------
> >   fs/ubifs/file.c    | 16 +++++++++-------
> >   fs/ubifs/ioctl.c   |  2 +-
> >   fs/ubifs/journal.c |  4 ++--
> >   fs/ubifs/super.c   |  4 ++--
> >   fs/ubifs/xattr.c   |  6 +++---
> >   7 files changed, 30 insertions(+), 30 deletions(-)
> > 
> > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > index 9c9d3f0e36a4..eef9e527d9ff 100644
> > --- a/fs/ubifs/debug.c
> > +++ b/fs/ubifs/debug.c
> > @@ -243,8 +243,8 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> >   	       (unsigned int)inode->i_mtime.tv_sec,
> >   	       (unsigned int)inode->i_mtime.tv_nsec);
> >   	pr_err("\tctime          %u.%u\n",
> > -	       (unsigned int)inode->i_ctime.tv_sec,
> > -	       (unsigned int)inode->i_ctime.tv_nsec);
> > +	       (unsigned int) inode_get_ctime(inode).tv_sec,
> > +	       (unsigned int) inode_get_ctime(inode).tv_nsec);
> >   	pr_err("\tcreat_sqnum    %llu\n", ui->creat_sqnum);
> >   	pr_err("\txattr_size     %u\n", ui->xattr_size);
> >   	pr_err("\txattr_cnt      %u\n", ui->xattr_cnt);
> > diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> > index 7ec25310bd8a..3a1ba8ba308a 100644
> > --- a/fs/ubifs/dir.c
> > +++ b/fs/ubifs/dir.c
> > @@ -96,8 +96,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
> >   	inode->i_flags |= S_NOCMTIME;
> >   
> >   	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
> > -	inode->i_mtime = inode->i_atime = inode->i_ctime =
> > -			 current_time(inode);
> > +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
> >   	inode->i_mapping->nrpages = 0;
> >   
> >   	if (!is_xattr) {
> > @@ -325,7 +324,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
> >   	mutex_lock(&dir_ui->ui_mutex);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -765,10 +764,10 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
> >   
> >   	inc_nlink(inode);
> >   	ihold(inode);
> > -	inode->i_ctime = current_time(inode);
> > +	inode_set_ctime_current(inode);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -838,11 +837,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
> >   	}
> >   
> >   	lock_2_inodes(dir, inode);
> > -	inode->i_ctime = current_time(dir);
> > +	inode_set_ctime_current(inode);
> >   	drop_nlink(inode);
> >   	dir->i_size -= sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -940,12 +939,12 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
> >   	}
> >   
> >   	lock_2_inodes(dir, inode);
> > -	inode->i_ctime = current_time(dir);
> > +	inode_set_ctime_current(inode);
> >   	clear_nlink(inode);
> >   	drop_nlink(dir);
> >   	dir->i_size -= sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 1, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -1019,7 +1018,7 @@ static int ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> >   	inc_nlink(dir);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err) {
> >   		ubifs_err(c, "cannot create directory, error %d", err);
> > @@ -1110,7 +1109,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> >   	mutex_lock(&dir_ui->ui_mutex);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -1210,7 +1209,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> >   	mutex_lock(&dir_ui->ui_mutex);
> >   	dir->i_size += sz_change;
> >   	dir_ui->ui_size = dir->i_size;
> > -	dir->i_mtime = dir->i_ctime = inode->i_ctime;
> > +	dir->i_mtime = inode_set_ctime_to_ts(dir, inode_get_ctime(inode));
> >   	err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
> >   	if (err)
> >   		goto out_cancel;
> > @@ -1298,7 +1297,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
> >   	struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
> >   			.dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
> >   	struct ubifs_budget_req wht_req;
> > -	struct timespec64 time;
> >   	unsigned int saved_nlink;
> >   	struct fscrypt_name old_nm, new_nm;
> >   
> 
> It would be better to put the change of do_rename in '[PATCH v2 10/92] 
> ubifs: convert to simple_rename_timestamp'.
> 
> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 

Good catch. I'll fix that up in my tree.

Thanks!

> > diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> > index 6738fe43040b..436b27d7c58f 100644
> > --- a/fs/ubifs/file.c
> > +++ b/fs/ubifs/file.c
> > @@ -1092,7 +1092,7 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
> >   	if (attr->ia_valid & ATTR_MTIME)
> >   		inode->i_mtime = attr->ia_mtime;
> >   	if (attr->ia_valid & ATTR_CTIME)
> > -		inode->i_ctime = attr->ia_ctime;
> > +		inode_set_ctime_to_ts(inode, attr->ia_ctime);
> >   	if (attr->ia_valid & ATTR_MODE) {
> >   		umode_t mode = attr->ia_mode;
> >   
> > @@ -1192,7 +1192,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
> >   	mutex_lock(&ui->ui_mutex);
> >   	ui->ui_size = inode->i_size;
> >   	/* Truncation changes inode [mc]time */
> > -	inode->i_mtime = inode->i_ctime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >   	/* Other attributes may be changed at the same time as well */
> >   	do_attr_changes(inode, attr);
> >   	err = ubifs_jnl_truncate(c, inode, old_size, new_size);
> > @@ -1239,7 +1239,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
> >   	mutex_lock(&ui->ui_mutex);
> >   	if (attr->ia_valid & ATTR_SIZE) {
> >   		/* Truncation changes inode [mc]time */
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >   		/* 'truncate_setsize()' changed @i_size, update @ui_size */
> >   		ui->ui_size = inode->i_size;
> >   	}
> > @@ -1364,8 +1364,10 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
> >   static inline int mctime_update_needed(const struct inode *inode,
> >   				       const struct timespec64 *now)
> >   {
> > +	struct timespec64 ctime = inode_get_ctime(inode);
> > +
> >   	if (!timespec64_equal(&inode->i_mtime, now) ||
> > -	    !timespec64_equal(&inode->i_ctime, now))
> > +	    !timespec64_equal(&ctime, now))
> >   		return 1;
> >   	return 0;
> >   }
> > @@ -1396,7 +1398,7 @@ int ubifs_update_time(struct inode *inode, struct timespec64 *time,
> >   	if (flags & S_ATIME)
> >   		inode->i_atime = *time;
> >   	if (flags & S_CTIME)
> > -		inode->i_ctime = *time;
> > +		inode_set_ctime_to_ts(inode, *time);
> >   	if (flags & S_MTIME)
> >   		inode->i_mtime = *time;
> >   
> > @@ -1432,7 +1434,7 @@ static int update_mctime(struct inode *inode)
> >   			return err;
> >   
> >   		mutex_lock(&ui->ui_mutex);
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >   		release = ui->dirty;
> >   		mark_inode_dirty_sync(inode);
> >   		mutex_unlock(&ui->ui_mutex);
> > @@ -1570,7 +1572,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
> >   		struct ubifs_inode *ui = ubifs_inode(inode);
> >   
> >   		mutex_lock(&ui->ui_mutex);
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >   		release = ui->dirty;
> >   		mark_inode_dirty_sync(inode);
> >   		mutex_unlock(&ui->ui_mutex);
> > diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
> > index 67c5108abd89..d79cabe193c3 100644
> > --- a/fs/ubifs/ioctl.c
> > +++ b/fs/ubifs/ioctl.c
> > @@ -118,7 +118,7 @@ static int setflags(struct inode *inode, int flags)
> >   	ui->flags &= ~ioctl2ubifs(UBIFS_SETTABLE_IOCTL_FLAGS);
> >   	ui->flags |= ioctl2ubifs(flags);
> >   	ubifs_set_inode_flags(inode);
> > -	inode->i_ctime = current_time(inode);
> > +	inode_set_ctime_current(inode);
> >   	release = ui->dirty;
> >   	mark_inode_dirty_sync(inode);
> >   	mutex_unlock(&ui->ui_mutex);
> > diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> > index dc52ac0f4a34..ffc9beee7be6 100644
> > --- a/fs/ubifs/journal.c
> > +++ b/fs/ubifs/journal.c
> > @@ -454,8 +454,8 @@ static void pack_inode(struct ubifs_info *c, struct ubifs_ino_node *ino,
> >   	ino->creat_sqnum = cpu_to_le64(ui->creat_sqnum);
> >   	ino->atime_sec  = cpu_to_le64(inode->i_atime.tv_sec);
> >   	ino->atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> > -	ino->ctime_sec  = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	ino->ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	ino->ctime_sec  = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	ino->ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >   	ino->mtime_sec  = cpu_to_le64(inode->i_mtime.tv_sec);
> >   	ino->mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
> >   	ino->uid   = cpu_to_le32(i_uid_read(inode));
> > diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> > index 32cb14759796..b08fb28d16b5 100644
> > --- a/fs/ubifs/super.c
> > +++ b/fs/ubifs/super.c
> > @@ -146,8 +146,8 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
> >   	inode->i_atime.tv_nsec = le32_to_cpu(ino->atime_nsec);
> >   	inode->i_mtime.tv_sec  = (int64_t)le64_to_cpu(ino->mtime_sec);
> >   	inode->i_mtime.tv_nsec = le32_to_cpu(ino->mtime_nsec);
> > -	inode->i_ctime.tv_sec  = (int64_t)le64_to_cpu(ino->ctime_sec);
> > -	inode->i_ctime.tv_nsec = le32_to_cpu(ino->ctime_nsec);
> > +	inode_set_ctime(inode, (int64_t)le64_to_cpu(ino->ctime_sec),
> > +			le32_to_cpu(ino->ctime_nsec));
> >   	inode->i_mode = le32_to_cpu(ino->mode);
> >   	inode->i_size = le64_to_cpu(ino->size);
> >   
> > diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
> > index 349228dd1191..406c82eab513 100644
> > --- a/fs/ubifs/xattr.c
> > +++ b/fs/ubifs/xattr.c
> > @@ -134,7 +134,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
> >   	ui->data_len = size;
> >   
> >   	mutex_lock(&host_ui->ui_mutex);
> > -	host->i_ctime = current_time(host);
> > +	inode_set_ctime_current(host);
> >   	host_ui->xattr_cnt += 1;
> >   	host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm));
> >   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
> > @@ -215,7 +215,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
> >   	ui->data_len = size;
> >   
> >   	mutex_lock(&host_ui->ui_mutex);
> > -	host->i_ctime = current_time(host);
> > +	inode_set_ctime_current(host);
> >   	host_ui->xattr_size -= CALC_XATTR_BYTES(old_size);
> >   	host_ui->xattr_size += CALC_XATTR_BYTES(size);
> >   
> > @@ -474,7 +474,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
> >   		return err;
> >   
> >   	mutex_lock(&host_ui->ui_mutex);
> > -	host->i_ctime = current_time(host);
> > +	inode_set_ctime_current(host);
> >   	host_ui->xattr_cnt -= 1;
> >   	host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm));
> >   	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
> > 
> 

-- 
Jeff Layton <jlayton@kernel.org>

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

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

* Re: [PATCH v2 42/92] ext4: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 42/92] ext4: " Jeff Layton
@ 2023-07-06 12:36     ` Jan Kara
  2023-07-06 13:10       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:36 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Theodore Ts'o, Andreas Dilger, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-ext4

[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]

On Wed 05-07-23 15:01:07, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Some comment below:

> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 0a2d55faa095..d502b930431b 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3823,6 +3823,27 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
>  	return buffer_uptodate(bh);
>  }
>  
> +static inline void ext4_inode_set_ctime(struct inode *inode, struct ext4_inode *raw_inode)
> +{
> +	struct timespec64 ctime = inode_get_ctime(inode);
> +
> +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra)) {
> +		raw_inode->i_ctime = cpu_to_le32(ctime.tv_sec);
> +		raw_inode->i_ctime_extra = ext4_encode_extra_time(&ctime);
> +	} else {
> +		raw_inode->i_ctime = cpu_to_le32(clamp_t(int32_t, ctime.tv_sec, S32_MIN, S32_MAX));
> +	}
> +}
> +
> +static inline void ext4_inode_get_ctime(struct inode *inode, const struct ext4_inode *raw_inode)
> +{
> +	struct timespec64 ctime = { .tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime) };
> +
> +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra))
> +		ext4_decode_extra_time(&ctime, raw_inode->i_ctime_extra);
> +	inode_set_ctime(inode, ctime.tv_sec, ctime.tv_nsec);
> +}
> +

This duplication is kind of unpleasant. I was looking into it for a while
and I think we can rather do some initial cleanup (attached patch 1) and
then your conversion patch would not need to duplicate the conversion code
(see attached patch 2).

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[-- Attachment #2: 0001-ext4-deduplicate-macros-for-converting-inode-timesta.patch --]
[-- Type: text/x-patch, Size: 5614 bytes --]

From b9fd173302ca572f0160d8d41d13fa4792fe2720 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Thu, 6 Jul 2023 14:07:16 +0200
Subject: [PATCH 1/2] ext4: deduplicate macros for converting inode timestamps

In ext4 we have macros that convert between on-disk and in-memory time
stamps and due to various configuration details that is a non-trivial
task. We have two flavors of these macros - one for atime, mtime, and
ctime and one for crtime. Deduplicate implementation of these two
flavors. I will also simplify introduction of ctime accessor functions.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/ext4.h       | 70 +++++++++++++++++++-------------------------
 fs/ext4/inode-test.c |  6 ++--
 2 files changed, 33 insertions(+), 43 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0a2d55faa095..99d145259d5a 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -868,64 +868,54 @@ struct ext4_inode {
  * affected filesystem before 2242.
  */
 
-static inline __le32 ext4_encode_extra_time(struct timespec64 *time)
+static inline __le32 ext4_encode_extra_time(struct timespec64 ts)
 {
-	u32 extra =((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK;
-	return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS));
+	u32 extra = ((ts.tv_sec - (s32)ts.tv_sec) >> 32) & EXT4_EPOCH_MASK;
+	return cpu_to_le32(extra | (ts.tv_nsec << EXT4_EPOCH_BITS));
 }
 
-static inline void ext4_decode_extra_time(struct timespec64 *time,
-					  __le32 extra)
+static inline struct timespec64 ext4_decode_extra_time(__le32 base,
+						       __le32 extra)
 {
+	struct timespec64 ts = { .tv_sec = le32_to_cpu(base) };
+
 	if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK)))
-		time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32;
-	time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS;
+		ts.tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32;
+	ts.tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS;
+	return ts;
 }
 
-#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)				\
+#define EXT4_INODE_SET_XTIME_VAL(xtime, inode, raw_inode, ts)			\
 do {										\
-	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     {\
-		(raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec);	\
-		(raw_inode)->xtime ## _extra =					\
-				ext4_encode_extra_time(&(inode)->xtime);	\
-		}								\
-	else	\
-		(raw_inode)->xtime = cpu_to_le32(clamp_t(int32_t, (inode)->xtime.tv_sec, S32_MIN, S32_MAX));	\
+	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {	\
+		(raw_inode)->xtime = cpu_to_le32((ts).tv_sec);			\
+		(raw_inode)->xtime ## _extra = ext4_encode_extra_time(ts);	\
+	} else									\
+		(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_EINODE_SET_XTIME(xtime, einode, raw_inode)			       \
-do {									       \
-	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime))		       \
-		(raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec);      \
-	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra))	       \
-		(raw_inode)->xtime ## _extra =				       \
-				ext4_encode_extra_time(&(einode)->xtime);      \
-} while (0)
+	EXT4_INODE_SET_XTIME_VAL(xtime, &((einode)->vfs_inode), raw_inode, (einode)->xtime)
+
+#define EXT4_INODE_GET_XTIME_VAL(xtime, inode, raw_inode)			\
+	(EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra) ?	\
+		ext4_decode_extra_time((raw_inode)->xtime,				\
+				       (raw_inode)->xtime ## _extra) :		\
+		(struct timespec64) {						\
+			.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime)	\
+		})
 
 #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)				\
 do {										\
-	(inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);	\
-	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {	\
-		ext4_decode_extra_time(&(inode)->xtime,				\
-				       raw_inode->xtime ## _extra);		\
-		}								\
-	else									\
-		(inode)->xtime.tv_nsec = 0;					\
+	(inode)->xtime = EXT4_INODE_GET_XTIME_VAL(xtime, inode, raw_inode);	\
 } while (0)
 
-
 #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode)			       \
 do {									       \
-	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime))		       \
-		(einode)->xtime.tv_sec = 				       \
-			(signed)le32_to_cpu((raw_inode)->xtime);	       \
-	else								       \
-		(einode)->xtime.tv_sec = 0;				       \
-	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra))	       \
-		ext4_decode_extra_time(&(einode)->xtime,		       \
-				       raw_inode->xtime ## _extra);	       \
-	else								       \
-		(einode)->xtime.tv_nsec = 0;				       \
+	(einode)->xtime = EXT4_INODE_GET_XTIME_VAL(xtime, &(einode->vfs_inode), raw_inode);	\
 } while (0)
 
 #define i_disk_version osd1.linux1.l_i_version
diff --git a/fs/ext4/inode-test.c b/fs/ext4/inode-test.c
index 7935ea6cf92c..f0c0fd507fbc 100644
--- a/fs/ext4/inode-test.c
+++ b/fs/ext4/inode-test.c
@@ -245,9 +245,9 @@ static void inode_test_xtimestamp_decoding(struct kunit *test)
 	struct timestamp_expectation *test_param =
 			(struct timestamp_expectation *)(test->param_value);
 
-	timestamp.tv_sec = get_32bit_time(test_param);
-	ext4_decode_extra_time(&timestamp,
-			       cpu_to_le32(test_param->extra_bits));
+	timestamp = ext4_decode_extra_time(
+				cpu_to_le32(get_32bit_time(test_param)),
+				cpu_to_le32(test_param->extra_bits));
 
 	KUNIT_EXPECT_EQ_MSG(test,
 			    test_param->expected.tv_sec,
-- 
2.35.3


[-- Attachment #3: 0002-ext4-convert-to-ctime-accessor-functions.patch --]
[-- Type: text/x-patch, Size: 15421 bytes --]

From 6a46b34c5f5b71a327a88fc3425e37fd67706a52 Mon Sep 17 00:00:00 2001
From: Jeff Layton <jlayton@kernel.org>
Date: Thu, 6 Jul 2023 14:20:31 +0200
Subject: [PATCH 2/2] ext4: convert to ctime accessor functions

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/acl.c     |  2 +-
 fs/ext4/ext4.h    |  9 +++++++++
 fs/ext4/extents.c | 12 ++++++------
 fs/ext4/ialloc.c  |  2 +-
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   | 16 +++++++---------
 fs/ext4/ioctl.c   |  9 +++++----
 fs/ext4/namei.c   | 26 ++++++++++++--------------
 fs/ext4/super.c   |  2 +-
 fs/ext4/xattr.c   |  6 +++---
 10 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 27fcbddfb148..3bffe862f954 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -259,7 +259,7 @@ ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 	error = __ext4_set_acl(handle, inode, type, acl, 0 /* xattr_flags */);
 	if (!error && update_mode) {
 		inode->i_mode = mode;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		error = ext4_mark_inode_dirty(handle, inode);
 	}
 out_stop:
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 99d145259d5a..d63543187359 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -897,6 +897,9 @@ do {										\
 #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)				\
 	EXT4_INODE_SET_XTIME_VAL(xtime, inode, raw_inode, (inode)->xtime)
 
+#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)			       \
 	EXT4_INODE_SET_XTIME_VAL(xtime, &((einode)->vfs_inode), raw_inode, (einode)->xtime)
 
@@ -913,6 +916,12 @@ do {										\
 	(inode)->xtime = EXT4_INODE_GET_XTIME_VAL(xtime, inode, raw_inode);	\
 } while (0)
 
+#define EXT4_INODE_GET_CTIME(inode, raw_inode)					\
+do {										\
+	inode_set_ctime_to_ts(inode,						\
+		EXT4_INODE_GET_XTIME_VAL(i_ctime, inode, raw_inode));		\
+} while (0)
+
 #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode)			       \
 do {									       \
 	(einode)->xtime = EXT4_INODE_GET_XTIME_VAL(xtime, &(einode->vfs_inode), raw_inode);	\
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e4115d338f10..202c76996b62 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4476,12 +4476,12 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 		map.m_lblk += ret;
 		map.m_len = len = len - ret;
 		epos = (loff_t)map.m_lblk << inode->i_blkbits;
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		if (new_size) {
 			if (epos > new_size)
 				epos = new_size;
 			if (ext4_update_inode_size(inode, epos) & 0x1)
-				inode->i_mtime = inode->i_ctime;
+				inode->i_mtime = inode_get_ctime(inode);
 		}
 		ret2 = ext4_mark_inode_dirty(handle, inode);
 		ext4_update_inode_fsync_trans(handle, inode, 1);
@@ -4617,7 +4617,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->i_ctime = current_time(inode);
+		inode->i_mtime = inode_set_ctime_current(inode);
 
 		ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 					     flags);
@@ -4642,7 +4642,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 		goto out_mutex;
 	}
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	if (new_size)
 		ext4_update_inode_size(inode, new_size);
 	ret = ext4_mark_inode_dirty(handle, inode);
@@ -5378,7 +5378,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->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	ret = ext4_mark_inode_dirty(handle, inode);
 	ext4_update_inode_fsync_trans(handle, inode, 1);
 
@@ -5488,7 +5488,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->i_ctime = current_time(inode);
+	inode->i_mtime = 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 754f961cd9fd..48abef5f23e7 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1250,7 +1250,7 @@ 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->i_ctime = current_time(inode);
+	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
 	ei->i_crtime = inode->i_mtime;
 
 	memset(ei->i_data, 0, sizeof(ei->i_data));
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index a4b7e4bc32d4..003861037374 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 = dir->i_ctime = current_time(dir);
+	dir->i_mtime = 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->i_ctime = current_time(inode);
+		inode->i_mtime = 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 43775a6ca505..86696b40c58f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3986,7 +3986,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->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	ret2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(ret2))
 		ret = ret2;
@@ -4146,7 +4146,7 @@ int ext4_truncate(struct inode *inode)
 	if (inode->i_nlink)
 		ext4_orphan_del(handle, inode);
 
-	inode->i_mtime = inode->i_ctime = current_time(inode);
+	inode->i_mtime = inode_set_ctime_current(inode);
 	err2 = ext4_mark_inode_dirty(handle, inode);
 	if (unlikely(err2 && !err))
 		err = err2;
@@ -4249,7 +4249,7 @@ 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_XTIME(i_ctime, inode, raw_inode);
+	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_EINODE_SET_XTIME(i_crtime, ei, raw_inode);
@@ -4858,7 +4858,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 		}
 	}
 
-	EXT4_INODE_GET_XTIME(i_ctime, inode, raw_inode);
+	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_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
@@ -4981,7 +4981,7 @@ static void __ext4_update_other_inode_time(struct super_block *sb,
 		spin_unlock(&inode->i_lock);
 
 		spin_lock(&ei->i_raw_lock);
-		EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
+		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_csum_set(inode, raw_inode, ei);
@@ -5376,10 +5376,8 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 			 * Update c/mtime on truncate up, ext4_truncate() will
 			 * update c/mtime in shrink case below
 			 */
-			if (!shrink) {
-				inode->i_mtime = current_time(inode);
-				inode->i_ctime = inode->i_mtime;
-			}
+			if (!shrink)
+				inode->i_mtime = 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 331859511f80..b0349f451863 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -449,7 +449,8 @@ static long swap_inode_boot_loader(struct super_block *sb,
 	diff = size - size_bl;
 	swap_inode_data(inode, inode_bl);
 
-	inode->i_ctime = inode_bl->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
+	inode_set_ctime_current(inode_bl);
 	inode_inc_iversion(inode);
 
 	inode->i_generation = get_random_u32();
@@ -663,7 +664,7 @@ static int ext4_ioctl_setflags(struct inode *inode,
 
 	ext4_set_inode_flags(inode, false);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_iversion(inode);
 
 	err = ext4_mark_iloc_dirty(handle, inode, &iloc);
@@ -774,7 +775,7 @@ static int ext4_ioctl_setproject(struct inode *inode, __u32 projid)
 	}
 
 	EXT4_I(inode)->i_projid = kprojid;
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	inode_inc_iversion(inode);
 out_dirty:
 	rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
@@ -1266,7 +1267,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		}
 		err = ext4_reserve_inode_write(handle, inode, &iloc);
 		if (err == 0) {
-			inode->i_ctime = current_time(inode);
+			inode_set_ctime_current(inode);
 			inode_inc_iversion(inode);
 			inode->i_generation = generation;
 			err = ext4_mark_iloc_dirty(handle, inode, &iloc);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 0caf6c730ce3..07f6d96ebc60 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2203,7 +2203,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 = dir->i_ctime = current_time(dir);
+	dir->i_mtime = inode_set_ctime_current(dir);
 	ext4_update_dx_flag(dir);
 	inode_inc_iversion(dir);
 	err2 = ext4_mark_inode_dirty(handle, dir);
@@ -3197,7 +3197,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
 	 * recovery. */
 	inode->i_size = 0;
 	ext4_orphan_add(handle, inode);
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_ctime_current(inode);
 	retval = ext4_mark_inode_dirty(handle, inode);
 	if (retval)
 		goto end_rmdir;
@@ -3271,7 +3272,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_ctime = dir->i_mtime = current_time(dir);
+		dir->i_mtime = inode_set_ctime_current(dir);
 		ext4_update_dx_flag(dir);
 		retval = ext4_mark_inode_dirty(handle, dir);
 		if (retval)
@@ -3286,7 +3287,7 @@ int __ext4_unlink(struct inode *dir, const struct qstr *d_name,
 		drop_nlink(inode);
 	if (!inode->i_nlink)
 		ext4_orphan_add(handle, inode);
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	retval = ext4_mark_inode_dirty(handle, inode);
 	if (dentry && !retval)
 		ext4_fc_track_unlink(handle, dentry);
@@ -3463,7 +3464,7 @@ int __ext4_link(struct inode *dir, struct inode *inode, struct dentry *dentry)
 	if (IS_DIRSYNC(dir))
 		ext4_handle_sync(handle);
 
-	inode->i_ctime = current_time(inode);
+	inode_set_ctime_current(inode);
 	ext4_inc_count(inode);
 	ihold(inode);
 
@@ -3641,8 +3642,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_ctime = ent->dir->i_mtime =
-		current_time(ent->dir);
+	ent->dir->i_mtime = 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) {
@@ -3941,7 +3941,7 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	old.inode->i_ctime = current_time(old.inode);
+	inode_set_ctime_current(old.inode);
 	retval = ext4_mark_inode_dirty(handle, old.inode);
 	if (unlikely(retval))
 		goto end_rename;
@@ -3955,9 +3955,9 @@ static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 
 	if (new.inode) {
 		ext4_dec_count(new.inode);
-		new.inode->i_ctime = current_time(new.inode);
+		inode_set_ctime_current(new.inode);
 	}
-	old.dir->i_ctime = old.dir->i_mtime = current_time(old.dir);
+	old.dir->i_mtime = inode_set_ctime_current(old.inode);
 	ext4_update_dx_flag(old.dir);
 	if (old.dir_bh) {
 		retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino);
@@ -4053,7 +4053,6 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	};
 	u8 new_file_type;
 	int retval;
-	struct timespec64 ctime;
 
 	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
 	     !projid_eq(EXT4_I(new_dir)->i_projid,
@@ -4147,9 +4146,8 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 * Like most other Unix systems, set the ctime for inodes on a
 	 * rename.
 	 */
-	ctime = current_time(old.inode);
-	old.inode->i_ctime = ctime;
-	new.inode->i_ctime = ctime;
+	inode_set_ctime_current(old.inode);
+	inode_set_ctime_current(new.inode);
 	retval = ext4_mark_inode_dirty(handle, old.inode);
 	if (unlikely(retval))
 		goto end_rename;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c94ebf704616..b54c70e1a74e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -7103,7 +7103,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->i_ctime = current_time(inode);
+	inode->i_mtime = 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 321e3a888c20..dbe54cddda3d 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -356,13 +356,13 @@ 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)ea_inode->i_ctime.tv_sec << 32) |
+	return ((u64) inode_get_ctime(ea_inode).tv_sec << 32) |
 		(u32) inode_peek_iversion_raw(ea_inode);
 }
 
 static void ext4_xattr_inode_set_ref(struct inode *ea_inode, u64 ref_count)
 {
-	ea_inode->i_ctime.tv_sec = (u32)(ref_count >> 32);
+	inode_set_ctime(ea_inode, (u32)(ref_count >> 32), 0);
 	inode_set_iversion_raw(ea_inode, ref_count & 0xffffffff);
 }
 
@@ -2459,7 +2459,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 	}
 	if (!error) {
 		ext4_xattr_update_super_block(handle, inode->i_sb);
-		inode->i_ctime = current_time(inode);
+		inode_set_ctime_current(inode);
 		inode_inc_iversion(inode);
 		if (!value)
 			no_expand = 0;
-- 
2.35.3


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

* Re: [PATCH v2 53/92] isofs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 53/92] isofs: " Jeff Layton
@ 2023-07-06 12:39     ` Jan Kara
  2023-07-06 13:11       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:39 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jan Kara, Al Viro, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:18, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/isofs/inode.c |  8 ++++----
>  fs/isofs/rock.c  | 16 +++++++---------
>  2 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
> index df9d70588b60..98a78200cff1 100644
> --- a/fs/isofs/inode.c
> +++ b/fs/isofs/inode.c
> @@ -1424,11 +1424,11 @@ static int isofs_read_inode(struct inode *inode, int relocated)
>  #endif
>  
>  	inode->i_mtime.tv_sec =
> -	inode->i_atime.tv_sec =
> -	inode->i_ctime.tv_sec = iso_date(de->date, high_sierra);
> +	inode->i_atime.tv_sec = inode_set_ctime(inode,
> +						iso_date(de->date, high_sierra),
> +						0).tv_sec;
>  	inode->i_mtime.tv_nsec =
> -	inode->i_atime.tv_nsec =
> -	inode->i_ctime.tv_nsec = 0;
> +	inode->i_atime.tv_nsec = 0;

This would be IMHO more readable as:

	inode->i_mtime = inode->i_atime =
		inode_set_ctime(inode, iso_date(de->date, high_sierra), 0);


Otherwise the patch looks good.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 52/92] hugetlbfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 52/92] hugetlbfs: " Jeff Layton
  2023-07-05 19:58     ` Mike Kravetz
@ 2023-07-06 12:40     ` Jan Kara
  1 sibling, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:40 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Mike Kravetz, Muchun Song, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-mm

On Wed 05-07-23 15:01:17, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/hugetlbfs/inode.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 7b17ccfa039d..93d3bcfd4fc8 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -887,7 +887,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
>  
>  	if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size)
>  		i_size_write(inode, offset + len);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  out:
>  	inode_unlock(inode);
>  	return error;
> @@ -935,7 +935,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
>  		inode->i_mode = S_IFDIR | ctx->mode;
>  		inode->i_uid = ctx->uid;
>  		inode->i_gid = ctx->gid;
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		inode->i_op = &hugetlbfs_dir_inode_operations;
>  		inode->i_fop = &simple_dir_operations;
>  		/* directory inodes start off with i_nlink == 2 (for "." entry) */
> @@ -979,7 +979,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
>  		lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
>  				&hugetlbfs_i_mmap_rwsem_key);
>  		inode->i_mapping->a_ops = &hugetlbfs_aops;
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		inode->i_mapping->private_data = resv_map;
>  		info->seals = F_SEAL_SEAL;
>  		switch (mode & S_IFMT) {
> @@ -1022,7 +1022,7 @@ static int hugetlbfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  	inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev);
>  	if (!inode)
>  		return -ENOSPC;
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	d_instantiate(dentry, inode);
>  	dget(dentry);/* Extra count - pin the dentry in core */
>  	return 0;
> @@ -1054,7 +1054,7 @@ static int hugetlbfs_tmpfile(struct mnt_idmap *idmap,
>  	inode = hugetlbfs_get_inode(dir->i_sb, dir, mode | S_IFREG, 0);
>  	if (!inode)
>  		return -ENOSPC;
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	d_tmpfile(file, inode);
>  	return finish_open_simple(file, 0);
>  }
> @@ -1076,7 +1076,7 @@ static int hugetlbfs_symlink(struct mnt_idmap *idmap,
>  		} else
>  			iput(inode);
>  	}
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  
>  	return error;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 51/92] hpfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 51/92] hpfs: " Jeff Layton
@ 2023-07-06 12:47     ` Jan Kara
  2023-07-06 13:11       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:47 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Mikulas Patocka, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:16, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

...

> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index 69fb40b2c99a..36babb78b510 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -13,10 +13,10 @@ static void hpfs_update_directory_times(struct inode *dir)
>  {
>  	time64_t t = local_to_gmt(dir->i_sb, local_get_seconds(dir->i_sb));
>  	if (t == dir->i_mtime.tv_sec &&
> -	    t == dir->i_ctime.tv_sec)
> +	    t == inode_get_ctime(dir).tv_sec)
>  		return;
> -	dir->i_mtime.tv_sec = dir->i_ctime.tv_sec = t;
> -	dir->i_mtime.tv_nsec = dir->i_ctime.tv_nsec = 0;
> +	dir->i_mtime.tv_sec = inode_set_ctime(dir, t, 0).tv_sec;
> +	dir->i_mtime.tv_nsec = 0;

Easier to read:

	dir->i_mtime = inode_set_ctime(dir, t, 0);

> @@ -59,8 +59,9 @@ static int hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  	result->i_ino = fno;
>  	hpfs_i(result)->i_parent_dir = dir->i_ino;
>  	hpfs_i(result)->i_dno = dno;
> -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> -	result->i_ctime.tv_nsec = 0; 
> +	inode_set_ctime(result,
> +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> +			0);
>  	result->i_mtime.tv_nsec = 0; 
>  	result->i_atime.tv_nsec = 0; 

Here also:
	result->i_mtime = result->i_atime = inode_set_ctime(result,
		local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)), 0)

> @@ -167,8 +168,9 @@ static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
>  	result->i_fop = &hpfs_file_ops;
>  	set_nlink(result, 1);
>  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> -	result->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(result,
> +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> +			0);
>  	result->i_mtime.tv_nsec = 0;
>  	result->i_atime.tv_nsec = 0;

And here exactly the same.

> @@ -250,8 +252,9 @@ static int hpfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  	hpfs_init_inode(result);
>  	result->i_ino = fno;
>  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> -	result->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(result,
> +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> +			0);
>  	result->i_mtime.tv_nsec = 0;
>  	result->i_atime.tv_nsec = 0;
>  	hpfs_i(result)->i_ea_size = 0;
> @@ -326,8 +329,9 @@ static int hpfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  	result->i_ino = fno;
>  	hpfs_init_inode(result);
>  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> -	result->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(result,
> +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> +			0);
>  	result->i_mtime.tv_nsec = 0;
>  	result->i_atime.tv_nsec = 0;
>  	hpfs_i(result)->i_ea_size = 0;

And in above two as well.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 50/92] hostfs: convert to ctime accessor functions
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-06 12:48       ` Jan Kara
  -1 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:48 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Al Viro, Jan Kara, linux-fsdevel, linux-kernel,
	linux-um

On Wed 05-07-23 15:01:15, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/hostfs/hostfs_kern.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 46387090eb76..182af84a9c12 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -517,8 +517,7 @@ static int hostfs_inode_update(struct inode *ino, const struct hostfs_stat *st)
>  		(struct timespec64){ st->atime.tv_sec, st->atime.tv_nsec };
>  	ino->i_mtime =
>  		(struct timespec64){ st->mtime.tv_sec, st->mtime.tv_nsec };
> -	ino->i_ctime =
> -		(struct timespec64){ st->ctime.tv_sec, st->ctime.tv_nsec };
> +	inode_set_ctime_to_ts(ino, &st->ctime);
>  	ino->i_size = st->size;
>  	ino->i_blocks = st->blocks;
>  	return 0;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

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

* Re: [PATCH v2 50/92] hostfs: convert to ctime accessor functions
@ 2023-07-06 12:48       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:48 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Al Viro, Jan Kara, linux-fsdevel, linux-kernel,
	linux-um

On Wed 05-07-23 15:01:15, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/hostfs/hostfs_kern.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 46387090eb76..182af84a9c12 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -517,8 +517,7 @@ static int hostfs_inode_update(struct inode *ino, const struct hostfs_stat *st)
>  		(struct timespec64){ st->atime.tv_sec, st->atime.tv_nsec };
>  	ino->i_mtime =
>  		(struct timespec64){ st->mtime.tv_sec, st->mtime.tv_nsec };
> -	ino->i_ctime =
> -		(struct timespec64){ st->ctime.tv_sec, st->ctime.tv_nsec };
> +	inode_set_ctime_to_ts(ino, &st->ctime);
>  	ino->i_size = st->size;
>  	ino->i_blocks = st->blocks;
>  	return 0;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 49/92] hfsplus: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 49/92] hfsplus: " Jeff Layton
@ 2023-07-06 12:49     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:49 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:14, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/hfsplus/catalog.c |  8 ++++----
>  fs/hfsplus/dir.c     |  6 +++---
>  fs/hfsplus/inode.c   | 16 +++++++++-------
>  3 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
> index 35472cba750e..e71ae2537eaa 100644
> --- a/fs/hfsplus/catalog.c
> +++ b/fs/hfsplus/catalog.c
> @@ -312,7 +312,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
>  	dir->i_size++;
>  	if (S_ISDIR(inode->i_mode))
>  		hfsplus_subfolders_inc(dir);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY);
>  
>  	hfs_find_exit(&fd);
> @@ -417,7 +417,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str)
>  	dir->i_size--;
>  	if (type == HFSPLUS_FOLDER)
>  		hfsplus_subfolders_dec(dir);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	hfsplus_mark_inode_dirty(dir, HFSPLUS_I_CAT_DIRTY);
>  
>  	if (type == HFSPLUS_FILE || type == HFSPLUS_FOLDER) {
> @@ -494,7 +494,7 @@ int hfsplus_rename_cat(u32 cnid,
>  	dst_dir->i_size++;
>  	if (type == HFSPLUS_FOLDER)
>  		hfsplus_subfolders_inc(dst_dir);
> -	dst_dir->i_mtime = dst_dir->i_ctime = current_time(dst_dir);
> +	dst_dir->i_mtime = inode_set_ctime_current(dst_dir);
>  
>  	/* finally remove the old entry */
>  	err = hfsplus_cat_build_key(sb, src_fd.search_key,
> @@ -511,7 +511,7 @@ int hfsplus_rename_cat(u32 cnid,
>  	src_dir->i_size--;
>  	if (type == HFSPLUS_FOLDER)
>  		hfsplus_subfolders_dec(src_dir);
> -	src_dir->i_mtime = src_dir->i_ctime = current_time(src_dir);
> +	src_dir->i_mtime = inode_set_ctime_current(src_dir);
>  
>  	/* remove old thread entry */
>  	hfsplus_cat_build_key_with_cnid(sb, src_fd.search_key, cnid);
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 56fb5f1312e7..f5c4b3e31a1c 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -346,7 +346,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
>  	inc_nlink(inode);
>  	hfsplus_instantiate(dst_dentry, inode, cnid);
>  	ihold(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	sbi->file_count++;
>  	hfsplus_mark_mdb_dirty(dst_dir->i_sb);
> @@ -405,7 +405,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
>  			hfsplus_delete_inode(inode);
>  	} else
>  		sbi->file_count--;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  out:
>  	mutex_unlock(&sbi->vh_mutex);
> @@ -426,7 +426,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
>  	if (res)
>  		goto out;
>  	clear_nlink(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	hfsplus_delete_inode(inode);
>  	mark_inode_dirty(inode);
>  out:
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index 7d1a675e037d..40c61ab4a918 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -267,7 +267,7 @@ static int hfsplus_setattr(struct mnt_idmap *idmap,
>  		}
>  		truncate_setsize(inode, attr->ia_size);
>  		hfsplus_file_truncate(inode);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  
>  	setattr_copy(&nop_mnt_idmap, inode, attr);
> @@ -392,7 +392,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
>  	inode->i_ino = sbi->next_cnid++;
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
>  	set_nlink(inode, 1);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  
>  	hip = HFSPLUS_I(inode);
>  	INIT_LIST_HEAD(&hip->open_dir_list);
> @@ -523,7 +523,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
>  		inode->i_size = 2 + be32_to_cpu(folder->valence);
>  		inode->i_atime = hfsp_mt2ut(folder->access_date);
>  		inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
> -		inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date);
> +		inode_set_ctime_to_ts(inode,
> +				      hfsp_mt2ut(folder->attribute_mod_date));
>  		HFSPLUS_I(inode)->create_date = folder->create_date;
>  		HFSPLUS_I(inode)->fs_blocks = 0;
>  		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
> @@ -564,7 +565,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
>  		}
>  		inode->i_atime = hfsp_mt2ut(file->access_date);
>  		inode->i_mtime = hfsp_mt2ut(file->content_mod_date);
> -		inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
> +		inode_set_ctime_to_ts(inode,
> +				      hfsp_mt2ut(file->attribute_mod_date));
>  		HFSPLUS_I(inode)->create_date = file->create_date;
>  	} else {
>  		pr_err("bad catalog entry used to create inode\n");
> @@ -609,7 +611,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
>  		hfsplus_cat_set_perms(inode, &folder->permissions);
>  		folder->access_date = hfsp_ut2mt(inode->i_atime);
>  		folder->content_mod_date = hfsp_ut2mt(inode->i_mtime);
> -		folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
> +		folder->attribute_mod_date = hfsp_ut2mt(inode_get_ctime(inode));
>  		folder->valence = cpu_to_be32(inode->i_size - 2);
>  		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
>  			folder->subfolders =
> @@ -644,7 +646,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
>  			file->flags &= cpu_to_be16(~HFSPLUS_FILE_LOCKED);
>  		file->access_date = hfsp_ut2mt(inode->i_atime);
>  		file->content_mod_date = hfsp_ut2mt(inode->i_mtime);
> -		file->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
> +		file->attribute_mod_date = hfsp_ut2mt(inode_get_ctime(inode));
>  		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
>  					 sizeof(struct hfsplus_cat_file));
>  	}
> @@ -700,7 +702,7 @@ int hfsplus_fileattr_set(struct mnt_idmap *idmap,
>  	else
>  		hip->userflags &= ~HFSPLUS_FLG_NODUMP;
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	return 0;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 48/92] hfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 48/92] hfs: " Jeff Layton
@ 2023-07-06 12:50     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:50 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:13, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/hfs/catalog.c |  8 ++++----
>  fs/hfs/dir.c     |  2 +-
>  fs/hfs/inode.c   | 13 ++++++-------
>  fs/hfs/sysdep.c  |  4 +++-
>  4 files changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
> index d365bf0b8c77..632c226a3972 100644
> --- a/fs/hfs/catalog.c
> +++ b/fs/hfs/catalog.c
> @@ -133,7 +133,7 @@ int hfs_cat_create(u32 cnid, struct inode *dir, const struct qstr *str, struct i
>  		goto err1;
>  
>  	dir->i_size++;
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	hfs_find_exit(&fd);
>  	return 0;
> @@ -269,7 +269,7 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, const struct qstr *str)
>  	}
>  
>  	dir->i_size--;
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	res = 0;
>  out:
> @@ -337,7 +337,7 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
>  	if (err)
>  		goto out;
>  	dst_dir->i_size++;
> -	dst_dir->i_mtime = dst_dir->i_ctime = current_time(dst_dir);
> +	dst_dir->i_mtime = inode_set_ctime_current(dst_dir);
>  	mark_inode_dirty(dst_dir);
>  
>  	/* finally remove the old entry */
> @@ -349,7 +349,7 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
>  	if (err)
>  		goto out;
>  	src_dir->i_size--;
> -	src_dir->i_mtime = src_dir->i_ctime = current_time(src_dir);
> +	src_dir->i_mtime = inode_set_ctime_current(src_dir);
>  	mark_inode_dirty(src_dir);
>  
>  	type = entry.type;
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index 3e1e3dcf0b48..b75c26045df4 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -263,7 +263,7 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
>  	if (res)
>  		return res;
>  	clear_nlink(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	hfs_delete_inode(inode);
>  	mark_inode_dirty(inode);
>  	return 0;
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 441d7fc952e3..ee349b72cfb3 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -200,7 +200,7 @@ struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t
>  	inode->i_uid = current_fsuid();
>  	inode->i_gid = current_fsgid();
>  	set_nlink(inode, 1);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	HFS_I(inode)->flags = 0;
>  	HFS_I(inode)->rsrc_inode = NULL;
>  	HFS_I(inode)->fs_blocks = 0;
> @@ -355,8 +355,8 @@ static int hfs_read_inode(struct inode *inode, void *data)
>  			inode->i_mode |= S_IWUGO;
>  		inode->i_mode &= ~hsb->s_file_umask;
>  		inode->i_mode |= S_IFREG;
> -		inode->i_ctime = inode->i_atime = inode->i_mtime =
> -				hfs_m_to_utime(rec->file.MdDat);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode,
> +									hfs_m_to_utime(rec->file.MdDat));
>  		inode->i_op = &hfs_file_inode_operations;
>  		inode->i_fop = &hfs_file_operations;
>  		inode->i_mapping->a_ops = &hfs_aops;
> @@ -366,8 +366,8 @@ static int hfs_read_inode(struct inode *inode, void *data)
>  		inode->i_size = be16_to_cpu(rec->dir.Val) + 2;
>  		HFS_I(inode)->fs_blocks = 0;
>  		inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
> -		inode->i_ctime = inode->i_atime = inode->i_mtime =
> -				hfs_m_to_utime(rec->dir.MdDat);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode,
> +									hfs_m_to_utime(rec->dir.MdDat));
>  		inode->i_op = &hfs_dir_inode_operations;
>  		inode->i_fop = &hfs_dir_operations;
>  		break;
> @@ -654,8 +654,7 @@ int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  
>  		truncate_setsize(inode, attr->ia_size);
>  		hfs_file_truncate(inode);
> -		inode->i_atime = inode->i_mtime = inode->i_ctime =
> -						  current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  
>  	setattr_copy(&nop_mnt_idmap, inode, attr);
> diff --git a/fs/hfs/sysdep.c b/fs/hfs/sysdep.c
> index 2875961fdc10..dc27d418fbcd 100644
> --- a/fs/hfs/sysdep.c
> +++ b/fs/hfs/sysdep.c
> @@ -28,7 +28,9 @@ static int hfs_revalidate_dentry(struct dentry *dentry, unsigned int flags)
>  	/* fix up inode on a timezone change */
>  	diff = sys_tz.tz_minuteswest * 60 - HFS_I(inode)->tz_secondswest;
>  	if (diff) {
> -		inode->i_ctime.tv_sec += diff;
> +		struct timespec64 ctime = inode_get_ctime(inode);
> +
> +		inode_set_ctime(inode, ctime.tv_sec + diff, ctime.tv_nsec);
>  		inode->i_atime.tv_sec += diff;
>  		inode->i_mtime.tv_sec += diff;
>  		HFS_I(inode)->tz_secondswest += diff;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 47/92] gfs2: convert to ctime accessor functions
  2023-07-05 19:01     ` [Cluster-devel] " Jeff Layton
@ 2023-07-06 12:54       ` Jan Kara
  -1 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:54 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Bob Peterson, Andreas Gruenbacher, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, cluster-devel

On Wed 05-07-23 15:01:12, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/gfs2/acl.c   |  2 +-
>  fs/gfs2/bmap.c  | 11 +++++------
>  fs/gfs2/dir.c   | 15 ++++++++-------
>  fs/gfs2/file.c  |  2 +-
>  fs/gfs2/glops.c |  4 ++--
>  fs/gfs2/inode.c |  8 ++++----
>  fs/gfs2/super.c |  4 ++--
>  fs/gfs2/xattr.c |  8 ++++----
>  8 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
> index a392aa0f041d..443640e6fb9c 100644
> --- a/fs/gfs2/acl.c
> +++ b/fs/gfs2/acl.c
> @@ -142,7 +142,7 @@ int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
>  
>  	ret = __gfs2_set_acl(inode, acl, type);
>  	if (!ret && mode != inode->i_mode) {
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		inode->i_mode = mode;
>  		mark_inode_dirty(inode);
>  	}
> diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
> index 8d611fbcf0bd..45ea63f7167d 100644
> --- a/fs/gfs2/bmap.c
> +++ b/fs/gfs2/bmap.c
> @@ -1386,7 +1386,7 @@ static int trunc_start(struct inode *inode, u64 newsize)
>  		ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG;
>  
>  	i_size_write(inode, newsize);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	gfs2_dinode_out(ip, dibh->b_data);
>  
>  	if (journaled)
> @@ -1583,8 +1583,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
>  
>  			/* Every transaction boundary, we rewrite the dinode
>  			   to keep its di_blocks current in case of failure. */
> -			ip->i_inode.i_mtime = ip->i_inode.i_ctime =
> -				current_time(&ip->i_inode);
> +			ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  			gfs2_trans_add_meta(ip->i_gl, dibh);
>  			gfs2_dinode_out(ip, dibh->b_data);
>  			brelse(dibh);
> @@ -1950,7 +1949,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
>  		gfs2_statfs_change(sdp, 0, +btotal, 0);
>  		gfs2_quota_change(ip, -(s64)btotal, ip->i_inode.i_uid,
>  				  ip->i_inode.i_gid);
> -		ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +		ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  		gfs2_trans_add_meta(ip->i_gl, dibh);
>  		gfs2_dinode_out(ip, dibh->b_data);
>  		up_write(&ip->i_rw_mutex);
> @@ -1993,7 +1992,7 @@ static int trunc_end(struct gfs2_inode *ip)
>  		gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
>  		gfs2_ordered_del_inode(ip);
>  	}
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG;
>  
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
> @@ -2094,7 +2093,7 @@ static int do_grow(struct inode *inode, u64 size)
>  		goto do_end_trans;
>  
>  	truncate_setsize(inode, size);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
>  	gfs2_dinode_out(ip, dibh->b_data);
>  	brelse(dibh);
> diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
> index 54a6d17b8c25..1a2afa88f8be 100644
> --- a/fs/gfs2/dir.c
> +++ b/fs/gfs2/dir.c
> @@ -130,7 +130,7 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
>  	memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
>  	if (ip->i_inode.i_size < offset + size)
>  		i_size_write(&ip->i_inode, offset + size);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	gfs2_dinode_out(ip, dibh->b_data);
>  
>  	brelse(dibh);
> @@ -227,7 +227,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
>  
>  	if (ip->i_inode.i_size < offset + copied)
>  		i_size_write(&ip->i_inode, offset + copied);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
>  	gfs2_dinode_out(ip, dibh->b_data);
> @@ -1814,7 +1814,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
>  			gfs2_inum_out(nip, dent);
>  			dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode));
>  			dent->de_rahead = cpu_to_be16(gfs2_inode_ra_len(nip));
> -			tv = current_time(&ip->i_inode);
> +			tv = inode_set_ctime_current(&ip->i_inode);
>  			if (ip->i_diskflags & GFS2_DIF_EXHASH) {
>  				leaf = (struct gfs2_leaf *)bh->b_data;
>  				be16_add_cpu(&leaf->lf_entries, 1);
> @@ -1825,7 +1825,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
>  			da->bh = NULL;
>  			brelse(bh);
>  			ip->i_entries++;
> -			ip->i_inode.i_mtime = ip->i_inode.i_ctime = tv;
> +			ip->i_inode.i_mtime = tv;
>  			if (S_ISDIR(nip->i_inode.i_mode))
>  				inc_nlink(&ip->i_inode);
>  			mark_inode_dirty(inode);
> @@ -1876,7 +1876,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
>  	const struct qstr *name = &dentry->d_name;
>  	struct gfs2_dirent *dent, *prev = NULL;
>  	struct buffer_head *bh;
> -	struct timespec64 tv = current_time(&dip->i_inode);
> +	struct timespec64 tv;
>  
>  	/* Returns _either_ the entry (if its first in block) or the
>  	   previous entry otherwise */
> @@ -1896,6 +1896,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
>  	}
>  
>  	dirent_del(dip, bh, prev, dent);
> +	tv = inode_set_ctime_current(&dip->i_inode);
>  	if (dip->i_diskflags & GFS2_DIF_EXHASH) {
>  		struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
>  		u16 entries = be16_to_cpu(leaf->lf_entries);
> @@ -1910,7 +1911,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
>  	if (!dip->i_entries)
>  		gfs2_consist_inode(dip);
>  	dip->i_entries--;
> -	dip->i_inode.i_mtime = dip->i_inode.i_ctime = tv;
> +	dip->i_inode.i_mtime =  tv;
>  	if (d_is_dir(dentry))
>  		drop_nlink(&dip->i_inode);
>  	mark_inode_dirty(&dip->i_inode);
> @@ -1951,7 +1952,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
>  	dent->de_type = cpu_to_be16(new_type);
>  	brelse(bh);
>  
> -	dip->i_inode.i_mtime = dip->i_inode.i_ctime = current_time(&dip->i_inode);
> +	dip->i_inode.i_mtime = inode_set_ctime_current(&dip->i_inode);
>  	mark_inode_dirty_sync(&dip->i_inode);
>  	return 0;
>  }
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 1bf3c4453516..ecbfbc6df621 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -260,7 +260,7 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
>  	error = gfs2_meta_inode_buffer(ip, &bh);
>  	if (error)
>  		goto out_trans_end;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	gfs2_trans_add_meta(ip->i_gl, bh);
>  	ip->i_diskflags = new_flags;
>  	gfs2_dinode_out(ip, bh->b_data);
> diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
> index 54319328b16b..aecdac3cfbe1 100644
> --- a/fs/gfs2/glops.c
> +++ b/fs/gfs2/glops.c
> @@ -437,8 +437,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
>  		inode->i_atime = atime;
>  	inode->i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
>  	inode->i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
> -	inode->i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
> -	inode->i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
> +	inode_set_ctime(inode, be64_to_cpu(str->di_ctime),
> +			be32_to_cpu(str->di_ctime_nsec));
>  
>  	ip->i_goal = be64_to_cpu(str->di_goal_meta);
>  	ip->i_generation = be64_to_cpu(str->di_generation);
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 17c994a0c0d0..2ded6c813f20 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -690,7 +690,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
>  	set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
>  	inode->i_rdev = dev;
>  	inode->i_size = size;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	munge_mode_uid_gid(dip, inode);
>  	check_and_update_goal(dip);
>  	ip->i_goal = dip->i_goal;
> @@ -1029,7 +1029,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
>  
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
>  	inc_nlink(&ip->i_inode);
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	ihold(inode);
>  	d_instantiate(dentry, inode);
>  	mark_inode_dirty(inode);
> @@ -1114,7 +1114,7 @@ static int gfs2_unlink_inode(struct gfs2_inode *dip,
>  		return error;
>  
>  	ip->i_entries = 0;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	if (S_ISDIR(inode->i_mode))
>  		clear_nlink(inode);
>  	else
> @@ -1371,7 +1371,7 @@ static int update_moved_ino(struct gfs2_inode *ip, struct gfs2_inode *ndip,
>  	if (dir_rename)
>  		return gfs2_dir_mvino(ip, &gfs2_qdotdot, ndip, DT_DIR);
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	mark_inode_dirty_sync(&ip->i_inode);
>  	return 0;
>  }
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index 9f4d5d6549ee..ec0296b35dfe 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -412,7 +412,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
>  	str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(inode));
>  	str->di_atime = cpu_to_be64(inode->i_atime.tv_sec);
>  	str->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec);
> -	str->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec);
> +	str->di_ctime = cpu_to_be64(inode_get_ctime(inode).tv_sec);
>  
>  	str->di_goal_meta = cpu_to_be64(ip->i_goal);
>  	str->di_goal_data = cpu_to_be64(ip->i_goal);
> @@ -429,7 +429,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
>  	str->di_eattr = cpu_to_be64(ip->i_eattr);
>  	str->di_atime_nsec = cpu_to_be32(inode->i_atime.tv_nsec);
>  	str->di_mtime_nsec = cpu_to_be32(inode->i_mtime.tv_nsec);
> -	str->di_ctime_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
> +	str->di_ctime_nsec = cpu_to_be32(inode_get_ctime(inode).tv_nsec);
>  }
>  
>  /**
> diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
> index 93b36d026bb4..4fea70c0fe3d 100644
> --- a/fs/gfs2/xattr.c
> +++ b/fs/gfs2/xattr.c
> @@ -311,7 +311,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
>  		ea->ea_num_ptrs = 0;
>  	}
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  	gfs2_trans_end(sdp);
> @@ -763,7 +763,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
>  	if (error)
>  		goto out_end_trans;
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  out_end_trans:
> @@ -888,7 +888,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
>  	if (es->es_el)
>  		ea_set_remove_stuffed(ip, es->es_el);
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  	gfs2_trans_end(GFS2_SB(&ip->i_inode));
> @@ -1106,7 +1106,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
>  		ea->ea_type = GFS2_EATYPE_UNUSED;
>  	}
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  	gfs2_trans_end(GFS2_SB(&ip->i_inode));
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* [Cluster-devel] [PATCH v2 47/92] gfs2: convert to ctime accessor functions
@ 2023-07-06 12:54       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:54 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed 05-07-23 15:01:12, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/gfs2/acl.c   |  2 +-
>  fs/gfs2/bmap.c  | 11 +++++------
>  fs/gfs2/dir.c   | 15 ++++++++-------
>  fs/gfs2/file.c  |  2 +-
>  fs/gfs2/glops.c |  4 ++--
>  fs/gfs2/inode.c |  8 ++++----
>  fs/gfs2/super.c |  4 ++--
>  fs/gfs2/xattr.c |  8 ++++----
>  8 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
> index a392aa0f041d..443640e6fb9c 100644
> --- a/fs/gfs2/acl.c
> +++ b/fs/gfs2/acl.c
> @@ -142,7 +142,7 @@ int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
>  
>  	ret = __gfs2_set_acl(inode, acl, type);
>  	if (!ret && mode != inode->i_mode) {
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		inode->i_mode = mode;
>  		mark_inode_dirty(inode);
>  	}
> diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
> index 8d611fbcf0bd..45ea63f7167d 100644
> --- a/fs/gfs2/bmap.c
> +++ b/fs/gfs2/bmap.c
> @@ -1386,7 +1386,7 @@ static int trunc_start(struct inode *inode, u64 newsize)
>  		ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG;
>  
>  	i_size_write(inode, newsize);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	gfs2_dinode_out(ip, dibh->b_data);
>  
>  	if (journaled)
> @@ -1583,8 +1583,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
>  
>  			/* Every transaction boundary, we rewrite the dinode
>  			   to keep its di_blocks current in case of failure. */
> -			ip->i_inode.i_mtime = ip->i_inode.i_ctime =
> -				current_time(&ip->i_inode);
> +			ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  			gfs2_trans_add_meta(ip->i_gl, dibh);
>  			gfs2_dinode_out(ip, dibh->b_data);
>  			brelse(dibh);
> @@ -1950,7 +1949,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
>  		gfs2_statfs_change(sdp, 0, +btotal, 0);
>  		gfs2_quota_change(ip, -(s64)btotal, ip->i_inode.i_uid,
>  				  ip->i_inode.i_gid);
> -		ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +		ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  		gfs2_trans_add_meta(ip->i_gl, dibh);
>  		gfs2_dinode_out(ip, dibh->b_data);
>  		up_write(&ip->i_rw_mutex);
> @@ -1993,7 +1992,7 @@ static int trunc_end(struct gfs2_inode *ip)
>  		gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
>  		gfs2_ordered_del_inode(ip);
>  	}
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG;
>  
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
> @@ -2094,7 +2093,7 @@ static int do_grow(struct inode *inode, u64 size)
>  		goto do_end_trans;
>  
>  	truncate_setsize(inode, size);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
>  	gfs2_dinode_out(ip, dibh->b_data);
>  	brelse(dibh);
> diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
> index 54a6d17b8c25..1a2afa88f8be 100644
> --- a/fs/gfs2/dir.c
> +++ b/fs/gfs2/dir.c
> @@ -130,7 +130,7 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
>  	memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
>  	if (ip->i_inode.i_size < offset + size)
>  		i_size_write(&ip->i_inode, offset + size);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  	gfs2_dinode_out(ip, dibh->b_data);
>  
>  	brelse(dibh);
> @@ -227,7 +227,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
>  
>  	if (ip->i_inode.i_size < offset + copied)
>  		i_size_write(&ip->i_inode, offset + copied);
> -	ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	ip->i_inode.i_mtime = inode_set_ctime_current(&ip->i_inode);
>  
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
>  	gfs2_dinode_out(ip, dibh->b_data);
> @@ -1814,7 +1814,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
>  			gfs2_inum_out(nip, dent);
>  			dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode));
>  			dent->de_rahead = cpu_to_be16(gfs2_inode_ra_len(nip));
> -			tv = current_time(&ip->i_inode);
> +			tv = inode_set_ctime_current(&ip->i_inode);
>  			if (ip->i_diskflags & GFS2_DIF_EXHASH) {
>  				leaf = (struct gfs2_leaf *)bh->b_data;
>  				be16_add_cpu(&leaf->lf_entries, 1);
> @@ -1825,7 +1825,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
>  			da->bh = NULL;
>  			brelse(bh);
>  			ip->i_entries++;
> -			ip->i_inode.i_mtime = ip->i_inode.i_ctime = tv;
> +			ip->i_inode.i_mtime = tv;
>  			if (S_ISDIR(nip->i_inode.i_mode))
>  				inc_nlink(&ip->i_inode);
>  			mark_inode_dirty(inode);
> @@ -1876,7 +1876,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
>  	const struct qstr *name = &dentry->d_name;
>  	struct gfs2_dirent *dent, *prev = NULL;
>  	struct buffer_head *bh;
> -	struct timespec64 tv = current_time(&dip->i_inode);
> +	struct timespec64 tv;
>  
>  	/* Returns _either_ the entry (if its first in block) or the
>  	   previous entry otherwise */
> @@ -1896,6 +1896,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
>  	}
>  
>  	dirent_del(dip, bh, prev, dent);
> +	tv = inode_set_ctime_current(&dip->i_inode);
>  	if (dip->i_diskflags & GFS2_DIF_EXHASH) {
>  		struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
>  		u16 entries = be16_to_cpu(leaf->lf_entries);
> @@ -1910,7 +1911,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
>  	if (!dip->i_entries)
>  		gfs2_consist_inode(dip);
>  	dip->i_entries--;
> -	dip->i_inode.i_mtime = dip->i_inode.i_ctime = tv;
> +	dip->i_inode.i_mtime =  tv;
>  	if (d_is_dir(dentry))
>  		drop_nlink(&dip->i_inode);
>  	mark_inode_dirty(&dip->i_inode);
> @@ -1951,7 +1952,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
>  	dent->de_type = cpu_to_be16(new_type);
>  	brelse(bh);
>  
> -	dip->i_inode.i_mtime = dip->i_inode.i_ctime = current_time(&dip->i_inode);
> +	dip->i_inode.i_mtime = inode_set_ctime_current(&dip->i_inode);
>  	mark_inode_dirty_sync(&dip->i_inode);
>  	return 0;
>  }
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 1bf3c4453516..ecbfbc6df621 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -260,7 +260,7 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
>  	error = gfs2_meta_inode_buffer(ip, &bh);
>  	if (error)
>  		goto out_trans_end;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	gfs2_trans_add_meta(ip->i_gl, bh);
>  	ip->i_diskflags = new_flags;
>  	gfs2_dinode_out(ip, bh->b_data);
> diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
> index 54319328b16b..aecdac3cfbe1 100644
> --- a/fs/gfs2/glops.c
> +++ b/fs/gfs2/glops.c
> @@ -437,8 +437,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
>  		inode->i_atime = atime;
>  	inode->i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
>  	inode->i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
> -	inode->i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
> -	inode->i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
> +	inode_set_ctime(inode, be64_to_cpu(str->di_ctime),
> +			be32_to_cpu(str->di_ctime_nsec));
>  
>  	ip->i_goal = be64_to_cpu(str->di_goal_meta);
>  	ip->i_generation = be64_to_cpu(str->di_generation);
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 17c994a0c0d0..2ded6c813f20 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -690,7 +690,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
>  	set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
>  	inode->i_rdev = dev;
>  	inode->i_size = size;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	munge_mode_uid_gid(dip, inode);
>  	check_and_update_goal(dip);
>  	ip->i_goal = dip->i_goal;
> @@ -1029,7 +1029,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
>  
>  	gfs2_trans_add_meta(ip->i_gl, dibh);
>  	inc_nlink(&ip->i_inode);
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	ihold(inode);
>  	d_instantiate(dentry, inode);
>  	mark_inode_dirty(inode);
> @@ -1114,7 +1114,7 @@ static int gfs2_unlink_inode(struct gfs2_inode *dip,
>  		return error;
>  
>  	ip->i_entries = 0;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	if (S_ISDIR(inode->i_mode))
>  		clear_nlink(inode);
>  	else
> @@ -1371,7 +1371,7 @@ static int update_moved_ino(struct gfs2_inode *ip, struct gfs2_inode *ndip,
>  	if (dir_rename)
>  		return gfs2_dir_mvino(ip, &gfs2_qdotdot, ndip, DT_DIR);
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	mark_inode_dirty_sync(&ip->i_inode);
>  	return 0;
>  }
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index 9f4d5d6549ee..ec0296b35dfe 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -412,7 +412,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
>  	str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(inode));
>  	str->di_atime = cpu_to_be64(inode->i_atime.tv_sec);
>  	str->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec);
> -	str->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec);
> +	str->di_ctime = cpu_to_be64(inode_get_ctime(inode).tv_sec);
>  
>  	str->di_goal_meta = cpu_to_be64(ip->i_goal);
>  	str->di_goal_data = cpu_to_be64(ip->i_goal);
> @@ -429,7 +429,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
>  	str->di_eattr = cpu_to_be64(ip->i_eattr);
>  	str->di_atime_nsec = cpu_to_be32(inode->i_atime.tv_nsec);
>  	str->di_mtime_nsec = cpu_to_be32(inode->i_mtime.tv_nsec);
> -	str->di_ctime_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
> +	str->di_ctime_nsec = cpu_to_be32(inode_get_ctime(inode).tv_nsec);
>  }
>  
>  /**
> diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
> index 93b36d026bb4..4fea70c0fe3d 100644
> --- a/fs/gfs2/xattr.c
> +++ b/fs/gfs2/xattr.c
> @@ -311,7 +311,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
>  		ea->ea_num_ptrs = 0;
>  	}
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  	gfs2_trans_end(sdp);
> @@ -763,7 +763,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
>  	if (error)
>  		goto out_end_trans;
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  out_end_trans:
> @@ -888,7 +888,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
>  	if (es->es_el)
>  		ea_set_remove_stuffed(ip, es->es_el);
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  	gfs2_trans_end(GFS2_SB(&ip->i_inode));
> @@ -1106,7 +1106,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
>  		ea->ea_type = GFS2_EATYPE_UNUSED;
>  	}
>  
> -	ip->i_inode.i_ctime = current_time(&ip->i_inode);
> +	inode_set_ctime_current(&ip->i_inode);
>  	__mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC);
>  
>  	gfs2_trans_end(GFS2_SB(&ip->i_inode));
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


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

* Re: [PATCH v2 79/92] udf: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 79/92] udf: " Jeff Layton
@ 2023-07-06 12:57     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 12:57 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Jan Kara, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel

On Wed 05-07-23 15:01:44, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/udf/ialloc.c |  2 +-
>  fs/udf/inode.c  | 17 ++++++++++-------
>  fs/udf/namei.c  | 24 ++++++++++++------------
>  3 files changed, 23 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
> index 5f7ac8c84798..6b558cbbeb6b 100644
> --- a/fs/udf/ialloc.c
> +++ b/fs/udf/ialloc.c
> @@ -100,7 +100,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
>  		iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
>  	else
>  		iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	iinfo->i_crtime = inode->i_mtime;
>  	if (unlikely(insert_inode_locked(inode) < 0)) {
>  		make_bad_inode(inode);
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 28cdfc57d946..d089795074e8 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -910,7 +910,7 @@ static int inode_getblk(struct inode *inode, struct udf_map_rq *map)
>  	map->oflags = UDF_BLK_NEW | UDF_BLK_MAPPED;
>  	iinfo->i_next_alloc_block = map->lblk + 1;
>  	iinfo->i_next_alloc_goal = newblocknum + 1;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  
>  	if (IS_SYNC(inode))
>  		udf_sync_inode(inode);
> @@ -1298,7 +1298,7 @@ int udf_setsize(struct inode *inode, loff_t newsize)
>  			goto out_unlock;
>  	}
>  update_time:
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		udf_sync_inode(inode);
>  	else
> @@ -1329,6 +1329,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
>  	int bs = inode->i_sb->s_blocksize;
>  	int ret = -EIO;
>  	uint32_t uid, gid;
> +	struct timespec64 ctime;
>  
>  reread:
>  	if (iloc->partitionReferenceNum >= sbi->s_partitions) {
> @@ -1507,7 +1508,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
>  
>  		udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime);
>  		udf_disk_stamp_to_time(&inode->i_mtime, fe->modificationTime);
> -		udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime);
> +		udf_disk_stamp_to_time(&ctime, fe->attrTime);
> +		inode_set_ctime_to_ts(inode, ctime);
>  
>  		iinfo->i_unique = le64_to_cpu(fe->uniqueID);
>  		iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
> @@ -1522,7 +1524,8 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
>  		udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime);
>  		udf_disk_stamp_to_time(&inode->i_mtime, efe->modificationTime);
>  		udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
> -		udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime);
> +		udf_disk_stamp_to_time(&ctime, efe->attrTime);
> +		inode_set_ctime_to_ts(inode, ctime);
>  
>  		iinfo->i_unique = le64_to_cpu(efe->uniqueID);
>  		iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
> @@ -1799,7 +1802,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
>  
>  		udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime);
>  		udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime);
> -		udf_time_to_disk_stamp(&fe->attrTime, inode->i_ctime);
> +		udf_time_to_disk_stamp(&fe->attrTime, inode_get_ctime(inode));
>  		memset(&(fe->impIdent), 0, sizeof(struct regid));
>  		strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER);
>  		fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
> @@ -1830,12 +1833,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
>  
>  		udf_adjust_time(iinfo, inode->i_atime);
>  		udf_adjust_time(iinfo, inode->i_mtime);
> -		udf_adjust_time(iinfo, inode->i_ctime);
> +		udf_adjust_time(iinfo, inode_get_ctime(inode));
>  
>  		udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
>  		udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);
>  		udf_time_to_disk_stamp(&efe->createTime, iinfo->i_crtime);
> -		udf_time_to_disk_stamp(&efe->attrTime, inode->i_ctime);
> +		udf_time_to_disk_stamp(&efe->attrTime, inode_get_ctime(inode));
>  
>  		memset(&(efe->impIdent), 0, sizeof(efe->impIdent));
>  		strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index a95579b043ab..ae55ab8859b6 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -365,7 +365,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
>  	*(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
>  		cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL);
>  	udf_fiiter_write_fi(&iter, NULL);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	udf_fiiter_release(&iter);
>  	udf_add_fid_counter(dir->i_sb, false, 1);
> @@ -471,7 +471,7 @@ static int udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  	udf_fiiter_release(&iter);
>  	udf_add_fid_counter(dir->i_sb, true, 1);
>  	inc_nlink(dir);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	d_instantiate_new(dentry, inode);
>  
> @@ -523,8 +523,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
>  	inode->i_size = 0;
>  	inode_dec_link_count(dir);
>  	udf_add_fid_counter(dir->i_sb, true, -1);
> -	inode->i_ctime = dir->i_ctime = dir->i_mtime =
> -						current_time(inode);
> +	dir->i_mtime = inode_set_ctime_to_ts(dir,
> +					     inode_set_ctime_current(inode));
>  	mark_inode_dirty(dir);
>  	ret = 0;
>  end_rmdir:
> @@ -555,11 +555,11 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
>  		set_nlink(inode, 1);
>  	}
>  	udf_fiiter_delete_entry(&iter);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	inode_dec_link_count(inode);
>  	udf_add_fid_counter(dir->i_sb, false, -1);
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  	ret = 0;
>  end_unlink:
>  	udf_fiiter_release(&iter);
> @@ -746,9 +746,9 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
>  
>  	inc_nlink(inode);
>  	udf_add_fid_counter(dir->i_sb, false, 1);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	ihold(inode);
>  	d_instantiate(dentry, inode);
> @@ -833,7 +833,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  	 * Like most other Unix systems, set the ctime for inodes on a
>  	 * rename.
>  	 */
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	mark_inode_dirty(old_inode);
>  
>  	/*
> @@ -861,13 +861,13 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  	}
>  
>  	if (new_inode) {
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		inode_dec_link_count(new_inode);
>  		udf_add_fid_counter(old_dir->i_sb, S_ISDIR(new_inode->i_mode),
>  				    -1);
>  	}
> -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> -	new_dir->i_ctime = new_dir->i_mtime = current_time(new_dir);
> +	old_dir->i_mtime = inode_set_ctime_current(old_dir);
> +	new_dir->i_mtime = inode_set_ctime_current(new_dir);
>  	mark_inode_dirty(old_dir);
>  	mark_inode_dirty(new_dir);
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 42/92] ext4: convert to ctime accessor functions
  2023-07-06 12:36     ` Jan Kara
@ 2023-07-06 13:10       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 13:10 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Theodore Ts'o, Andreas Dilger, Al Viro,
	linux-fsdevel, linux-kernel, linux-ext4

On Thu, 2023-07-06 at 14:36 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:07, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Some comment below:
> 
> > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> > index 0a2d55faa095..d502b930431b 100644
> > --- a/fs/ext4/ext4.h
> > +++ b/fs/ext4/ext4.h
> > @@ -3823,6 +3823,27 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
> >  	return buffer_uptodate(bh);
> >  }
> >  
> > +static inline void ext4_inode_set_ctime(struct inode *inode, struct ext4_inode *raw_inode)
> > +{
> > +	struct timespec64 ctime = inode_get_ctime(inode);
> > +
> > +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra)) {
> > +		raw_inode->i_ctime = cpu_to_le32(ctime.tv_sec);
> > +		raw_inode->i_ctime_extra = ext4_encode_extra_time(&ctime);
> > +	} else {
> > +		raw_inode->i_ctime = cpu_to_le32(clamp_t(int32_t, ctime.tv_sec, S32_MIN, S32_MAX));
> > +	}
> > +}
> > +
> > +static inline void ext4_inode_get_ctime(struct inode *inode, const struct ext4_inode *raw_inode)
> > +{
> > +	struct timespec64 ctime = { .tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime) };
> > +
> > +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra))
> > +		ext4_decode_extra_time(&ctime, raw_inode->i_ctime_extra);
> > +	inode_set_ctime(inode, ctime.tv_sec, ctime.tv_nsec);
> > +}
> > +
> 
> This duplication is kind of unpleasant. I was looking into it for a while
> and I think we can rather do some initial cleanup (attached patch 1) and
> then your conversion patch would not need to duplicate the conversion code
> (see attached patch 2).
> 
> 	
> 

Thanks Jan. That looks fine at first glance. I'll plan to drop my ext4
patch and replace it with these.

Cheers,
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 51/92] hpfs: convert to ctime accessor functions
  2023-07-06 12:47     ` Jan Kara
@ 2023-07-06 13:11       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 13:11 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Mikulas Patocka, Al Viro, linux-fsdevel, linux-kernel

On Thu, 2023-07-06 at 14:47 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:16, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> ...
> 
> > diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> > index 69fb40b2c99a..36babb78b510 100644
> > --- a/fs/hpfs/namei.c
> > +++ b/fs/hpfs/namei.c
> > @@ -13,10 +13,10 @@ static void hpfs_update_directory_times(struct inode *dir)
> >  {
> >  	time64_t t = local_to_gmt(dir->i_sb, local_get_seconds(dir->i_sb));
> >  	if (t == dir->i_mtime.tv_sec &&
> > -	    t == dir->i_ctime.tv_sec)
> > +	    t == inode_get_ctime(dir).tv_sec)
> >  		return;
> > -	dir->i_mtime.tv_sec = dir->i_ctime.tv_sec = t;
> > -	dir->i_mtime.tv_nsec = dir->i_ctime.tv_nsec = 0;
> > +	dir->i_mtime.tv_sec = inode_set_ctime(dir, t, 0).tv_sec;
> > +	dir->i_mtime.tv_nsec = 0;
> 
> Easier to read:
> 
> 	dir->i_mtime = inode_set_ctime(dir, t, 0);
> 
> > @@ -59,8 +59,9 @@ static int hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> >  	result->i_ino = fno;
> >  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> >  	hpfs_i(result)->i_dno = dno;
> > -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> > -	result->i_ctime.tv_nsec = 0; 
> > +	inode_set_ctime(result,
> > +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> > +			0);
> >  	result->i_mtime.tv_nsec = 0; 
> >  	result->i_atime.tv_nsec = 0; 
> 
> Here also:
> 	result->i_mtime = result->i_atime = inode_set_ctime(result,
> 		local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)), 0)
> 
> > @@ -167,8 +168,9 @@ static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
> >  	result->i_fop = &hpfs_file_ops;
> >  	set_nlink(result, 1);
> >  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> > -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> > -	result->i_ctime.tv_nsec = 0;
> > +	inode_set_ctime(result,
> > +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> > +			0);
> >  	result->i_mtime.tv_nsec = 0;
> >  	result->i_atime.tv_nsec = 0;
> 
> And here exactly the same.
> 
> > @@ -250,8 +252,9 @@ static int hpfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> >  	hpfs_init_inode(result);
> >  	result->i_ino = fno;
> >  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> > -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> > -	result->i_ctime.tv_nsec = 0;
> > +	inode_set_ctime(result,
> > +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> > +			0);
> >  	result->i_mtime.tv_nsec = 0;
> >  	result->i_atime.tv_nsec = 0;
> >  	hpfs_i(result)->i_ea_size = 0;
> > @@ -326,8 +329,9 @@ static int hpfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> >  	result->i_ino = fno;
> >  	hpfs_init_inode(result);
> >  	hpfs_i(result)->i_parent_dir = dir->i_ino;
> > -	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
> > -	result->i_ctime.tv_nsec = 0;
> > +	inode_set_ctime(result,
> > +			result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)),
> > +			0);
> >  	result->i_mtime.tv_nsec = 0;
> >  	result->i_atime.tv_nsec = 0;
> >  	hpfs_i(result)->i_ea_size = 0;
> 
> And in above two as well.
> 
> 								Honza

Thanks. I fixed those up in my tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 53/92] isofs: convert to ctime accessor functions
  2023-07-06 12:39     ` Jan Kara
@ 2023-07-06 13:11       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 13:11 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christian Brauner, Al Viro, linux-fsdevel, linux-kernel

On Thu, 2023-07-06 at 14:39 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:18, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  fs/isofs/inode.c |  8 ++++----
> >  fs/isofs/rock.c  | 16 +++++++---------
> >  2 files changed, 11 insertions(+), 13 deletions(-)
> > 
> > diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
> > index df9d70588b60..98a78200cff1 100644
> > --- a/fs/isofs/inode.c
> > +++ b/fs/isofs/inode.c
> > @@ -1424,11 +1424,11 @@ static int isofs_read_inode(struct inode *inode, int relocated)
> >  #endif
> >  
> >  	inode->i_mtime.tv_sec =
> > -	inode->i_atime.tv_sec =
> > -	inode->i_ctime.tv_sec = iso_date(de->date, high_sierra);
> > +	inode->i_atime.tv_sec = inode_set_ctime(inode,
> > +						iso_date(de->date, high_sierra),
> > +						0).tv_sec;
> >  	inode->i_mtime.tv_nsec =
> > -	inode->i_atime.tv_nsec =
> > -	inode->i_ctime.tv_nsec = 0;
> > +	inode->i_atime.tv_nsec = 0;
> 
> This would be IMHO more readable as:
> 
> 	inode->i_mtime = inode->i_atime =
> 		inode_set_ctime(inode, iso_date(de->date, high_sierra), 0);
> 
> 
> Otherwise the patch looks good.
> 

Thanks. Fixed in my tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 54/92] jffs2: convert to ctime accessor functions
  2023-07-05 19:01     ` Jeff Layton
@ 2023-07-06 13:25       ` Jan Kara
  -1 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:25 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, David Woodhouse, Richard Weinberger, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

On Wed 05-07-23 15:01:19, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jffs2/dir.c      | 24 +++++++++++++++---------
>  fs/jffs2/file.c     |  3 ++-
>  fs/jffs2/fs.c       | 10 +++++-----
>  fs/jffs2/os-linux.h |  2 +-
>  4 files changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index 5075a0a6d594..091ab0eaabbe 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -204,7 +204,8 @@ static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
>  	if (ret)
>  		goto fail;
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(ri->ctime)));
>  
>  	jffs2_free_raw_inode(ri);
>  
> @@ -237,7 +238,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
>  	if (dead_f->inocache)
>  		set_nlink(d_inode(dentry), dead_f->inocache->pino_nlink);
>  	if (!ret)
> -		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
> +		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
>  	return ret;
>  }
>  /***********************************************************************/
> @@ -271,7 +272,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
>  		set_nlink(d_inode(old_dentry), ++f->inocache->pino_nlink);
>  		mutex_unlock(&f->sem);
>  		d_instantiate(dentry, d_inode(old_dentry));
> -		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
> +		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
>  		ihold(d_inode(old_dentry));
>  	}
>  	return ret;
> @@ -422,7 +423,8 @@ static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
>  		goto fail;
>  	}
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(rd->mctime)));
>  
>  	jffs2_free_raw_dirent(rd);
>  
> @@ -566,7 +568,8 @@ static int jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,
>  		goto fail;
>  	}
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(rd->mctime)));
>  	inc_nlink(dir_i);
>  
>  	jffs2_free_raw_dirent(rd);
> @@ -607,7 +610,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
>  	ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,
>  			      dentry->d_name.len, f, now);
>  	if (!ret) {
> -		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
> +		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
>  		clear_nlink(d_inode(dentry));
>  		drop_nlink(dir_i);
>  	}
> @@ -743,7 +746,8 @@ static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
>  		goto fail;
>  	}
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(rd->mctime)));
>  
>  	jffs2_free_raw_dirent(rd);
>  
> @@ -864,14 +868,16 @@ static int jffs2_rename (struct mnt_idmap *idmap,
>  		 * caller won't do it on its own since we are returning an error.
>  		 */
>  		d_invalidate(new_dentry);
> -		new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now);
> +		new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i,
> +							   ITIME(now));
>  		return ret;
>  	}
>  
>  	if (d_is_dir(old_dentry))
>  		drop_nlink(old_dir_i);
>  
> -	new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
> +	old_dir_i->i_mtime = inode_set_ctime_to_ts(old_dir_i, ITIME(now));
> +	new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i, ITIME(now));
>  
>  	return 0;
>  }
> diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
> index 2345ca3f09ee..11c66793960e 100644
> --- a/fs/jffs2/file.c
> +++ b/fs/jffs2/file.c
> @@ -317,7 +317,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
>  			inode->i_size = pos + writtenlen;
>  			inode->i_blocks = (inode->i_size + 511) >> 9;
>  
> -			inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
> +			inode->i_mtime = inode_set_ctime_to_ts(inode,
> +							       ITIME(je32_to_cpu(ri->ctime)));
>  		}
>  	}
>  
> diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
> index 038516bee1ab..0403efab4089 100644
> --- a/fs/jffs2/fs.c
> +++ b/fs/jffs2/fs.c
> @@ -115,7 +115,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
>  	ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
>  	ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
>  	ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
> -	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
> +	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode_get_ctime(inode)));
>  
>  	ri->offset = cpu_to_je32(0);
>  	ri->csize = ri->dsize = cpu_to_je32(mdatalen);
> @@ -148,7 +148,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
>  	}
>  	/* It worked. Update the inode */
>  	inode->i_atime = ITIME(je32_to_cpu(ri->atime));
> -	inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
> +	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(ri->ctime)));
>  	inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
>  	inode->i_mode = jemode_to_cpu(ri->mode);
>  	i_uid_write(inode, je16_to_cpu(ri->uid));
> @@ -284,7 +284,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
>  	inode->i_size = je32_to_cpu(latest_node.isize);
>  	inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
>  	inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
> -	inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
> +	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(latest_node.ctime)));
>  
>  	set_nlink(inode, f->inocache->pino_nlink);
>  
> @@ -388,7 +388,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
>  	iattr.ia_gid = inode->i_gid;
>  	iattr.ia_atime = inode->i_atime;
>  	iattr.ia_mtime = inode->i_mtime;
> -	iattr.ia_ctime = inode->i_ctime;
> +	iattr.ia_ctime = inode_get_ctime(inode);
>  
>  	jffs2_do_setattr(inode, &iattr);
>  }
> @@ -475,7 +475,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
>  	inode->i_mode = jemode_to_cpu(ri->mode);
>  	i_gid_write(inode, je16_to_cpu(ri->gid));
>  	i_uid_write(inode, je16_to_cpu(ri->uid));
> -	inode->i_atime = inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
>  
>  	inode->i_blocks = 0;
> diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
> index 8da19766c101..50727a1ff931 100644
> --- a/fs/jffs2/os-linux.h
> +++ b/fs/jffs2/os-linux.h
> @@ -35,7 +35,7 @@ struct kvec;
>  #define ITIME(sec) ((struct timespec64){sec, 0})
>  #define JFFS2_NOW() JFFS2_CLAMP_TIME(ktime_get_real_seconds())
>  #define I_SEC(tv) JFFS2_CLAMP_TIME((tv).tv_sec)
> -#define JFFS2_F_I_CTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_ctime)
> +#define JFFS2_F_I_CTIME(f) I_SEC(inode_get_ctime(OFNI_EDONI_2SFFJ(f)))
>  #define JFFS2_F_I_MTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_mtime)
>  #define JFFS2_F_I_ATIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_atime)
>  #define sleep_on_spinunlock(wq, s)				\
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

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

* Re: [PATCH v2 54/92] jffs2: convert to ctime accessor functions
@ 2023-07-06 13:25       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:25 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, David Woodhouse, Richard Weinberger, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-mtd

On Wed 05-07-23 15:01:19, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jffs2/dir.c      | 24 +++++++++++++++---------
>  fs/jffs2/file.c     |  3 ++-
>  fs/jffs2/fs.c       | 10 +++++-----
>  fs/jffs2/os-linux.h |  2 +-
>  4 files changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index 5075a0a6d594..091ab0eaabbe 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -204,7 +204,8 @@ static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
>  	if (ret)
>  		goto fail;
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(ri->ctime)));
>  
>  	jffs2_free_raw_inode(ri);
>  
> @@ -237,7 +238,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
>  	if (dead_f->inocache)
>  		set_nlink(d_inode(dentry), dead_f->inocache->pino_nlink);
>  	if (!ret)
> -		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
> +		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
>  	return ret;
>  }
>  /***********************************************************************/
> @@ -271,7 +272,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
>  		set_nlink(d_inode(old_dentry), ++f->inocache->pino_nlink);
>  		mutex_unlock(&f->sem);
>  		d_instantiate(dentry, d_inode(old_dentry));
> -		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
> +		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
>  		ihold(d_inode(old_dentry));
>  	}
>  	return ret;
> @@ -422,7 +423,8 @@ static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
>  		goto fail;
>  	}
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(rd->mctime)));
>  
>  	jffs2_free_raw_dirent(rd);
>  
> @@ -566,7 +568,8 @@ static int jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,
>  		goto fail;
>  	}
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(rd->mctime)));
>  	inc_nlink(dir_i);
>  
>  	jffs2_free_raw_dirent(rd);
> @@ -607,7 +610,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
>  	ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,
>  			      dentry->d_name.len, f, now);
>  	if (!ret) {
> -		dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
> +		dir_i->i_mtime = inode_set_ctime_to_ts(dir_i, ITIME(now));
>  		clear_nlink(d_inode(dentry));
>  		drop_nlink(dir_i);
>  	}
> @@ -743,7 +746,8 @@ static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
>  		goto fail;
>  	}
>  
> -	dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
> +	dir_i->i_mtime = inode_set_ctime_to_ts(dir_i,
> +					       ITIME(je32_to_cpu(rd->mctime)));
>  
>  	jffs2_free_raw_dirent(rd);
>  
> @@ -864,14 +868,16 @@ static int jffs2_rename (struct mnt_idmap *idmap,
>  		 * caller won't do it on its own since we are returning an error.
>  		 */
>  		d_invalidate(new_dentry);
> -		new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now);
> +		new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i,
> +							   ITIME(now));
>  		return ret;
>  	}
>  
>  	if (d_is_dir(old_dentry))
>  		drop_nlink(old_dir_i);
>  
> -	new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
> +	old_dir_i->i_mtime = inode_set_ctime_to_ts(old_dir_i, ITIME(now));
> +	new_dir_i->i_mtime = inode_set_ctime_to_ts(new_dir_i, ITIME(now));
>  
>  	return 0;
>  }
> diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
> index 2345ca3f09ee..11c66793960e 100644
> --- a/fs/jffs2/file.c
> +++ b/fs/jffs2/file.c
> @@ -317,7 +317,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
>  			inode->i_size = pos + writtenlen;
>  			inode->i_blocks = (inode->i_size + 511) >> 9;
>  
> -			inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
> +			inode->i_mtime = inode_set_ctime_to_ts(inode,
> +							       ITIME(je32_to_cpu(ri->ctime)));
>  		}
>  	}
>  
> diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
> index 038516bee1ab..0403efab4089 100644
> --- a/fs/jffs2/fs.c
> +++ b/fs/jffs2/fs.c
> @@ -115,7 +115,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
>  	ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
>  	ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
>  	ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
> -	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
> +	ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode_get_ctime(inode)));
>  
>  	ri->offset = cpu_to_je32(0);
>  	ri->csize = ri->dsize = cpu_to_je32(mdatalen);
> @@ -148,7 +148,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
>  	}
>  	/* It worked. Update the inode */
>  	inode->i_atime = ITIME(je32_to_cpu(ri->atime));
> -	inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
> +	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(ri->ctime)));
>  	inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
>  	inode->i_mode = jemode_to_cpu(ri->mode);
>  	i_uid_write(inode, je16_to_cpu(ri->uid));
> @@ -284,7 +284,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
>  	inode->i_size = je32_to_cpu(latest_node.isize);
>  	inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
>  	inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
> -	inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
> +	inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(latest_node.ctime)));
>  
>  	set_nlink(inode, f->inocache->pino_nlink);
>  
> @@ -388,7 +388,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
>  	iattr.ia_gid = inode->i_gid;
>  	iattr.ia_atime = inode->i_atime;
>  	iattr.ia_mtime = inode->i_mtime;
> -	iattr.ia_ctime = inode->i_ctime;
> +	iattr.ia_ctime = inode_get_ctime(inode);
>  
>  	jffs2_do_setattr(inode, &iattr);
>  }
> @@ -475,7 +475,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
>  	inode->i_mode = jemode_to_cpu(ri->mode);
>  	i_gid_write(inode, je16_to_cpu(ri->gid));
>  	i_uid_write(inode, je16_to_cpu(ri->uid));
> -	inode->i_atime = inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
>  
>  	inode->i_blocks = 0;
> diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
> index 8da19766c101..50727a1ff931 100644
> --- a/fs/jffs2/os-linux.h
> +++ b/fs/jffs2/os-linux.h
> @@ -35,7 +35,7 @@ struct kvec;
>  #define ITIME(sec) ((struct timespec64){sec, 0})
>  #define JFFS2_NOW() JFFS2_CLAMP_TIME(ktime_get_real_seconds())
>  #define I_SEC(tv) JFFS2_CLAMP_TIME((tv).tv_sec)
> -#define JFFS2_F_I_CTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_ctime)
> +#define JFFS2_F_I_CTIME(f) I_SEC(inode_get_ctime(OFNI_EDONI_2SFFJ(f)))
>  #define JFFS2_F_I_MTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_mtime)
>  #define JFFS2_F_I_ATIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_atime)
>  #define sleep_on_spinunlock(wq, s)				\
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 55/92] jfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 55/92] jfs: " Jeff Layton
@ 2023-07-06 13:27     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:27 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Dave Kleikamp, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, Dave Kleikamp, jfs-discussion

On Wed 05-07-23 15:01:20, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jfs/acl.c       |  2 +-
>  fs/jfs/inode.c     |  2 +-
>  fs/jfs/ioctl.c     |  2 +-
>  fs/jfs/jfs_imap.c  |  8 ++++----
>  fs/jfs/jfs_inode.c |  4 ++--
>  fs/jfs/namei.c     | 24 ++++++++++++------------
>  fs/jfs/super.c     |  2 +-
>  fs/jfs/xattr.c     |  2 +-
>  8 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
> index fb96f872d207..1de3602c98de 100644
> --- a/fs/jfs/acl.c
> +++ b/fs/jfs/acl.c
> @@ -116,7 +116,7 @@ int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
>  	if (!rc) {
>  		if (update_mode) {
>  			inode->i_mode = mode;
> -			inode->i_ctime = current_time(inode);
> +			inode_set_ctime_current(inode);
>  			mark_inode_dirty(inode);
>  		}
>  		rc = txCommit(tid, 1, &inode, 0);
> diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
> index 8ac10e396050..920d58a1566b 100644
> --- a/fs/jfs/inode.c
> +++ b/fs/jfs/inode.c
> @@ -393,7 +393,7 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
>  			break;
>  		}
>  
> -		ip->i_mtime = ip->i_ctime = current_time(ip);
> +		ip->i_mtime = inode_set_ctime_current(ip);
>  		mark_inode_dirty(ip);
>  
>  		txCommit(tid, 1, &ip, 0);
> diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
> index ed7989bc2db1..f7bd7e8f5be4 100644
> --- a/fs/jfs/ioctl.c
> +++ b/fs/jfs/ioctl.c
> @@ -96,7 +96,7 @@ int jfs_fileattr_set(struct mnt_idmap *idmap,
>  	jfs_inode->mode2 = flags;
>  
>  	jfs_set_inode_flags(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	return 0;
> diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
> index 390cbfce391f..a40383aa6c84 100644
> --- a/fs/jfs/jfs_imap.c
> +++ b/fs/jfs/jfs_imap.c
> @@ -3064,8 +3064,8 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
>  	ip->i_atime.tv_nsec = le32_to_cpu(dip->di_atime.tv_nsec);
>  	ip->i_mtime.tv_sec = le32_to_cpu(dip->di_mtime.tv_sec);
>  	ip->i_mtime.tv_nsec = le32_to_cpu(dip->di_mtime.tv_nsec);
> -	ip->i_ctime.tv_sec = le32_to_cpu(dip->di_ctime.tv_sec);
> -	ip->i_ctime.tv_nsec = le32_to_cpu(dip->di_ctime.tv_nsec);
> +	inode_set_ctime(ip, le32_to_cpu(dip->di_ctime.tv_sec),
> +			le32_to_cpu(dip->di_ctime.tv_nsec));
>  	ip->i_blocks = LBLK2PBLK(ip->i_sb, le64_to_cpu(dip->di_nblocks));
>  	ip->i_generation = le32_to_cpu(dip->di_gen);
>  
> @@ -3139,8 +3139,8 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip)
>  
>  	dip->di_atime.tv_sec = cpu_to_le32(ip->i_atime.tv_sec);
>  	dip->di_atime.tv_nsec = cpu_to_le32(ip->i_atime.tv_nsec);
> -	dip->di_ctime.tv_sec = cpu_to_le32(ip->i_ctime.tv_sec);
> -	dip->di_ctime.tv_nsec = cpu_to_le32(ip->i_ctime.tv_nsec);
> +	dip->di_ctime.tv_sec = cpu_to_le32(inode_get_ctime(ip).tv_sec);
> +	dip->di_ctime.tv_nsec = cpu_to_le32(inode_get_ctime(ip).tv_nsec);
>  	dip->di_mtime.tv_sec = cpu_to_le32(ip->i_mtime.tv_sec);
>  	dip->di_mtime.tv_nsec = cpu_to_le32(ip->i_mtime.tv_nsec);
>  	dip->di_ixpxd = jfs_ip->ixpxd;	/* in-memory pxd's are little-endian */
> diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c
> index 9e1f02767201..87594efa7f7c 100644
> --- a/fs/jfs/jfs_inode.c
> +++ b/fs/jfs/jfs_inode.c
> @@ -97,8 +97,8 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
>  	jfs_inode->mode2 |= inode->i_mode;
>  
>  	inode->i_blocks = 0;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> -	jfs_inode->otime = inode->i_ctime.tv_sec;
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
> +	jfs_inode->otime = inode_get_ctime(inode).tv_sec;
>  	inode->i_generation = JFS_SBI(sb)->gengen++;
>  
>  	jfs_inode->cflag = 0;
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 9b030297aa64..541578126b1a 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -149,7 +149,7 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
>  
>  	mark_inode_dirty(ip);
>  
> -	dip->i_ctime = dip->i_mtime = current_time(dip);
> +	dip->i_mtime = inode_set_ctime_current(dip);
>  
>  	mark_inode_dirty(dip);
>  
> @@ -284,7 +284,7 @@ static int jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,
>  
>  	/* update parent directory inode */
>  	inc_nlink(dip);		/* for '..' from child directory */
> -	dip->i_ctime = dip->i_mtime = current_time(dip);
> +	dip->i_mtime = inode_set_ctime_current(dip);
>  	mark_inode_dirty(dip);
>  
>  	rc = txCommit(tid, 2, &iplist[0], 0);
> @@ -390,7 +390,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
>  	/* update parent directory's link count corresponding
>  	 * to ".." entry of the target directory deleted
>  	 */
> -	dip->i_ctime = dip->i_mtime = current_time(dip);
> +	dip->i_mtime = inode_set_ctime_current(dip);
>  	inode_dec_link_count(dip);
>  
>  	/*
> @@ -512,7 +512,7 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
>  
>  	ASSERT(ip->i_nlink);
>  
> -	ip->i_ctime = dip->i_ctime = dip->i_mtime = current_time(ip);
> +	dip->i_mtime = inode_set_ctime_to_ts(dip, inode_set_ctime_current(ip));
>  	mark_inode_dirty(dip);
>  
>  	/* update target's inode */
> @@ -827,8 +827,8 @@ static int jfs_link(struct dentry *old_dentry,
>  
>  	/* update object inode */
>  	inc_nlink(ip);		/* for new link */
> -	ip->i_ctime = current_time(ip);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	inode_set_ctime_current(ip);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	ihold(ip);
>  
> @@ -1028,7 +1028,7 @@ static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
>  
>  	mark_inode_dirty(ip);
>  
> -	dip->i_ctime = dip->i_mtime = current_time(dip);
> +	dip->i_mtime = inode_set_ctime_current(dip);
>  	mark_inode_dirty(dip);
>  	/*
>  	 * commit update of parent directory and link object
> @@ -1205,7 +1205,7 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  			tblk->xflag |= COMMIT_DELETE;
>  			tblk->u.ip = new_ip;
>  		} else {
> -			new_ip->i_ctime = current_time(new_ip);
> +			inode_set_ctime_current(new_ip);
>  			mark_inode_dirty(new_ip);
>  		}
>  	} else {
> @@ -1268,10 +1268,10 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  	/*
>  	 * Update ctime on changed/moved inodes & mark dirty
>  	 */
> -	old_ip->i_ctime = current_time(old_ip);
> +	inode_set_ctime_current(old_ip);
>  	mark_inode_dirty(old_ip);
>  
> -	new_dir->i_ctime = new_dir->i_mtime = current_time(new_dir);
> +	new_dir->i_mtime = inode_set_ctime_current(new_dir);
>  	mark_inode_dirty(new_dir);
>  
>  	/* Build list of inodes modified by this transaction */
> @@ -1283,7 +1283,7 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  
>  	if (old_dir != new_dir) {
>  		iplist[ipcount++] = new_dir;
> -		old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> +		old_dir->i_mtime = inode_set_ctime_current(old_dir);
>  		mark_inode_dirty(old_dir);
>  	}
>  
> @@ -1416,7 +1416,7 @@ static int jfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  
>  	mark_inode_dirty(ip);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  
>  	mark_inode_dirty(dir);
>  
> diff --git a/fs/jfs/super.c b/fs/jfs/super.c
> index d2f82cb7db1b..2e2f7f6d36a0 100644
> --- a/fs/jfs/super.c
> +++ b/fs/jfs/super.c
> @@ -818,7 +818,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,
>  	}
>  	if (inode->i_size < off+len-towrite)
>  		i_size_write(inode, off+len-towrite);
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	inode_unlock(inode);
>  	return len - towrite;
> diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
> index 931e50018f88..8577ad494e05 100644
> --- a/fs/jfs/xattr.c
> +++ b/fs/jfs/xattr.c
> @@ -647,7 +647,7 @@ static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf,
>  	if (old_blocks)
>  		dquot_free_block(inode, old_blocks);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  
>  	return 0;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 56/92] kernfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 56/92] kernfs: " Jeff Layton
@ 2023-07-06 13:32     ` Jan Kara
  2023-07-06 13:50       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:32 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Greg Kroah-Hartman, Tejun Heo, Alexander Viro,
	Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:21, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

It looks like there are like three commits squashed into this patch -
kernfs, libfs, minix.

kernfs and libfs parts look good to me - feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

to them. For the minix part I have one nit:

> diff --git a/fs/minix/inode.c b/fs/minix/inode.c
> index e9fbb5303a22..3715a3940bd4 100644
> --- a/fs/minix/inode.c
> +++ b/fs/minix/inode.c
> @@ -501,10 +501,11 @@ static struct inode *V1_minix_iget(struct inode *inode)
>  	i_gid_write(inode, raw_inode->i_gid);
>  	set_nlink(inode, raw_inode->i_nlinks);
>  	inode->i_size = raw_inode->i_size;
> -	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = raw_inode->i_time;
> +	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode_set_ctime(inode,
> +									raw_inode->i_time,
> +									0).tv_sec;
>  	inode->i_mtime.tv_nsec = 0;
>  	inode->i_atime.tv_nsec = 0;
> -	inode->i_ctime.tv_nsec = 0;

The usual simplification:
	inode->i_mtime = inode->i_atime = inode_set_ctime(inode,
							  raw_inode->i_time, 0);

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 57/92] nfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 57/92] nfs: " Jeff Layton
@ 2023-07-06 13:34     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:34 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Trond Myklebust, Anna Schumaker, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-nfs

On Wed 05-07-23 15:01:22, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/nfs/callback_proc.c |  2 +-
>  fs/nfs/fscache.h       |  4 ++--
>  fs/nfs/inode.c         | 20 ++++++++++----------
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
> index c1eda73254e1..6bed1394d748 100644
> --- a/fs/nfs/callback_proc.c
> +++ b/fs/nfs/callback_proc.c
> @@ -59,7 +59,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
>  	res->change_attr = delegation->change_attr;
>  	if (nfs_have_writebacks(inode))
>  		res->change_attr++;
> -	res->ctime = inode->i_ctime;
> +	res->ctime = inode_get_ctime(inode);
>  	res->mtime = inode->i_mtime;
>  	res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
>  		args->bitmap[0];
> diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
> index e1706e736c64..2dc64454492b 100644
> --- a/fs/nfs/fscache.h
> +++ b/fs/nfs/fscache.h
> @@ -116,8 +116,8 @@ static inline void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *
>  	memset(auxdata, 0, sizeof(*auxdata));
>  	auxdata->mtime_sec  = inode->i_mtime.tv_sec;
>  	auxdata->mtime_nsec = inode->i_mtime.tv_nsec;
> -	auxdata->ctime_sec  = inode->i_ctime.tv_sec;
> -	auxdata->ctime_nsec = inode->i_ctime.tv_nsec;
> +	auxdata->ctime_sec  = inode_get_ctime(inode).tv_sec;
> +	auxdata->ctime_nsec = inode_get_ctime(inode).tv_nsec;
>  
>  	if (NFS_SERVER(inode)->nfs_client->rpc_ops->version == 4)
>  		auxdata->change_attr = inode_peek_iversion_raw(inode);
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 8172dd4135a1..1283fdfa4b0a 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -514,7 +514,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
>  
>  		memset(&inode->i_atime, 0, sizeof(inode->i_atime));
>  		memset(&inode->i_mtime, 0, sizeof(inode->i_mtime));
> -		memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
> +		inode_set_ctime(inode, 0, 0);
>  		inode_set_iversion_raw(inode, 0);
>  		inode->i_size = 0;
>  		clear_nlink(inode);
> @@ -535,7 +535,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
>  		else if (fattr_supported & NFS_ATTR_FATTR_MTIME)
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
>  		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
> -			inode->i_ctime = fattr->ctime;
> +			inode_set_ctime_to_ts(inode, fattr->ctime);
>  		else if (fattr_supported & NFS_ATTR_FATTR_CTIME)
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CTIME);
>  		if (fattr->valid & NFS_ATTR_FATTR_CHANGE)
> @@ -731,7 +731,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
>  		if ((attr->ia_valid & ATTR_GID) != 0)
>  			inode->i_gid = attr->ia_gid;
>  		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
> -			inode->i_ctime = fattr->ctime;
> +			inode_set_ctime_to_ts(inode, fattr->ctime);
>  		else
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
>  					| NFS_INO_INVALID_CTIME);
> @@ -749,7 +749,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME);
>  
>  		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
> -			inode->i_ctime = fattr->ctime;
> +			inode_set_ctime_to_ts(inode, fattr->ctime);
>  		else
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
>  					| NFS_INO_INVALID_CTIME);
> @@ -765,7 +765,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
>  
>  		if (fattr->valid & NFS_ATTR_FATTR_CTIME)
> -			inode->i_ctime = fattr->ctime;
> +			inode_set_ctime_to_ts(inode, fattr->ctime);
>  		else
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
>  					| NFS_INO_INVALID_CTIME);
> @@ -1444,11 +1444,11 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
>  			nfs_set_cache_invalid(inode, NFS_INO_INVALID_XATTR);
>  	}
>  	/* If we have atomic WCC data, we may update some attributes */
> -	ts = inode->i_ctime;
> +	ts = inode_get_ctime(inode);
>  	if ((fattr->valid & NFS_ATTR_FATTR_PRECTIME)
>  			&& (fattr->valid & NFS_ATTR_FATTR_CTIME)
>  			&& timespec64_equal(&ts, &fattr->pre_ctime)) {
> -		inode->i_ctime = fattr->ctime;
> +		inode_set_ctime_to_ts(inode, fattr->ctime);
>  	}
>  
>  	ts = inode->i_mtime;
> @@ -1510,7 +1510,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
>  		if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec64_equal(&ts, &fattr->mtime))
>  			invalid |= NFS_INO_INVALID_MTIME;
>  
> -		ts = inode->i_ctime;
> +		ts = inode_get_ctime(inode);
>  		if ((fattr->valid & NFS_ATTR_FATTR_CTIME) && !timespec64_equal(&ts, &fattr->ctime))
>  			invalid |= NFS_INO_INVALID_CTIME;
>  
> @@ -1997,7 +1997,7 @@ int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fa
>  	}
>  	if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 &&
>  			(fattr->valid & NFS_ATTR_FATTR_PRECTIME) == 0) {
> -		fattr->pre_ctime = inode->i_ctime;
> +		fattr->pre_ctime = inode_get_ctime(inode);
>  		fattr->valid |= NFS_ATTR_FATTR_PRECTIME;
>  	}
>  	if ((fattr->valid & NFS_ATTR_FATTR_MTIME) != 0 &&
> @@ -2190,7 +2190,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
>  			save_cache_validity & NFS_INO_INVALID_MTIME;
>  
>  	if (fattr->valid & NFS_ATTR_FATTR_CTIME)
> -		inode->i_ctime = fattr->ctime;
> +		inode_set_ctime_to_ts(inode, fattr->ctime);
>  	else if (fattr_supported & NFS_ATTR_FATTR_CTIME)
>  		nfsi->cache_validity |=
>  			save_cache_validity & NFS_INO_INVALID_CTIME;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 58/92] nfsd: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 58/92] nfsd: " Jeff Layton
@ 2023-07-06 13:34     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:34 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Chuck Lever, Neil Brown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-nfs

On Wed 05-07-23 15:01:23, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Chuck Lever <chuck.lever@oracle.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/nfsd/nfsctl.c | 2 +-
>  fs/nfsd/vfs.c    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 1b8b1aab9a15..a53c5660a8c4 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -1131,7 +1131,7 @@ static struct inode *nfsd_get_inode(struct super_block *sb, umode_t mode)
>  	/* Following advice from simple_fill_super documentation: */
>  	inode->i_ino = iunique(sb, NFSD_MaxReserved);
>  	inode->i_mode = mode;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	switch (mode & S_IFMT) {
>  	case S_IFDIR:
>  		inode->i_fop = &simple_dir_operations;
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 8a2321d19194..40a68bae88fc 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -520,7 +520,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
>  
>  	nfsd_sanitize_attrs(inode, iap);
>  
> -	if (check_guard && guardtime != inode->i_ctime.tv_sec)
> +	if (check_guard && guardtime != inode_get_ctime(inode).tv_sec)
>  		return nfserr_notsync;
>  
>  	/*
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 59/92] nilfs2: convert to ctime accessor functions
@ 2023-07-06 13:35       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:35 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Ryusuke Konishi, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-nilfs

On Wed 05-07-23 15:01:24, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/nilfs2/dir.c   |  6 +++---
>  fs/nilfs2/inode.c | 12 ++++++------
>  fs/nilfs2/ioctl.c |  2 +-
>  fs/nilfs2/namei.c |  8 ++++----
>  4 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
> index decd6471300b..bce734b68f08 100644
> --- a/fs/nilfs2/dir.c
> +++ b/fs/nilfs2/dir.c
> @@ -429,7 +429,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
>  	nilfs_set_de_type(de, inode);
>  	nilfs_commit_chunk(page, mapping, from, to);
>  	nilfs_put_page(page);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  }
>  
>  /*
> @@ -519,7 +519,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
>  	de->inode = cpu_to_le64(inode->i_ino);
>  	nilfs_set_de_type(de, inode);
>  	nilfs_commit_chunk(page, page->mapping, from, to);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	nilfs_mark_inode_dirty(dir);
>  	/* OFFSET_CACHE */
>  out_put:
> @@ -567,7 +567,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
>  		pde->rec_len = nilfs_rec_len_to_disk(to - from);
>  	dir->inode = 0;
>  	nilfs_commit_chunk(page, mapping, from, to);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  out:
>  	nilfs_put_page(page);
>  	return err;
> diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
> index a8ce522ac747..5259b94ca1dc 100644
> --- a/fs/nilfs2/inode.c
> +++ b/fs/nilfs2/inode.c
> @@ -366,7 +366,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
>  	atomic64_inc(&root->inodes_count);
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
>  	inode->i_ino = ino;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  
>  	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
>  		err = nilfs_bmap_read(ii->i_bmap, NULL);
> @@ -450,10 +450,10 @@ int nilfs_read_inode_common(struct inode *inode,
>  	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
>  	inode->i_size = le64_to_cpu(raw_inode->i_size);
>  	inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
> -	inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
> +	inode_set_ctime(inode, le64_to_cpu(raw_inode->i_ctime),
> +			le32_to_cpu(raw_inode->i_ctime_nsec));
>  	inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
>  	inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
>  	if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode))
>  		return -EIO; /* this inode is for metadata and corrupted */
> @@ -768,9 +768,9 @@ void nilfs_write_inode_common(struct inode *inode,
>  	raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));
>  	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
>  	raw_inode->i_size = cpu_to_le64(inode->i_size);
> -	raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> +	raw_inode->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
>  	raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
> -	raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	raw_inode->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  	raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
>  
> @@ -875,7 +875,7 @@ void nilfs_truncate(struct inode *inode)
>  
>  	nilfs_truncate_bmap(ii, blkoff);
>  
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		nilfs_set_transaction_flag(NILFS_TI_SYNC);
>  
> diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
> index 1dfbc0c34513..40ffade49f38 100644
> --- a/fs/nilfs2/ioctl.c
> +++ b/fs/nilfs2/ioctl.c
> @@ -149,7 +149,7 @@ int nilfs_fileattr_set(struct mnt_idmap *idmap,
>  	NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE);
>  
>  	nilfs_set_inode_flags(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		nilfs_set_transaction_flag(NILFS_TI_SYNC);
>  
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index c7024da8f1e2..2a4e7f4a8102 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -185,7 +185,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
>  	if (err)
>  		return err;
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	inode_inc_link_count(inode);
>  	ihold(inode);
>  
> @@ -283,7 +283,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
>  	if (err)
>  		goto out;
>  
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  	drop_nlink(inode);
>  	err = 0;
>  out:
> @@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
>  			goto out_dir;
>  		nilfs_set_link(new_dir, new_de, new_page, old_inode);
>  		nilfs_mark_inode_dirty(new_dir);
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		if (dir_de)
>  			drop_nlink(new_inode);
>  		drop_nlink(new_inode);
> @@ -406,7 +406,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
>  	 * Like most other Unix systems, set the ctime for inodes on a
>  	 * rename.
>  	 */
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  
>  	nilfs_delete_entry(old_de, old_page);
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 59/92] nilfs2: convert to ctime accessor functions
@ 2023-07-06 13:35       ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:35 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Ryusuke Konishi, Al Viro, Jan Kara,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-nilfs-u79uwXL29TY76Z2rM5mHXA

On Wed 05-07-23 15:01:24, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Ryusuke Konishi <konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Jeff Layton <jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>

								Honza

> ---
>  fs/nilfs2/dir.c   |  6 +++---
>  fs/nilfs2/inode.c | 12 ++++++------
>  fs/nilfs2/ioctl.c |  2 +-
>  fs/nilfs2/namei.c |  8 ++++----
>  4 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
> index decd6471300b..bce734b68f08 100644
> --- a/fs/nilfs2/dir.c
> +++ b/fs/nilfs2/dir.c
> @@ -429,7 +429,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,
>  	nilfs_set_de_type(de, inode);
>  	nilfs_commit_chunk(page, mapping, from, to);
>  	nilfs_put_page(page);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  }
>  
>  /*
> @@ -519,7 +519,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
>  	de->inode = cpu_to_le64(inode->i_ino);
>  	nilfs_set_de_type(de, inode);
>  	nilfs_commit_chunk(page, page->mapping, from, to);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	nilfs_mark_inode_dirty(dir);
>  	/* OFFSET_CACHE */
>  out_put:
> @@ -567,7 +567,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
>  		pde->rec_len = nilfs_rec_len_to_disk(to - from);
>  	dir->inode = 0;
>  	nilfs_commit_chunk(page, mapping, from, to);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  out:
>  	nilfs_put_page(page);
>  	return err;
> diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
> index a8ce522ac747..5259b94ca1dc 100644
> --- a/fs/nilfs2/inode.c
> +++ b/fs/nilfs2/inode.c
> @@ -366,7 +366,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
>  	atomic64_inc(&root->inodes_count);
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
>  	inode->i_ino = ino;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  
>  	if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
>  		err = nilfs_bmap_read(ii->i_bmap, NULL);
> @@ -450,10 +450,10 @@ int nilfs_read_inode_common(struct inode *inode,
>  	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
>  	inode->i_size = le64_to_cpu(raw_inode->i_size);
>  	inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
> -	inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
> +	inode_set_ctime(inode, le64_to_cpu(raw_inode->i_ctime),
> +			le32_to_cpu(raw_inode->i_ctime_nsec));
>  	inode->i_mtime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
>  	inode->i_atime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(raw_inode->i_ctime_nsec);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(raw_inode->i_mtime_nsec);
>  	if (nilfs_is_metadata_file_inode(inode) && !S_ISREG(inode->i_mode))
>  		return -EIO; /* this inode is for metadata and corrupted */
> @@ -768,9 +768,9 @@ void nilfs_write_inode_common(struct inode *inode,
>  	raw_inode->i_gid = cpu_to_le32(i_gid_read(inode));
>  	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
>  	raw_inode->i_size = cpu_to_le64(inode->i_size);
> -	raw_inode->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> +	raw_inode->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
>  	raw_inode->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
> -	raw_inode->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	raw_inode->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	raw_inode->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  	raw_inode->i_blocks = cpu_to_le64(inode->i_blocks);
>  
> @@ -875,7 +875,7 @@ void nilfs_truncate(struct inode *inode)
>  
>  	nilfs_truncate_bmap(ii, blkoff);
>  
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		nilfs_set_transaction_flag(NILFS_TI_SYNC);
>  
> diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
> index 1dfbc0c34513..40ffade49f38 100644
> --- a/fs/nilfs2/ioctl.c
> +++ b/fs/nilfs2/ioctl.c
> @@ -149,7 +149,7 @@ int nilfs_fileattr_set(struct mnt_idmap *idmap,
>  	NILFS_I(inode)->i_flags = oldflags | (flags & FS_FL_USER_MODIFIABLE);
>  
>  	nilfs_set_inode_flags(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		nilfs_set_transaction_flag(NILFS_TI_SYNC);
>  
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index c7024da8f1e2..2a4e7f4a8102 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -185,7 +185,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
>  	if (err)
>  		return err;
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	inode_inc_link_count(inode);
>  	ihold(inode);
>  
> @@ -283,7 +283,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
>  	if (err)
>  		goto out;
>  
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  	drop_nlink(inode);
>  	err = 0;
>  out:
> @@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
>  			goto out_dir;
>  		nilfs_set_link(new_dir, new_de, new_page, old_inode);
>  		nilfs_mark_inode_dirty(new_dir);
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		if (dir_de)
>  			drop_nlink(new_inode);
>  		drop_nlink(new_inode);
> @@ -406,7 +406,7 @@ static int nilfs_rename(struct mnt_idmap *idmap,
>  	 * Like most other Unix systems, set the ctime for inodes on a
>  	 * rename.
>  	 */
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  
>  	nilfs_delete_entry(old_de, old_page);
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
SUSE Labs, CR

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

* Re: [PATCH v2 60/92] ntfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 60/92] ntfs: " Jeff Layton
@ 2023-07-06 13:37     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:37 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Anton Altaparmakov, Namjae Jeon, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-ntfs-dev

On Wed 05-07-23 15:01:25, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ntfs/inode.c | 15 ++++++++-------
>  fs/ntfs/mft.c   |  3 +--
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
> index 6c3f38d66579..99ac6ea277c4 100644
> --- a/fs/ntfs/inode.c
> +++ b/fs/ntfs/inode.c
> @@ -654,7 +654,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
>  	 * always changes, when mtime is changed. ctime can be changed on its
>  	 * own, mtime is then not changed, e.g. when a file is renamed.
>  	 */
> -	vi->i_ctime = ntfs2utc(si->last_mft_change_time);
> +	inode_set_ctime_to_ts(vi, ntfs2utc(si->last_mft_change_time));
>  	/*
>  	 * Last access to the data within the file. Not changed during a rename
>  	 * for example but changed whenever the file is written to.
> @@ -1218,7 +1218,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
>  	vi->i_gid	= base_vi->i_gid;
>  	set_nlink(vi, base_vi->i_nlink);
>  	vi->i_mtime	= base_vi->i_mtime;
> -	vi->i_ctime	= base_vi->i_ctime;
> +	inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi));
>  	vi->i_atime	= base_vi->i_atime;
>  	vi->i_generation = ni->seq_no = base_ni->seq_no;
>  
> @@ -1484,7 +1484,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
>  	vi->i_gid	= base_vi->i_gid;
>  	set_nlink(vi, base_vi->i_nlink);
>  	vi->i_mtime	= base_vi->i_mtime;
> -	vi->i_ctime	= base_vi->i_ctime;
> +	inode_set_ctime_to_ts(vi, inode_get_ctime(base_vi));
>  	vi->i_atime	= base_vi->i_atime;
>  	vi->i_generation = ni->seq_no = base_ni->seq_no;
>  	/* Set inode type to zero but preserve permissions. */
> @@ -2804,13 +2804,14 @@ int ntfs_truncate(struct inode *vi)
>  	 */
>  	if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) {
>  		struct timespec64 now = current_time(VFS_I(base_ni));
> +		struct timespec64 ctime = inode_get_ctime(VFS_I(base_ni));
>  		int sync_it = 0;
>  
>  		if (!timespec64_equal(&VFS_I(base_ni)->i_mtime, &now) ||
> -		    !timespec64_equal(&VFS_I(base_ni)->i_ctime, &now))
> +		    !timespec64_equal(&ctime, &now))
>  			sync_it = 1;
> +		inode_set_ctime_to_ts(VFS_I(base_ni), now);
>  		VFS_I(base_ni)->i_mtime = now;
> -		VFS_I(base_ni)->i_ctime = now;
>  
>  		if (sync_it)
>  			mark_inode_dirty_sync(VFS_I(base_ni));
> @@ -2928,7 +2929,7 @@ int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  	if (ia_valid & ATTR_MTIME)
>  		vi->i_mtime = attr->ia_mtime;
>  	if (ia_valid & ATTR_CTIME)
> -		vi->i_ctime = attr->ia_ctime;
> +		inode_set_ctime_to_ts(vi, attr->ia_ctime);
>  	mark_inode_dirty(vi);
>  out:
>  	return err;
> @@ -3004,7 +3005,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
>  		si->last_data_change_time = nt;
>  		modified = true;
>  	}
> -	nt = utc2ntfs(vi->i_ctime);
> +	nt = utc2ntfs(inode_get_ctime(vi));
>  	if (si->last_mft_change_time != nt) {
>  		ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, "
>  				"new = 0x%llx", vi->i_ino, (long long)
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 0155f106ec34..ad1a8f72da22 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -2682,8 +2682,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
>  			vi->i_mode &= ~S_IWUGO;
>  
>  		/* Set the inode times to the current time. */
> -		vi->i_atime = vi->i_mtime = vi->i_ctime =
> -			current_time(vi);
> +		vi->i_atime = vi->i_mtime = inode_set_ctime_current(vi);
>  		/*
>  		 * Set the file size to 0, the ntfs inode sizes are set to 0 by
>  		 * the call to ntfs_init_big_inode() below.
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 61/92] ntfs3: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 61/92] ntfs3: " Jeff Layton
@ 2023-07-06 13:47     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:47 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Konstantin Komarov, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, ntfs3

On Wed 05-07-23 15:01:26, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ntfs3/file.c    |  6 +++---
>  fs/ntfs3/frecord.c |  3 ++-
>  fs/ntfs3/inode.c   | 14 ++++++++------
>  fs/ntfs3/namei.c   |  4 ++--
>  fs/ntfs3/xattr.c   |  4 ++--
>  5 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index 1d6c824246c4..12788601dc84 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -342,7 +342,7 @@ static int ntfs_extend(struct inode *inode, loff_t pos, size_t count,
>  		err = 0;
>  	}
>  
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	if (IS_SYNC(inode)) {
> @@ -400,7 +400,7 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
>  	ni_unlock(ni);
>  
>  	ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE;
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	if (!IS_DIRSYNC(inode)) {
>  		dirty = 1;
>  	} else {
> @@ -642,7 +642,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
>  		filemap_invalidate_unlock(mapping);
>  
>  	if (!err) {
> -		inode->i_ctime = inode->i_mtime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		mark_inode_dirty(inode);
>  	}
>  
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 16bd9faa2d28..2b85cb10f0be 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -3265,6 +3265,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
>  	if (is_rec_inuse(ni->mi.mrec) &&
>  	    !(sbi->flags & NTFS_FLAGS_LOG_REPLAYING) && inode->i_nlink) {
>  		bool modified = false;
> +		struct timespec64 ctime = inode_get_ctime(inode);
>  
>  		/* Update times in standard attribute. */
>  		std = ni_std(ni);
> @@ -3280,7 +3281,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
>  			modified = true;
>  		}
>  
> -		dup.c_time = kernel2nt(&inode->i_ctime);
> +		dup.c_time = kernel2nt(&ctime);
>  		if (std->c_time != dup.c_time) {
>  			std->c_time = dup.c_time;
>  			modified = true;
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index dc7e7ab701c6..4123e126c4d0 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -44,6 +44,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
>  	u64 t64;
>  	struct MFT_REC *rec;
>  	struct runs_tree *run;
> +	struct timespec64 ctime;
>  
>  	inode->i_op = NULL;
>  	/* Setup 'uid' and 'gid' */
> @@ -169,7 +170,8 @@ static struct inode *ntfs_read_mft(struct inode *inode,
>  		nt2kernel(std5->cr_time, &ni->i_crtime);
>  #endif
>  		nt2kernel(std5->a_time, &inode->i_atime);
> -		nt2kernel(std5->c_time, &inode->i_ctime);
> +		ctime = inode_get_ctime(inode);
> +		nt2kernel(std5->c_time, &ctime);
>  		nt2kernel(std5->m_time, &inode->i_mtime);
>  
>  		ni->std_fa = std5->fa;
> @@ -958,7 +960,7 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
>  
>  	if (err >= 0) {
>  		if (!(ni->std_fa & FILE_ATTRIBUTE_ARCHIVE)) {
> -			inode->i_ctime = inode->i_mtime = current_time(inode);
> +			inode->i_mtime = inode_set_ctime_current(inode);
>  			ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE;
>  			dirty = true;
>  		}
> @@ -1658,8 +1660,8 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
>  	d_instantiate(dentry, inode);
>  
>  	/* Set original time. inode times (i_ctime) may be changed in ntfs_init_acl. */
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = dir->i_mtime =
> -		dir->i_ctime = ni->i_crtime;
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode, ni->i_crtime);
> +	dir->i_mtime = inode_set_ctime_to_ts(dir, ni->i_crtime);
>  
>  	mark_inode_dirty(dir);
>  	mark_inode_dirty(inode);
> @@ -1765,9 +1767,9 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)
>  
>  	if (!err) {
>  		drop_nlink(inode);
> -		dir->i_mtime = dir->i_ctime = current_time(dir);
> +		dir->i_mtime = inode_set_ctime_current(dir);
>  		mark_inode_dirty(dir);
> -		inode->i_ctime = dir->i_ctime;
> +		inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  		if (inode->i_nlink)
>  			mark_inode_dirty(inode);
>  	} else if (!ni_remove_name_undo(dir_ni, ni, de, de2, undo_remove)) {
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index bfd986699f9e..ad430d50bd79 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -156,8 +156,8 @@ static int ntfs_link(struct dentry *ode, struct inode *dir, struct dentry *de)
>  	err = ntfs_link_inode(inode, de);
>  
>  	if (!err) {
> -		dir->i_ctime = dir->i_mtime = inode->i_ctime =
> -			current_time(dir);
> +		dir->i_mtime = inode_set_ctime_to_ts(inode,
> +						     inode_set_ctime_current(dir));
>  		mark_inode_dirty(inode);
>  		mark_inode_dirty(dir);
>  		d_instantiate(de, inode);
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 023f314e8950..29fd391899e5 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -637,7 +637,7 @@ static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
>  	if (!err) {
>  		set_cached_acl(inode, type, acl);
>  		inode->i_mode = mode;
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		mark_inode_dirty(inode);
>  	}
>  
> @@ -924,7 +924,7 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
>  			  NULL);
>  
>  out:
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  
>  	return err;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 56/92] kernfs: convert to ctime accessor functions
  2023-07-06 13:32     ` Jan Kara
@ 2023-07-06 13:50       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 13:50 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Greg Kroah-Hartman, Tejun Heo, Alexander Viro,
	linux-fsdevel, linux-kernel

On Thu, 2023-07-06 at 15:32 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:21, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> It looks like there are like three commits squashed into this patch -
> kernfs, libfs, minix.
> 
> kernfs and libfs parts look good to me - feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> to them. For the minix part I have one nit:
> 
> > diff --git a/fs/minix/inode.c b/fs/minix/inode.c
> > index e9fbb5303a22..3715a3940bd4 100644
> > --- a/fs/minix/inode.c
> > +++ b/fs/minix/inode.c
> > @@ -501,10 +501,11 @@ static struct inode *V1_minix_iget(struct inode *inode)
> >  	i_gid_write(inode, raw_inode->i_gid);
> >  	set_nlink(inode, raw_inode->i_nlinks);
> >  	inode->i_size = raw_inode->i_size;
> > -	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = raw_inode->i_time;
> > +	inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode_set_ctime(inode,
> > +									raw_inode->i_time,
> > +									0).tv_sec;
> >  	inode->i_mtime.tv_nsec = 0;
> >  	inode->i_atime.tv_nsec = 0;
> > -	inode->i_ctime.tv_nsec = 0;
> 
> The usual simplification:
> 	inode->i_mtime = inode->i_atime = inode_set_ctime(inode,
> 							  raw_inode->i_time, 0);
> 
> 								Honza


Thanks. I'm not sure what happened with this patch, as some of the
subsystems got squashed together. I'll break that up properly too.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 62/92] ocfs2: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 62/92] ocfs2: " Jeff Layton
@ 2023-07-06 13:51     ` Jan Kara
  2023-07-07  3:15     ` Joseph Qi
  1 sibling, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:51 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Mark Fasheh, Joel Becker, Joseph Qi, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, ocfs2-devel

On Wed 05-07-23 15:01:27, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ocfs2/acl.c          |  6 +++---
>  fs/ocfs2/alloc.c        |  6 +++---
>  fs/ocfs2/aops.c         |  2 +-
>  fs/ocfs2/dir.c          |  8 ++++----
>  fs/ocfs2/dlmfs/dlmfs.c  |  4 ++--
>  fs/ocfs2/dlmglue.c      |  7 +++++--
>  fs/ocfs2/file.c         | 16 +++++++++-------
>  fs/ocfs2/inode.c        | 12 ++++++------
>  fs/ocfs2/move_extents.c |  6 +++---
>  fs/ocfs2/namei.c        | 21 +++++++++++----------
>  fs/ocfs2/refcounttree.c | 14 +++++++-------
>  fs/ocfs2/xattr.c        |  6 +++---
>  12 files changed, 57 insertions(+), 51 deletions(-)
> 
> diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
> index 9fd03eaf15f8..e75137a8e7cb 100644
> --- a/fs/ocfs2/acl.c
> +++ b/fs/ocfs2/acl.c
> @@ -191,10 +191,10 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
>  	}
>  
>  	inode->i_mode = new_mode;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	di->i_mode = cpu_to_le16(inode->i_mode);
> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>  
>  	ocfs2_journal_dirty(handle, di_bh);
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 51c93929a146..aef58f1395c8 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -7436,10 +7436,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
>  	}
>  
>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
> -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  
>  	ocfs2_update_inode_fsync_trans(handle, inode, 1);
>  	ocfs2_journal_dirty(handle, di_bh);
> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
> index 8dfc284e85f0..0fdba30740ab 100644
> --- a/fs/ocfs2/aops.c
> +++ b/fs/ocfs2/aops.c
> @@ -2048,7 +2048,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
>  		}
>  		inode->i_blocks = ocfs2_inode_sector_count(inode);
>  		di->i_size = cpu_to_le64((u64)i_size_read(inode));
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
>  		di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  		if (handle)
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index 694471fc46b8..8b123d543e6e 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -1658,7 +1658,7 @@ int __ocfs2_add_entry(handle_t *handle,
>  				offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
>  
>  		if (ocfs2_dirent_would_fit(de, rec_len)) {
> -			dir->i_mtime = dir->i_ctime = current_time(dir);
> +			dir->i_mtime = inode_set_ctime_current(dir);
>  			retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
>  			if (retval < 0) {
>  				mlog_errno(retval);
> @@ -2962,11 +2962,11 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
>  	ocfs2_dinode_new_extent_list(dir, di);
>  
>  	i_size_write(dir, sb->s_blocksize);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  
>  	di->i_size = cpu_to_le64(sb->s_blocksize);
> -	di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec);
> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec);
> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(dir).tv_sec);
> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(dir).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, dir, 1);
>  
>  	/*
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index ba26c5567cff..81265123ce6c 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -337,7 +337,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
>  		inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		inc_nlink(inode);
>  
>  		inode->i_fop = &simple_dir_operations;
> @@ -360,7 +360,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
>  
>  	inode->i_ino = get_next_ino();
>  	inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	ip = DLMFS_I(inode);
>  	ip->ip_conn = DLMFS_I(parent)->ip_conn;
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index c28bc983a7b1..c3e2961ee5db 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -2162,6 +2162,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
>  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
>  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
>  	struct ocfs2_meta_lvb *lvb;
> +	struct timespec64 ctime = inode_get_ctime(inode);
>  
>  	lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
>  
> @@ -2185,7 +2186,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
>  	lvb->lvb_iatime_packed  =
>  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime));
>  	lvb->lvb_ictime_packed =
> -		cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime));
> +		cpu_to_be64(ocfs2_pack_timespec(&ctime));
>  	lvb->lvb_imtime_packed =
>  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
>  	lvb->lvb_iattr    = cpu_to_be32(oi->ip_attr);
> @@ -2208,6 +2209,7 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
>  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
>  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
>  	struct ocfs2_meta_lvb *lvb;
> +	struct timespec64 ctime;
>  
>  	mlog_meta_lvb(0, lockres);
>  
> @@ -2238,8 +2240,9 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
>  			      be64_to_cpu(lvb->lvb_iatime_packed));
>  	ocfs2_unpack_timespec(&inode->i_mtime,
>  			      be64_to_cpu(lvb->lvb_imtime_packed));
> -	ocfs2_unpack_timespec(&inode->i_ctime,
> +	ocfs2_unpack_timespec(&ctime,
>  			      be64_to_cpu(lvb->lvb_ictime_packed));
> +	inode_set_ctime_to_ts(inode, ctime);
>  	spin_unlock(&oi->ip_lock);
>  	return 0;
>  }
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 9e417cd4fd16..e8c78d16e815 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -232,8 +232,10 @@ int ocfs2_should_update_atime(struct inode *inode,
>  		return 0;
>  
>  	if (vfsmnt->mnt_flags & MNT_RELATIME) {
> +		struct timespec64 ctime = inode_get_ctime(inode);
> +
>  		if ((timespec64_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
> -		    (timespec64_compare(&inode->i_atime, &inode->i_ctime) <= 0))
> +		    (timespec64_compare(&inode->i_atime, &ctime) <= 0))
>  			return 1;
>  
>  		return 0;
> @@ -294,7 +296,7 @@ int ocfs2_set_inode_size(handle_t *handle,
>  
>  	i_size_write(inode, new_i_size);
>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	status = ocfs2_mark_inode_dirty(handle, inode, fe_bh);
>  	if (status < 0) {
> @@ -415,12 +417,12 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
>  	}
>  
>  	i_size_write(inode, new_i_size);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	di = (struct ocfs2_dinode *) fe_bh->b_data;
>  	di->i_size = cpu_to_le64(new_i_size);
> -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>  
>  	ocfs2_journal_dirty(handle, fe_bh);
> @@ -819,7 +821,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
>  	i_size_write(inode, abs_to);
>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
>  	di->i_size = cpu_to_le64((u64)i_size_read(inode));
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
>  	di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  	di->i_mtime_nsec = di->i_ctime_nsec;
> @@ -2038,7 +2040,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
>  		goto out_inode_unlock;
>  	}
>  
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
>  	if (ret < 0)
>  		mlog_errno(ret);
> diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
> index bb116c39b581..e8771600b930 100644
> --- a/fs/ocfs2/inode.c
> +++ b/fs/ocfs2/inode.c
> @@ -306,8 +306,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
>  	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
>  	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
> -	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
> +	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
> +		        le32_to_cpu(fe->i_ctime_nsec));
>  
>  	if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
>  		mlog(ML_ERROR,
> @@ -1314,8 +1314,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
>  	fe->i_mode = cpu_to_le16(inode->i_mode);
>  	fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
>  	fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> -	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
>  	fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  
> @@ -1352,8 +1352,8 @@ void ocfs2_refresh_inode(struct inode *inode,
>  	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
>  	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
> -	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
> +	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
> +			le32_to_cpu(fe->i_ctime_nsec));
>  
>  	spin_unlock(&OCFS2_I(inode)->ip_lock);
>  }
> diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
> index b1e32ec4a9d4..05d67968a3a9 100644
> --- a/fs/ocfs2/move_extents.c
> +++ b/fs/ocfs2/move_extents.c
> @@ -950,9 +950,9 @@ static int ocfs2_move_extents(struct ocfs2_move_extents_context *context)
>  	}
>  
>  	di = (struct ocfs2_dinode *)di_bh->b_data;
> -	inode->i_ctime = current_time(inode);
> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	inode_set_ctime_current(inode);
> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>  
>  	ocfs2_journal_dirty(handle, di_bh);
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 17c52225b87d..e4a684d45308 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -793,10 +793,10 @@ static int ocfs2_link(struct dentry *old_dentry,
>  	}
>  
>  	inc_nlink(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ocfs2_set_links_count(fe, inode->i_nlink);
> -	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_journal_dirty(handle, fe_bh);
>  
>  	err = ocfs2_add_entry(handle, dentry, inode,
> @@ -995,7 +995,7 @@ static int ocfs2_unlink(struct inode *dir,
>  	ocfs2_set_links_count(fe, inode->i_nlink);
>  	ocfs2_journal_dirty(handle, fe_bh);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	if (S_ISDIR(inode->i_mode))
>  		drop_nlink(dir);
>  
> @@ -1537,7 +1537,7 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  					 new_dir_bh, &target_insert);
>  	}
>  
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	mark_inode_dirty(old_inode);
>  
>  	status = ocfs2_journal_access_di(handle, INODE_CACHE(old_inode),
> @@ -1546,8 +1546,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  	if (status >= 0) {
>  		old_di = (struct ocfs2_dinode *) old_inode_bh->b_data;
>  
> -		old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
> -		old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
> +		old_di->i_ctime = cpu_to_le64(inode_get_ctime(old_inode).tv_sec);
> +		old_di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(old_inode).tv_nsec);
>  		ocfs2_journal_dirty(handle, old_inode_bh);
>  	} else
>  		mlog_errno(status);
> @@ -1586,9 +1586,9 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  
>  	if (new_inode) {
>  		drop_nlink(new_inode);
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  	}
> -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> +	old_dir->i_mtime = inode_set_ctime_current(old_dir);
>  
>  	if (update_dot_dot) {
>  		status = ocfs2_update_entry(old_inode, handle,
> @@ -1610,7 +1610,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  
>  	if (old_dir != new_dir) {
>  		/* Keep the same times on both directories.*/
> -		new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime;
> +		new_dir->i_mtime = inode_set_ctime_to_ts(new_dir,
> +							 inode_get_ctime(old_dir));
>  
>  		/*
>  		 * This will also pick up the i_nlink change from the
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index 564ab48d03ef..25c8ec3c8c3a 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -3750,9 +3750,9 @@ static int ocfs2_change_ctime(struct inode *inode,
>  		goto out_commit;
>  	}
>  
> -	inode->i_ctime = current_time(inode);
> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	inode_set_ctime_current(inode);
> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  
>  	ocfs2_journal_dirty(handle, di_bh);
>  
> @@ -4073,10 +4073,10 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
>  		 * we want mtime to appear identical to the source and
>  		 * update ctime.
>  		 */
> -		t_inode->i_ctime = current_time(t_inode);
> +		inode_set_ctime_current(t_inode);
>  
> -		di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec);
> -		di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec);
> +		di->i_ctime = cpu_to_le64(inode_get_ctime(t_inode).tv_sec);
> +		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(t_inode).tv_nsec);
>  
>  		t_inode->i_mtime = s_inode->i_mtime;
>  		di->i_mtime = s_di->i_mtime;
> @@ -4456,7 +4456,7 @@ int ocfs2_reflink_update_dest(struct inode *dest,
>  	if (newlen > i_size_read(dest))
>  		i_size_write(dest, newlen);
>  	spin_unlock(&OCFS2_I(dest)->ip_lock);
> -	dest->i_ctime = dest->i_mtime = current_time(dest);
> +	dest->i_mtime = inode_set_ctime_current(dest);
>  
>  	ret = ocfs2_mark_inode_dirty(handle, dest, d_bh);
>  	if (ret) {
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 4ac77ff6e676..6510ad783c91 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -3421,9 +3421,9 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
>  			goto out;
>  		}
>  
> -		inode->i_ctime = current_time(inode);
> -		di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -		di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +		inode_set_ctime_current(inode);
> +		di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  		ocfs2_journal_dirty(ctxt->handle, xis->inode_bh);
>  	}
>  out:
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 63/92] omfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 63/92] omfs: " Jeff Layton
@ 2023-07-06 13:52     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:52 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Bob Copeland, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-karma-devel

On Wed 05-07-23 15:01:28, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Bob Copeland <me@bobcopeland.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/omfs/dir.c   | 4 ++--
>  fs/omfs/inode.c | 9 ++++-----
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
> index 82cf7e9a665f..6bda275826d6 100644
> --- a/fs/omfs/dir.c
> +++ b/fs/omfs/dir.c
> @@ -143,7 +143,7 @@ static int omfs_add_link(struct dentry *dentry, struct inode *inode)
>  	mark_buffer_dirty(bh);
>  	brelse(bh);
>  
> -	dir->i_ctime = current_time(dir);
> +	inode_set_ctime_current(dir);
>  
>  	/* mark affected inodes dirty to rebuild checksums */
>  	mark_inode_dirty(dir);
> @@ -399,7 +399,7 @@ static int omfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  	if (err)
>  		goto out;
>  
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	mark_inode_dirty(old_inode);
>  out:
>  	return err;
> diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
> index c4c79e07efc7..2f8c1882f45c 100644
> --- a/fs/omfs/inode.c
> +++ b/fs/omfs/inode.c
> @@ -51,7 +51,7 @@ struct inode *omfs_new_inode(struct inode *dir, umode_t mode)
>  	inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
>  	inode->i_mapping->a_ops = &omfs_aops;
>  
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	switch (mode & S_IFMT) {
>  	case S_IFDIR:
>  		inode->i_op = &omfs_dir_inops;
> @@ -134,8 +134,8 @@ static int __omfs_write_inode(struct inode *inode, int wait)
>  	oi->i_head.h_magic = OMFS_IMAGIC;
>  	oi->i_size = cpu_to_be64(inode->i_size);
>  
> -	ctime = inode->i_ctime.tv_sec * 1000LL +
> -		((inode->i_ctime.tv_nsec + 999)/1000);
> +	ctime = inode_get_ctime(inode).tv_sec * 1000LL +
> +		((inode_get_ctime(inode).tv_nsec + 999)/1000);
>  	oi->i_ctime = cpu_to_be64(ctime);
>  
>  	omfs_update_checksums(oi);
> @@ -232,10 +232,9 @@ struct inode *omfs_iget(struct super_block *sb, ino_t ino)
>  
>  	inode->i_atime.tv_sec = ctime;
>  	inode->i_mtime.tv_sec = ctime;
> -	inode->i_ctime.tv_sec = ctime;
> +	inode_set_ctime(inode, ctime, nsecs);
>  	inode->i_atime.tv_nsec = nsecs;
>  	inode->i_mtime.tv_nsec = nsecs;
> -	inode->i_ctime.tv_nsec = nsecs;
>  
>  	inode->i_mapping->a_ops = &omfs_aops;
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 64/92] openpromfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 64/92] openpromfs: " Jeff Layton
@ 2023-07-06 13:52     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:52 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:29, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/openpromfs/inode.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
> index f0b7f4d51a17..b2457cb97fa0 100644
> --- a/fs/openpromfs/inode.c
> +++ b/fs/openpromfs/inode.c
> @@ -237,7 +237,7 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry
>  	if (IS_ERR(inode))
>  		return ERR_CAST(inode);
>  	if (inode->i_state & I_NEW) {
> -		inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  		ent_oi = OP_I(inode);
>  		ent_oi->type = ent_type;
>  		ent_oi->u = ent_data;
> @@ -387,8 +387,7 @@ static int openprom_fill_super(struct super_block *s, struct fs_context *fc)
>  		goto out_no_root;
>  	}
>  
> -	root_inode->i_mtime = root_inode->i_atime =
> -		root_inode->i_ctime = current_time(root_inode);
> +	root_inode->i_mtime = root_inode->i_atime = inode_set_ctime_current(root_inode);
>  	root_inode->i_op = &openprom_inode_operations;
>  	root_inode->i_fop = &openprom_operations;
>  	root_inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 65/92] orangefs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 65/92] orangefs: " Jeff Layton
@ 2023-07-06 13:55     ` Jan Kara
  2023-07-06 13:56     ` Jan Kara
  1 sibling, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:55 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Mike Marshall, Martin Brandenburg, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, devel

On Wed 05-07-23 15:01:30, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/orangefs/namei.c          | 2 +-
>  fs/orangefs/orangefs-utils.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index 77518e248cf7..c9dfd5c6a097 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -421,7 +421,7 @@ static int orangefs_rename(struct mnt_idmap *idmap,
>  		     ret);
>  
>  	if (new_dentry->d_inode)
> -		new_dentry->d_inode->i_ctime = current_time(new_dentry->d_inode);
> +		inode_set_ctime_current(d_inode(new_dentry));
>  
>  	op_release(new_op);
>  	return ret;
> diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
> index 46b7dcff18ac..0a9fcfdf552f 100644
> --- a/fs/orangefs/orangefs-utils.c
> +++ b/fs/orangefs/orangefs-utils.c
> @@ -361,11 +361,11 @@ int orangefs_inode_getattr(struct inode *inode, int flags)
>  	    downcall.resp.getattr.attributes.atime;
>  	inode->i_mtime.tv_sec = (time64_t)new_op->
>  	    downcall.resp.getattr.attributes.mtime;
> -	inode->i_ctime.tv_sec = (time64_t)new_op->
> -	    downcall.resp.getattr.attributes.ctime;
> +	inode_set_ctime(inode,
> +			(time64_t)new_op->downcall.resp.getattr.attributes.ctime,
> +			0);
>  	inode->i_atime.tv_nsec = 0;
>  	inode->i_mtime.tv_nsec = 0;
> -	inode->i_ctime.tv_nsec = 0;
>  
>  	/* special case: mark the root inode as sticky */
>  	inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) |
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 65/92] orangefs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 65/92] orangefs: " Jeff Layton
  2023-07-06 13:55     ` Jan Kara
@ 2023-07-06 13:56     ` Jan Kara
  1 sibling, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:56 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Mike Marshall, Martin Brandenburg, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, devel

On Wed 05-07-23 15:01:30, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/orangefs/namei.c          | 2 +-
>  fs/orangefs/orangefs-utils.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index 77518e248cf7..c9dfd5c6a097 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -421,7 +421,7 @@ static int orangefs_rename(struct mnt_idmap *idmap,
>  		     ret);
>  
>  	if (new_dentry->d_inode)
> -		new_dentry->d_inode->i_ctime = current_time(new_dentry->d_inode);
> +		inode_set_ctime_current(d_inode(new_dentry));
>  
>  	op_release(new_op);
>  	return ret;
> diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
> index 46b7dcff18ac..0a9fcfdf552f 100644
> --- a/fs/orangefs/orangefs-utils.c
> +++ b/fs/orangefs/orangefs-utils.c
> @@ -361,11 +361,11 @@ int orangefs_inode_getattr(struct inode *inode, int flags)
>  	    downcall.resp.getattr.attributes.atime;
>  	inode->i_mtime.tv_sec = (time64_t)new_op->
>  	    downcall.resp.getattr.attributes.mtime;
> -	inode->i_ctime.tv_sec = (time64_t)new_op->
> -	    downcall.resp.getattr.attributes.ctime;
> +	inode_set_ctime(inode,
> +			(time64_t)new_op->downcall.resp.getattr.attributes.ctime,
> +			0);
>  	inode->i_atime.tv_nsec = 0;
>  	inode->i_mtime.tv_nsec = 0;
> -	inode->i_ctime.tv_nsec = 0;
>  
>  	/* special case: mark the root inode as sticky */
>  	inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) |
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 66/92] overlayfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 66/92] overlayfs: " Jeff Layton
@ 2023-07-06 13:58     ` Jan Kara
  2023-07-06 14:01       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:58 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Miklos Szeredi, Amir Goldstein, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-unionfs

On Wed 05-07-23 15:01:31, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
...
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 21245b00722a..7acd3e3fe790 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
...
> @@ -249,10 +250,12 @@ static void ovl_file_accessed(struct file *file)
>  	if (!upperinode)
>  		return;
>  
> +	ctime = inode_get_ctime(inode);
> +	uctime = inode_get_ctime(upperinode);
>  	if ((!timespec64_equal(&inode->i_mtime, &upperinode->i_mtime) ||
> -	     !timespec64_equal(&inode->i_ctime, &upperinode->i_ctime))) {
> +	     !timespec64_equal(&ctime, &uctime))) {
>  		inode->i_mtime = upperinode->i_mtime;
> -		inode->i_ctime = upperinode->i_ctime;
> +		inode_set_ctime_to_ts(inode, inode_get_ctime(upperinode));

I think you can use uctime here instead of inode_get_ctime(upperinode)?
Otherwise the patch looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 67/92] procfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 67/92] procfs: " Jeff Layton
@ 2023-07-06 13:59     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 13:59 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Luis Chamberlain, Kees Cook, Iurii Zaikin,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:32, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Luis Chamberlain <mcgrof@kernel.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  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 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index eb2e498e3b8d..bbc998fd2a2f 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1902,7 +1902,7 @@ struct inode *proc_pid_make_inode(struct super_block *sb,
>  	ei = PROC_I(inode);
>  	inode->i_mode = mode;
>  	inode->i_ino = get_next_ino();
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_op = &proc_def_inode_operations;
>  
>  	/*
> diff --git a/fs/proc/inode.c b/fs/proc/inode.c
> index 67b09a1d9433..532dc9d240f7 100644
> --- a/fs/proc/inode.c
> +++ b/fs/proc/inode.c
> @@ -660,7 +660,7 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
>  
>  	inode->i_private = de->data;
>  	inode->i_ino = de->low_ino;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	PROC_I(inode)->pde = de;
>  	if (is_empty_pde(de)) {
>  		make_empty_dir_inode(inode);
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 5ea42653126e..6bc10e7e0ff7 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -463,7 +463,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
>  	head->count++;
>  	spin_unlock(&sysctl_lock);
>  
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_mode = table->mode;
>  	if (!S_ISDIR(table->mode)) {
>  		inode->i_mode |= S_IFREG;
> diff --git a/fs/proc/self.c b/fs/proc/self.c
> index 72cd69bcaf4a..ecc4da8d265e 100644
> --- a/fs/proc/self.c
> +++ b/fs/proc/self.c
> @@ -46,7 +46,7 @@ int proc_setup_self(struct super_block *s)
>  		struct inode *inode = new_inode(s);
>  		if (inode) {
>  			inode->i_ino = self_inum;
> -			inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +			inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  			inode->i_mode = S_IFLNK | S_IRWXUGO;
>  			inode->i_uid = GLOBAL_ROOT_UID;
>  			inode->i_gid = GLOBAL_ROOT_GID;
> diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
> index a553273fbd41..63ac1f93289f 100644
> --- a/fs/proc/thread_self.c
> +++ b/fs/proc/thread_self.c
> @@ -46,7 +46,7 @@ int proc_setup_thread_self(struct super_block *s)
>  		struct inode *inode = new_inode(s);
>  		if (inode) {
>  			inode->i_ino = thread_self_inum;
> -			inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +			inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  			inode->i_mode = S_IFLNK | S_IRWXUGO;
>  			inode->i_uid = GLOBAL_ROOT_UID;
>  			inode->i_gid = GLOBAL_ROOT_GID;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 68/92] pstore: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 68/92] pstore: " Jeff Layton
@ 2023-07-06 14:00     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:00 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Kees Cook, Tony Luck, Guilherme G. Piccoli,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-hardening

On Wed 05-07-23 15:01:33, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/pstore/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
> index ffbadb8b3032..a756af980d0c 100644
> --- a/fs/pstore/inode.c
> +++ b/fs/pstore/inode.c
> @@ -223,7 +223,7 @@ static struct inode *pstore_get_inode(struct super_block *sb)
>  	struct inode *inode = new_inode(sb);
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  	return inode;
>  }
> @@ -390,7 +390,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
>  	inode->i_private = private;
>  
>  	if (record->time.tv_sec)
> -		inode->i_mtime = inode->i_ctime = record->time;
> +		inode->i_mtime = inode_set_ctime_to_ts(inode, record->time);
>  
>  	d_add(dentry, inode);
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 69/92] qnx4: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 69/92] qnx4: " Jeff Layton
@ 2023-07-06 14:00     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:00 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Anders Larsen, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:34, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Anders Larsen <al@alarsen.net>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/qnx4/inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
> index 391ea402920d..a7171f5532a1 100644
> --- a/fs/qnx4/inode.c
> +++ b/fs/qnx4/inode.c
> @@ -305,8 +305,7 @@ struct inode *qnx4_iget(struct super_block *sb, unsigned long ino)
>  	inode->i_mtime.tv_nsec = 0;
>  	inode->i_atime.tv_sec   = le32_to_cpu(raw_inode->di_atime);
>  	inode->i_atime.tv_nsec = 0;
> -	inode->i_ctime.tv_sec   = le32_to_cpu(raw_inode->di_ctime);
> -	inode->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(inode, le32_to_cpu(raw_inode->di_ctime), 0);
>  	inode->i_blocks  = le32_to_cpu(raw_inode->di_first_xtnt.xtnt_size);
>  
>  	memcpy(qnx4_inode, raw_inode, QNX4_DIR_ENTRY_SIZE);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 70/92] qnx6: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 70/92] qnx6: " Jeff Layton
@ 2023-07-06 14:01     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:01 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:35, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/qnx6/inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
> index 85b2fa3b211c..21f90d519f1a 100644
> --- a/fs/qnx6/inode.c
> +++ b/fs/qnx6/inode.c
> @@ -562,8 +562,7 @@ struct inode *qnx6_iget(struct super_block *sb, unsigned ino)
>  	inode->i_mtime.tv_nsec = 0;
>  	inode->i_atime.tv_sec   = fs32_to_cpu(sbi, raw_inode->di_atime);
>  	inode->i_atime.tv_nsec = 0;
> -	inode->i_ctime.tv_sec   = fs32_to_cpu(sbi, raw_inode->di_ctime);
> -	inode->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(inode, fs32_to_cpu(sbi, raw_inode->di_ctime), 0);
>  
>  	/* calc blocks based on 512 byte blocksize */
>  	inode->i_blocks = (inode->i_size + 511) >> 9;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 71/92] ramfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 71/92] ramfs: " Jeff Layton
@ 2023-07-06 14:01     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:01 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:36, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ramfs/inode.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> index fef477c78107..18e8387cab41 100644
> --- a/fs/ramfs/inode.c
> +++ b/fs/ramfs/inode.c
> @@ -65,7 +65,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
>  		inode->i_mapping->a_ops = &ram_aops;
>  		mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER);
>  		mapping_set_unevictable(inode->i_mapping);
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		switch (mode & S_IFMT) {
>  		default:
>  			init_special_inode(inode, mode, dev);
> @@ -105,7 +105,7 @@ ramfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  		d_instantiate(dentry, inode);
>  		dget(dentry);	/* Extra count - pin the dentry in core */
>  		error = 0;
> -		dir->i_mtime = dir->i_ctime = current_time(dir);
> +		dir->i_mtime = inode_set_ctime_current(dir);
>  	}
>  	return error;
>  }
> @@ -138,7 +138,7 @@ static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  		if (!error) {
>  			d_instantiate(dentry, inode);
>  			dget(dentry);
> -			dir->i_mtime = dir->i_ctime = current_time(dir);
> +			dir->i_mtime = inode_set_ctime_current(dir);
>  		} else
>  			iput(inode);
>  	}
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 66/92] overlayfs: convert to ctime accessor functions
  2023-07-06 13:58     ` Jan Kara
@ 2023-07-06 14:01       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 14:01 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christian Brauner, Miklos Szeredi, Amir Goldstein, Al Viro,
	linux-fsdevel, linux-kernel, linux-unionfs

On Thu, 2023-07-06 at 15:58 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:31, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ...
> > diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> > index 21245b00722a..7acd3e3fe790 100644
> > --- a/fs/overlayfs/file.c
> > +++ b/fs/overlayfs/file.c
> ...
> > @@ -249,10 +250,12 @@ static void ovl_file_accessed(struct file *file)
> >  	if (!upperinode)
> >  		return;
> >  
> > +	ctime = inode_get_ctime(inode);
> > +	uctime = inode_get_ctime(upperinode);
> >  	if ((!timespec64_equal(&inode->i_mtime, &upperinode->i_mtime) ||
> > -	     !timespec64_equal(&inode->i_ctime, &upperinode->i_ctime))) {
> > +	     !timespec64_equal(&ctime, &uctime))) {
> >  		inode->i_mtime = upperinode->i_mtime;
> > -		inode->i_ctime = upperinode->i_ctime;
> > +		inode_set_ctime_to_ts(inode, inode_get_ctime(upperinode));
> 
> I think you can use uctime here instead of inode_get_ctime(upperinode)?
> Otherwise the patch looks good. Feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 

Thanks, fixed in tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 72/92] reiserfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 72/92] reiserfs: " Jeff Layton
@ 2023-07-06 14:03     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:03 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, reiserfs-devel

On Wed 05-07-23 15:01:37, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/reiserfs/inode.c     | 12 +++++-------
>  fs/reiserfs/ioctl.c     |  4 ++--
>  fs/reiserfs/namei.c     | 11 ++++++-----
>  fs/reiserfs/stree.c     |  4 ++--
>  fs/reiserfs/super.c     |  2 +-
>  fs/reiserfs/xattr.c     |  5 +++--
>  fs/reiserfs/xattr_acl.c |  2 +-
>  7 files changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
> index 77bd3b27059f..86e55d4bb10d 100644
> --- a/fs/reiserfs/inode.c
> +++ b/fs/reiserfs/inode.c
> @@ -1259,9 +1259,8 @@ static void init_inode(struct inode *inode, struct treepath *path)
>  		inode->i_size = sd_v1_size(sd);
>  		inode->i_atime.tv_sec = sd_v1_atime(sd);
>  		inode->i_mtime.tv_sec = sd_v1_mtime(sd);
> -		inode->i_ctime.tv_sec = sd_v1_ctime(sd);
> +		inode_set_ctime(inode, sd_v1_ctime(sd), 0);
>  		inode->i_atime.tv_nsec = 0;
> -		inode->i_ctime.tv_nsec = 0;
>  		inode->i_mtime.tv_nsec = 0;
>  
>  		inode->i_blocks = sd_v1_blocks(sd);
> @@ -1314,8 +1313,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
>  		i_gid_write(inode, sd_v2_gid(sd));
>  		inode->i_mtime.tv_sec = sd_v2_mtime(sd);
>  		inode->i_atime.tv_sec = sd_v2_atime(sd);
> -		inode->i_ctime.tv_sec = sd_v2_ctime(sd);
> -		inode->i_ctime.tv_nsec = 0;
> +		inode_set_ctime(inode, sd_v2_ctime(sd), 0);
>  		inode->i_mtime.tv_nsec = 0;
>  		inode->i_atime.tv_nsec = 0;
>  		inode->i_blocks = sd_v2_blocks(sd);
> @@ -1374,7 +1372,7 @@ static void inode2sd(void *sd, struct inode *inode, loff_t size)
>  	set_sd_v2_gid(sd_v2, i_gid_read(inode));
>  	set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
>  	set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
> -	set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
> +	set_sd_v2_ctime(sd_v2, inode_get_ctime(inode).tv_sec);
>  	set_sd_v2_blocks(sd_v2, to_fake_used_blocks(inode, SD_V2_SIZE));
>  	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
>  		set_sd_v2_rdev(sd_v2, new_encode_dev(inode->i_rdev));
> @@ -1394,7 +1392,7 @@ static void inode2sd_v1(void *sd, struct inode *inode, loff_t size)
>  	set_sd_v1_nlink(sd_v1, inode->i_nlink);
>  	set_sd_v1_size(sd_v1, size);
>  	set_sd_v1_atime(sd_v1, inode->i_atime.tv_sec);
> -	set_sd_v1_ctime(sd_v1, inode->i_ctime.tv_sec);
> +	set_sd_v1_ctime(sd_v1, inode_get_ctime(inode).tv_sec);
>  	set_sd_v1_mtime(sd_v1, inode->i_mtime.tv_sec);
>  
>  	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
> @@ -1986,7 +1984,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
>  
>  	/* uid and gid must already be set by the caller for quota init */
>  
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_size = i_size;
>  	inode->i_blocks = 0;
>  	inode->i_bytes = 0;
> diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
> index 6bf9b54e58ca..dd33f8cc6eda 100644
> --- a/fs/reiserfs/ioctl.c
> +++ b/fs/reiserfs/ioctl.c
> @@ -55,7 +55,7 @@ int reiserfs_fileattr_set(struct mnt_idmap *idmap,
>  	}
>  	sd_attrs_to_i_attrs(flags, inode);
>  	REISERFS_I(inode)->i_attrs = flags;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	err = 0;
>  unlock:
> @@ -107,7 +107,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  			err = -EFAULT;
>  			goto setversion_out;
>  		}
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		mark_inode_dirty(inode);
>  setversion_out:
>  		mnt_drop_write_file(filp);
> diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
> index 405ac59eb2dd..9c5704be2435 100644
> --- a/fs/reiserfs/namei.c
> +++ b/fs/reiserfs/namei.c
> @@ -572,7 +572,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
>  	}
>  
>  	dir->i_size += paste_size;
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	if (!S_ISDIR(inode->i_mode) && visible)
>  		/* reiserfs_mkdir or reiserfs_rename will do that by itself */
>  		reiserfs_update_sd(th, dir);
> @@ -966,7 +966,8 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
>  			       inode->i_nlink);
>  
>  	clear_nlink(inode);
> -	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_to_ts(dir,
> +					     inode_set_ctime_current(inode));
>  	reiserfs_update_sd(&th, inode);
>  
>  	DEC_DIR_INODE_NLINK(dir)
> @@ -1070,11 +1071,11 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
>  		inc_nlink(inode);
>  		goto end_unlink;
>  	}
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	reiserfs_update_sd(&th, inode);
>  
>  	dir->i_size -= (de.de_entrylen + DEH_SIZE);
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	reiserfs_update_sd(&th, dir);
>  
>  	if (!savelink)
> @@ -1250,7 +1251,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
>  		return err ? err : retval;
>  	}
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	reiserfs_update_sd(&th, inode);
>  
>  	ihold(inode);
> diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
> index ce5003986789..3676e02a0232 100644
> --- a/fs/reiserfs/stree.c
> +++ b/fs/reiserfs/stree.c
> @@ -2004,7 +2004,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
>  
>  			if (update_timestamps) {
>  				inode->i_mtime = current_time(inode);
> -				inode->i_ctime = current_time(inode);
> +				inode_set_ctime_current(inode);
>  			}
>  			reiserfs_update_sd(th, inode);
>  
> @@ -2029,7 +2029,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
>  	if (update_timestamps) {
>  		/* this is truncate, not file closing */
>  		inode->i_mtime = current_time(inode);
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  	}
>  	reiserfs_update_sd(th, inode);
>  
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 929acce6e731..7eaf36b3de12 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -2587,7 +2587,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
>  		return err;
>  	if (inode->i_size < off + len - towrite)
>  		i_size_write(inode, off + len - towrite);
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	return len - towrite;
>  }
> diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
> index 651027967159..6000964c2b80 100644
> --- a/fs/reiserfs/xattr.c
> +++ b/fs/reiserfs/xattr.c
> @@ -466,12 +466,13 @@ int reiserfs_commit_write(struct file *f, struct page *page,
>  static void update_ctime(struct inode *inode)
>  {
>  	struct timespec64 now = current_time(inode);
> +	struct timespec64 ctime = inode_get_ctime(inode);
>  
>  	if (inode_unhashed(inode) || !inode->i_nlink ||
> -	    timespec64_equal(&inode->i_ctime, &now))
> +	    timespec64_equal(&ctime, &now))
>  		return;
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_to_ts(inode, now);
>  	mark_inode_dirty(inode);
>  }
>  
> diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
> index 138060452678..064264992b49 100644
> --- a/fs/reiserfs/xattr_acl.c
> +++ b/fs/reiserfs/xattr_acl.c
> @@ -285,7 +285,7 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
>  	if (error == -ENODATA) {
>  		error = 0;
>  		if (type == ACL_TYPE_ACCESS) {
> -			inode->i_ctime = current_time(inode);
> +			inode_set_ctime_current(inode);
>  			mark_inode_dirty(inode);
>  		}
>  	}
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 73/92] romfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 73/92] romfs: " Jeff Layton
@ 2023-07-06 14:04     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:04 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:38, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

> diff --git a/fs/romfs/super.c b/fs/romfs/super.c
> index c59b230d55b4..961b9d342e0e 100644
> --- a/fs/romfs/super.c
> +++ b/fs/romfs/super.c
> @@ -322,8 +322,8 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
>  
>  	set_nlink(i, 1);		/* Hard to decide.. */
>  	i->i_size = be32_to_cpu(ri.size);
> -	i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;
> -	i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;
> +	i->i_mtime.tv_sec = i->i_atime.tv_sec = inode_set_ctime(i, 0, 0).tv_sec;
> +	i->i_mtime.tv_nsec = i->i_atime.tv_nsec = 0;

The usual simplification:

	i->i_mtime = i->i_atime = inode_set_ctime(i, 0, 0);

								Honza
  
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 75/92] squashfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 75/92] squashfs: " Jeff Layton
@ 2023-07-06 14:04     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:04 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Phillip Lougher, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:40, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/squashfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
> index 24463145b351..c6e626b00546 100644
> --- a/fs/squashfs/inode.c
> +++ b/fs/squashfs/inode.c
> @@ -61,7 +61,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
>  	inode->i_ino = le32_to_cpu(sqsh_ino->inode_number);
>  	inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime);
>  	inode->i_atime.tv_sec = inode->i_mtime.tv_sec;
> -	inode->i_ctime.tv_sec = inode->i_mtime.tv_sec;
> +	inode_set_ctime(inode, inode->i_mtime.tv_sec, 0);
>  	inode->i_mode = le16_to_cpu(sqsh_ino->mode);
>  	inode->i_size = 0;
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 76/92] sysv: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 76/92] sysv: " Jeff Layton
@ 2023-07-06 14:05     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:05 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:41, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/sysv/dir.c    | 6 +++---
>  fs/sysv/ialloc.c | 2 +-
>  fs/sysv/inode.c  | 5 ++---
>  fs/sysv/itree.c  | 4 ++--
>  fs/sysv/namei.c  | 6 +++---
>  5 files changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
> index 0140010aa0c3..2f5ead88d00b 100644
> --- a/fs/sysv/dir.c
> +++ b/fs/sysv/dir.c
> @@ -224,7 +224,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
>  	memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
>  	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
>  	dir_commit_chunk(page, pos, SYSV_DIRSIZE);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	err = sysv_handle_dirsync(dir);
>  out_page:
> @@ -249,7 +249,7 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
>  	}
>  	de->inode = 0;
>  	dir_commit_chunk(page, pos, SYSV_DIRSIZE);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	return sysv_handle_dirsync(inode);
>  }
> @@ -346,7 +346,7 @@ int sysv_set_link(struct sysv_dir_entry *de, struct page *page,
>  	}
>  	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
>  	dir_commit_chunk(page, pos, SYSV_DIRSIZE);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	return sysv_handle_dirsync(inode);
>  }
> diff --git a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
> index e732879036ab..6719da5889d9 100644
> --- a/fs/sysv/ialloc.c
> +++ b/fs/sysv/ialloc.c
> @@ -165,7 +165,7 @@ struct inode * sysv_new_inode(const struct inode * dir, umode_t mode)
>  	dirty_sb(sb);
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
>  	inode->i_ino = fs16_to_cpu(sbi, ino);
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_blocks = 0;
>  	memset(SYSV_I(inode)->i_data, 0, sizeof(SYSV_I(inode)->i_data));
>  	SYSV_I(inode)->i_dir_start_lookup = 0;
> diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
> index 9e8d4a6fb2f3..0aa3827d8178 100644
> --- a/fs/sysv/inode.c
> +++ b/fs/sysv/inode.c
> @@ -202,8 +202,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned int ino)
>  	inode->i_size = fs32_to_cpu(sbi, raw_inode->i_size);
>  	inode->i_atime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_atime);
>  	inode->i_mtime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_mtime);
> -	inode->i_ctime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_ctime);
> -	inode->i_ctime.tv_nsec = 0;
> +	inode_set_ctime(inode, fs32_to_cpu(sbi, raw_inode->i_ctime), 0);
>  	inode->i_atime.tv_nsec = 0;
>  	inode->i_mtime.tv_nsec = 0;
>  	inode->i_blocks = 0;
> @@ -256,7 +255,7 @@ static int __sysv_write_inode(struct inode *inode, int wait)
>  	raw_inode->i_size = cpu_to_fs32(sbi, inode->i_size);
>  	raw_inode->i_atime = cpu_to_fs32(sbi, inode->i_atime.tv_sec);
>  	raw_inode->i_mtime = cpu_to_fs32(sbi, inode->i_mtime.tv_sec);
> -	raw_inode->i_ctime = cpu_to_fs32(sbi, inode->i_ctime.tv_sec);
> +	raw_inode->i_ctime = cpu_to_fs32(sbi, inode_get_ctime(inode).tv_sec);
>  
>  	si = SYSV_I(inode);
>  	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
> diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
> index 58d7f43a1371..dba6a2ef26f1 100644
> --- a/fs/sysv/itree.c
> +++ b/fs/sysv/itree.c
> @@ -183,7 +183,7 @@ static inline int splice_branch(struct inode *inode,
>  	*where->p = where->key;
>  	write_unlock(&pointers_lock);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  
>  	/* had we spliced it onto indirect block? */
>  	if (where->bh)
> @@ -423,7 +423,7 @@ void sysv_truncate (struct inode * inode)
>  		}
>  		n++;
>  	}
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		sysv_sync_inode (inode);
>  	else
> diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
> index fcf163fea3ad..d6b73798071b 100644
> --- a/fs/sysv/namei.c
> +++ b/fs/sysv/namei.c
> @@ -103,7 +103,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir,
>  {
>  	struct inode *inode = d_inode(old_dentry);
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	inode_inc_link_count(inode);
>  	ihold(inode);
>  
> @@ -161,7 +161,7 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry)
>  
>  	err = sysv_delete_entry(de, page);
>  	if (!err) {
> -		inode->i_ctime = dir->i_ctime;
> +		inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  		inode_dec_link_count(inode);
>  	}
>  	unmap_and_put_page(page, de);
> @@ -230,7 +230,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		unmap_and_put_page(new_page, new_de);
>  		if (err)
>  			goto out_dir;
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		if (dir_de)
>  			drop_nlink(new_inode);
>  		inode_dec_link_count(new_inode);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 77/92] tracefs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 77/92] tracefs: " Jeff Layton
@ 2023-07-06 14:06     ` Jan Kara
  2023-07-06 14:27     ` Steven Rostedt
  1 sibling, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:06 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Steven Rostedt, Masami Hiramatsu, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-trace-kernel

On Wed 05-07-23 15:01:42, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/tracefs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index 57ac8aa4a724..2feb6c58648c 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -132,7 +132,7 @@ static struct inode *tracefs_get_inode(struct super_block *sb)
>  	struct inode *inode = new_inode(sb);
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  	return inode;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 77/92] tracefs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 77/92] tracefs: " Jeff Layton
  2023-07-06 14:06     ` Jan Kara
@ 2023-07-06 14:27     ` Steven Rostedt
  1 sibling, 0 replies; 208+ messages in thread
From: Steven Rostedt @ 2023-07-06 14:27 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Masami Hiramatsu, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-trace-kernel

On Wed,  5 Jul 2023 15:01:42 -0400
Jeff Layton <jlayton@kernel.org> wrote:

> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/tracefs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index 57ac8aa4a724..2feb6c58648c 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -132,7 +132,7 @@ static struct inode *tracefs_get_inode(struct super_block *sb)
>  	struct inode *inode = new_inode(sb);
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  	return inode;
>  }

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve

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

* Re: [PATCH v2 80/92] ufs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 80/92] ufs: " Jeff Layton
@ 2023-07-06 14:49     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:49 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Evgeniy Dushistov, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:45, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ufs/dir.c    |  6 +++---
>  fs/ufs/ialloc.c |  2 +-
>  fs/ufs/inode.c  | 23 +++++++++++++----------
>  fs/ufs/namei.c  |  8 ++++----
>  4 files changed, 21 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
> index 379d75796a5c..fd57f03b6c93 100644
> --- a/fs/ufs/dir.c
> +++ b/fs/ufs/dir.c
> @@ -107,7 +107,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
>  	ufs_commit_chunk(page, pos, len);
>  	ufs_put_page(page);
>  	if (update_times)
> -		dir->i_mtime = dir->i_ctime = current_time(dir);
> +		dir->i_mtime = inode_set_ctime_current(dir);
>  	mark_inode_dirty(dir);
>  	ufs_handle_dirsync(dir);
>  }
> @@ -397,7 +397,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
>  	ufs_set_de_type(sb, de, inode->i_mode);
>  
>  	ufs_commit_chunk(page, pos, rec_len);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  
>  	mark_inode_dirty(dir);
>  	err = ufs_handle_dirsync(dir);
> @@ -539,7 +539,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
>  		pde->d_reclen = cpu_to_fs16(sb, to - from);
>  	dir->d_ino = 0;
>  	ufs_commit_chunk(page, pos, to - from);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  	err = ufs_handle_dirsync(inode);
>  out:
> diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
> index 06bd84d555bd..a1e7bd9d1f98 100644
> --- a/fs/ufs/ialloc.c
> +++ b/fs/ufs/ialloc.c
> @@ -292,7 +292,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
>  	inode->i_blocks = 0;
>  	inode->i_generation = 0;
> -	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	ufsi->i_flags = UFS_I(dir)->i_flags;
>  	ufsi->i_lastfrag = 0;
>  	ufsi->i_shadow = 0;
> diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
> index a4246c83a8cd..21a4779a2de5 100644
> --- a/fs/ufs/inode.c
> +++ b/fs/ufs/inode.c
> @@ -296,7 +296,7 @@ ufs_inode_getfrag(struct inode *inode, unsigned index,
>  
>  	if (new)
>  		*new = 1;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	if (IS_SYNC(inode))
>  		ufs_sync_inode (inode);
>  	mark_inode_dirty(inode);
> @@ -378,7 +378,7 @@ ufs_inode_getblock(struct inode *inode, u64 ind_block,
>  	mark_buffer_dirty(bh);
>  	if (IS_SYNC(inode))
>  		sync_dirty_buffer(bh);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  out:
>  	brelse (bh);
> @@ -580,11 +580,12 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
>  
>  	inode->i_size = fs64_to_cpu(sb, ufs_inode->ui_size);
>  	inode->i_atime.tv_sec = (signed)fs32_to_cpu(sb, ufs_inode->ui_atime.tv_sec);
> -	inode->i_ctime.tv_sec = (signed)fs32_to_cpu(sb, ufs_inode->ui_ctime.tv_sec);
> +	inode_set_ctime(inode,
> +			(signed)fs32_to_cpu(sb, ufs_inode->ui_ctime.tv_sec),
> +			0);
>  	inode->i_mtime.tv_sec = (signed)fs32_to_cpu(sb, ufs_inode->ui_mtime.tv_sec);
>  	inode->i_mtime.tv_nsec = 0;
>  	inode->i_atime.tv_nsec = 0;
> -	inode->i_ctime.tv_nsec = 0;
>  	inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
>  	inode->i_generation = fs32_to_cpu(sb, ufs_inode->ui_gen);
>  	ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
> @@ -626,10 +627,10 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
>  
>  	inode->i_size = fs64_to_cpu(sb, ufs2_inode->ui_size);
>  	inode->i_atime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_atime);
> -	inode->i_ctime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_ctime);
> +	inode_set_ctime(inode, fs64_to_cpu(sb, ufs2_inode->ui_ctime),
> +			fs32_to_cpu(sb, ufs2_inode->ui_ctimensec));
>  	inode->i_mtime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_mtime);
>  	inode->i_atime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_atimensec);
> -	inode->i_ctime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_ctimensec);
>  	inode->i_mtime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_mtimensec);
>  	inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks);
>  	inode->i_generation = fs32_to_cpu(sb, ufs2_inode->ui_gen);
> @@ -726,7 +727,8 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
>  	ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size);
>  	ufs_inode->ui_atime.tv_sec = cpu_to_fs32(sb, inode->i_atime.tv_sec);
>  	ufs_inode->ui_atime.tv_usec = 0;
> -	ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb, inode->i_ctime.tv_sec);
> +	ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb,
> +						 inode_get_ctime(inode).tv_sec);
>  	ufs_inode->ui_ctime.tv_usec = 0;
>  	ufs_inode->ui_mtime.tv_sec = cpu_to_fs32(sb, inode->i_mtime.tv_sec);
>  	ufs_inode->ui_mtime.tv_usec = 0;
> @@ -770,8 +772,9 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
>  	ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size);
>  	ufs_inode->ui_atime = cpu_to_fs64(sb, inode->i_atime.tv_sec);
>  	ufs_inode->ui_atimensec = cpu_to_fs32(sb, inode->i_atime.tv_nsec);
> -	ufs_inode->ui_ctime = cpu_to_fs64(sb, inode->i_ctime.tv_sec);
> -	ufs_inode->ui_ctimensec = cpu_to_fs32(sb, inode->i_ctime.tv_nsec);
> +	ufs_inode->ui_ctime = cpu_to_fs64(sb, inode_get_ctime(inode).tv_sec);
> +	ufs_inode->ui_ctimensec = cpu_to_fs32(sb,
> +					      inode_get_ctime(inode).tv_nsec);
>  	ufs_inode->ui_mtime = cpu_to_fs64(sb, inode->i_mtime.tv_sec);
>  	ufs_inode->ui_mtimensec = cpu_to_fs32(sb, inode->i_mtime.tv_nsec);
>  
> @@ -1205,7 +1208,7 @@ static int ufs_truncate(struct inode *inode, loff_t size)
>  	truncate_setsize(inode, size);
>  
>  	ufs_truncate_blocks(inode);
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	mark_inode_dirty(inode);
>  out:
>  	UFSD("EXIT: err %d\n", err);
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index 36154b5aca6d..9cad29463791 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -153,7 +153,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
>  	struct inode *inode = d_inode(old_dentry);
>  	int error;
>  
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	inode_inc_link_count(inode);
>  	ihold(inode);
>  
> @@ -220,7 +220,7 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry)
>  	if (err)
>  		goto out;
>  
> -	inode->i_ctime = dir->i_ctime;
> +	inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
>  	inode_dec_link_count(inode);
>  	err = 0;
>  out:
> @@ -282,7 +282,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		if (!new_de)
>  			goto out_dir;
>  		ufs_set_link(new_dir, new_de, new_page, old_inode, 1);
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  		if (dir_de)
>  			drop_nlink(new_inode);
>  		inode_dec_link_count(new_inode);
> @@ -298,7 +298,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  	 * Like most other Unix systems, set the ctime for inodes on a
>   	 * rename.
>  	 */
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  
>  	ufs_delete_entry(old_dir, old_de, old_page);
>  	mark_inode_dirty(old_inode);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 81/92] vboxsf: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 81/92] vboxsf: " Jeff Layton
@ 2023-07-06 14:50     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:50 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Hans de Goede, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:46, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/vboxsf/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
> index dd0ae1188e87..576b91d571c5 100644
> --- a/fs/vboxsf/utils.c
> +++ b/fs/vboxsf/utils.c
> @@ -128,8 +128,8 @@ int vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode,
>  
>  	inode->i_atime = ns_to_timespec64(
>  				 info->access_time.ns_relative_to_unix_epoch);
> -	inode->i_ctime = ns_to_timespec64(
> -				 info->change_time.ns_relative_to_unix_epoch);
> +	inode_set_ctime_to_ts(inode,
> +			      ns_to_timespec64(info->change_time.ns_relative_to_unix_epoch));
>  	inode->i_mtime = ns_to_timespec64(
>  			   info->modification_time.ns_relative_to_unix_epoch);
>  	return 0;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 82/92] xfs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 82/92] xfs: " Jeff Layton
@ 2023-07-06 14:52     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:52 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Darrick J. Wong, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-xfs

On Wed 05-07-23 15:01:47, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c   | 5 +++--
>  fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
>  fs/xfs/xfs_acl.c                | 2 +-
>  fs/xfs/xfs_bmap_util.c          | 6 ++++--
>  fs/xfs/xfs_inode.c              | 3 +--
>  fs/xfs/xfs_inode_item.c         | 2 +-
>  fs/xfs/xfs_iops.c               | 4 ++--
>  fs/xfs/xfs_itable.c             | 4 ++--
>  8 files changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 758aacd8166b..a35781577cad 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -222,7 +222,8 @@ xfs_inode_from_disk(
>  	 */
>  	inode->i_atime = xfs_inode_from_disk_ts(from, from->di_atime);
>  	inode->i_mtime = xfs_inode_from_disk_ts(from, from->di_mtime);
> -	inode->i_ctime = xfs_inode_from_disk_ts(from, from->di_ctime);
> +	inode_set_ctime_to_ts(inode,
> +			      xfs_inode_from_disk_ts(from, from->di_ctime));
>  
>  	ip->i_disk_size = be64_to_cpu(from->di_size);
>  	ip->i_nblocks = be64_to_cpu(from->di_nblocks);
> @@ -316,7 +317,7 @@ xfs_inode_to_disk(
>  
>  	to->di_atime = xfs_inode_to_disk_ts(ip, inode->i_atime);
>  	to->di_mtime = xfs_inode_to_disk_ts(ip, inode->i_mtime);
> -	to->di_ctime = xfs_inode_to_disk_ts(ip, inode->i_ctime);
> +	to->di_ctime = xfs_inode_to_disk_ts(ip, inode_get_ctime(inode));
>  	to->di_nlink = cpu_to_be32(inode->i_nlink);
>  	to->di_gen = cpu_to_be32(inode->i_generation);
>  	to->di_mode = cpu_to_be16(inode->i_mode);
> diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
> index cb4796b6e693..6b2296ff248a 100644
> --- a/fs/xfs/libxfs/xfs_trans_inode.c
> +++ b/fs/xfs/libxfs/xfs_trans_inode.c
> @@ -67,7 +67,7 @@ xfs_trans_ichgtime(
>  	if (flags & XFS_ICHGTIME_MOD)
>  		inode->i_mtime = tv;
>  	if (flags & XFS_ICHGTIME_CHG)
> -		inode->i_ctime = tv;
> +		inode_set_ctime_to_ts(inode, tv);
>  	if (flags & XFS_ICHGTIME_CREATE)
>  		ip->i_crtime = tv;
>  }
> diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
> index 791db7d9c849..6b840301817a 100644
> --- a/fs/xfs/xfs_acl.c
> +++ b/fs/xfs/xfs_acl.c
> @@ -233,7 +233,7 @@ xfs_acl_set_mode(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  	inode->i_mode = mode;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
>  
>  	if (xfs_has_wsync(mp))
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index fbb675563208..fcefab687285 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1644,6 +1644,7 @@ xfs_swap_extents(
>  	uint64_t		f;
>  	int			resblks = 0;
>  	unsigned int		flags = 0;
> +	struct timespec64	ctime;
>  
>  	/*
>  	 * Lock the inodes against other IO, page faults and truncate to
> @@ -1756,8 +1757,9 @@ xfs_swap_extents(
>  	 * process that the file was not changed out from
>  	 * under it.
>  	 */
> -	if ((sbp->bs_ctime.tv_sec != VFS_I(ip)->i_ctime.tv_sec) ||
> -	    (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) ||
> +	ctime = inode_get_ctime(VFS_I(ip));
> +	if ((sbp->bs_ctime.tv_sec != ctime.tv_sec) ||
> +	    (sbp->bs_ctime.tv_nsec != ctime.tv_nsec) ||
>  	    (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
>  	    (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
>  		error = -EBUSY;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 9e62cc500140..360fe83a334f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -843,10 +843,9 @@ xfs_init_new_inode(
>  	ip->i_df.if_nextents = 0;
>  	ASSERT(ip->i_nblocks == 0);
>  
> -	tv = current_time(inode);
> +	tv = inode_set_ctime_current(inode);
>  	inode->i_mtime = tv;
>  	inode->i_atime = tv;
> -	inode->i_ctime = tv;
>  
>  	ip->i_extsize = 0;
>  	ip->i_diflags = 0;
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 91c847a84e10..127b2410eb20 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -528,7 +528,7 @@ xfs_inode_to_log_dinode(
>  	memset(to->di_pad3, 0, sizeof(to->di_pad3));
>  	to->di_atime = xfs_inode_to_log_dinode_ts(ip, inode->i_atime);
>  	to->di_mtime = xfs_inode_to_log_dinode_ts(ip, inode->i_mtime);
> -	to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode->i_ctime);
> +	to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode_get_ctime(inode));
>  	to->di_nlink = inode->i_nlink;
>  	to->di_gen = inode->i_generation;
>  	to->di_mode = inode->i_mode;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 24718adb3c16..3a9363953ef2 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -574,7 +574,7 @@ xfs_vn_getattr(
>  	stat->ino = ip->i_ino;
>  	stat->atime = inode->i_atime;
>  	stat->mtime = inode->i_mtime;
> -	stat->ctime = inode->i_ctime;
> +	stat->ctime = inode_get_ctime(inode);
>  	stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
>  
>  	if (xfs_has_v3inodes(mp)) {
> @@ -1055,7 +1055,7 @@ xfs_vn_update_time(
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	if (flags & S_CTIME)
> -		inode->i_ctime = *now;
> +		inode_set_ctime_to_ts(inode, *now);
>  	if (flags & S_MTIME)
>  		inode->i_mtime = *now;
>  	if (flags & S_ATIME)
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index f225413a993c..c2093cb56092 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -100,8 +100,8 @@ xfs_bulkstat_one_int(
>  	buf->bs_atime_nsec = inode->i_atime.tv_nsec;
>  	buf->bs_mtime = inode->i_mtime.tv_sec;
>  	buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
> -	buf->bs_ctime = inode->i_ctime.tv_sec;
> -	buf->bs_ctime_nsec = inode->i_ctime.tv_nsec;
> +	buf->bs_ctime = inode_get_ctime(inode).tv_sec;
> +	buf->bs_ctime_nsec = inode_get_ctime(inode).tv_nsec;
>  	buf->bs_gen = inode->i_generation;
>  	buf->bs_mode = inode->i_mode;
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 83/92] zonefs: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 83/92] zonefs: " Jeff Layton
@ 2023-07-06 14:52     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:52 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel

On Wed 05-07-23 15:01:48, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/zonefs/super.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index bbe44a26a8e5..eaaa23cf6d93 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -658,7 +658,8 @@ static struct inode *zonefs_get_file_inode(struct inode *dir,
>  
>  	inode->i_ino = ino;
>  	inode->i_mode = z->z_mode;
> -	inode->i_ctime = inode->i_mtime = inode->i_atime = dir->i_ctime;
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_to_ts(inode,
> +								inode_get_ctime(dir));
>  	inode->i_uid = z->z_uid;
>  	inode->i_gid = z->z_gid;
>  	inode->i_size = z->z_wpoffset;
> @@ -694,7 +695,8 @@ static struct inode *zonefs_get_zgroup_inode(struct super_block *sb,
>  	inode->i_ino = ino;
>  	inode_init_owner(&nop_mnt_idmap, inode, root, S_IFDIR | 0555);
>  	inode->i_size = sbi->s_zgroup[ztype].g_nr_zones;
> -	inode->i_ctime = inode->i_mtime = inode->i_atime = root->i_ctime;
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_to_ts(inode,
> +								inode_get_ctime(root));
>  	inode->i_private = &sbi->s_zgroup[ztype];
>  	set_nlink(inode, 2);
>  
> @@ -1317,7 +1319,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  
>  	inode->i_ino = bdev_nr_zones(sb->s_bdev);
>  	inode->i_mode = S_IFDIR | 0555;
> -	inode->i_ctime = inode->i_mtime = inode->i_atime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_op = &zonefs_dir_inode_operations;
>  	inode->i_fop = &zonefs_dir_operations;
>  	inode->i_size = 2;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 84/92] linux: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 84/92] linux: " Jeff Layton
@ 2023-07-06 14:53     ` Jan Kara
  2023-07-06 15:05       ` Jeff Layton
  0 siblings, 1 reply; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:53 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:49, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/fs_stack.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
> index 54210a42c30d..010d39d0dc1c 100644
> --- a/include/linux/fs_stack.h
> +++ b/include/linux/fs_stack.h
> @@ -24,7 +24,7 @@ static inline void fsstack_copy_attr_times(struct inode *dest,
>  {
>  	dest->i_atime = src->i_atime;
>  	dest->i_mtime = src->i_mtime;
> -	dest->i_ctime = src->i_ctime;
> +	inode_set_ctime_to_ts(dest, inode_get_ctime(src));
>  }
>  
>  #endif /* _LINUX_FS_STACK_H */
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 85/92] mqueue: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 85/92] mqueue: " Jeff Layton
@ 2023-07-06 14:54     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:54 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, Jan Kara, linux-fsdevel, linux-kernel

On Wed 05-07-23 15:01:50, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  ipc/mqueue.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/ipc/mqueue.c b/ipc/mqueue.c
> index 71881bddad25..ba8215ed663a 100644
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -302,7 +302,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
>  	inode->i_mode = mode;
>  	inode->i_uid = current_fsuid();
>  	inode->i_gid = current_fsgid();
> -	inode->i_mtime = inode->i_ctime = inode->i_atime = current_time(inode);
> +	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
>  
>  	if (S_ISREG(mode)) {
>  		struct mqueue_inode_info *info;
> @@ -596,7 +596,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg)
>  
>  	put_ipc_ns(ipc_ns);
>  	dir->i_size += DIRENT_SIZE;
> -	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
> +	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
>  
>  	d_instantiate(dentry, inode);
>  	dget(dentry);
> @@ -618,7 +618,7 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
>  {
>  	struct inode *inode = d_inode(dentry);
>  
> -	dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
> +	dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
>  	dir->i_size -= DIRENT_SIZE;
>  	drop_nlink(inode);
>  	dput(dentry);
> @@ -635,7 +635,8 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
>  static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
>  				size_t count, loff_t *off)
>  {
> -	struct mqueue_inode_info *info = MQUEUE_I(file_inode(filp));
> +	struct inode *inode = file_inode(filp);
> +	struct mqueue_inode_info *info = MQUEUE_I(inode);
>  	char buffer[FILENT_SIZE];
>  	ssize_t ret;
>  
> @@ -656,7 +657,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
>  	if (ret <= 0)
>  		return ret;
>  
> -	file_inode(filp)->i_atime = file_inode(filp)->i_ctime = current_time(file_inode(filp));
> +	inode->i_atime = inode_set_ctime_current(inode);
>  	return ret;
>  }
>  
> @@ -1162,8 +1163,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
>  				goto out_unlock;
>  			__do_notify(info);
>  		}
> -		inode->i_atime = inode->i_mtime = inode->i_ctime =
> -				current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  out_unlock:
>  	spin_unlock(&info->lock);
> @@ -1257,8 +1257,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
>  
>  		msg_ptr = msg_get(info);
>  
> -		inode->i_atime = inode->i_mtime = inode->i_ctime =
> -				current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  
>  		/* There is now free space in queue. */
>  		pipelined_receive(&wake_q, info);
> @@ -1396,7 +1395,7 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
>  	if (notification == NULL) {
>  		if (info->notify_owner == task_tgid(current)) {
>  			remove_notification(info);
> -			inode->i_atime = inode->i_ctime = current_time(inode);
> +			inode->i_atime = inode_set_ctime_current(inode);
>  		}
>  	} else if (info->notify_owner != NULL) {
>  		ret = -EBUSY;
> @@ -1422,7 +1421,7 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
>  
>  		info->notify_owner = get_pid(task_tgid(current));
>  		info->notify_user_ns = get_user_ns(current_user_ns());
> -		inode->i_atime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode_set_ctime_current(inode);
>  	}
>  	spin_unlock(&info->lock);
>  out_fput:
> @@ -1485,7 +1484,7 @@ static int do_mq_getsetattr(int mqdes, struct mq_attr *new, struct mq_attr *old)
>  			f.file->f_flags &= ~O_NONBLOCK;
>  		spin_unlock(&f.file->f_lock);
>  
> -		inode->i_atime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode_set_ctime_current(inode);
>  	}
>  
>  	spin_unlock(&info->lock);
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 86/92] bpf: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 86/92] bpf: " Jeff Layton
@ 2023-07-06 14:55     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:55 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, bpf

On Wed 05-07-23 15:01:51, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  kernel/bpf/inode.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 4174f76133df..99d0625b6c82 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -118,9 +118,8 @@ static struct inode *bpf_get_inode(struct super_block *sb,
>  		return ERR_PTR(-ENOSPC);
>  
>  	inode->i_ino = get_next_ino();
> -	inode->i_atime = current_time(inode);
> +	inode->i_atime = inode_set_ctime_current(inode);
>  	inode->i_mtime = inode->i_atime;
> -	inode->i_ctime = inode->i_atime;
>  
>  	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
>  
> @@ -148,8 +147,7 @@ static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
>  	d_instantiate(dentry, inode);
>  	dget(dentry);
>  
> -	dir->i_mtime = current_time(dir);
> -	dir->i_ctime = dir->i_mtime;
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  }
>  
>  static int bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 87/92] shmem: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 87/92] shmem: " Jeff Layton
@ 2023-07-06 14:56     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:56 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Hugh Dickins, Andrew Morton, Al Viro,
	Jan Kara, linux-fsdevel, linux-kernel, linux-mm

On Wed 05-07-23 15:01:52, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  mm/shmem.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 1693134959c5..51aaaf479437 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1064,7 +1064,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
>  void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
>  {
>  	shmem_undo_range(inode, lstart, lend, false);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	inode_inc_iversion(inode);
>  }
>  EXPORT_SYMBOL_GPL(shmem_truncate_range);
> @@ -1161,9 +1161,9 @@ static int shmem_setattr(struct mnt_idmap *idmap,
>  	if (attr->ia_valid & ATTR_MODE)
>  		error = posix_acl_chmod(idmap, dentry, inode->i_mode);
>  	if (!error && update_ctime) {
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		if (update_mtime)
> -			inode->i_mtime = inode->i_ctime;
> +			inode->i_mtime = inode_get_ctime(inode);
>  		inode_inc_iversion(inode);
>  	}
>  	return error;
> @@ -2394,7 +2394,7 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap, struct super_block
>  		inode->i_ino = ino;
>  		inode_init_owner(idmap, inode, dir, mode);
>  		inode->i_blocks = 0;
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		inode->i_generation = get_random_u32();
>  		info = SHMEM_I(inode);
>  		memset(info, 0, (char *)inode - (char *)info);
> @@ -3110,7 +3110,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
>  			goto out_iput;
>  
>  		dir->i_size += BOGO_DIRENT_SIZE;
> -		dir->i_ctime = dir->i_mtime = current_time(dir);
> +		dir->i_mtime = inode_set_ctime_current(dir);
>  		inode_inc_iversion(dir);
>  		d_instantiate(dentry, inode);
>  		dget(dentry); /* Extra count - pin the dentry in core */
> @@ -3193,7 +3193,8 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr
>  	}
>  
>  	dir->i_size += BOGO_DIRENT_SIZE;
> -	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
> +	dir->i_mtime = inode_set_ctime_to_ts(dir,
> +					     inode_set_ctime_current(inode));
>  	inode_inc_iversion(dir);
>  	inc_nlink(inode);
>  	ihold(inode);	/* New dentry reference */
> @@ -3213,7 +3214,8 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)
>  	simple_offset_remove(shmem_get_offset_ctx(dir), dentry);
>  
>  	dir->i_size -= BOGO_DIRENT_SIZE;
> -	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
> +	dir->i_mtime = inode_set_ctime_to_ts(dir,
> +					     inode_set_ctime_current(inode));
>  	inode_inc_iversion(dir);
>  	drop_nlink(inode);
>  	dput(dentry);	/* Undo the count from "create" - this does all the work */
> @@ -3360,7 +3362,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  		folio_put(folio);
>  	}
>  	dir->i_size += BOGO_DIRENT_SIZE;
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	inode_inc_iversion(dir);
>  	d_instantiate(dentry, inode);
>  	dget(dentry);
> @@ -3438,7 +3440,7 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap,
>  		(fa->flags & SHMEM_FL_USER_MODIFIABLE);
>  
>  	shmem_set_inode_flags(inode, info->fsflags);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	inode_inc_iversion(inode);
>  	return 0;
>  }
> @@ -3508,7 +3510,7 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
>  	name = xattr_full_name(handler, name);
>  	err = simple_xattr_set(&info->xattrs, name, value, size, flags, NULL);
>  	if (!err) {
> -		inode->i_ctime = current_time(inode);
> +		inode_set_ctime_current(inode);
>  		inode_inc_iversion(inode);
>  	}
>  	return err;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 88/92] sunrpc: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 88/92] sunrpc: " Jeff Layton
@ 2023-07-06 14:56     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:56 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, linux-nfs,
	netdev

On Wed 05-07-23 15:01:53, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  net/sunrpc/rpc_pipe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
> index 0b6034fab9ab..f420d8457345 100644
> --- a/net/sunrpc/rpc_pipe.c
> +++ b/net/sunrpc/rpc_pipe.c
> @@ -472,7 +472,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)
>  		return NULL;
>  	inode->i_ino = get_next_ino();
>  	inode->i_mode = mode;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	switch (mode & S_IFMT) {
>  	case S_IFDIR:
>  		inode->i_fop = &simple_dir_operations;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 89/92] apparmor: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 89/92] apparmor: " Jeff Layton
@ 2023-07-06 14:57     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:57 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Al Viro, Jan Kara, linux-fsdevel, linux-kernel,
	apparmor, linux-security-module

On Wed 05-07-23 15:01:54, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  security/apparmor/apparmorfs.c    | 6 +++---
>  security/apparmor/policy_unpack.c | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
> index 3d0d370d6ffd..7dbd0a5aaeeb 100644
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -226,7 +226,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry,
>  
>  	inode->i_ino = get_next_ino();
>  	inode->i_mode = mode;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	inode->i_private = data;
>  	if (S_ISDIR(mode)) {
>  		inode->i_op = iops ? iops : &simple_dir_inode_operations;
> @@ -1557,7 +1557,7 @@ void __aafs_profile_migrate_dents(struct aa_profile *old,
>  		if (new->dents[i]) {
>  			struct inode *inode = d_inode(new->dents[i]);
>  
> -			inode->i_mtime = inode->i_ctime = current_time(inode);
> +			inode->i_mtime = inode_set_ctime_current(inode);
>  		}
>  		old->dents[i] = NULL;
>  	}
> @@ -2546,7 +2546,7 @@ static int aa_mk_null_file(struct dentry *parent)
>  
>  	inode->i_ino = get_next_ino();
>  	inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO,
>  			   MKDEV(MEM_MAJOR, 3));
>  	d_instantiate(dentry, inode);
> diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
> index ed180722a833..8b8846073e14 100644
> --- a/security/apparmor/policy_unpack.c
> +++ b/security/apparmor/policy_unpack.c
> @@ -89,10 +89,10 @@ void __aa_loaddata_update(struct aa_loaddata *data, long revision)
>  		struct inode *inode;
>  
>  		inode = d_inode(data->dents[AAFS_LOADDATA_DIR]);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  
>  		inode = d_inode(data->dents[AAFS_LOADDATA_REVISION]);
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  	}
>  }
>  
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 90/92] security: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 90/92] security: " Jeff Layton
@ 2023-07-06 14:57     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:57 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Paul Moore, James Morris, Serge E. Hallyn,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel,
	linux-security-module

On Wed 05-07-23 15:01:55, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Paul Moore <paul@paul-moore.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  security/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/inode.c b/security/inode.c
> index 6c326939750d..3aa75fffa8c9 100644
> --- a/security/inode.c
> +++ b/security/inode.c
> @@ -145,7 +145,7 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
>  
>  	inode->i_ino = get_next_ino();
>  	inode->i_mode = mode;
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  	inode->i_private = data;
>  	if (S_ISDIR(mode)) {
>  		inode->i_op = &simple_dir_inode_operations;
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 91/92] selinux: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 91/92] selinux: " Jeff Layton
@ 2023-07-06 14:57     ` Jan Kara
  0 siblings, 0 replies; 208+ messages in thread
From: Jan Kara @ 2023-07-06 14:57 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Paul Moore, Stephen Smalley, Eric Paris,
	Al Viro, Jan Kara, linux-fsdevel, linux-kernel, selinux

On Wed 05-07-23 15:01:56, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Acked-by: Paul Moore <paul@paul-moore.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  security/selinux/selinuxfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
> index bad1f6b685fd..9dafb6ff110d 100644
> --- a/security/selinux/selinuxfs.c
> +++ b/security/selinux/selinuxfs.c
> @@ -1197,7 +1197,7 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
>  
>  	if (ret) {
>  		ret->i_mode = mode;
> -		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
> +		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
>  	}
>  	return ret;
>  }
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH v2 84/92] linux: convert to ctime accessor functions
  2023-07-06 14:53     ` Jan Kara
@ 2023-07-06 15:05       ` Jeff Layton
  0 siblings, 0 replies; 208+ messages in thread
From: Jeff Layton @ 2023-07-06 15:05 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christian Brauner, Al Viro, linux-fsdevel, linux-kernel

On Thu, 2023-07-06 at 16:53 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:49, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Looks good. Feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> 								Honza
> 

I'll fix the subject line on this one too, which should be "fs_stack:".
Many thanks for all of the review!

> > ---
> >  include/linux/fs_stack.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
> > index 54210a42c30d..010d39d0dc1c 100644
> > --- a/include/linux/fs_stack.h
> > +++ b/include/linux/fs_stack.h
> > @@ -24,7 +24,7 @@ static inline void fsstack_copy_attr_times(struct inode *dest,
> >  {
> >  	dest->i_atime = src->i_atime;
> >  	dest->i_mtime = src->i_mtime;
> > -	dest->i_ctime = src->i_ctime;
> > +	inode_set_ctime_to_ts(dest, inode_get_ctime(src));
> >  }
> >  
> >  #endif /* _LINUX_FS_STACK_H */
> > -- 
> > 2.41.0
> > 

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 39/92] erofs: convert to ctime accessor functions
  2023-07-06 11:00       ` Jan Kara
@ 2023-07-06 15:12         ` Gao Xiang
  -1 siblings, 0 replies; 208+ messages in thread
From: Gao Xiang @ 2023-07-06 15:12 UTC (permalink / raw)
  To: Jan Kara, Jeff Layton
  Cc: Christian Brauner, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
	Al Viro, linux-fsdevel, linux-kernel, linux-erofs

Hi Jan,

On 2023/7/6 19:00, Jan Kara wrote:
> On Wed 05-07-23 15:01:04, Jeff Layton wrote:
>> In later patches, we're going to change how the inode's ctime field is
>> used. Switch to using accessor functions instead of raw accesses of
>> inode->i_ctime.
>>
>> Acked-by: Gao Xiang <xiang@kernel.org>
>> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Just one nit below:
> 
>> @@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
>>   		vi->chunkbits = sb->s_blocksize_bits +
>>   			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
>>   	}
>> -	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
>> -	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
>> -	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
>> -	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
>> +	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
>> +	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
>> +	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
>> +	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> 
> Isn't this just longer way to write:
> 
> 	inode->i_atime = inode->i_mtime = inode_get_ctime(inode);

I'm fine with this.  I think we could use this (although I'm not sure
if checkpatch will complain but personally I'm fine.)

Thanks,
Gao Xiang

> 
> ?
> 
> 								Honza

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

* Re: [PATCH v2 39/92] erofs: convert to ctime accessor functions
@ 2023-07-06 15:12         ` Gao Xiang
  0 siblings, 0 replies; 208+ messages in thread
From: Gao Xiang @ 2023-07-06 15:12 UTC (permalink / raw)
  To: Jan Kara, Jeff Layton
  Cc: Christian Brauner, linux-kernel, linux-fsdevel, Yue Hu, Al Viro,
	linux-erofs

Hi Jan,

On 2023/7/6 19:00, Jan Kara wrote:
> On Wed 05-07-23 15:01:04, Jeff Layton wrote:
>> In later patches, we're going to change how the inode's ctime field is
>> used. Switch to using accessor functions instead of raw accesses of
>> inode->i_ctime.
>>
>> Acked-by: Gao Xiang <xiang@kernel.org>
>> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Just one nit below:
> 
>> @@ -176,10 +175,10 @@ static void *erofs_read_inode(struct erofs_buf *buf,
>>   		vi->chunkbits = sb->s_blocksize_bits +
>>   			(vi->chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
>>   	}
>> -	inode->i_mtime.tv_sec = inode->i_ctime.tv_sec;
>> -	inode->i_atime.tv_sec = inode->i_ctime.tv_sec;
>> -	inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec;
>> -	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec;
>> +	inode->i_mtime.tv_sec = inode_get_ctime(inode).tv_sec;
>> +	inode->i_atime.tv_sec = inode_get_ctime(inode).tv_sec;
>> +	inode->i_mtime.tv_nsec = inode_get_ctime(inode).tv_nsec;
>> +	inode->i_atime.tv_nsec = inode_get_ctime(inode).tv_nsec;
> 
> Isn't this just longer way to write:
> 
> 	inode->i_atime = inode->i_mtime = inode_get_ctime(inode);

I'm fine with this.  I think we could use this (although I'm not sure
if checkpatch will complain but personally I'm fine.)

Thanks,
Gao Xiang

> 
> ?
> 
> 								Honza

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

* Re: [PATCH v2 06/92] cifs: update the ctime on a partial page write
  2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
       [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
@ 2023-07-06 15:26     ` Steve French
  1 sibling, 0 replies; 208+ messages in thread
From: Steve French @ 2023-07-06 15:26 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Steve French, Paulo Alcantara,
	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-cifs, samba-technical

Reviewed-by: Steve French <stfrench@microsoft.com>

On Wed, Jul 5, 2023 at 2:04 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> POSIX says:
>
>     "Upon successful completion, where nbyte is greater than 0, write()
>      shall mark for update the last data modification and last file status
>      change timestamps of the file..."
>
> Add the missing ctime update.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/smb/client/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 879bc8e6555c..0a5fe8d5314b 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
>                                            write_data, to - from, &offset);
>                 cifsFileInfo_put(open_file);
>                 /* Does mm or vfs already set times? */
> -               inode->i_atime = inode->i_mtime = current_time(inode);
> +               inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
>                 if ((bytes_written > 0) && (offset))
>                         rc = 0;
>                 else if (bytes_written < 0)
> --
> 2.41.0
>


-- 
Thanks,

Steve

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

* Re: [PATCH v2 74/92] smb: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 74/92] smb: " Jeff Layton
  2023-07-05 23:01     ` Jeff Layton
@ 2023-07-06 15:28     ` Steve French
  1 sibling, 0 replies; 208+ messages in thread
From: Steve French @ 2023-07-06 15:28 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Steve French, Paulo Alcantara,
	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, Namjae Jeon,
	Sergey Senozhatsky, Al Viro, Jan Kara, linux-fsdevel,
	linux-kernel, linux-cifs, samba-technical

Acked-by: Steve French <stfrench@microsoft.com>

On Wed, Jul 5, 2023 at 2:42 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
>
> Acked-by: Tom Talpey <tom@talpey.com>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/smb/client/file.c    |  4 ++--
>  fs/smb/client/fscache.h |  5 +++--
>  fs/smb/client/inode.c   | 14 +++++++-------
>  fs/smb/client/smb2ops.c |  3 ++-
>  fs/smb/server/smb2pdu.c |  8 ++++----
>  5 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 0a5fe8d5314b..689058e1b6e6 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -1085,7 +1085,7 @@ int cifs_close(struct inode *inode, struct file *file)
>                     !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
>                     dclose) {
>                         if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) {
> -                               inode->i_ctime = inode->i_mtime = current_time(inode);
> +                               inode->i_mtime = inode_set_ctime_current(inode);
>                         }
>                         spin_lock(&cinode->deferred_lock);
>                         cifs_add_deferred_close(cfile, dclose);
> @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
>                                            write_data, to - from, &offset);
>                 cifsFileInfo_put(open_file);
>                 /* Does mm or vfs already set times? */
> -               inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +               inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>                 if ((bytes_written > 0) && (offset))
>                         rc = 0;
>                 else if (bytes_written < 0)
> diff --git a/fs/smb/client/fscache.h b/fs/smb/client/fscache.h
> index 173999610997..a228964bc2ce 100644
> --- a/fs/smb/client/fscache.h
> +++ b/fs/smb/client/fscache.h
> @@ -50,12 +50,13 @@ void cifs_fscache_fill_coherency(struct inode *inode,
>                                  struct cifs_fscache_inode_coherency_data *cd)
>  {
>         struct cifsInodeInfo *cifsi = CIFS_I(inode);
> +       struct timespec64 ctime = inode_get_ctime(inode);
>
>         memset(cd, 0, sizeof(*cd));
>         cd->last_write_time_sec   = cpu_to_le64(cifsi->netfs.inode.i_mtime.tv_sec);
>         cd->last_write_time_nsec  = cpu_to_le32(cifsi->netfs.inode.i_mtime.tv_nsec);
> -       cd->last_change_time_sec  = cpu_to_le64(cifsi->netfs.inode.i_ctime.tv_sec);
> -       cd->last_change_time_nsec = cpu_to_le32(cifsi->netfs.inode.i_ctime.tv_nsec);
> +       cd->last_change_time_sec  = cpu_to_le64(ctime.tv_sec);
> +       cd->last_change_time_nsec  = cpu_to_le64(ctime.tv_nsec);
>  }
>
>
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index c3eeae07e139..218f03dd3f52 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -172,7 +172,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
>         else
>                 inode->i_atime = fattr->cf_atime;
>         inode->i_mtime = fattr->cf_mtime;
> -       inode->i_ctime = fattr->cf_ctime;
> +       inode_set_ctime_to_ts(inode, fattr->cf_ctime);
>         inode->i_rdev = fattr->cf_rdev;
>         cifs_nlink_fattr_to_inode(inode, fattr);
>         inode->i_uid = fattr->cf_uid;
> @@ -1744,9 +1744,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>                 cifs_inode = CIFS_I(inode);
>                 cifs_inode->time = 0;   /* will force revalidate to get info
>                                            when needed */
> -               inode->i_ctime = current_time(inode);
> +               inode_set_ctime_current(inode);
>         }
> -       dir->i_ctime = dir->i_mtime = current_time(dir);
> +       dir->i_mtime = inode_set_ctime_current(dir);
>         cifs_inode = CIFS_I(dir);
>         CIFS_I(dir)->time = 0;  /* force revalidate of dir as well */
>  unlink_out:
> @@ -2060,8 +2060,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
>          */
>         cifsInode->time = 0;
>
> -       d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime =
> -               current_time(inode);
> +       inode_set_ctime_current(d_inode(direntry));
> +       inode->i_mtime = inode_set_ctime_current(inode);
>
>  rmdir_exit:
>         free_dentry_path(page);
> @@ -2267,8 +2267,8 @@ cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
>         /* force revalidate to go get info when needed */
>         CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
>
> -       source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
> -               target_dir->i_mtime = current_time(source_dir);
> +       source_dir->i_mtime = target_dir->i_mtime = inode_set_ctime_to_ts(source_dir,
> +                                                                         inode_set_ctime_current(target_dir));
>
>  cifs_rename_exit:
>         kfree(info_buf_source);
> diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> index 87abce010974..3cc3c4a71e32 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -1396,7 +1396,8 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon,
>         if (file_inf.LastWriteTime)
>                 inode->i_mtime = cifs_NTtimeToUnix(file_inf.LastWriteTime);
>         if (file_inf.ChangeTime)
> -               inode->i_ctime = cifs_NTtimeToUnix(file_inf.ChangeTime);
> +               inode_set_ctime_to_ts(inode,
> +                                     cifs_NTtimeToUnix(file_inf.ChangeTime));
>         if (file_inf.LastAccessTime)
>                 inode->i_atime = cifs_NTtimeToUnix(file_inf.LastAccessTime);
>
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index cf8822103f50..f9099831c8ff 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -4779,7 +4779,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
>         file_info->LastAccessTime = cpu_to_le64(time);
>         time = ksmbd_UnixTimeToNT(inode->i_mtime);
>         file_info->LastWriteTime = cpu_to_le64(time);
> -       time = ksmbd_UnixTimeToNT(inode->i_ctime);
> +       time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
>         file_info->ChangeTime = cpu_to_le64(time);
>         file_info->DosAttributes = fp->f_ci->m_fattr;
>         file_info->Inode = cpu_to_le64(inode->i_ino);
> @@ -5422,7 +5422,7 @@ int smb2_close(struct ksmbd_work *work)
>                 rsp->LastAccessTime = cpu_to_le64(time);
>                 time = ksmbd_UnixTimeToNT(inode->i_mtime);
>                 rsp->LastWriteTime = cpu_to_le64(time);
> -               time = ksmbd_UnixTimeToNT(inode->i_ctime);
> +               time = ksmbd_UnixTimeToNT(inode_get_ctime(inode));
>                 rsp->ChangeTime = cpu_to_le64(time);
>                 ksmbd_fd_put(work, fp);
>         } else {
> @@ -5644,7 +5644,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
>         if (file_info->ChangeTime)
>                 attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
>         else
> -               attrs.ia_ctime = inode->i_ctime;
> +               attrs.ia_ctime = inode_get_ctime(inode);
>
>         if (file_info->LastWriteTime) {
>                 attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime);
> @@ -5689,7 +5689,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
>                         return -EACCES;
>
>                 inode_lock(inode);
> -               inode->i_ctime = attrs.ia_ctime;
> +               inode_set_ctime_to_ts(inode, attrs.ia_ctime);
>                 attrs.ia_valid &= ~ATTR_CTIME;
>                 rc = notify_change(idmap, dentry, &attrs, NULL);
>                 inode_unlock(inode);
> --
> 2.41.0
>


-- 
Thanks,

Steve

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

* Re: [PATCH v2 32/92] configfs: convert to ctime accessor functions
  2023-07-06 10:54     ` Jan Kara
@ 2023-07-06 22:12       ` Joel Becker
  0 siblings, 0 replies; 208+ messages in thread
From: Joel Becker @ 2023-07-06 22:12 UTC (permalink / raw)
  To: Jan Kara
  Cc: Jeff Layton, Christian Brauner, Christoph Hellwig, Al Viro,
	linux-fsdevel, linux-kernel

On Thu, Jul 06, 2023 at 12:54:46PM +0200, Jan Kara wrote:
> On Wed 05-07-23 15:00:57, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Looks good. Feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>

Agreed.

Acked-by: Joel Becker <jlbec@evilplan.org>

> 
> 								Honza
> 
> > ---
> >  fs/configfs/inode.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
> > index 1c15edbe70ff..fbdcb3582926 100644
> > --- a/fs/configfs/inode.c
> > +++ b/fs/configfs/inode.c
> > @@ -88,8 +88,7 @@ int configfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> >  static inline void set_default_inode_attr(struct inode * inode, umode_t mode)
> >  {
> >  	inode->i_mode = mode;
> > -	inode->i_atime = inode->i_mtime =
> > -		inode->i_ctime = current_time(inode);
> > +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
> >  }
> >  
> >  static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
> > @@ -99,7 +98,7 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
> >  	inode->i_gid = iattr->ia_gid;
> >  	inode->i_atime = iattr->ia_atime;
> >  	inode->i_mtime = iattr->ia_mtime;
> > -	inode->i_ctime = iattr->ia_ctime;
> > +	inode_set_ctime_to_ts(inode, iattr->ia_ctime);
> >  }
> >  
> >  struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent *sd,
> > @@ -172,7 +171,7 @@ struct inode *configfs_create(struct dentry *dentry, umode_t mode)
> >  		return ERR_PTR(-ENOMEM);
> >  
> >  	p_inode = d_inode(dentry->d_parent);
> > -	p_inode->i_mtime = p_inode->i_ctime = current_time(p_inode);
> > +	p_inode->i_mtime = inode_set_ctime_current(p_inode);
> >  	configfs_set_inode_lock_class(sd, inode);
> >  	return inode;
> >  }
> > -- 
> > 2.41.0
> > 
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR

-- 

Life's Little Instruction Book #237

	"Seek out the good in people."

			http://www.jlbec.org/
			jlbec@evilplan.org

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

* Re: [PATCH v2 62/92] ocfs2: convert to ctime accessor functions
  2023-07-05 19:01   ` [PATCH v2 62/92] ocfs2: " Jeff Layton
  2023-07-06 13:51     ` Jan Kara
@ 2023-07-07  3:15     ` Joseph Qi
  2023-07-07 10:07       ` Jeff Layton
  1 sibling, 1 reply; 208+ messages in thread
From: Joseph Qi @ 2023-07-07  3:15 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Mark Fasheh, Joel Becker
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ocfs2-devel



On 7/6/23 3:01 AM, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ocfs2/acl.c          |  6 +++---
>  fs/ocfs2/alloc.c        |  6 +++---
>  fs/ocfs2/aops.c         |  2 +-
>  fs/ocfs2/dir.c          |  8 ++++----
>  fs/ocfs2/dlmfs/dlmfs.c  |  4 ++--
>  fs/ocfs2/dlmglue.c      |  7 +++++--
>  fs/ocfs2/file.c         | 16 +++++++++-------
>  fs/ocfs2/inode.c        | 12 ++++++------
>  fs/ocfs2/move_extents.c |  6 +++---
>  fs/ocfs2/namei.c        | 21 +++++++++++----------
>  fs/ocfs2/refcounttree.c | 14 +++++++-------
>  fs/ocfs2/xattr.c        |  6 +++---
>  12 files changed, 57 insertions(+), 51 deletions(-)
> 
> diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
> index 9fd03eaf15f8..e75137a8e7cb 100644
> --- a/fs/ocfs2/acl.c
> +++ b/fs/ocfs2/acl.c
> @@ -191,10 +191,10 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
>  	}
>  
>  	inode->i_mode = new_mode;
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	di->i_mode = cpu_to_le16(inode->i_mode);
> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>  
>  	ocfs2_journal_dirty(handle, di_bh);
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 51c93929a146..aef58f1395c8 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -7436,10 +7436,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
>  	}
>  
>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
> -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  
>  	ocfs2_update_inode_fsync_trans(handle, inode, 1);
>  	ocfs2_journal_dirty(handle, di_bh);
> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
> index 8dfc284e85f0..0fdba30740ab 100644
> --- a/fs/ocfs2/aops.c
> +++ b/fs/ocfs2/aops.c
> @@ -2048,7 +2048,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
>  		}
>  		inode->i_blocks = ocfs2_inode_sector_count(inode);
>  		di->i_size = cpu_to_le64((u64)i_size_read(inode));
> -		inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_mtime = inode_set_ctime_current(inode);
>  		di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
>  		di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  		if (handle)
> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> index 694471fc46b8..8b123d543e6e 100644
> --- a/fs/ocfs2/dir.c
> +++ b/fs/ocfs2/dir.c
> @@ -1658,7 +1658,7 @@ int __ocfs2_add_entry(handle_t *handle,
>  				offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
>  
>  		if (ocfs2_dirent_would_fit(de, rec_len)) {
> -			dir->i_mtime = dir->i_ctime = current_time(dir);
> +			dir->i_mtime = inode_set_ctime_current(dir);
>  			retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
>  			if (retval < 0) {
>  				mlog_errno(retval);
> @@ -2962,11 +2962,11 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
>  	ocfs2_dinode_new_extent_list(dir, di);
>  
>  	i_size_write(dir, sb->s_blocksize);
> -	dir->i_mtime = dir->i_ctime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  
>  	di->i_size = cpu_to_le64(sb->s_blocksize);
> -	di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec);
> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec);
> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(dir).tv_sec);
> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(dir).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, dir, 1);
>  
>  	/*
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index ba26c5567cff..81265123ce6c 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -337,7 +337,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
>  	if (inode) {
>  		inode->i_ino = get_next_ino();
>  		inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  		inc_nlink(inode);
>  
>  		inode->i_fop = &simple_dir_operations;
> @@ -360,7 +360,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
>  
>  	inode->i_ino = get_next_ino();
>  	inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	ip = DLMFS_I(inode);
>  	ip->ip_conn = DLMFS_I(parent)->ip_conn;
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index c28bc983a7b1..c3e2961ee5db 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -2162,6 +2162,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
>  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
>  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
>  	struct ocfs2_meta_lvb *lvb;
> +	struct timespec64 ctime = inode_get_ctime(inode);
>  
>  	lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
>  
> @@ -2185,7 +2186,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
>  	lvb->lvb_iatime_packed  =
>  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime));
>  	lvb->lvb_ictime_packed =
> -		cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime));
> +		cpu_to_be64(ocfs2_pack_timespec(&ctime));
>  	lvb->lvb_imtime_packed =
>  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
>  	lvb->lvb_iattr    = cpu_to_be32(oi->ip_attr);
> @@ -2208,6 +2209,7 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
>  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
>  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
>  	struct ocfs2_meta_lvb *lvb;
> +	struct timespec64 ctime;
>  
>  	mlog_meta_lvb(0, lockres);
>  
> @@ -2238,8 +2240,9 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
>  			      be64_to_cpu(lvb->lvb_iatime_packed));
>  	ocfs2_unpack_timespec(&inode->i_mtime,
>  			      be64_to_cpu(lvb->lvb_imtime_packed));
> -	ocfs2_unpack_timespec(&inode->i_ctime,
> +	ocfs2_unpack_timespec(&ctime,
>  			      be64_to_cpu(lvb->lvb_ictime_packed));
> +	inode_set_ctime_to_ts(inode, ctime);

A quick glance, it seems not an equivalent replace.

Thanks,
Joseph

>  	spin_unlock(&oi->ip_lock);
>  	return 0;
>  }
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 9e417cd4fd16..e8c78d16e815 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -232,8 +232,10 @@ int ocfs2_should_update_atime(struct inode *inode,
>  		return 0;
>  
>  	if (vfsmnt->mnt_flags & MNT_RELATIME) {
> +		struct timespec64 ctime = inode_get_ctime(inode);
> +
>  		if ((timespec64_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
> -		    (timespec64_compare(&inode->i_atime, &inode->i_ctime) <= 0))
> +		    (timespec64_compare(&inode->i_atime, &ctime) <= 0))
>  			return 1;
>  
>  		return 0;
> @@ -294,7 +296,7 @@ int ocfs2_set_inode_size(handle_t *handle,
>  
>  	i_size_write(inode, new_i_size);
>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	status = ocfs2_mark_inode_dirty(handle, inode, fe_bh);
>  	if (status < 0) {
> @@ -415,12 +417,12 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
>  	}
>  
>  	i_size_write(inode, new_i_size);
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  
>  	di = (struct ocfs2_dinode *) fe_bh->b_data;
>  	di->i_size = cpu_to_le64(new_i_size);
> -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>  
>  	ocfs2_journal_dirty(handle, fe_bh);
> @@ -819,7 +821,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
>  	i_size_write(inode, abs_to);
>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
>  	di->i_size = cpu_to_le64((u64)i_size_read(inode));
> -	inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
>  	di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  	di->i_mtime_nsec = di->i_ctime_nsec;
> @@ -2038,7 +2040,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
>  		goto out_inode_unlock;
>  	}
>  
> -	inode->i_ctime = inode->i_mtime = current_time(inode);
> +	inode->i_mtime = inode_set_ctime_current(inode);
>  	ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
>  	if (ret < 0)
>  		mlog_errno(ret);
> diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
> index bb116c39b581..e8771600b930 100644
> --- a/fs/ocfs2/inode.c
> +++ b/fs/ocfs2/inode.c
> @@ -306,8 +306,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
>  	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
>  	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
> -	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
> +	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
> +		        le32_to_cpu(fe->i_ctime_nsec));
>  
>  	if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
>  		mlog(ML_ERROR,
> @@ -1314,8 +1314,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
>  	fe->i_mode = cpu_to_le16(inode->i_mode);
>  	fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
>  	fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> -	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
>  	fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>  
> @@ -1352,8 +1352,8 @@ void ocfs2_refresh_inode(struct inode *inode,
>  	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
>  	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
>  	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
> -	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
> -	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
> +	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
> +			le32_to_cpu(fe->i_ctime_nsec));
>  
>  	spin_unlock(&OCFS2_I(inode)->ip_lock);
>  }
> diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
> index b1e32ec4a9d4..05d67968a3a9 100644
> --- a/fs/ocfs2/move_extents.c
> +++ b/fs/ocfs2/move_extents.c
> @@ -950,9 +950,9 @@ static int ocfs2_move_extents(struct ocfs2_move_extents_context *context)
>  	}
>  
>  	di = (struct ocfs2_dinode *)di_bh->b_data;
> -	inode->i_ctime = current_time(inode);
> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	inode_set_ctime_current(inode);
> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>  
>  	ocfs2_journal_dirty(handle, di_bh);
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 17c52225b87d..e4a684d45308 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -793,10 +793,10 @@ static int ocfs2_link(struct dentry *old_dentry,
>  	}
>  
>  	inc_nlink(inode);
> -	inode->i_ctime = current_time(inode);
> +	inode_set_ctime_current(inode);
>  	ocfs2_set_links_count(fe, inode->i_nlink);
> -	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  	ocfs2_journal_dirty(handle, fe_bh);
>  
>  	err = ocfs2_add_entry(handle, dentry, inode,
> @@ -995,7 +995,7 @@ static int ocfs2_unlink(struct inode *dir,
>  	ocfs2_set_links_count(fe, inode->i_nlink);
>  	ocfs2_journal_dirty(handle, fe_bh);
>  
> -	dir->i_ctime = dir->i_mtime = current_time(dir);
> +	dir->i_mtime = inode_set_ctime_current(dir);
>  	if (S_ISDIR(inode->i_mode))
>  		drop_nlink(dir);
>  
> @@ -1537,7 +1537,7 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  					 new_dir_bh, &target_insert);
>  	}
>  
> -	old_inode->i_ctime = current_time(old_inode);
> +	inode_set_ctime_current(old_inode);
>  	mark_inode_dirty(old_inode);
>  
>  	status = ocfs2_journal_access_di(handle, INODE_CACHE(old_inode),
> @@ -1546,8 +1546,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  	if (status >= 0) {
>  		old_di = (struct ocfs2_dinode *) old_inode_bh->b_data;
>  
> -		old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
> -		old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
> +		old_di->i_ctime = cpu_to_le64(inode_get_ctime(old_inode).tv_sec);
> +		old_di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(old_inode).tv_nsec);
>  		ocfs2_journal_dirty(handle, old_inode_bh);
>  	} else
>  		mlog_errno(status);
> @@ -1586,9 +1586,9 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  
>  	if (new_inode) {
>  		drop_nlink(new_inode);
> -		new_inode->i_ctime = current_time(new_inode);
> +		inode_set_ctime_current(new_inode);
>  	}
> -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> +	old_dir->i_mtime = inode_set_ctime_current(old_dir);
>  
>  	if (update_dot_dot) {
>  		status = ocfs2_update_entry(old_inode, handle,
> @@ -1610,7 +1610,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
>  
>  	if (old_dir != new_dir) {
>  		/* Keep the same times on both directories.*/
> -		new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime;
> +		new_dir->i_mtime = inode_set_ctime_to_ts(new_dir,
> +							 inode_get_ctime(old_dir));
>  
>  		/*
>  		 * This will also pick up the i_nlink change from the
> diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> index 564ab48d03ef..25c8ec3c8c3a 100644
> --- a/fs/ocfs2/refcounttree.c
> +++ b/fs/ocfs2/refcounttree.c
> @@ -3750,9 +3750,9 @@ static int ocfs2_change_ctime(struct inode *inode,
>  		goto out_commit;
>  	}
>  
> -	inode->i_ctime = current_time(inode);
> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +	inode_set_ctime_current(inode);
> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  
>  	ocfs2_journal_dirty(handle, di_bh);
>  
> @@ -4073,10 +4073,10 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
>  		 * we want mtime to appear identical to the source and
>  		 * update ctime.
>  		 */
> -		t_inode->i_ctime = current_time(t_inode);
> +		inode_set_ctime_current(t_inode);
>  
> -		di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec);
> -		di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec);
> +		di->i_ctime = cpu_to_le64(inode_get_ctime(t_inode).tv_sec);
> +		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(t_inode).tv_nsec);
>  
>  		t_inode->i_mtime = s_inode->i_mtime;
>  		di->i_mtime = s_di->i_mtime;
> @@ -4456,7 +4456,7 @@ int ocfs2_reflink_update_dest(struct inode *dest,
>  	if (newlen > i_size_read(dest))
>  		i_size_write(dest, newlen);
>  	spin_unlock(&OCFS2_I(dest)->ip_lock);
> -	dest->i_ctime = dest->i_mtime = current_time(dest);
> +	dest->i_mtime = inode_set_ctime_current(dest);
>  
>  	ret = ocfs2_mark_inode_dirty(handle, dest, d_bh);
>  	if (ret) {
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 4ac77ff6e676..6510ad783c91 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -3421,9 +3421,9 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
>  			goto out;
>  		}
>  
> -		inode->i_ctime = current_time(inode);
> -		di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> -		di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> +		inode_set_ctime_current(inode);
> +		di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> +		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>  		ocfs2_journal_dirty(ctxt->handle, xis->inode_bh);
>  	}
>  out:

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

* Re: [PATCH v2 62/92] ocfs2: convert to ctime accessor functions
  2023-07-07  3:15     ` Joseph Qi
@ 2023-07-07 10:07       ` Jeff Layton
  2023-07-09 13:59         ` Joseph Qi
  0 siblings, 1 reply; 208+ messages in thread
From: Jeff Layton @ 2023-07-07 10:07 UTC (permalink / raw)
  To: Joseph Qi, Christian Brauner, Mark Fasheh, Joel Becker
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ocfs2-devel

On Fri, 2023-07-07 at 11:15 +0800, Joseph Qi wrote:
> 
> On 7/6/23 3:01 AM, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  fs/ocfs2/acl.c          |  6 +++---
> >  fs/ocfs2/alloc.c        |  6 +++---
> >  fs/ocfs2/aops.c         |  2 +-
> >  fs/ocfs2/dir.c          |  8 ++++----
> >  fs/ocfs2/dlmfs/dlmfs.c  |  4 ++--
> >  fs/ocfs2/dlmglue.c      |  7 +++++--
> >  fs/ocfs2/file.c         | 16 +++++++++-------
> >  fs/ocfs2/inode.c        | 12 ++++++------
> >  fs/ocfs2/move_extents.c |  6 +++---
> >  fs/ocfs2/namei.c        | 21 +++++++++++----------
> >  fs/ocfs2/refcounttree.c | 14 +++++++-------
> >  fs/ocfs2/xattr.c        |  6 +++---
> >  12 files changed, 57 insertions(+), 51 deletions(-)
> > 
> > diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
> > index 9fd03eaf15f8..e75137a8e7cb 100644
> > --- a/fs/ocfs2/acl.c
> > +++ b/fs/ocfs2/acl.c
> > @@ -191,10 +191,10 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
> >  	}
> >  
> >  	inode->i_mode = new_mode;
> > -	inode->i_ctime = current_time(inode);
> > +	inode_set_ctime_current(inode);
> >  	di->i_mode = cpu_to_le16(inode->i_mode);
> > -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
> >  
> >  	ocfs2_journal_dirty(handle, di_bh);
> > diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> > index 51c93929a146..aef58f1395c8 100644
> > --- a/fs/ocfs2/alloc.c
> > +++ b/fs/ocfs2/alloc.c
> > @@ -7436,10 +7436,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
> >  	}
> >  
> >  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> > -	inode->i_ctime = inode->i_mtime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >  
> > -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  
> >  	ocfs2_update_inode_fsync_trans(handle, inode, 1);
> >  	ocfs2_journal_dirty(handle, di_bh);
> > diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
> > index 8dfc284e85f0..0fdba30740ab 100644
> > --- a/fs/ocfs2/aops.c
> > +++ b/fs/ocfs2/aops.c
> > @@ -2048,7 +2048,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
> >  		}
> >  		inode->i_blocks = ocfs2_inode_sector_count(inode);
> >  		di->i_size = cpu_to_le64((u64)i_size_read(inode));
> > -		inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_mtime = inode_set_ctime_current(inode);
> >  		di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
> >  		di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
> >  		if (handle)
> > diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
> > index 694471fc46b8..8b123d543e6e 100644
> > --- a/fs/ocfs2/dir.c
> > +++ b/fs/ocfs2/dir.c
> > @@ -1658,7 +1658,7 @@ int __ocfs2_add_entry(handle_t *handle,
> >  				offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
> >  
> >  		if (ocfs2_dirent_would_fit(de, rec_len)) {
> > -			dir->i_mtime = dir->i_ctime = current_time(dir);
> > +			dir->i_mtime = inode_set_ctime_current(dir);
> >  			retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
> >  			if (retval < 0) {
> >  				mlog_errno(retval);
> > @@ -2962,11 +2962,11 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
> >  	ocfs2_dinode_new_extent_list(dir, di);
> >  
> >  	i_size_write(dir, sb->s_blocksize);
> > -	dir->i_mtime = dir->i_ctime = current_time(dir);
> > +	dir->i_mtime = inode_set_ctime_current(dir);
> >  
> >  	di->i_size = cpu_to_le64(sb->s_blocksize);
> > -	di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec);
> > -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec);
> > +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(dir).tv_sec);
> > +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(dir).tv_nsec);
> >  	ocfs2_update_inode_fsync_trans(handle, dir, 1);
> >  
> >  	/*
> > diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> > index ba26c5567cff..81265123ce6c 100644
> > --- a/fs/ocfs2/dlmfs/dlmfs.c
> > +++ b/fs/ocfs2/dlmfs/dlmfs.c
> > @@ -337,7 +337,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
> >  	if (inode) {
> >  		inode->i_ino = get_next_ino();
> >  		inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
> > -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> > +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
> >  		inc_nlink(inode);
> >  
> >  		inode->i_fop = &simple_dir_operations;
> > @@ -360,7 +360,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
> >  
> >  	inode->i_ino = get_next_ino();
> >  	inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
> > -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> > +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
> >  
> >  	ip = DLMFS_I(inode);
> >  	ip->ip_conn = DLMFS_I(parent)->ip_conn;
> > diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> > index c28bc983a7b1..c3e2961ee5db 100644
> > --- a/fs/ocfs2/dlmglue.c
> > +++ b/fs/ocfs2/dlmglue.c
> > @@ -2162,6 +2162,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
> >  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
> >  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
> >  	struct ocfs2_meta_lvb *lvb;
> > +	struct timespec64 ctime = inode_get_ctime(inode);
> >  
> >  	lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
> >  
> > @@ -2185,7 +2186,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
> >  	lvb->lvb_iatime_packed  =
> >  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime));
> >  	lvb->lvb_ictime_packed =
> > -		cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime));
> > +		cpu_to_be64(ocfs2_pack_timespec(&ctime));
> >  	lvb->lvb_imtime_packed =
> >  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
> >  	lvb->lvb_iattr    = cpu_to_be32(oi->ip_attr);
> > @@ -2208,6 +2209,7 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
> >  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
> >  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
> >  	struct ocfs2_meta_lvb *lvb;
> > +	struct timespec64 ctime;
> >  
> >  	mlog_meta_lvb(0, lockres);
> >  
> > @@ -2238,8 +2240,9 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
> >  			      be64_to_cpu(lvb->lvb_iatime_packed));
> >  	ocfs2_unpack_timespec(&inode->i_mtime,
> >  			      be64_to_cpu(lvb->lvb_imtime_packed));
> > -	ocfs2_unpack_timespec(&inode->i_ctime,
> > +	ocfs2_unpack_timespec(&ctime,
> >  			      be64_to_cpu(lvb->lvb_ictime_packed));
> > +	inode_set_ctime_to_ts(inode, ctime);
> 
> A quick glance, it seems not an equivalent replace.
> 


How so?

The old code unpacked the time directly into the inode->i_ctime. The new
one unpacks it into a local timespec64 variable and then sets the
inode->i_ctime to that value. The result should still be the same.


> >  	spin_unlock(&oi->ip_lock);
> >  	return 0;
> >  }
> > diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> > index 9e417cd4fd16..e8c78d16e815 100644
> > --- a/fs/ocfs2/file.c
> > +++ b/fs/ocfs2/file.c
> > @@ -232,8 +232,10 @@ int ocfs2_should_update_atime(struct inode *inode,
> >  		return 0;
> >  
> >  	if (vfsmnt->mnt_flags & MNT_RELATIME) {
> > +		struct timespec64 ctime = inode_get_ctime(inode);
> > +
> >  		if ((timespec64_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
> > -		    (timespec64_compare(&inode->i_atime, &inode->i_ctime) <= 0))
> > +		    (timespec64_compare(&inode->i_atime, &ctime) <= 0))
> >  			return 1;
> >  
> >  		return 0;
> > @@ -294,7 +296,7 @@ int ocfs2_set_inode_size(handle_t *handle,
> >  
> >  	i_size_write(inode, new_i_size);
> >  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> > -	inode->i_ctime = inode->i_mtime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >  
> >  	status = ocfs2_mark_inode_dirty(handle, inode, fe_bh);
> >  	if (status < 0) {
> > @@ -415,12 +417,12 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
> >  	}
> >  
> >  	i_size_write(inode, new_i_size);
> > -	inode->i_ctime = inode->i_mtime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >  
> >  	di = (struct ocfs2_dinode *) fe_bh->b_data;
> >  	di->i_size = cpu_to_le64(new_i_size);
> > -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
> >  
> >  	ocfs2_journal_dirty(handle, fe_bh);
> > @@ -819,7 +821,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
> >  	i_size_write(inode, abs_to);
> >  	inode->i_blocks = ocfs2_inode_sector_count(inode);
> >  	di->i_size = cpu_to_le64((u64)i_size_read(inode));
> > -	inode->i_mtime = inode->i_ctime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >  	di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
> >  	di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
> >  	di->i_mtime_nsec = di->i_ctime_nsec;
> > @@ -2038,7 +2040,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
> >  		goto out_inode_unlock;
> >  	}
> >  
> > -	inode->i_ctime = inode->i_mtime = current_time(inode);
> > +	inode->i_mtime = inode_set_ctime_current(inode);
> >  	ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
> >  	if (ret < 0)
> >  		mlog_errno(ret);
> > diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
> > index bb116c39b581..e8771600b930 100644
> > --- a/fs/ocfs2/inode.c
> > +++ b/fs/ocfs2/inode.c
> > @@ -306,8 +306,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
> >  	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
> >  	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
> >  	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
> > -	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
> > -	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
> > +	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
> > +		        le32_to_cpu(fe->i_ctime_nsec));
> >  
> >  	if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
> >  		mlog(ML_ERROR,
> > @@ -1314,8 +1314,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
> >  	fe->i_mode = cpu_to_le16(inode->i_mode);
> >  	fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
> >  	fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
> > -	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  	fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
> >  	fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
> >  
> > @@ -1352,8 +1352,8 @@ void ocfs2_refresh_inode(struct inode *inode,
> >  	inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
> >  	inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
> >  	inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
> > -	inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
> > -	inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
> > +	inode_set_ctime(inode, le64_to_cpu(fe->i_ctime),
> > +			le32_to_cpu(fe->i_ctime_nsec));
> >  
> >  	spin_unlock(&OCFS2_I(inode)->ip_lock);
> >  }
> > diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
> > index b1e32ec4a9d4..05d67968a3a9 100644
> > --- a/fs/ocfs2/move_extents.c
> > +++ b/fs/ocfs2/move_extents.c
> > @@ -950,9 +950,9 @@ static int ocfs2_move_extents(struct ocfs2_move_extents_context *context)
> >  	}
> >  
> >  	di = (struct ocfs2_dinode *)di_bh->b_data;
> > -	inode->i_ctime = current_time(inode);
> > -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	inode_set_ctime_current(inode);
> > +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
> >  
> >  	ocfs2_journal_dirty(handle, di_bh);
> > diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> > index 17c52225b87d..e4a684d45308 100644
> > --- a/fs/ocfs2/namei.c
> > +++ b/fs/ocfs2/namei.c
> > @@ -793,10 +793,10 @@ static int ocfs2_link(struct dentry *old_dentry,
> >  	}
> >  
> >  	inc_nlink(inode);
> > -	inode->i_ctime = current_time(inode);
> > +	inode_set_ctime_current(inode);
> >  	ocfs2_set_links_count(fe, inode->i_nlink);
> > -	fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	fe->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	fe->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  	ocfs2_journal_dirty(handle, fe_bh);
> >  
> >  	err = ocfs2_add_entry(handle, dentry, inode,
> > @@ -995,7 +995,7 @@ static int ocfs2_unlink(struct inode *dir,
> >  	ocfs2_set_links_count(fe, inode->i_nlink);
> >  	ocfs2_journal_dirty(handle, fe_bh);
> >  
> > -	dir->i_ctime = dir->i_mtime = current_time(dir);
> > +	dir->i_mtime = inode_set_ctime_current(dir);
> >  	if (S_ISDIR(inode->i_mode))
> >  		drop_nlink(dir);
> >  
> > @@ -1537,7 +1537,7 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
> >  					 new_dir_bh, &target_insert);
> >  	}
> >  
> > -	old_inode->i_ctime = current_time(old_inode);
> > +	inode_set_ctime_current(old_inode);
> >  	mark_inode_dirty(old_inode);
> >  
> >  	status = ocfs2_journal_access_di(handle, INODE_CACHE(old_inode),
> > @@ -1546,8 +1546,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
> >  	if (status >= 0) {
> >  		old_di = (struct ocfs2_dinode *) old_inode_bh->b_data;
> >  
> > -		old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
> > -		old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
> > +		old_di->i_ctime = cpu_to_le64(inode_get_ctime(old_inode).tv_sec);
> > +		old_di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(old_inode).tv_nsec);
> >  		ocfs2_journal_dirty(handle, old_inode_bh);
> >  	} else
> >  		mlog_errno(status);
> > @@ -1586,9 +1586,9 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
> >  
> >  	if (new_inode) {
> >  		drop_nlink(new_inode);
> > -		new_inode->i_ctime = current_time(new_inode);
> > +		inode_set_ctime_current(new_inode);
> >  	}
> > -	old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
> > +	old_dir->i_mtime = inode_set_ctime_current(old_dir);
> >  
> >  	if (update_dot_dot) {
> >  		status = ocfs2_update_entry(old_inode, handle,
> > @@ -1610,7 +1610,8 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
> >  
> >  	if (old_dir != new_dir) {
> >  		/* Keep the same times on both directories.*/
> > -		new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime;
> > +		new_dir->i_mtime = inode_set_ctime_to_ts(new_dir,
> > +							 inode_get_ctime(old_dir));
> >  
> >  		/*
> >  		 * This will also pick up the i_nlink change from the
> > diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
> > index 564ab48d03ef..25c8ec3c8c3a 100644
> > --- a/fs/ocfs2/refcounttree.c
> > +++ b/fs/ocfs2/refcounttree.c
> > @@ -3750,9 +3750,9 @@ static int ocfs2_change_ctime(struct inode *inode,
> >  		goto out_commit;
> >  	}
> >  
> > -	inode->i_ctime = current_time(inode);
> > -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +	inode_set_ctime_current(inode);
> > +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  
> >  	ocfs2_journal_dirty(handle, di_bh);
> >  
> > @@ -4073,10 +4073,10 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
> >  		 * we want mtime to appear identical to the source and
> >  		 * update ctime.
> >  		 */
> > -		t_inode->i_ctime = current_time(t_inode);
> > +		inode_set_ctime_current(t_inode);
> >  
> > -		di->i_ctime = cpu_to_le64(t_inode->i_ctime.tv_sec);
> > -		di->i_ctime_nsec = cpu_to_le32(t_inode->i_ctime.tv_nsec);
> > +		di->i_ctime = cpu_to_le64(inode_get_ctime(t_inode).tv_sec);
> > +		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(t_inode).tv_nsec);
> >  
> >  		t_inode->i_mtime = s_inode->i_mtime;
> >  		di->i_mtime = s_di->i_mtime;
> > @@ -4456,7 +4456,7 @@ int ocfs2_reflink_update_dest(struct inode *dest,
> >  	if (newlen > i_size_read(dest))
> >  		i_size_write(dest, newlen);
> >  	spin_unlock(&OCFS2_I(dest)->ip_lock);
> > -	dest->i_ctime = dest->i_mtime = current_time(dest);
> > +	dest->i_mtime = inode_set_ctime_current(dest);
> >  
> >  	ret = ocfs2_mark_inode_dirty(handle, dest, d_bh);
> >  	if (ret) {
> > diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> > index 4ac77ff6e676..6510ad783c91 100644
> > --- a/fs/ocfs2/xattr.c
> > +++ b/fs/ocfs2/xattr.c
> > @@ -3421,9 +3421,9 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
> >  			goto out;
> >  		}
> >  
> > -		inode->i_ctime = current_time(inode);
> > -		di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
> > -		di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
> > +		inode_set_ctime_current(inode);
> > +		di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
> > +		di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
> >  		ocfs2_journal_dirty(ctxt->handle, xis->inode_bh);
> >  	}
> >  out:

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH v2 62/92] ocfs2: convert to ctime accessor functions
  2023-07-07 10:07       ` Jeff Layton
@ 2023-07-09 13:59         ` Joseph Qi
  0 siblings, 0 replies; 208+ messages in thread
From: Joseph Qi @ 2023-07-09 13:59 UTC (permalink / raw)
  To: Jeff Layton, Christian Brauner, Mark Fasheh, Joel Becker
  Cc: Al Viro, Jan Kara, linux-fsdevel, linux-kernel, ocfs2-devel



On 7/7/23 6:07 PM, Jeff Layton wrote:
> On Fri, 2023-07-07 at 11:15 +0800, Joseph Qi wrote:
>>
>> On 7/6/23 3:01 AM, Jeff Layton wrote:
>>> In later patches, we're going to change how the inode's ctime field is
>>> used. Switch to using accessor functions instead of raw accesses of
>>> inode->i_ctime.
>>>
>>> Signed-off-by: Jeff Layton <jlayton@kernel.org>
>>> ---
>>>  fs/ocfs2/acl.c          |  6 +++---
>>>  fs/ocfs2/alloc.c        |  6 +++---
>>>  fs/ocfs2/aops.c         |  2 +-
>>>  fs/ocfs2/dir.c          |  8 ++++----
>>>  fs/ocfs2/dlmfs/dlmfs.c  |  4 ++--
>>>  fs/ocfs2/dlmglue.c      |  7 +++++--
>>>  fs/ocfs2/file.c         | 16 +++++++++-------
>>>  fs/ocfs2/inode.c        | 12 ++++++------
>>>  fs/ocfs2/move_extents.c |  6 +++---
>>>  fs/ocfs2/namei.c        | 21 +++++++++++----------
>>>  fs/ocfs2/refcounttree.c | 14 +++++++-------
>>>  fs/ocfs2/xattr.c        |  6 +++---
>>>  12 files changed, 57 insertions(+), 51 deletions(-)
>>>
>>> diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
>>> index 9fd03eaf15f8..e75137a8e7cb 100644
>>> --- a/fs/ocfs2/acl.c
>>> +++ b/fs/ocfs2/acl.c
>>> @@ -191,10 +191,10 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
>>>  	}
>>>  
>>>  	inode->i_mode = new_mode;
>>> -	inode->i_ctime = current_time(inode);
>>> +	inode_set_ctime_current(inode);
>>>  	di->i_mode = cpu_to_le16(inode->i_mode);
>>> -	di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
>>> -	di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
>>> +	di->i_ctime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
>>> +	di->i_ctime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>>>  	ocfs2_update_inode_fsync_trans(handle, inode, 0);
>>>  
>>>  	ocfs2_journal_dirty(handle, di_bh);
>>> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
>>> index 51c93929a146..aef58f1395c8 100644
>>> --- a/fs/ocfs2/alloc.c
>>> +++ b/fs/ocfs2/alloc.c
>>> @@ -7436,10 +7436,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
>>>  	}
>>>  
>>>  	inode->i_blocks = ocfs2_inode_sector_count(inode);
>>> -	inode->i_ctime = inode->i_mtime = current_time(inode);
>>> +	inode->i_mtime = inode_set_ctime_current(inode);
>>>  
>>> -	di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
>>> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
>>> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(inode).tv_sec);
>>> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(inode).tv_nsec);
>>>  
>>>  	ocfs2_update_inode_fsync_trans(handle, inode, 1);
>>>  	ocfs2_journal_dirty(handle, di_bh);
>>> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
>>> index 8dfc284e85f0..0fdba30740ab 100644
>>> --- a/fs/ocfs2/aops.c
>>> +++ b/fs/ocfs2/aops.c
>>> @@ -2048,7 +2048,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
>>>  		}
>>>  		inode->i_blocks = ocfs2_inode_sector_count(inode);
>>>  		di->i_size = cpu_to_le64((u64)i_size_read(inode));
>>> -		inode->i_mtime = inode->i_ctime = current_time(inode);
>>> +		inode->i_mtime = inode_set_ctime_current(inode);
>>>  		di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec);
>>>  		di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
>>>  		if (handle)
>>> diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
>>> index 694471fc46b8..8b123d543e6e 100644
>>> --- a/fs/ocfs2/dir.c
>>> +++ b/fs/ocfs2/dir.c
>>> @@ -1658,7 +1658,7 @@ int __ocfs2_add_entry(handle_t *handle,
>>>  				offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
>>>  
>>>  		if (ocfs2_dirent_would_fit(de, rec_len)) {
>>> -			dir->i_mtime = dir->i_ctime = current_time(dir);
>>> +			dir->i_mtime = inode_set_ctime_current(dir);
>>>  			retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
>>>  			if (retval < 0) {
>>>  				mlog_errno(retval);
>>> @@ -2962,11 +2962,11 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
>>>  	ocfs2_dinode_new_extent_list(dir, di);
>>>  
>>>  	i_size_write(dir, sb->s_blocksize);
>>> -	dir->i_mtime = dir->i_ctime = current_time(dir);
>>> +	dir->i_mtime = inode_set_ctime_current(dir);
>>>  
>>>  	di->i_size = cpu_to_le64(sb->s_blocksize);
>>> -	di->i_ctime = di->i_mtime = cpu_to_le64(dir->i_ctime.tv_sec);
>>> -	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(dir->i_ctime.tv_nsec);
>>> +	di->i_ctime = di->i_mtime = cpu_to_le64(inode_get_ctime(dir).tv_sec);
>>> +	di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode_get_ctime(dir).tv_nsec);
>>>  	ocfs2_update_inode_fsync_trans(handle, dir, 1);
>>>  
>>>  	/*
>>> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
>>> index ba26c5567cff..81265123ce6c 100644
>>> --- a/fs/ocfs2/dlmfs/dlmfs.c
>>> +++ b/fs/ocfs2/dlmfs/dlmfs.c
>>> @@ -337,7 +337,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
>>>  	if (inode) {
>>>  		inode->i_ino = get_next_ino();
>>>  		inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
>>> -		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
>>> +		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>>>  		inc_nlink(inode);
>>>  
>>>  		inode->i_fop = &simple_dir_operations;
>>> @@ -360,7 +360,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
>>>  
>>>  	inode->i_ino = get_next_ino();
>>>  	inode_init_owner(&nop_mnt_idmap, inode, parent, mode);
>>> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
>>> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>>>  
>>>  	ip = DLMFS_I(inode);
>>>  	ip->ip_conn = DLMFS_I(parent)->ip_conn;
>>> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
>>> index c28bc983a7b1..c3e2961ee5db 100644
>>> --- a/fs/ocfs2/dlmglue.c
>>> +++ b/fs/ocfs2/dlmglue.c
>>> @@ -2162,6 +2162,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
>>>  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
>>>  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
>>>  	struct ocfs2_meta_lvb *lvb;
>>> +	struct timespec64 ctime = inode_get_ctime(inode);
>>>  
>>>  	lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
>>>  
>>> @@ -2185,7 +2186,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
>>>  	lvb->lvb_iatime_packed  =
>>>  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime));
>>>  	lvb->lvb_ictime_packed =
>>> -		cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime));
>>> +		cpu_to_be64(ocfs2_pack_timespec(&ctime));
>>>  	lvb->lvb_imtime_packed =
>>>  		cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
>>>  	lvb->lvb_iattr    = cpu_to_be32(oi->ip_attr);
>>> @@ -2208,6 +2209,7 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
>>>  	struct ocfs2_inode_info *oi = OCFS2_I(inode);
>>>  	struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
>>>  	struct ocfs2_meta_lvb *lvb;
>>> +	struct timespec64 ctime;
>>>  
>>>  	mlog_meta_lvb(0, lockres);
>>>  
>>> @@ -2238,8 +2240,9 @@ static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
>>>  			      be64_to_cpu(lvb->lvb_iatime_packed));
>>>  	ocfs2_unpack_timespec(&inode->i_mtime,
>>>  			      be64_to_cpu(lvb->lvb_imtime_packed));
>>> -	ocfs2_unpack_timespec(&inode->i_ctime,
>>> +	ocfs2_unpack_timespec(&ctime,
>>>  			      be64_to_cpu(lvb->lvb_ictime_packed));
>>> +	inode_set_ctime_to_ts(inode, ctime);
>>
>> A quick glance, it seems not an equivalent replace.
>>
> 
> 
> How so?
> 
> The old code unpacked the time directly into the inode->i_ctime. The new
> one unpacks it into a local timespec64 variable and then sets the
> inode->i_ctime to that value. The result should still be the same.
> 
IC, it looks fine to me.

Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>


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

* Re: [PATCH v2 16/92] s390: convert to ctime accessor functions
  2023-07-05 19:00   ` [PATCH v2 16/92] s390: " Jeff Layton
@ 2023-07-12 12:56     ` Alexander Gordeev
  0 siblings, 0 replies; 208+ messages in thread
From: Alexander Gordeev @ 2023-07-12 12:56 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, Al Viro, Jan Kara,
	linux-fsdevel, linux-kernel, linux-s390

On Wed, Jul 05, 2023 at 03:00:41PM -0400, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  arch/s390/hypfs/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
> index ee919bfc8186..5feef8da406b 100644
> --- a/arch/s390/hypfs/inode.c
> +++ b/arch/s390/hypfs/inode.c
> @@ -53,7 +53,7 @@ static void hypfs_update_update(struct super_block *sb)
>  	struct inode *inode = d_inode(sb_info->update_file);
>  
>  	sb_info->last_update = ktime_get_seconds();
> -	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
> +	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
>  }
>  
>  /* directory tree removal functions */
> @@ -101,7 +101,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)
>  		ret->i_mode = mode;
>  		ret->i_uid = hypfs_info->uid;
>  		ret->i_gid = hypfs_info->gid;
> -		ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
> +		ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
>  		if (S_ISDIR(mode))
>  			set_nlink(ret, 2);
>  	}

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>

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

* Re: [f2fs-dev] [PATCH v2 43/92] f2fs: convert to ctime accessor functions
  2023-07-05 19:01     ` Jeff Layton
@ 2023-09-04 18:11       ` patchwork-bot+f2fs
  -1 siblings, 0 replies; 208+ messages in thread
From: patchwork-bot+f2fs @ 2023-09-04 18:11 UTC (permalink / raw)
  To: Jeff Layton
  Cc: brauner, jaegeuk, chao, linux-fsdevel, linux-f2fs-devel, jack,
	viro, linux-kernel

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Christian Brauner <brauner@kernel.org>:

On Wed,  5 Jul 2023 15:01:08 -0400 you wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/f2fs/dir.c      |  8 ++++----
>  fs/f2fs/f2fs.h     |  4 +++-
>  fs/f2fs/file.c     | 20 ++++++++++----------
>  fs/f2fs/inline.c   |  2 +-
>  fs/f2fs/inode.c    | 10 +++++-----
>  fs/f2fs/namei.c    | 12 ++++++------
>  fs/f2fs/recovery.c |  4 ++--
>  fs/f2fs/super.c    |  2 +-
>  fs/f2fs/xattr.c    |  2 +-
>  9 files changed, 33 insertions(+), 31 deletions(-)

Here is the summary with links:
  - [f2fs-dev,v2,43/92] f2fs: convert to ctime accessor functions
    https://git.kernel.org/jaegeuk/f2fs/c/c62ebd3501cc

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [f2fs-dev] [PATCH v2 43/92] f2fs: convert to ctime accessor functions
@ 2023-09-04 18:11       ` patchwork-bot+f2fs
  0 siblings, 0 replies; 208+ messages in thread
From: patchwork-bot+f2fs @ 2023-09-04 18:11 UTC (permalink / raw)
  To: Jeff Layton
  Cc: brauner, jack, linux-kernel, linux-f2fs-devel, viro,
	linux-fsdevel, jaegeuk

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Christian Brauner <brauner@kernel.org>:

On Wed,  5 Jul 2023 15:01:08 -0400 you wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/f2fs/dir.c      |  8 ++++----
>  fs/f2fs/f2fs.h     |  4 +++-
>  fs/f2fs/file.c     | 20 ++++++++++----------
>  fs/f2fs/inline.c   |  2 +-
>  fs/f2fs/inode.c    | 10 +++++-----
>  fs/f2fs/namei.c    | 12 ++++++------
>  fs/f2fs/recovery.c |  4 ++--
>  fs/f2fs/super.c    |  2 +-
>  fs/f2fs/xattr.c    |  2 +-
>  9 files changed, 33 insertions(+), 31 deletions(-)

Here is the summary with links:
  - [f2fs-dev,v2,43/92] f2fs: convert to ctime accessor functions
    https://git.kernel.org/jaegeuk/f2fs/c/c62ebd3501cc

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




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

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

end of thread, other threads:[~2023-09-04 18:11 UTC | newest]

Thread overview: 208+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230705185755.579053-1-jlayton@kernel.org>
2023-07-05 19:00 ` [PATCH v2 01/92] ibmvmc: update ctime in conjunction with mtime on write Jeff Layton
2023-07-05 19:00   ` [PATCH v2 02/92] bfs: update ctime in addition to mtime when adding entries Jeff Layton
2023-07-05 19:00   ` [PATCH v2 03/92] efivarfs: update ctime when mtime changes on a write Jeff Layton
2023-07-05 19:00   ` [PATCH v2 04/92] exfat: ensure that ctime is updated whenever the mtime is Jeff Layton
2023-07-05 19:00   ` [PATCH v2 05/92] apparmor: update ctime whenever the mtime changes on an inode Jeff Layton
2023-07-05 19:00   ` [PATCH v2 06/92] cifs: update the ctime on a partial page write Jeff Layton
     [not found]     ` <CAH2r5mv+Fc9PuNtb8qMTwpb8qrEO2Tta5+o=mxD-2AY0cU5Aeg@mail.gmail.com>
2023-07-06  7:11       ` Christian Brauner
2023-07-06 15:26     ` Steve French
2023-07-05 19:00   ` [PATCH v2 09/92] btrfs: convert to simple_rename_timestamp Jeff Layton
2023-07-05 19:00   ` [PATCH v2 10/92] ubifs: " Jeff Layton
2023-07-05 19:00     ` Jeff Layton
2023-07-06 10:30     ` Jan Kara
2023-07-06 10:30       ` Jan Kara
2023-07-06 12:08     ` Zhihao Cheng
2023-07-06 12:08       ` Zhihao Cheng
2023-07-05 19:00   ` [PATCH v2 11/92] shmem: " Jeff Layton
2023-07-06 10:33     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 12/92] exfat: " Jeff Layton
2023-07-06 10:39     ` Jan Kara
2023-07-06 11:40       ` Jeff Layton
2023-07-05 19:00   ` [PATCH v2 13/92] ntfs3: " Jeff Layton
2023-07-06 10:40     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 14/92] reiserfs: " Jeff Layton
2023-07-06 10:32     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 15/92] spufs: convert to ctime accessor functions Jeff Layton
2023-07-05 19:00     ` Jeff Layton
2023-07-06 11:34     ` Arnd Bergmann
2023-07-06 11:34       ` Arnd Bergmann
2023-07-05 19:00   ` [PATCH v2 16/92] s390: " Jeff Layton
2023-07-12 12:56     ` Alexander Gordeev
2023-07-05 19:00   ` [PATCH v2 17/92] binderfs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 18/92] infiniband: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 19/92] ibm: " Jeff Layton
2023-07-06 10:41     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 20/92] usb: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 21/92] 9p: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 22/92] adfs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 23/92] affs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 24/92] afs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 25/92] fs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 26/92] autofs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 27/92] befs: " Jeff Layton
2023-07-05 19:00   ` [PATCH v2 28/92] bfs: " Jeff Layton
2023-07-06 10:44     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 29/92] btrfs: " Jeff Layton
2023-07-06 10:51     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 30/92] ceph: " Jeff Layton
2023-07-06 10:53     ` Jan Kara
2023-07-06 11:47       ` Jeff Layton
2023-07-05 19:00   ` [PATCH v2 31/92] coda: " Jeff Layton
2023-07-06 10:54     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 32/92] configfs: " Jeff Layton
2023-07-06 10:54     ` Jan Kara
2023-07-06 22:12       ` Joel Becker
2023-07-05 19:00   ` [PATCH v2 33/92] cramfs: " Jeff Layton
2023-07-06 10:55     ` Jan Kara
2023-07-05 19:00   ` [PATCH v2 34/92] debugfs: " Jeff Layton
2023-07-06 10:55     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 35/92] devpts: " Jeff Layton
2023-07-06 10:56     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 36/92] ecryptfs: " Jeff Layton
2023-07-06 10:56     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 37/92] efivarfs: " Jeff Layton
2023-07-06 10:57     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 38/92] efs: " Jeff Layton
2023-07-06 10:57     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 39/92] erofs: " Jeff Layton
2023-07-05 19:01     ` Jeff Layton
2023-07-06 11:00     ` Jan Kara
2023-07-06 11:00       ` Jan Kara
2023-07-06 11:53       ` Jeff Layton
2023-07-06 11:53         ` Jeff Layton
2023-07-06 15:12       ` Gao Xiang
2023-07-06 15:12         ` Gao Xiang
2023-07-05 19:01   ` [PATCH v2 40/92] exfat: " Jeff Layton
2023-07-06 11:01     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 41/92] ext2: " Jeff Layton
2023-07-06 11:03     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 42/92] ext4: " Jeff Layton
2023-07-06 12:36     ` Jan Kara
2023-07-06 13:10       ` Jeff Layton
2023-07-05 19:01   ` [f2fs-dev] [PATCH v2 43/92] f2fs: " Jeff Layton
2023-07-05 19:01     ` Jeff Layton
2023-07-06 11:18     ` Jan Kara
2023-07-06 11:18       ` [f2fs-dev] " Jan Kara
2023-09-04 18:11     ` patchwork-bot+f2fs
2023-09-04 18:11       ` patchwork-bot+f2fs
2023-07-05 19:01   ` [PATCH v2 44/92] fat: " Jeff Layton
2023-07-06  1:54     ` OGAWA Hirofumi
2023-07-06 11:25       ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 45/92] freevxfs: " Jeff Layton
2023-07-06 11:19     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 46/92] fuse: " Jeff Layton
2023-07-06 11:20     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 47/92] gfs2: " Jeff Layton
2023-07-05 19:01     ` [Cluster-devel] " Jeff Layton
2023-07-06 12:54     ` Jan Kara
2023-07-06 12:54       ` [Cluster-devel] " Jan Kara
2023-07-05 19:01   ` [PATCH v2 48/92] hfs: " Jeff Layton
2023-07-06 12:50     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 49/92] hfsplus: " Jeff Layton
2023-07-06 12:49     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 50/92] hostfs: " Jeff Layton
2023-07-05 19:01     ` Jeff Layton
2023-07-06 12:48     ` Jan Kara
2023-07-06 12:48       ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 51/92] hpfs: " Jeff Layton
2023-07-06 12:47     ` Jan Kara
2023-07-06 13:11       ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 52/92] hugetlbfs: " Jeff Layton
2023-07-05 19:58     ` Mike Kravetz
2023-07-06 12:40     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 53/92] isofs: " Jeff Layton
2023-07-06 12:39     ` Jan Kara
2023-07-06 13:11       ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 54/92] jffs2: " Jeff Layton
2023-07-05 19:01     ` Jeff Layton
2023-07-06 13:25     ` Jan Kara
2023-07-06 13:25       ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 55/92] jfs: " Jeff Layton
2023-07-06 13:27     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 56/92] kernfs: " Jeff Layton
2023-07-06 13:32     ` Jan Kara
2023-07-06 13:50       ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 57/92] nfs: " Jeff Layton
2023-07-06 13:34     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 58/92] nfsd: " Jeff Layton
2023-07-06 13:34     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 59/92] nilfs2: " Jeff Layton
2023-07-05 19:01     ` Jeff Layton
2023-07-06 13:35     ` Jan Kara
2023-07-06 13:35       ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 60/92] ntfs: " Jeff Layton
2023-07-06 13:37     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 61/92] ntfs3: " Jeff Layton
2023-07-06 13:47     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 62/92] ocfs2: " Jeff Layton
2023-07-06 13:51     ` Jan Kara
2023-07-07  3:15     ` Joseph Qi
2023-07-07 10:07       ` Jeff Layton
2023-07-09 13:59         ` Joseph Qi
2023-07-05 19:01   ` [PATCH v2 63/92] omfs: " Jeff Layton
2023-07-06 13:52     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 64/92] openpromfs: " Jeff Layton
2023-07-06 13:52     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 65/92] orangefs: " Jeff Layton
2023-07-06 13:55     ` Jan Kara
2023-07-06 13:56     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 66/92] overlayfs: " Jeff Layton
2023-07-06 13:58     ` Jan Kara
2023-07-06 14:01       ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 67/92] procfs: " Jeff Layton
2023-07-06 13:59     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 68/92] pstore: " Jeff Layton
2023-07-06 14:00     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 69/92] qnx4: " Jeff Layton
2023-07-06 14:00     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 70/92] qnx6: " Jeff Layton
2023-07-06 14:01     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 71/92] ramfs: " Jeff Layton
2023-07-06 14:01     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 72/92] reiserfs: " Jeff Layton
2023-07-06 14:03     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 73/92] romfs: " Jeff Layton
2023-07-06 14:04     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 74/92] smb: " Jeff Layton
2023-07-05 23:01     ` Jeff Layton
2023-07-06 15:28     ` Steve French
2023-07-05 19:01   ` [PATCH v2 75/92] squashfs: " Jeff Layton
2023-07-06 14:04     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 76/92] sysv: " Jeff Layton
2023-07-06 14:05     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 77/92] tracefs: " Jeff Layton
2023-07-06 14:06     ` Jan Kara
2023-07-06 14:27     ` Steven Rostedt
2023-07-05 19:01   ` [PATCH v2 78/92] ubifs: " Jeff Layton
2023-07-05 19:01     ` Jeff Layton
2023-07-06 12:07     ` Zhihao Cheng
2023-07-06 12:07       ` Zhihao Cheng
2023-07-06 12:10       ` Jeff Layton
2023-07-06 12:10         ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 79/92] udf: " Jeff Layton
2023-07-06 12:57     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 80/92] ufs: " Jeff Layton
2023-07-06 14:49     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 81/92] vboxsf: " Jeff Layton
2023-07-06 14:50     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 82/92] xfs: " Jeff Layton
2023-07-06 14:52     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 83/92] zonefs: " Jeff Layton
2023-07-06 14:52     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 84/92] linux: " Jeff Layton
2023-07-06 14:53     ` Jan Kara
2023-07-06 15:05       ` Jeff Layton
2023-07-05 19:01   ` [PATCH v2 85/92] mqueue: " Jeff Layton
2023-07-06 14:54     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 86/92] bpf: " Jeff Layton
2023-07-06 14:55     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 87/92] shmem: " Jeff Layton
2023-07-06 14:56     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 88/92] sunrpc: " Jeff Layton
2023-07-06 14:56     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 89/92] apparmor: " Jeff Layton
2023-07-06 14:57     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 90/92] security: " Jeff Layton
2023-07-06 14:57     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 91/92] selinux: " Jeff Layton
2023-07-06 14:57     ` Jan Kara

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.