Skip to contentSkip to conversation

fs: new accessors for inode->i_ctime

PATCH Superseded Jeff Layton 29 participants 151 messages Jun 21, 2023 – Jul 12, 2023 2 messages not in the archive Page 2 of 2

Subsystems (74)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
author maintainer
#136 lore raw

PATCH 72/79 mqueue: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 ipc/mqueue.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
ipc/mqueue.c +9 -11
index 71881bddad25..dd8564be3894 100644
@@ -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_atime = inode->i_mtime = inode_ctime_set_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);
+	inode_ctime_set(dir, dir->i_mtime = dir->i_atime = current_time(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);
+	inode_ctime_set(dir, dir->i_mtime = dir->i_atime = current_time(dir));
 	dir->i_size -= DIRENT_SIZE;
 	drop_nlink(inode);
 	dput(dentry);
@@ -656,7 +656,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));
+	file_inode(filp)->i_atime = inode_ctime_set_current(file_inode(filp));
 	return ret;
 }
 
@@ -1162,8 +1162,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_ctime_set_current(inode);
 	}
 out_unlock:
 	spin_unlock(&info->lock);
@@ -1257,8 +1256,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_ctime_set_current(inode);
 
 		/* There is now free space in queue. */
 		pipelined_receive(&wake_q, info);
@@ -1396,7 +1394,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_ctime_set_current(inode);
 		}
 	} else if (info->notify_owner != NULL) {
 		ret = -EBUSY;
@@ -1422,7 +1420,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_ctime_set_current(inode);
 	}
 	spin_unlock(&info->lock);
 out_fput:
@@ -1485,7 +1483,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_ctime_set_current(inode);
 	}
 
 	spin_unlock(&info->lock);
Signature · 1 line
2.41.0
author maintainer
#137 lore raw

PATCH 73/79 bpf: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 kernel/bpf/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/inode.c +2 -2
index 4174f76133df..d4489bb761df 100644
@@ -120,7 +120,7 @@ static struct inode *bpf_get_inode(struct super_block *sb,
 	inode->i_ino = get_next_ino();
 	inode->i_atime = current_time(inode);
 	inode->i_mtime = inode->i_atime;
-	inode->i_ctime = inode->i_atime;
+	inode_ctime_set(inode, inode->i_atime);
 
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 
@@ -149,7 +149,7 @@ static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
 	dget(dentry);
 
 	dir->i_mtime = current_time(dir);
-	dir->i_ctime = dir->i_mtime;
+	inode_ctime_set(dir, dir->i_mtime);
 }
 
 static int bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
Signature · 1 line
2.41.0
author maintainer
#138 lore raw

PATCH 74/79 shmem: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 mm/shmem.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
mm/shmem.c +15 -13
index 4752084720b2..4979cb3e37e5 100644
@@ -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_ctime_set_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_ctime_set_current(inode);
 		if (update_mtime)
-			inode->i_mtime = inode->i_ctime;
+			inode->i_mtime = inode_ctime_peek(inode);
 		inode_inc_iversion(inode);
 	}
 	return error;
@@ -2389,7 +2389,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_ctime_set_current(inode);
 		inode->i_generation = get_random_u32();
 		info = SHMEM_I(inode);
 		memset(info, 0, (char *)inode - (char *)info);
@@ -3101,7 +3101,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
 
 		error = 0;
 		dir->i_size += BOGO_DIRENT_SIZE;
-		dir->i_ctime = dir->i_mtime = current_time(dir);
+		dir->i_mtime = inode_ctime_set_current(dir);
 		inode_inc_iversion(dir);
 		d_instantiate(dentry, inode);
 		dget(dentry); /* Extra count - pin the dentry in core */
@@ -3177,7 +3177,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_ctime_set_current(inode);
+	inode_ctime_set(dir, dir->i_mtime);
 	inode_inc_iversion(dir);
 	inc_nlink(inode);
 	ihold(inode);	/* New dentry reference */
@@ -3195,7 +3196,8 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)
 		shmem_free_inode(inode->i_sb);
 
 	dir->i_size -= BOGO_DIRENT_SIZE;
-	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
+	dir->i_mtime = inode_ctime_set_current(inode);
+	inode_ctime_set(dir, dir->i_mtime);
 	inode_inc_iversion(dir);
 	drop_nlink(inode);
 	dput(dentry);	/* Undo the count from "create" - this does all the work */
@@ -3283,9 +3285,9 @@ 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);
+	old_dir->i_mtime = inode_ctime_set_current(old_dir);
+	new_dir->i_mtime = inode_ctime_set_current(new_dir);
+	inode_ctime_set_current(inode);
 	inode_inc_iversion(old_dir);
 	inode_inc_iversion(new_dir);
 	return 0;
@@ -3339,7 +3341,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_ctime_set_current(dir);
 	inode_inc_iversion(dir);
 	d_instantiate(dentry, inode);
 	dget(dentry);
@@ -3411,7 +3413,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_ctime_set_current(inode);
 	inode_inc_iversion(inode);
 	return 0;
 }
@@ -3481,7 +3483,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_ctime_set_current(inode);
 		inode_inc_iversion(inode);
 	}
 	return err;
Signature · 1 line
2.41.0
author maintainer
#139 lore raw

PATCH 75/79 rpc_pipefs: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 net/sunrpc/rpc_pipe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/rpc_pipe.c +1 -1
index 0b6034fab9ab..aa382e7ae982 100644
@@ -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_ctime_set_current(inode);
 	switch (mode & S_IFMT) {
 	case S_IFDIR:
 		inode->i_fop = &simple_dir_operations;
Signature · 1 line
2.41.0
author maintainer
#140 lore raw

PATCH 76/79 apparmor: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 security/apparmor/apparmorfs.c    | 6 +++---
 security/apparmor/policy_unpack.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
security/apparmor/apparmorfs.c +3 -3
index 3d0d370d6ffd..8c72a94dd9e3 100644
@@ -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_ctime_set_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_ctime_set_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_ctime_set_current(inode);
 	init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO,
 			   MKDEV(MEM_MAJOR, 3));
 	d_instantiate(dentry, inode);
security/apparmor/policy_unpack.c +2 -2
index 4c188a44d65c..334d69b118a9 100644
@@ -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_ctime_set_current(inode);
 
 		inode = d_inode(data->dents[AAFS_LOADDATA_REVISION]);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_ctime_set_current(inode);
 	}
 }
 
Signature · 1 line
2.41.0
maintainer Acked-by on v1 76/79
#141 lore raw

Re: [PATCH 76/79] apparmor: switch to new ctime accessors

Quoted 5 lines · Jeff Layton

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.

lgtm

Quoted 53 lines
---
  security/apparmor/apparmorfs.c    | 6 +++---
  security/apparmor/policy_unpack.c | 4 ++--
  2 files changed, 5 insertions(+), 5 deletions(-)
security/apparmor/apparmorfs.c +3 -3
index 3d0d370d6ffd..8c72a94dd9e3 100644
@@ -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_ctime_set_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_ctime_set_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_ctime_set_current(inode);
  	init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO,
  			   MKDEV(MEM_MAJOR, 3));
  	d_instantiate(dentry, inode);
security/apparmor/policy_unpack.c +2 -2
index 4c188a44d65c..334d69b118a9 100644
@@ -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_ctime_set_current(inode);
 
  		inode = d_inode(data->dents[AAFS_LOADDATA_REVISION]);
-		inode->i_mtime = inode->i_ctime = current_time(inode);
+		inode->i_mtime = inode_ctime_set_current(inode);
  	}
  }
 
author maintainer
#142 lore raw

PATCH 77/79 security: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 security/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/inode.c +1 -1
index 6c326939750d..086280390793 100644
@@ -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_ctime_set_current(inode);
 	inode->i_private = data;
 	if (S_ISDIR(mode)) {
 		inode->i_op = &simple_dir_inode_operations;
Signature · 1 line
2.41.0
maintainer Acked-by on v1 77/79
#143 lore raw

Re: [PATCH 77/79] security: switch to new ctime accessors

Quoted 15 lines · Jeff Layton

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.

---
 security/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/inode.c +0 -0
index 6c326939750d..086280390793 100644

security/inode.c static struct dentry *securityfs_create_dentry(const char *name, umode_t mode, · line 148

Quoted 5 lines
security/inode.c +1 -1
@@ -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_ctime_set_current(inode);

In the process of looking at inode_ctime_set_current() I ran into the same bug others noticed regarding inode_set_ctime()/inode_ctime_set(); assuming that gets fixed this looks fine to me.

Quoted 5 lines
security/inode.c +0 -1
        inode->i_private = data;
        if (S_ISDIR(mode)) {
                inode->i_op = &simple_dir_inode_operations;
--

2.41.0

Signature · 1 line
paul-moore.com
author maintainer
#144 lore raw

PATCH 78/79 selinux: switch to new ctime accessors

In reply to Jeff Layton

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.

---
 security/selinux/selinuxfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/selinuxfs.c +1 -1
index bad1f6b685fd..d3908baddb30 100644
@@ -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_ctime_set_current(ret);
 	}
 	return ret;
 }
Signature · 1 line
2.41.0
maintainer Acked-by on v1 78/79
#145 lore raw

Re: [PATCH 78/79] selinux: switch to new ctime accessors

Quoted 15 lines · Jeff Layton

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.

---
 security/selinux/selinuxfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/selinuxfs.c +0 -0
index bad1f6b685fd..d3908baddb30 100644

security/selinux/selinuxfs.c static struct inode *sel_make_inode(struct super_block *sb, int mode) · line 1200

Quoted 5 lines
security/selinux/selinuxfs.c +1 -1
@@ -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_ctime_set_current(ret);

Same issue as in 77/79.

--
paul-moore.com

maintainer Reviewed-by on v1 2/79
#146 lore raw

Re: [PATCH 02/79] spufs: switch to new ctime accessors

In reply to Jeff Layton
Quoted 5 lines · Jeff Layton

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.

Looks good to me. Feel free to add:

Honza

Quoted 20 lines
---
 arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/cell/spufs/inode.c +1 -1
index ea807aa0c31a..55418395bd9a 100644
@@ -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_ctime_set_current(inode);
 out:
 	return inode;
 }
Signature · 1 line
2.41.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Acked-by on v1 2/79
#147 lore raw

Re: [PATCH 02/79] spufs: switch to new ctime accessors

In reply to Jeff Layton

Hi Jeff,

Quoted 3 lines

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.

s/utilized/used/ :D

All looks good on the spufs change:

(also, thanks for including the accessors patch on the wider list, made it much easier to review in context)

Cheers,

Jeremy

author maintainer
#148 lore raw

PATCH 79/79 fs: rename i_ctime field to __i_ctime

In reply to Jeff Layton

Now that everything in-tree is converted to use the accessor functions, rename the i_ctime field in the inode to make its accesses more self-documenting.

---
 include/linux/fs.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/fs.h +5 -5
index 9afb30606373..2ca46c532b49 100644
@@ -642,7 +642,7 @@ struct inode {
 	loff_t			i_size;
 	struct timespec64	i_atime;
 	struct timespec64	i_mtime;
-	struct timespec64	i_ctime;
+	struct timespec64	__i_ctime; /* use inode_ctime_* accessors! */
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	unsigned short          i_bytes;
 	u8			i_blkbits;
@@ -1485,7 +1485,7 @@ struct timespec64 inode_ctime_set_current(struct inode *inode);
  */
 static inline struct timespec64 inode_ctime_peek(const struct inode *inode)
 {
-	return inode->i_ctime;
+	return inode->__i_ctime;
 }
 
 /**
@@ -1497,7 +1497,7 @@ static inline struct timespec64 inode_ctime_peek(const struct inode *inode)
  */
 static inline struct timespec64 inode_ctime_set(struct inode *inode, struct timespec64 ts)
 {
-	inode->i_ctime = ts;
+	inode->__i_ctime = ts;
 	return ts;
 }
 
@@ -1510,7 +1510,7 @@ static inline struct timespec64 inode_ctime_set(struct inode *inode, struct time
  */
 static inline time64_t inode_ctime_set_sec(struct inode *inode, time64_t sec)
 {
-	inode->i_ctime.tv_sec = sec;
+	inode->__i_ctime.tv_sec = sec;
 	return sec;
 }
 
@@ -1523,7 +1523,7 @@ static inline time64_t inode_ctime_set_sec(struct inode *inode, time64_t sec)
  */
 static inline long inode_ctime_set_nsec(struct inode *inode, long nsec)
 {
-	inode->i_ctime.tv_nsec = nsec;
+	inode->__i_ctime.tv_nsec = nsec;
 	return nsec;
 }
 
Signature · 1 line
2.41.0
maintainer
#149 lore raw
In reply to Jeff Layton
Quoted 4 lines · On Wed, 21 Jun 2023 10:45:05 -0400 Jeff Layton <[email protected]> wrote:

Most of this conversion was done via coccinelle, with a few of the more non-standard accesses done by hand. There should be no behavioral changes with this set. That will come later, as we convert individual filesystems to use multigrain timestamps.

BTW, Linus has suggested to me that whenever a conccinelle script is used, it should be included in the change log.

-- Steve

author maintainer
#150 lore raw
Quoted 11 lines · Steven Rostedt
Quoted 4 lines · On Wed, 21 Jun 2023 10:45:05 -0400 Jeff Layton <[email protected]> wrote:

Most of this conversion was done via coccinelle, with a few of the more non-standard accesses done by hand. There should be no behavioral changes with this set. That will come later, as we convert individual filesystems to use multigrain timestamps.

BTW, Linus has suggested to me that whenever a conccinelle script is used, it should be included in the change log.

Ok, here's what I have. I note again that my usage of coccinelle is pretty primitive, so I ended up doing a fair bit of by-hand fixing after applying these.

Given the way that this change is broken up into 77 patches by subsystem, to which changelogs should I add it? I could add it to the "infrastructure" patch, but that's the one where I _didn't_ use it.

Maybe to patch #79 (the one that renames i_ctime)?

------------------------8<------------------------------ @@
expression inode;
@@

- inode->i_ctime = current_time(inode)
+ inode_set_current_ctime(inode)

@@
expression inode;
@@

- inode->i_ctime = inode->i_mtime = current_time(inode)
+ inode->i_mtime = inode_set_current_ctime(inode)

@@
struct inode *inode;
expression value;
@@

- inode->i_ctime = value;
+ inode_set_ctime(inode, value);

@@
struct inode *inode;
expression val;
@@
- inode->i_ctime.tv_sec = val
+ inode_set_ctime_sec(inode, val)

@@
struct inode *inode;
expression val;
@@
- inode->i_ctime.tv_nsec = val
+ inode_set_ctime_nsec(inode, val)

@@
struct inode *inode;
@@
- inode->i_ctime
+ inode_ctime_peek(inode)

#151 lore raw
Quoted 17 lines · Jeff Layton
Quoted 11 lines · Steven Rostedt
Quoted 4 lines · On Wed, 21 Jun 2023 10:45:05 -0400 Jeff Layton <[email protected]> wrote:

Most of this conversion was done via coccinelle, with a few of the more non-standard accesses done by hand. There should be no behavioral changes with this set. That will come later, as we convert individual filesystems to use multigrain timestamps.

BTW, Linus has suggested to me that whenever a conccinelle script is used, it should be included in the change log.

Ok, here's what I have. I note again that my usage of coccinelle is pretty primitive, so I ended up doing a fair bit of by-hand fixing after applying these.

Quoted 5 lines

Given the way that this change is broken up into 77 patches by subsystem, to which changelogs should I add it? I could add it to the "infrastructure" patch, but that's the one where I _didn't_ use it.Â

Maybe to patch #79 (the one that renames i_ctime)?

That works. I can also put this into a merge commit or pr message.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#152 lore raw
In reply to Steven Rostedt
Quoted 10 lines · Steven Rostedt
Quoted 4 lines · On Wed, 21 Jun 2023 10:45:05 -0400 Jeff Layton <[email protected]> wrote:

Most of this conversion was done via coccinelle, with a few of the more non-standard accesses done by hand. There should be no behavioral changes with this set. That will come later, as we convert individual filesystems to use multigrain timestamps.

BTW, Linus has suggested to me that whenever a conccinelle script is used, it should be included in the change log.

Sometimes people like the coccinelle included in the commit, sometimes people don't [0], it really ends up being up to a subjective maintainer preference. A compromise could be to use git notes as these are optional, however if we want to go down that path we should try to make a general consensus on it so we can send a consistent message.

[0] https://lore.kernel.org/all/[email protected]/

Luis