Skip to content

Commit e54c86f

Browse files
jtlaytonbrauner
authored andcommitted
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: Jeff Layton <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Zhihao Cheng <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 130f1ec commit e54c86f

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

fs/ubifs/dir.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
14141414
* Like most other Unix systems, set the @i_ctime for inodes on a
14151415
* rename.
14161416
*/
1417-
time = current_time(old_dir);
1418-
old_inode->i_ctime = time;
1417+
simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
14191418

14201419
/* We must adjust parent link count when renaming directories */
14211420
if (is_dir) {
@@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
14441443

14451444
old_dir->i_size -= old_sz;
14461445
ubifs_inode(old_dir)->ui_size = old_dir->i_size;
1447-
old_dir->i_mtime = old_dir->i_ctime = time;
1448-
new_dir->i_mtime = new_dir->i_ctime = time;
14491446

14501447
/*
14511448
* And finally, if we unlinked a direntry which happened to have the
14521449
* same name as the moved direntry, we have to decrement @i_nlink of
1453-
* the unlinked inode and change its ctime.
1450+
* the unlinked inode.
14541451
*/
14551452
if (unlink) {
14561453
/*
@@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
14621459
clear_nlink(new_inode);
14631460
else
14641461
drop_nlink(new_inode);
1465-
new_inode->i_ctime = time;
14661462
} else {
14671463
new_dir->i_size += new_sz;
14681464
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,
15571553
int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
15581554
struct inode *fst_inode = d_inode(old_dentry);
15591555
struct inode *snd_inode = d_inode(new_dentry);
1560-
struct timespec64 time;
15611556
int err;
15621557
struct fscrypt_name fst_nm, snd_nm;
15631558

@@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
15881583

15891584
lock_4_inodes(old_dir, new_dir, NULL, NULL);
15901585

1591-
time = current_time(old_dir);
1592-
fst_inode->i_ctime = time;
1593-
snd_inode->i_ctime = time;
1594-
old_dir->i_mtime = old_dir->i_ctime = time;
1595-
new_dir->i_mtime = new_dir->i_ctime = time;
1586+
simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
15961587

15971588
if (old_dir != new_dir) {
15981589
if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {

0 commit comments

Comments
 (0)