exfat: remove unnecessary read entry in __exfat_rename()

To determine whether it is a directory, there is no need to read its
directory entry, just use S_ISDIR(inode->i_mode).

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
Reviewed-by: Daniel Palmer <daniel.palmer@sony.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Yuezhang Mo 2024-08-08 15:37:13 +08:00 committed by Namjae Jeon
parent 2e94e5bb94
commit 30ef0e0d7f

View File

@ -1131,17 +1131,12 @@ static int __exfat_rename(struct inode *old_parent_inode,
int ret;
int dentry;
struct exfat_chain olddir, newdir;
struct exfat_chain *p_dir = NULL;
struct exfat_uni_name uni_name;
struct exfat_dentry *ep;
struct super_block *sb = old_parent_inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
const unsigned char *new_path = new_dentry->d_name.name;
struct inode *new_inode = new_dentry->d_inode;
struct exfat_inode_info *new_ei = NULL;
unsigned int new_entry_type = TYPE_UNUSED;
int new_entry = 0;
struct buffer_head *new_bh = NULL;
/* check the validity of pointer parameters */
if (new_path == NULL || strlen(new_path) == 0)
@ -1167,17 +1162,8 @@ static int __exfat_rename(struct inode *old_parent_inode,
goto out;
}
p_dir = &(new_ei->dir);
new_entry = new_ei->entry;
ep = exfat_get_dentry(sb, p_dir, new_entry, &new_bh);
if (!ep)
goto out;
new_entry_type = exfat_get_entry_type(ep);
brelse(new_bh);
/* if new_inode exists, update ei */
if (new_entry_type == TYPE_DIR) {
if (S_ISDIR(new_inode->i_mode)) {
struct exfat_chain new_clu;
new_clu.dir = new_ei->start_clu;
@ -1209,6 +1195,8 @@ static int __exfat_rename(struct inode *old_parent_inode,
if (!ret && new_inode) {
struct exfat_entry_set_cache es;
struct exfat_chain *p_dir = &(new_ei->dir);
int new_entry = new_ei->entry;
/* delete entries of new_dir */
ret = exfat_get_dentry_set(&es, sb, p_dir, new_entry,
@ -1225,7 +1213,7 @@ static int __exfat_rename(struct inode *old_parent_inode,
goto del_out;
/* Free the clusters if new_inode is a dir(as if exfat_rmdir) */
if (new_entry_type == TYPE_DIR &&
if (S_ISDIR(new_inode->i_mode) &&
new_ei->start_clu != EXFAT_EOF_CLUSTER) {
/* new_ei, new_clu_to_free */
struct exfat_chain new_clu_to_free;