mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 14:21:47 +00:00
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
8cf058834b
commit
7dee6f57d7
@ -110,8 +110,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);
|
||||
|
||||
@ -228,12 +227,13 @@ 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);
|
||||
unsigned int blocksize = i_blocksize(inode);
|
||||
loff_t aligned_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)
|
||||
*/
|
||||
@ -260,11 +260,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);
|
||||
}
|
||||
|
||||
|
@ -114,10 +114,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;
|
||||
@ -416,10 +415,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;
|
||||
}
|
||||
|
||||
|
@ -395,9 +395,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;
|
||||
}
|
||||
|
||||
|
@ -366,9 +366,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);
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
|
||||
|
Loading…
Reference in New Issue
Block a user