mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
exfat: convert to new timestamp accessors
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-31-jlayton@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
594370f7e8
commit
4c72a36edd
@ -549,6 +549,7 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
|
|||||||
void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
|
void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
|
||||||
u8 tz, __le16 time, __le16 date, u8 time_cs);
|
u8 tz, __le16 time, __le16 date, u8 time_cs);
|
||||||
void exfat_truncate_atime(struct timespec64 *ts);
|
void exfat_truncate_atime(struct timespec64 *ts);
|
||||||
|
void exfat_truncate_inode_atime(struct inode *inode);
|
||||||
void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
|
void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
|
||||||
u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
|
u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
|
||||||
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
|
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
|
||||||
|
@ -22,7 +22,7 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
inode->i_mtime = inode_set_ctime_current(inode);
|
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
|
|
||||||
if (!IS_SYNC(inode))
|
if (!IS_SYNC(inode))
|
||||||
@ -290,10 +290,9 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attr->ia_valid & ATTR_SIZE)
|
if (attr->ia_valid & ATTR_SIZE)
|
||||||
inode->i_mtime = inode_set_ctime_current(inode);
|
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
|
||||||
|
|
||||||
setattr_copy(&nop_mnt_idmap, inode, attr);
|
exfat_truncate_inode_atime(inode);
|
||||||
exfat_truncate_atime(&inode->i_atime);
|
|
||||||
|
|
||||||
if (attr->ia_valid & ATTR_SIZE) {
|
if (attr->ia_valid & ATTR_SIZE) {
|
||||||
error = exfat_block_truncate_page(inode, attr->ia_size);
|
error = exfat_block_truncate_page(inode, attr->ia_size);
|
||||||
|
@ -26,6 +26,7 @@ int __exfat_write_inode(struct inode *inode, int sync)
|
|||||||
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
||||||
struct exfat_inode_info *ei = EXFAT_I(inode);
|
struct exfat_inode_info *ei = EXFAT_I(inode);
|
||||||
bool is_dir = (ei->type == TYPE_DIR) ? true : false;
|
bool is_dir = (ei->type == TYPE_DIR) ? true : false;
|
||||||
|
struct timespec64 ts;
|
||||||
|
|
||||||
if (inode->i_ino == EXFAT_ROOT_INO)
|
if (inode->i_ino == EXFAT_ROOT_INO)
|
||||||
return 0;
|
return 0;
|
||||||
@ -55,16 +56,18 @@ int __exfat_write_inode(struct inode *inode, int sync)
|
|||||||
&ep->dentry.file.create_time,
|
&ep->dentry.file.create_time,
|
||||||
&ep->dentry.file.create_date,
|
&ep->dentry.file.create_date,
|
||||||
&ep->dentry.file.create_time_cs);
|
&ep->dentry.file.create_time_cs);
|
||||||
exfat_set_entry_time(sbi, &inode->i_mtime,
|
exfat_set_entry_time(sbi, &ts,
|
||||||
&ep->dentry.file.modify_tz,
|
&ep->dentry.file.modify_tz,
|
||||||
&ep->dentry.file.modify_time,
|
&ep->dentry.file.modify_time,
|
||||||
&ep->dentry.file.modify_date,
|
&ep->dentry.file.modify_date,
|
||||||
&ep->dentry.file.modify_time_cs);
|
&ep->dentry.file.modify_time_cs);
|
||||||
exfat_set_entry_time(sbi, &inode->i_atime,
|
inode_set_mtime_to_ts(inode, ts);
|
||||||
&ep->dentry.file.access_tz,
|
exfat_set_entry_time(sbi, &ts,
|
||||||
&ep->dentry.file.access_time,
|
&ep->dentry.file.access_tz,
|
||||||
&ep->dentry.file.access_date,
|
&ep->dentry.file.access_time,
|
||||||
NULL);
|
&ep->dentry.file.access_date,
|
||||||
|
NULL);
|
||||||
|
inode_set_atime_to_ts(inode, ts);
|
||||||
|
|
||||||
/* File size should be zero if there is no cluster allocated */
|
/* File size should be zero if there is no cluster allocated */
|
||||||
on_disk_size = i_size_read(inode);
|
on_disk_size = i_size_read(inode);
|
||||||
@ -355,7 +358,7 @@ static void exfat_write_failed(struct address_space *mapping, loff_t to)
|
|||||||
|
|
||||||
if (to > i_size_read(inode)) {
|
if (to > i_size_read(inode)) {
|
||||||
truncate_pagecache(inode, i_size_read(inode));
|
truncate_pagecache(inode, i_size_read(inode));
|
||||||
inode->i_mtime = inode_set_ctime_current(inode);
|
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
|
||||||
exfat_truncate(inode);
|
exfat_truncate(inode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,7 +401,7 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,
|
|||||||
exfat_write_failed(mapping, pos+len);
|
exfat_write_failed(mapping, pos+len);
|
||||||
|
|
||||||
if (!(err < 0) && !(ei->attr & ATTR_ARCHIVE)) {
|
if (!(err < 0) && !(ei->attr & ATTR_ARCHIVE)) {
|
||||||
inode->i_mtime = inode_set_ctime_current(inode);
|
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
|
||||||
ei->attr |= ATTR_ARCHIVE;
|
ei->attr |= ATTR_ARCHIVE;
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
}
|
}
|
||||||
@ -576,10 +579,10 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
|
|||||||
exfat_save_attr(inode, info->attr);
|
exfat_save_attr(inode, info->attr);
|
||||||
|
|
||||||
inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9;
|
inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9;
|
||||||
inode->i_mtime = info->mtime;
|
inode_set_mtime_to_ts(inode, info->mtime);
|
||||||
inode_set_ctime_to_ts(inode, info->mtime);
|
inode_set_ctime_to_ts(inode, info->mtime);
|
||||||
ei->i_crtime = info->crtime;
|
ei->i_crtime = info->crtime;
|
||||||
inode->i_atime = info->atime;
|
inode_set_atime_to_ts(inode, info->atime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,14 @@ void exfat_truncate_atime(struct timespec64 *ts)
|
|||||||
ts->tv_nsec = 0;
|
ts->tv_nsec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exfat_truncate_inode_atime(struct inode *inode)
|
||||||
|
{
|
||||||
|
struct timespec64 atime = inode_get_atime(inode);
|
||||||
|
|
||||||
|
exfat_truncate_atime(&atime);
|
||||||
|
inode_set_atime_to_ts(inode, atime);
|
||||||
|
}
|
||||||
|
|
||||||
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type)
|
u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -569,7 +569,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
inode_inc_iversion(dir);
|
inode_inc_iversion(dir);
|
||||||
dir->i_mtime = inode_set_ctime_current(dir);
|
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
|
||||||
if (IS_DIRSYNC(dir))
|
if (IS_DIRSYNC(dir))
|
||||||
exfat_sync_inode(dir);
|
exfat_sync_inode(dir);
|
||||||
else
|
else
|
||||||
@ -582,8 +582,9 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
inode_inc_iversion(inode);
|
inode_inc_iversion(inode);
|
||||||
inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
|
EXFAT_I(inode)->i_crtime = simple_inode_init_ts(inode);
|
||||||
exfat_truncate_atime(&inode->i_atime);
|
exfat_truncate_inode_atime(inode);
|
||||||
|
|
||||||
/* timestamp is already written, so mark_inode_dirty() is unneeded. */
|
/* timestamp is already written, so mark_inode_dirty() is unneeded. */
|
||||||
|
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
@ -816,16 +817,16 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
|
|||||||
ei->dir.dir = DIR_DELETED;
|
ei->dir.dir = DIR_DELETED;
|
||||||
|
|
||||||
inode_inc_iversion(dir);
|
inode_inc_iversion(dir);
|
||||||
dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
|
simple_inode_init_ts(dir);
|
||||||
exfat_truncate_atime(&dir->i_atime);
|
exfat_truncate_inode_atime(dir);
|
||||||
if (IS_DIRSYNC(dir))
|
if (IS_DIRSYNC(dir))
|
||||||
exfat_sync_inode(dir);
|
exfat_sync_inode(dir);
|
||||||
else
|
else
|
||||||
mark_inode_dirty(dir);
|
mark_inode_dirty(dir);
|
||||||
|
|
||||||
clear_nlink(inode);
|
clear_nlink(inode);
|
||||||
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
|
simple_inode_init_ts(inode);
|
||||||
exfat_truncate_atime(&inode->i_atime);
|
exfat_truncate_inode_atime(inode);
|
||||||
exfat_unhash_inode(inode);
|
exfat_unhash_inode(inode);
|
||||||
exfat_d_version_set(dentry, inode_query_iversion(dir));
|
exfat_d_version_set(dentry, inode_query_iversion(dir));
|
||||||
unlock:
|
unlock:
|
||||||
@ -851,7 +852,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
inode_inc_iversion(dir);
|
inode_inc_iversion(dir);
|
||||||
dir->i_mtime = inode_set_ctime_current(dir);
|
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
|
||||||
if (IS_DIRSYNC(dir))
|
if (IS_DIRSYNC(dir))
|
||||||
exfat_sync_inode(dir);
|
exfat_sync_inode(dir);
|
||||||
else
|
else
|
||||||
@ -865,8 +866,8 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
inode_inc_iversion(inode);
|
inode_inc_iversion(inode);
|
||||||
inode->i_mtime = inode->i_atime = EXFAT_I(inode)->i_crtime = inode_set_ctime_current(inode);
|
EXFAT_I(inode)->i_crtime = simple_inode_init_ts(inode);
|
||||||
exfat_truncate_atime(&inode->i_atime);
|
exfat_truncate_inode_atime(inode);
|
||||||
/* timestamp is already written, so mark_inode_dirty() is unneeded. */
|
/* timestamp is already written, so mark_inode_dirty() is unneeded. */
|
||||||
|
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
@ -977,8 +978,8 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
|
|||||||
ei->dir.dir = DIR_DELETED;
|
ei->dir.dir = DIR_DELETED;
|
||||||
|
|
||||||
inode_inc_iversion(dir);
|
inode_inc_iversion(dir);
|
||||||
dir->i_mtime = dir->i_atime = inode_set_ctime_current(dir);
|
simple_inode_init_ts(dir);
|
||||||
exfat_truncate_atime(&dir->i_atime);
|
exfat_truncate_inode_atime(dir);
|
||||||
if (IS_DIRSYNC(dir))
|
if (IS_DIRSYNC(dir))
|
||||||
exfat_sync_inode(dir);
|
exfat_sync_inode(dir);
|
||||||
else
|
else
|
||||||
@ -986,8 +987,8 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
|
|||||||
drop_nlink(dir);
|
drop_nlink(dir);
|
||||||
|
|
||||||
clear_nlink(inode);
|
clear_nlink(inode);
|
||||||
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
|
simple_inode_init_ts(inode);
|
||||||
exfat_truncate_atime(&inode->i_atime);
|
exfat_truncate_inode_atime(inode);
|
||||||
exfat_unhash_inode(inode);
|
exfat_unhash_inode(inode);
|
||||||
exfat_d_version_set(dentry, inode_query_iversion(dir));
|
exfat_d_version_set(dentry, inode_query_iversion(dir));
|
||||||
unlock:
|
unlock:
|
||||||
@ -1312,7 +1313,7 @@ static int exfat_rename(struct mnt_idmap *idmap,
|
|||||||
inode_inc_iversion(new_dir);
|
inode_inc_iversion(new_dir);
|
||||||
simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
|
simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
|
||||||
EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
|
EXFAT_I(new_dir)->i_crtime = current_time(new_dir);
|
||||||
exfat_truncate_atime(&new_dir->i_atime);
|
exfat_truncate_inode_atime(new_dir);
|
||||||
if (IS_DIRSYNC(new_dir))
|
if (IS_DIRSYNC(new_dir))
|
||||||
exfat_sync_inode(new_dir);
|
exfat_sync_inode(new_dir);
|
||||||
else
|
else
|
||||||
|
@ -370,8 +370,8 @@ static int exfat_read_root(struct inode *inode)
|
|||||||
ei->i_size_ondisk = i_size_read(inode);
|
ei->i_size_ondisk = i_size_read(inode);
|
||||||
|
|
||||||
exfat_save_attr(inode, ATTR_SUBDIR);
|
exfat_save_attr(inode, ATTR_SUBDIR);
|
||||||
inode->i_mtime = inode->i_atime = ei->i_crtime = inode_set_ctime_current(inode);
|
ei->i_crtime = simple_inode_init_ts(inode);
|
||||||
exfat_truncate_atime(&inode->i_atime);
|
exfat_truncate_inode_atime(inode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user