Skip to content

Commit

Permalink
exfat: remove duplicate write inode for extending dir/file
Browse files Browse the repository at this point in the history
Since the timestamps need to be updated, the directory entries
will be updated by mark_inode_dirty() whether or not a new
cluster is allocated for the file or directory, so there is no
need to use __exfat_write_inode() to update the directory entries
when allocating a new cluster for a file or directory.

Signed-off-by: Yuezhang Mo <[email protected]>
Reviewed-by: Andy Wu <[email protected]>
Reviewed-by: Aoyama Wataru <[email protected]>
Reviewed-by: Daniel Palmer <[email protected]>
Reviewed-by: Sungjong Seo <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
YuezhangMo authored and namjaejeon committed Aug 1, 2022
1 parent 4493895 commit be17b1c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
9 changes: 1 addition & 8 deletions fs/exfat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void exfat_sync_inode(struct inode *inode)
static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
unsigned int *clu, int create)
{
int ret, modified = false;
int ret;
unsigned int last_clu;
struct exfat_chain new_clu;
struct super_block *sb = inode->i_sb;
Expand Down Expand Up @@ -203,7 +203,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
if (new_clu.flags == ALLOC_FAT_CHAIN)
ei->flags = ALLOC_FAT_CHAIN;
ei->start_clu = new_clu.dir;
modified = true;
} else {
if (new_clu.flags != ei->flags) {
/* no-fat-chain bit is disabled,
Expand All @@ -213,7 +212,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
exfat_chain_cont_cluster(sb, ei->start_clu,
num_clusters);
ei->flags = ALLOC_FAT_CHAIN;
modified = true;
}
if (new_clu.flags == ALLOC_FAT_CHAIN)
if (exfat_ent_set(sb, last_clu, new_clu.dir))
Expand All @@ -223,11 +221,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
num_clusters += num_to_be_allocated;
*clu = new_clu.dir;

if (modified) {
if (__exfat_write_inode(inode, inode_needs_sync(inode)))
return -EIO;
}

inode->i_blocks +=
num_to_be_allocated << sbi->sect_per_clus_bits;

Expand Down
4 changes: 0 additions & 4 deletions fs/exfat/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,6 @@ static int exfat_find_empty_entry(struct inode *inode,
ei->i_size_aligned += sbi->cluster_size;
ei->flags = p_dir->flags;
inode->i_blocks += 1 << sbi->sect_per_clus_bits;

/* update the directory entry */
if (__exfat_write_inode(inode, IS_DIRSYNC(inode)))
return -EIO;
}

return dentry;
Expand Down

0 comments on commit be17b1c

Please sign in to comment.