exfat: move free cluster out of exfat_init_ext_entry()
authorYuezhang Mo <Yuezhang.Mo@sony.com>
Wed, 1 Feb 2023 10:53:18 +0000 (18:53 +0800)
committerNamjae Jeon <linkinjeon@kernel.org>
Tue, 19 Mar 2024 11:55:45 +0000 (20:55 +0900)
exfat_init_ext_entry() is an init function, it's a bit strange
to free cluster in it. And the argument 'inode' will be removed
from exfat_init_ext_entry(). So this commit changes to free the
cluster in exfat_remove_entries().

Code refinement, no functional changes.

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/exfat/dir.c
fs/exfat/namei.c

index 599dc81c9a08362e980f67a5b059e8926a3c1b28..0008d4681d293ef104fd7d1d44c6890fcd86c817 100644 (file)
@@ -564,9 +564,6 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
                if (!ep)
                        return -EIO;
 
-               if (exfat_get_entry_type(ep) & TYPE_BENIGN_SEC)
-                       exfat_free_benign_secondary_clusters(inode, ep);
-
                exfat_init_name_entry(ep, uniname);
                exfat_update_bh(bh, sync);
                brelse(bh);
index f56e223b9b8fba449ef944be43026d01f7a60285..be6760297e8fa94407854a231cf4a55f21201f22 100644 (file)
@@ -1082,12 +1082,13 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
                        epold->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE);
                        ei->attr |= EXFAT_ATTR_ARCHIVE;
                }
+
+               exfat_remove_entries(inode, &old_es, ES_IDX_FIRST_FILENAME + 1);
+
                ret = exfat_init_ext_entry(inode, p_dir, oldentry,
                        num_new_entries, p_uniname);
                if (ret)
                        goto put_old_es;
-
-               exfat_remove_entries(inode, &old_es, num_new_entries);
        }
        return exfat_put_dentry_set(&old_es, sync);