Skip to content

Commit f83d8a3

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: reduce the size of exfat_entry_set_cache
In normal, there are 19 directory entries at most for a file or a directory. - A file directory entry - A stream extension directory entry - 1~17 file name directory entry So the directory entries are in 3 sectors at most, it is enough for struct exfat_entry_set_cache to pre-allocate 3 bh. This commit changes the size of struct exfat_entry_set_cache as: Before After 32-bit system 88 32 bytes 64-bit system 168 48 bytes 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 e298c8a commit f83d8a3

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

fs/exfat/exfat_fs.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/fs.h>
1010
#include <linux/ratelimit.h>
1111
#include <linux/nls.h>
12+
#include <linux/blkdev.h>
1213

1314
#define EXFAT_ROOT_INO 1
1415

@@ -41,6 +42,14 @@ enum {
4142
#define ES_2_ENTRIES 2
4243
#define ES_ALL_ENTRIES 0
4344

45+
#define ES_IDX_FILE 0
46+
#define ES_IDX_STREAM 1
47+
#define ES_IDX_FIRST_FILENAME 2
48+
#define EXFAT_FILENAME_ENTRY_NUM(name_len) \
49+
DIV_ROUND_UP(name_len, EXFAT_FILE_NAME_LEN)
50+
#define ES_IDX_LAST_FILENAME(name_len) \
51+
(ES_IDX_FIRST_FILENAME + EXFAT_FILENAME_ENTRY_NUM(name_len) - 1)
52+
4453
#define DIR_DELETED 0xFFFF0321
4554

4655
/* type values */
@@ -68,9 +77,6 @@ enum {
6877
#define MAX_NAME_LENGTH 255 /* max len of file name excluding NULL */
6978
#define MAX_VFSNAME_BUF_SIZE ((MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE)
7079

71-
/* Enough size to hold 256 dentry (even 512 Byte sector) */
72-
#define DIR_CACHE_SIZE (256*sizeof(struct exfat_dentry)/512+1)
73-
7480
#define EXFAT_HINT_NONE -1
7581
#define EXFAT_MIN_SUBDIR 2
7682

@@ -125,6 +131,17 @@ enum {
125131
#define BITS_PER_BYTE_MASK 0x7
126132
#define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1)
127133

134+
#define ES_ENTRY_NUM(name_len) (ES_IDX_LAST_FILENAME(name_len) + 1)
135+
/* 19 entries = 1 file entry + 1 stream entry + 17 filename entries */
136+
#define ES_MAX_ENTRY_NUM ES_ENTRY_NUM(MAX_NAME_LENGTH)
137+
138+
/*
139+
* 19 entries x 32 bytes/entry = 608 bytes.
140+
* The 608 bytes are in 3 sectors at most (even 512 Byte sector).
141+
*/
142+
#define DIR_CACHE_SIZE \
143+
(DIV_ROUND_UP(EXFAT_DEN_TO_B(ES_MAX_ENTRY_NUM), SECTOR_SIZE) + 1)
144+
128145
struct exfat_dentry_namebuf {
129146
char *lfn;
130147
int lfnbuf_len; /* usually MAX_UNINAME_BUF_SIZE */
@@ -166,11 +183,11 @@ struct exfat_hint {
166183

167184
struct exfat_entry_set_cache {
168185
struct super_block *sb;
169-
bool modified;
170186
unsigned int start_off;
171187
int num_bh;
172188
struct buffer_head *bh[DIR_CACHE_SIZE];
173189
unsigned int num_entries;
190+
bool modified;
174191
};
175192

176193
struct exfat_dir_entry {

0 commit comments

Comments
 (0)