@@ -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);