Commit e54c86fd authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner

ubifs: convert to simple_rename_timestamp

A rename potentially involves updating 4 different inode timestamps.
Convert to the new simple_rename_timestamp helper function.
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Message-Id: <20230705190309.579783-8-jlayton@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 130f1eca
...@@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -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 * Like most other Unix systems, set the @i_ctime for inodes on a
* rename. * rename.
*/ */
time = current_time(old_dir); simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
old_inode->i_ctime = time;
/* We must adjust parent link count when renaming directories */ /* We must adjust parent link count when renaming directories */
if (is_dir) { if (is_dir) {
...@@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
old_dir->i_size -= old_sz; old_dir->i_size -= old_sz;
ubifs_inode(old_dir)->ui_size = old_dir->i_size; 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 * 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 * 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) { if (unlink) {
/* /*
...@@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
clear_nlink(new_inode); clear_nlink(new_inode);
else else
drop_nlink(new_inode); drop_nlink(new_inode);
new_inode->i_ctime = time;
} else { } else {
new_dir->i_size += new_sz; new_dir->i_size += new_sz;
ubifs_inode(new_dir)->ui_size = new_dir->i_size; 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, ...@@ -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); int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
struct inode *fst_inode = d_inode(old_dentry); struct inode *fst_inode = d_inode(old_dentry);
struct inode *snd_inode = d_inode(new_dentry); struct inode *snd_inode = d_inode(new_dentry);
struct timespec64 time;
int err; int err;
struct fscrypt_name fst_nm, snd_nm; struct fscrypt_name fst_nm, snd_nm;
...@@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -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); lock_4_inodes(old_dir, new_dir, NULL, NULL);
time = current_time(old_dir); simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
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;
if (old_dir != new_dir) { if (old_dir != new_dir) {
if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) { if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment