public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Christian Brauner <brauner@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Richard Weinberger <richard@nod.at>
Cc: Al Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH 41/79] jffs2: switch to new ctime accessors
Date: Wed, 21 Jun 2023 10:45:54 -0400	[thread overview]
Message-ID: <20230621144735.55953-40-jlayton@kernel.org> (raw)
In-Reply-To: <20230621144735.55953-1-jlayton@kernel.org>

In later patches, we're going to change how the ctime.tv_nsec field is
utilized. 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      | 19 ++++++++++---------
 fs/jffs2/file.c     |  3 ++-
 fs/jffs2/fs.c       | 10 +++++-----
 fs/jffs2/os-linux.h |  2 +-
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 5075a0a6d594..2ade386a2c02 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -204,7 +204,7 @@ 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_ctime_set(dir_i, ITIME(je32_to_cpu(ri->ctime)));
 
 	jffs2_free_raw_inode(ri);
 
@@ -237,7 +237,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_ctime_set(dir_i, ITIME(now));
 	return ret;
 }
 /***********************************************************************/
@@ -271,7 +271,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_ctime_set(dir_i, ITIME(now));
 		ihold(d_inode(old_dentry));
 	}
 	return ret;
@@ -422,7 +422,7 @@ 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_ctime_set(dir_i, ITIME(je32_to_cpu(rd->mctime)));
 
 	jffs2_free_raw_dirent(rd);
 
@@ -566,7 +566,7 @@ 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_ctime_set(dir_i, ITIME(je32_to_cpu(rd->mctime)));
 	inc_nlink(dir_i);
 
 	jffs2_free_raw_dirent(rd);
@@ -607,7 +607,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_ctime_set(dir_i, ITIME(now));
 		clear_nlink(d_inode(dentry));
 		drop_nlink(dir_i);
 	}
@@ -743,7 +743,7 @@ 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_ctime_set(dir_i, ITIME(je32_to_cpu(rd->mctime)));
 
 	jffs2_free_raw_dirent(rd);
 
@@ -864,14 +864,15 @@ 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_ctime_set(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);
+	new_dir_i->i_mtime = inode_ctime_set(new_dir_i, ITIME(now));
+	old_dir_i->i_mtime = inode_ctime_set(old_dir_i, ITIME(now));
 
 	return 0;
 }
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 2345ca3f09ee..1935e4eb9aa8 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 = ITIME(je32_to_cpu(ri->ctime));
+			inode_ctime_set(inode, inode->i_mtime);
 		}
 	}
 
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 038516bee1ab..1d77c4616ca5 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_ctime_peek(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_ctime_set(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_ctime_set(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_ctime_peek(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_ctime_set_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..2c22fdd4762e 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_ctime_peek(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


  parent reply	other threads:[~2023-06-21 14:52 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230621144507.55591-1-jlayton@kernel.org>
2023-06-21 14:45 ` [PATCH 02/79] spufs: switch to new ctime accessors Jeff Layton
2023-06-21 14:45   ` [PATCH 03/79] s390: " Jeff Layton
2023-06-21 16:34     ` Jan Kara
2023-06-22 17:35     ` Alexander Gordeev
2023-06-22 17:51       ` Jeff Layton
2023-06-22 18:22         ` Alexander Gordeev
2023-06-22 18:46           ` Jeff Layton
2023-06-21 14:45   ` [PATCH 04/79] binderfs: " Jeff Layton
2023-06-21 15:29     ` Greg Kroah-Hartman
2023-06-21 16:35     ` Jan Kara
2023-06-21 14:45   ` [PATCH 05/79] qib_fs: " Jeff Layton
2023-06-21 16:35     ` Jan Kara
2023-06-21 19:37     ` Dennis Dalessandro
2023-06-21 14:45   ` [PATCH 06/79] ibm: " Jeff Layton
2023-06-21 15:29     ` Greg Kroah-Hartman
2023-06-21 16:35     ` Jan Kara
2023-06-21 14:45   ` [PATCH 07/79] usb: " Jeff Layton
2023-06-21 15:29     ` Greg Kroah-Hartman
2023-06-21 16:36     ` Jan Kara
2023-06-21 14:45   ` [PATCH 08/79] 9p: " Jeff Layton
2023-06-21 16:37     ` Jan Kara
2023-06-21 14:45   ` [PATCH 09/79] adfs: " Jeff Layton
2023-06-21 16:38     ` Jan Kara
2023-06-21 14:45   ` [PATCH 10/79] affs: " Jeff Layton
2023-06-21 16:39     ` Jan Kara
2023-06-22 11:37     ` David Sterba
2023-06-21 14:45   ` [PATCH 11/79] afs: " Jeff Layton
2023-06-21 16:43     ` Jan Kara
2023-06-21 14:45   ` [PATCH 12/79] fs: " Jeff Layton
2023-06-21 16:42     ` Jan Kara
2023-06-21 14:45   ` [PATCH 13/79] autofs: " Jeff Layton
2023-06-21 16:43     ` Jan Kara
2023-06-27  1:48     ` Ian Kent
2023-06-21 14:45   ` [PATCH 14/79] befs: " Jeff Layton
2023-06-21 16:44     ` Jan Kara
2023-06-21 14:45   ` [PATCH 15/79] bfs: " Jeff Layton
2023-06-21 16:48     ` Jan Kara
2023-06-21 16:57       ` Jeff Layton
2023-06-22 12:30         ` Jan Kara
2023-06-22 12:51           ` Jeff Layton
2023-06-22 14:57             ` Jan Kara
2023-06-23 12:33               ` Christian Brauner
2023-07-03 10:12                 ` Christian Brauner
2023-07-03 10:46                   ` Jeff Layton
2023-07-03 10:57                     ` Christian Brauner
2023-06-21 14:45   ` [PATCH 16/79] btrfs: " Jeff Layton
2023-06-22 11:42     ` David Sterba
2023-06-21 14:45   ` [PATCH 17/79] ceph: " Jeff Layton
2023-06-26  0:56     ` Xiubo Li
2023-06-21 14:45   ` [PATCH 18/79] coda: " Jeff Layton
2023-06-21 14:45   ` [PATCH 19/79] configfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 20/79] cramfs: " Jeff Layton
2023-06-21 15:29     ` Nicolas Pitre
2023-06-21 14:45   ` [PATCH 21/79] debugfs: " Jeff Layton
2023-06-21 15:29     ` Greg Kroah-Hartman
2023-06-21 14:45   ` [PATCH 22/79] devpts: " Jeff Layton
2023-06-21 14:45   ` [PATCH 23/79] ecryptfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 24/79] efivarfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 25/79] efs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 26/79] erofs: " Jeff Layton
2023-06-22  4:01     ` Gao Xiang
2023-06-21 14:45   ` [PATCH 27/79] exfat: " Jeff Layton
2023-06-21 14:45   ` [PATCH 28/79] ext2: " Jeff Layton
2023-06-21 14:45   ` [PATCH 29/79] ext4: " Jeff Layton
2023-06-21 14:45   ` [PATCH 30/79] f2fs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 31/79] fat: " Jeff Layton
2023-06-21 14:45   ` [PATCH 32/79] freevxfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 33/79] fuse: " Jeff Layton
2023-06-21 14:45   ` [PATCH 34/79] gfs2: " Jeff Layton
2023-06-21 14:45   ` [PATCH 35/79] hfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 36/79] hfsplus: " Jeff Layton
2023-06-21 14:45   ` [PATCH 37/79] hostfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 38/79] hpfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 39/79] hugetlbfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 40/79] isofs: " Jeff Layton
2023-06-21 14:45   ` Jeff Layton [this message]
2023-06-21 14:45   ` [PATCH 42/79] jfs: " Jeff Layton
2023-06-21 17:47     ` Dave Kleikamp
2023-06-21 14:45   ` [PATCH 43/79] kernfs: " Jeff Layton
2023-06-21 15:30     ` Greg Kroah-Hartman
2023-06-21 14:45   ` [PATCH 44/79] minix: " Jeff Layton
2023-06-21 14:45   ` [PATCH 45/79] nfs: " Jeff Layton
2023-06-21 14:45   ` [PATCH 46/79] nfsd: " Jeff Layton
2023-06-21 17:36     ` Chuck Lever
2023-06-21 14:46   ` [PATCH 47/79] nilfs2: " Jeff Layton
2023-06-26 15:26     ` Ryusuke Konishi
2023-06-21 14:46   ` [PATCH 48/79] ntfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 49/79] ntfs3: " Jeff Layton
2023-06-21 14:46   ` [PATCH 50/79] ocfs2: " Jeff Layton
2023-06-21 14:46   ` [PATCH 51/79] omfs: " Jeff Layton
2023-06-23 12:12     ` Bob Copeland
2023-06-21 14:46   ` [PATCH 52/79] openpromfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 53/79] orangefs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 54/79] overlayfs: " Jeff Layton
2023-06-22  6:44     ` Amir Goldstein
2023-06-21 14:46   ` [PATCH 55/79] proc: " Jeff Layton
2023-06-30 22:13     ` Luis Chamberlain
2023-06-21 14:46   ` [PATCH 56/79] pstore: " Jeff Layton
2023-06-21 17:50     ` Kees Cook
2023-06-21 14:46   ` [PATCH 57/79] qnx4: " Jeff Layton
2023-06-23 14:26     ` Anders Larsen
2023-06-21 14:46   ` [PATCH 58/79] qnx6: " Jeff Layton
2023-06-21 14:46   ` [PATCH 59/79] ramfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 60/79] reiserfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 61/79] romfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 62/79] smb: " Jeff Layton
2023-06-21 17:45     ` Tom Talpey
2023-06-23  5:03     ` Sergey Senozhatsky
2023-06-21 14:46   ` [PATCH 63/79] squashfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 64/79] sysv: " Jeff Layton
2023-06-21 14:46   ` [PATCH 65/79] tracefs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 66/79] ubifs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 67/79] udf: " Jeff Layton
2023-06-21 14:46   ` [PATCH 68/79] ufs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 69/79] vboxsf: " Jeff Layton
2023-06-21 14:46   ` [PATCH 70/79] xfs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 71/79] zonefs: " Jeff Layton
2023-06-22  0:48     ` Damien Le Moal
2023-06-21 14:46   ` [PATCH 72/79] mqueue: " Jeff Layton
2023-06-21 14:46   ` [PATCH 73/79] bpf: " Jeff Layton
2023-06-21 14:46   ` [PATCH 74/79] shmem: " Jeff Layton
2023-06-21 14:46   ` [PATCH 75/79] rpc_pipefs: " Jeff Layton
2023-06-21 14:46   ` [PATCH 76/79] apparmor: " Jeff Layton
2023-06-22  9:04     ` John Johansen
2023-06-21 14:46   ` [PATCH 77/79] security: " Jeff Layton
2023-06-23 14:15     ` Paul Moore
2023-06-21 14:46   ` [PATCH 78/79] selinux: " Jeff Layton
2023-06-23 14:17     ` Paul Moore
2023-06-21 16:34   ` [PATCH 02/79] spufs: " Jan Kara
2023-06-22  0:19   ` Jeremy Kerr
     [not found] ` <20230621152141.5961cf5f@gandalf.local.home>
     [not found]   ` <2a5a069572b46b59dd16fe8d54e549a9b5bbb6eb.camel@kernel.org>
2023-06-23 12:41     ` [PATCH 00/79] fs: new accessors for inode->i_ctime Christian Brauner
2023-06-30 22:11   ` Luis Chamberlain
     [not found] ` <20230621144507.55591-2-jlayton@kernel.org>
     [not found]   ` <99b3c749-23d9-6f09-fb75-6a84f3d1b066@kernel.org>
2023-06-22 10:14     ` [PATCH 01/79] fs: add ctime accessors infrastructure Jeff Layton
2023-06-30 22:12   ` Luis Chamberlain
2023-07-12 15:31   ` Randy Dunlap
2023-07-12 15:34     ` Christian Brauner

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20230621144735.55953-40-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=brauner@kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

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

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