diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 97d2774760fe..c356bde623bf 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -329,10 +329,7 @@ static int exfat_find_empty_entry(struct inode *inode, EXFAT_B_TO_CLU(i_size_read(inode), sbi), ei->flags); while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, - num_entries, es)) < 0) { - if (dentry == -EIO) - break; - + num_entries, es)) == -ENOSPC) { if (exfat_check_max_dentries(inode)) return -ENOSPC; @@ -395,6 +392,9 @@ static int exfat_find_empty_entry(struct inode *inode, inode->i_blocks += sbi->cluster_size >> 9; } + if (dentry < 0) + return dentry; + p_dir->dir = exfat_sector_to_cluster(sbi, es->bh[0]->b_blocknr); p_dir->size -= dentry / sbi->dentries_per_clu;