ntfs3: convert to new timestamp accessors
authorJeff Layton <jlayton@kernel.org>
Wed, 4 Oct 2023 18:52:40 +0000 (14:52 -0400)
committerChristian Brauner <brauner@kernel.org>
Wed, 18 Oct 2023 12:08:24 +0000 (14:08 +0200)
Convert to using the new inode timestamp accessor functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20231004185347.80880-53-jlayton@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/ntfs3/file.c
fs/ntfs3/frecord.c
fs/ntfs3/inode.c
fs/ntfs3/namei.c

index 962f12ce6c0a62c183236e3658b666f23c02ab58..322fb960ba5db5c73f8d2d48ed7442a40c38c6a8 100644 (file)
@@ -342,7 +342,7 @@ static int ntfs_extend(struct inode *inode, loff_t pos, size_t count,
                err = 0;
        }
 
-       inode->i_mtime = inode_set_ctime_current(inode);
+       inode_set_mtime_to_ts(inode, 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_mtime = inode_set_ctime_current(inode);
+       inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
        if (!IS_DIRSYNC(inode)) {
                dirty = 1;
        } else {
@@ -642,7 +642,7 @@ out:
                filemap_invalidate_unlock(mapping);
 
        if (!err) {
-               inode->i_mtime = inode_set_ctime_current(inode);
+               inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
                mark_inode_dirty(inode);
        }
 
index 2b85cb10f0be405e89390815a8fd77b0f6031fce..9f66dcf5da8ff339a22c505ad1331678ea3204cd 100644 (file)
@@ -3265,7 +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);
+               struct timespec64 ts;
 
                /* Update times in standard attribute. */
                std = ni_std(ni);
@@ -3275,19 +3275,22 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
                }
 
                /* Update the access times if they have changed. */
-               dup.m_time = kernel2nt(&inode->i_mtime);
+               ts = inode_get_mtime(inode);
+               dup.m_time = kernel2nt(&ts);
                if (std->m_time != dup.m_time) {
                        std->m_time = dup.m_time;
                        modified = true;
                }
 
-               dup.c_time = kernel2nt(&ctime);
+               ts = inode_get_mtime(inode);
+               dup.c_time = kernel2nt(&ts);
                if (std->c_time != dup.c_time) {
                        std->c_time = dup.c_time;
                        modified = true;
                }
 
-               dup.a_time = kernel2nt(&inode->i_atime);
+               ts = inode_get_atime(inode);
+               dup.a_time = kernel2nt(&ts);
                if (std->a_time != dup.a_time) {
                        std->a_time = dup.a_time;
                        modified = true;
index eb2ed0701495f103e62093283b769777752bf85e..5e3d713749185f116e145adea4b196fbd7be72d2 100644 (file)
@@ -44,7 +44,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,
        u64 t64;
        struct MFT_REC *rec;
        struct runs_tree *run;
-       struct timespec64 ctime;
+       struct timespec64 ts;
 
        inode->i_op = NULL;
        /* Setup 'uid' and 'gid' */
@@ -169,10 +169,12 @@ next_attr:
 #ifdef STATX_BTIME
                nt2kernel(std5->cr_time, &ni->i_crtime);
 #endif
-               nt2kernel(std5->a_time, &inode->i_atime);
-               ctime = inode_get_ctime(inode);
-               nt2kernel(std5->c_time, &ctime);
-               nt2kernel(std5->m_time, &inode->i_mtime);
+               nt2kernel(std5->a_time, &ts);
+               inode_set_atime_to_ts(inode, ts);
+               nt2kernel(std5->c_time, &ts);
+               inode_set_ctime_to_ts(inode, ts);
+               nt2kernel(std5->m_time, &ts);
+               inode_set_mtime_to_ts(inode, ts);
 
                ni->std_fa = std5->fa;
 
@@ -960,7 +962,8 @@ 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_mtime = inode_set_ctime_current(inode);
+                       inode_set_mtime_to_ts(inode,
+                                             inode_set_ctime_current(inode));
                        ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE;
                        dirty = true;
                }
@@ -1660,8 +1663,11 @@ 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_set_ctime_to_ts(inode, ni->i_crtime);
-       dir->i_mtime = inode_set_ctime_to_ts(dir, ni->i_crtime);
+       inode_set_atime_to_ts(inode, ni->i_crtime);
+       inode_set_ctime_to_ts(inode, ni->i_crtime);
+       inode_set_mtime_to_ts(inode, ni->i_crtime);
+       inode_set_mtime_to_ts(dir, ni->i_crtime);
+       inode_set_ctime_to_ts(dir, ni->i_crtime);
 
        mark_inode_dirty(dir);
        mark_inode_dirty(inode);
@@ -1767,7 +1773,7 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)
 
        if (!err) {
                drop_nlink(inode);
-               dir->i_mtime = inode_set_ctime_current(dir);
+               inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
                mark_inode_dirty(dir);
                inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
                if (inode->i_nlink)
index ad430d50bd79836dca326afe3190cbcd47adfb2a..d1a646274228119a8c57a04709b4f4458254b6b6 100644 (file)
@@ -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_mtime = inode_set_ctime_to_ts(inode,
-                                                    inode_set_ctime_current(dir));
+               inode_set_ctime_current(inode);
+               inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
                mark_inode_dirty(inode);
                mark_inode_dirty(dir);
                d_instantiate(de, inode);