Skip to content

Commit 36955d3

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: reuse exfat_find_location() to simplify exfat_get_dentry_set()
In exfat_get_dentry_set(), part of the code is the same as exfat_find_location(), reuse exfat_find_location() to simplify exfat_get_dentry_set(). Code refinement, no functional changes. Signed-off-by: Yuezhang Mo <[email protected]> Reviewed-by: Andy Wu <[email protected]> Reviewed-by: Aoyama Wataru <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 40306b4 commit 36955d3

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

fs/exfat/dir.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
818818
unsigned int type)
819819
{
820820
int ret, i, num_bh;
821-
unsigned int off, byte_offset, clu = 0;
821+
unsigned int off;
822822
sector_t sec;
823823
struct exfat_sb_info *sbi = EXFAT_SB(sb);
824824
struct exfat_dentry *ep;
@@ -831,27 +831,16 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
831831
return -EIO;
832832
}
833833

834-
byte_offset = EXFAT_DEN_TO_B(entry);
835-
ret = exfat_walk_fat_chain(sb, p_dir, byte_offset, &clu);
834+
ret = exfat_find_location(sb, p_dir, entry, &sec, &off);
836835
if (ret)
837836
return ret;
838837

839838
memset(es, 0, sizeof(*es));
840839
es->sb = sb;
841840
es->modified = false;
842-
843-
/* byte offset in cluster */
844-
byte_offset = EXFAT_CLU_OFFSET(byte_offset, sbi);
845-
846-
/* byte offset in sector */
847-
off = EXFAT_BLK_OFFSET(byte_offset, sb);
848841
es->start_off = off;
849842
es->bh = es->__bh;
850843

851-
/* sector offset in cluster */
852-
sec = EXFAT_B_TO_BLK(byte_offset, sb);
853-
sec += exfat_cluster_to_sector(sbi, clu);
854-
855844
bh = sb_bread(sb, sec);
856845
if (!bh)
857846
return -EIO;
@@ -878,6 +867,8 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
878867
for (i = 1; i < num_bh; i++) {
879868
/* get the next sector */
880869
if (exfat_is_last_sector_in_cluster(sbi, sec)) {
870+
unsigned int clu = exfat_sector_to_cluster(sbi, sec);
871+
881872
if (p_dir->flags == ALLOC_NO_FAT_CHAIN)
882873
clu++;
883874
else if (exfat_get_next_cluster(sb, &clu))

0 commit comments

Comments
 (0)