@@ -897,6 +897,29 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
897
897
return NULL ;
898
898
}
899
899
900
+ static inline void exfat_reset_empty_hint (struct exfat_hint_femp * hint_femp )
901
+ {
902
+ hint_femp -> eidx = EXFAT_HINT_NONE ;
903
+ hint_femp -> count = 0 ;
904
+ }
905
+
906
+ static inline void exfat_set_empty_hint (struct exfat_inode_info * ei ,
907
+ struct exfat_hint_femp * candi_empty , struct exfat_chain * clu ,
908
+ int dentry , int num_entries )
909
+ {
910
+ if (ei -> hint_femp .eidx == EXFAT_HINT_NONE ||
911
+ ei -> hint_femp .eidx > dentry ) {
912
+ if (candi_empty -> count == 0 ) {
913
+ candi_empty -> cur = * clu ;
914
+ candi_empty -> eidx = dentry ;
915
+ }
916
+
917
+ candi_empty -> count ++ ;
918
+ if (candi_empty -> count == num_entries )
919
+ ei -> hint_femp = * candi_empty ;
920
+ }
921
+ }
922
+
900
923
enum {
901
924
DIRENT_STEP_FILE ,
902
925
DIRENT_STEP_STRM ,
@@ -921,7 +944,7 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
921
944
{
922
945
int i , rewind = 0 , dentry = 0 , end_eidx = 0 , num_ext = 0 , len ;
923
946
int order , step , name_len = 0 ;
924
- int dentries_per_clu , num_empty = 0 ;
947
+ int dentries_per_clu ;
925
948
unsigned int entry_type ;
926
949
unsigned short * uniname = NULL ;
927
950
struct exfat_chain clu ;
@@ -939,10 +962,13 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
939
962
end_eidx = dentry ;
940
963
}
941
964
942
- candi_empty .eidx = EXFAT_HINT_NONE ;
965
+ exfat_reset_empty_hint (& ei -> hint_femp );
966
+
943
967
rewind :
944
968
order = 0 ;
945
969
step = DIRENT_STEP_FILE ;
970
+ exfat_reset_empty_hint (& candi_empty );
971
+
946
972
while (clu .dir != EXFAT_EOF_CLUSTER ) {
947
973
i = dentry & (dentries_per_clu - 1 );
948
974
for (; i < dentries_per_clu ; i ++ , dentry ++ ) {
@@ -962,35 +988,16 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
962
988
entry_type == TYPE_DELETED ) {
963
989
step = DIRENT_STEP_FILE ;
964
990
965
- num_empty ++ ;
966
- if (candi_empty .eidx == EXFAT_HINT_NONE &&
967
- num_empty == 1 ) {
968
- exfat_chain_set (& candi_empty .cur ,
969
- clu .dir , clu .size , clu .flags );
970
- }
971
-
972
- if (candi_empty .eidx == EXFAT_HINT_NONE &&
973
- num_empty >= num_entries ) {
974
- candi_empty .eidx =
975
- dentry - (num_empty - 1 );
976
- WARN_ON (candi_empty .eidx < 0 );
977
- candi_empty .count = num_empty ;
978
-
979
- if (ei -> hint_femp .eidx ==
980
- EXFAT_HINT_NONE ||
981
- candi_empty .eidx <=
982
- ei -> hint_femp .eidx )
983
- ei -> hint_femp = candi_empty ;
984
- }
991
+ exfat_set_empty_hint (ei , & candi_empty , & clu ,
992
+ dentry , num_entries );
985
993
986
994
brelse (bh );
987
995
if (entry_type == TYPE_UNUSED )
988
996
goto not_found ;
989
997
continue ;
990
998
}
991
999
992
- num_empty = 0 ;
993
- candi_empty .eidx = EXFAT_HINT_NONE ;
1000
+ exfat_reset_empty_hint (& candi_empty );
994
1001
995
1002
if (entry_type == TYPE_FILE || entry_type == TYPE_DIR ) {
996
1003
step = DIRENT_STEP_FILE ;
@@ -1090,9 +1097,6 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
1090
1097
rewind = 1 ;
1091
1098
dentry = 0 ;
1092
1099
clu .dir = p_dir -> dir ;
1093
- /* reset empty hint */
1094
- num_empty = 0 ;
1095
- candi_empty .eidx = EXFAT_HINT_NONE ;
1096
1100
goto rewind ;
1097
1101
}
1098
1102
0 commit comments