Skip to content

Commit

Permalink
exfat: convert to ctime accessor functions
Browse files Browse the repository at this point in the history
In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
jtlayton authored and namjaejeon committed Nov 2, 2023
1 parent 19d2265 commit 2d2dbae
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
8 changes: 8 additions & 0 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
return err;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode_set_ctime_current(inode);
#else
inode->i_ctime = inode->i_mtime = current_time(inode);
#endif
#else
inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
#endif
Expand Down Expand Up @@ -363,7 +367,11 @@ int exfat_setattr(struct dentry *dentry, struct iattr *attr)

if (attr->ia_valid & ATTR_SIZE)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_ctime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
#endif
Expand Down
12 changes: 12 additions & 0 deletions inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ static void exfat_write_failed(struct address_space *mapping, loff_t to)
if (to > i_size_read(inode)) {
truncate_pagecache(inode, i_size_read(inode));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_ctime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
#endif
Expand Down Expand Up @@ -438,7 +442,11 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,

if (!(err < 0) && !(ei->attr & EXFAT_ATTR_ARCHIVE)) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_ctime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
#endif
Expand Down Expand Up @@ -659,7 +667,11 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)

inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9;
inode->i_mtime = info->mtime;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode_set_ctime_to_ts(inode, info->mtime);
#else
inode->i_ctime = info->mtime;
#endif
ei->i_crtime = info->crtime;
inode->i_atime = info->atime;

Expand Down
36 changes: 36 additions & 0 deletions namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,11 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
dir->i_version++;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
dir->i_mtime = inode_set_ctime_current(dir);
#else
dir->i_ctime = dir->i_mtime = current_time(dir);
#endif
#else
dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
#endif
Expand All @@ -647,8 +651,12 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_atime = inode->i_ctime =
EXFAT_I(inode)->i_crtime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_atime = inode->i_ctime =
EXFAT_I(inode)->i_crtime = CURRENT_TIME_SEC;
Expand Down Expand Up @@ -903,7 +911,11 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
dir->i_version++;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
#else
dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
#endif
#else
dir->i_mtime = dir->i_atime = dir->i_ctime = CURRENT_TIME_SEC;
#endif
Expand All @@ -915,7 +927,11 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)

clear_nlink(inode);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_atime = dir->i_ctime = CURRENT_TIME_SEC;
#endif
Expand Down Expand Up @@ -964,7 +980,11 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
dir->i_mtime = inode_set_ctime_current(dir);
#else
dir->i_ctime = dir->i_mtime = current_time(dir);
#endif
#else
dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
#endif
Expand All @@ -986,8 +1006,12 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
inode->i_version++;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_atime = inode->i_ctime =
EXFAT_I(inode)->i_crtime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_atime = inode->i_ctime =
EXFAT_I(inode)->i_crtime = CURRENT_TIME_SEC;
Expand Down Expand Up @@ -1111,7 +1135,11 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
dir->i_version++;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
#else
dir->i_mtime = dir->i_atime = dir->i_ctime = current_time(dir);
#endif
#else
dir->i_mtime = dir->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
#endif
Expand All @@ -1124,7 +1152,11 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)

clear_nlink(inode);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
#endif
#else
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
#endif
Expand Down Expand Up @@ -1541,8 +1573,12 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
WARN_ON(new_inode->i_nlink == 0);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
EXFAT_I(new_inode)->i_crtime = current_time(new_inode);
#else
new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
current_time(new_inode);
#endif
#else
new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
CURRENT_TIME_SEC;
Expand Down
4 changes: 4 additions & 0 deletions super.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,12 @@ static int exfat_read_root(struct inode *inode)

exfat_save_attr(inode, EXFAT_ATTR_SUBDIR);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode->i_mtime = inode->i_atime = ei->i_crtime = inode_set_ctime_current(inode);
#else
inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
current_time(inode);
#endif
#else
inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
CURRENT_TIME_SEC;
Expand Down

0 comments on commit 2d2dbae

Please sign in to comment.