diff mbox series

[v1,08/11] exfat: remove __exfat_find_empty_entry()

Message ID tencent_FB9B093068189C7EB944A7EEFB35A46F8B0A@qq.com (mailing list archive)
State New, archived
Headers show
Series [v1,01/11] exfat: add __exfat_get_dentry_set() helper | expand

Commit Message

Yuezhang Mo Dec. 8, 2023, 11:23 a.m. UTC
From: Yuezhang Mo <Yuezhang.Mo@sony.com>

This commit removes exfat_find_empty_entry() and renames
__exfat_find_empty_entry() to exfat_find_empty_entry().

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>
---
 fs/exfat/namei.c | 49 ++++++++++++------------------------------------
 1 file changed, 12 insertions(+), 37 deletions(-)

Comments

Namjae Jeon Dec. 22, 2023, 5:07 a.m. UTC | #1
2023-12-08 20:23 GMT+09:00, yuezhang.mo@foxmail.com <yuezhang.mo@foxmail.com>:
> From: Yuezhang Mo <Yuezhang.Mo@sony.com>
>
> This commit removes exfat_find_empty_entry() and renames
> __exfat_find_empty_entry() to exfat_find_empty_entry().
>
> 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>
If you update 0003 patch, this patch is not needed. I don't understand
why you delete function again after adding it in previous patch.
diff mbox series

Patch

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index ee7d5fd0b16f..79e3fc9d6e19 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -291,7 +291,7 @@  static int exfat_check_max_dentries(struct inode *inode)
 /* find empty directory entry.
  * if there isn't any empty slot, expand cluster chain.
  */
-static int __exfat_find_empty_entry(struct inode *inode,
+static int exfat_find_empty_entry(struct inode *inode,
 		struct exfat_chain *p_dir, int num_entries,
 		struct exfat_entry_set_cache *es)
 {
@@ -382,21 +382,6 @@  static int __exfat_find_empty_entry(struct inode *inode,
 	return dentry;
 }
 
-static int exfat_find_empty_entry(struct inode *inode,
-		struct exfat_chain *p_dir, int num_entries)
-{
-	int entry;
-	struct exfat_entry_set_cache es;
-
-	entry = __exfat_find_empty_entry(inode, p_dir, num_entries, &es);
-	if (entry < 0)
-		return entry;
-
-	exfat_put_dentry_set(&es, false);
-
-	return entry;
-}
-
 /*
  * Name Resolution Functions :
  * Zero if it was successful; otherwise nonzero.
@@ -498,7 +483,7 @@  static int exfat_add_entry(struct inode *inode, const char *path,
 	}
 
 	/* exfat_find_empty_entry must be called before alloc_cluster() */
-	dentry = exfat_find_empty_entry(inode, p_dir, num_entries);
+	dentry = exfat_find_empty_entry(inode, p_dir, num_entries, &es);
 	if (dentry < 0) {
 		ret = dentry; /* -EIO or -ENOSPC */
 		goto out;
@@ -506,8 +491,10 @@  static int exfat_add_entry(struct inode *inode, const char *path,
 
 	if (type == TYPE_DIR && !sbi->options.zero_size_dir) {
 		ret = exfat_alloc_new_dir(inode, &clu);
-		if (ret)
+		if (ret) {
+			exfat_put_dentry_set(&es, false);
 			goto out;
+		}
 		start_clu = clu.dir;
 		clu_size = sbi->cluster_size;
 	}
@@ -516,11 +503,6 @@  static int exfat_add_entry(struct inode *inode, const char *path,
 	/* fill the dos name directory entry information of the created file.
 	 * the first cluster is not determined yet. (0)
 	 */
-
-	ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries);
-	if (ret)
-		goto out;
-
 	exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts);
 	exfat_init_ext_entry(&es, num_entries, &uniname);
 
@@ -1016,18 +998,13 @@  static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
 	if (old_es.num_entries < num_new_entries) {
 		int newentry;
 
-		newentry =
-			exfat_find_empty_entry(inode, p_dir, num_new_entries);
+		newentry = exfat_find_empty_entry(inode, p_dir, num_new_entries,
+				&new_es);
 		if (newentry < 0) {
 			ret = newentry; /* -EIO or -ENOSPC */
 			goto put_old_es;
 		}
 
-		ret = exfat_get_empty_dentry_set(&new_es, sb, p_dir, newentry,
-				num_new_entries);
-		if (ret)
-			goto put_old_es;
-
 		epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE);
 		*epnew = *epold;
 		if (exfat_get_entry_type(epnew) == TYPE_FILE) {
@@ -1077,19 +1054,17 @@  static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
 	if (num_new_entries < 0)
 		return num_new_entries;
 
-	newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries);
-	if (newentry < 0)
-		return newentry; /* -EIO or -ENOSPC */
-
 	ret = exfat_get_dentry_set(&mov_es, sb, p_olddir, oldentry,
 			ES_ALL_ENTRIES);
 	if (ret)
 		return -EIO;
 
-	ret = exfat_get_empty_dentry_set(&new_es, sb, p_newdir, newentry,
-			num_new_entries);
-	if (ret)
+	newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries,
+			&new_es);
+	if (newentry < 0) {
+		ret = newentry; /* -EIO or -ENOSPC */
 		goto put_mov_es;
+	}
 
 	epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE);
 	epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE);