exfat: reuse exfat_inode_info variable instead of calling EXFAT_I()
Also add a local "struct exfat_inode_info *ei" variable to exfat_truncate() to simplify the code. Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
parent
5ba7af6fce
commit
032c9d34c8
14
file.c
14
file.c
@ -117,8 +117,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
|
||||
exfat_set_volume_dirty(sb);
|
||||
|
||||
num_clusters_new = EXFAT_B_TO_CLU_ROUND_UP(i_size_read(inode), sbi);
|
||||
num_clusters_phys =
|
||||
EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, sbi);
|
||||
num_clusters_phys = EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi);
|
||||
|
||||
exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags);
|
||||
|
||||
@ -243,6 +242,7 @@ void exfat_truncate(struct inode *inode, loff_t size)
|
||||
{
|
||||
struct super_block *sb = inode->i_sb;
|
||||
struct exfat_sb_info *sbi = EXFAT_SB(sb);
|
||||
struct exfat_inode_info *ei = EXFAT_I(inode);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
|
||||
unsigned int blocksize = i_blocksize(inode);
|
||||
#else
|
||||
@ -252,7 +252,7 @@ void exfat_truncate(struct inode *inode, loff_t size)
|
||||
int err;
|
||||
|
||||
mutex_lock(&sbi->s_lock);
|
||||
if (EXFAT_I(inode)->start_clu == 0) {
|
||||
if (ei->start_clu == 0) {
|
||||
/*
|
||||
* Empty start_clu != ~0 (not allocated)
|
||||
*/
|
||||
@ -283,11 +283,11 @@ write_size:
|
||||
aligned_size++;
|
||||
}
|
||||
|
||||
if (EXFAT_I(inode)->i_size_ondisk > i_size_read(inode))
|
||||
EXFAT_I(inode)->i_size_ondisk = aligned_size;
|
||||
if (ei->i_size_ondisk > i_size_read(inode))
|
||||
ei->i_size_ondisk = aligned_size;
|
||||
|
||||
if (EXFAT_I(inode)->i_size_aligned > i_size_read(inode))
|
||||
EXFAT_I(inode)->i_size_aligned = aligned_size;
|
||||
if (ei->i_size_aligned > i_size_read(inode))
|
||||
ei->i_size_aligned = aligned_size;
|
||||
mutex_unlock(&sbi->s_lock);
|
||||
}
|
||||
|
||||
|
9
inode.c
9
inode.c
@ -116,10 +116,9 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
|
||||
unsigned int local_clu_offset = clu_offset;
|
||||
unsigned int num_to_be_allocated = 0, num_clusters = 0;
|
||||
|
||||
if (EXFAT_I(inode)->i_size_ondisk > 0)
|
||||
if (ei->i_size_ondisk > 0)
|
||||
num_clusters =
|
||||
EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk,
|
||||
sbi);
|
||||
EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi);
|
||||
|
||||
if (clu_offset >= num_clusters)
|
||||
num_to_be_allocated = clu_offset - num_clusters + 1;
|
||||
@ -426,10 +425,10 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,
|
||||
|
||||
err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata);
|
||||
|
||||
if (EXFAT_I(inode)->i_size_aligned < i_size_read(inode)) {
|
||||
if (ei->i_size_aligned < i_size_read(inode)) {
|
||||
exfat_fs_error(inode->i_sb,
|
||||
"invalid size(size(%llu) > aligned(%llu)\n",
|
||||
i_size_read(inode), EXFAT_I(inode)->i_size_aligned);
|
||||
i_size_read(inode), ei->i_size_aligned);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
6
namei.c
6
namei.c
@ -422,9 +422,9 @@ static int exfat_find_empty_entry(struct inode *inode,
|
||||
|
||||
/* directory inode should be updated in here */
|
||||
i_size_write(inode, size);
|
||||
EXFAT_I(inode)->i_size_ondisk += sbi->cluster_size;
|
||||
EXFAT_I(inode)->i_size_aligned += sbi->cluster_size;
|
||||
EXFAT_I(inode)->flags = p_dir->flags;
|
||||
ei->i_size_ondisk += sbi->cluster_size;
|
||||
ei->i_size_aligned += sbi->cluster_size;
|
||||
ei->flags = p_dir->flags;
|
||||
inode->i_blocks += 1 << sbi->sect_per_clus_bits;
|
||||
}
|
||||
|
||||
|
6
super.c
6
super.c
@ -611,9 +611,9 @@ static int exfat_read_root(struct inode *inode)
|
||||
|
||||
inode->i_blocks = ((i_size_read(inode) + (sbi->cluster_size - 1))
|
||||
& ~(sbi->cluster_size - 1)) >> inode->i_blkbits;
|
||||
EXFAT_I(inode)->i_pos = ((loff_t)sbi->root_dir << 32) | 0xffffffff;
|
||||
EXFAT_I(inode)->i_size_aligned = i_size_read(inode);
|
||||
EXFAT_I(inode)->i_size_ondisk = i_size_read(inode);
|
||||
ei->i_pos = ((loff_t)sbi->root_dir << 32) | 0xffffffff;
|
||||
ei->i_size_aligned = i_size_read(inode);
|
||||
ei->i_size_ondisk = i_size_read(inode);
|
||||
|
||||
exfat_save_attr(inode, ATTR_SUBDIR);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user