fat: eliminate iterations in fat_search_long in case of EOD
Subsystems (2)
PATCH 1/1 fat: eliminate iterations in fat_search_long in case of EOD
From: Namjae Jeon <[email protected]>
When searching a directory for names, we can stop checking for further entries if we detect End of Directory, i.e. if (de->name[0] == 0x00).The current code traverses the cluster chain of a directory until a hit is found or till the last cluster for that directory, ignoring the EOD mark. Fix this.
--- fs/fat/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/dir.c +2 -2
@@ -484,10 +484,10 @@ parse_record: nr_slots =0 ;if (de->name[0 ] ==DELETED_FLAG )continue ; +if (!de->name[0 ]) + goto end_of_dir;if (de->attr !=ATTR_EXT && (de->attr &ATTR_VOLUME ))continue ; -if (de->attr !=ATTR_EXT &&IS_FREE (de->name)) -continue ;if (de->attr ==ATTR_EXT ) {int status =fat_parse_long (inode, &cpos, &bh, &de, &unicode, &nr_slots);
Signature · 1 line
1.7.9.5
OGAWA Hirofumi
maintainerQuoted 7 lines · Namjae Jeon
From: Namjae Jeon <[email protected]>
When searching a directory for names, we can stop checking for further entries if we detect End of Directory, i.e. if (de->name[0] == 0x00).The current code traverses the cluster chain of a directory until a hit is found or till the last cluster for that directory, ignoring the EOD mark. Fix this.
f_pos still works fine after this change?
Quoted 23 lines
Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ravishankar N <[email protected]>--- fs/fat/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/fat/dir.c +2
-2@@ -484,10 +484,10 @@ parse_record: nr_slots =0 ;if (de->name[0 ] ==DELETED_FLAG )continue ; +if (!de->name[0 ]) + goto end_of_dir;if (de->attr !=ATTR_EXT && (de->attr &ATTR_VOLUME ))continue ; -if (de->attr !=ATTR_EXT &&IS_FREE (de->name)) -continue ;if (de->attr ==ATTR_EXT ) {int status =fat_parse_long (inode, &cpos, &bh, &de, &unicode, &nr_slots);
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2013/1/20, OGAWA Hirofumi <[email protected]>:
Quoted 11 lines
Quoted 7 lines · Namjae Jeon
From: Namjae Jeon <[email protected]>
When searching a directory for names, we can stop checking for further entries if we detect End of Directory, i.e. if (de->name[0] == 0x00).The current code traverses the cluster chain of a directory until a hit is found or till the last cluster for that directory, ignoring the EOD mark. Fix this.
f_posstill works fine after this change?
Hi OGAWA.
I can not find f_pos usage in fat_search_long function. Maybe, Have you seen other function such as __fat_readdir ? Let me know your opinion.
Thanks.
Quoted 28 lines
Quoted 14 lines
Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ravishankar N <[email protected]>--- fs/fat/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/fat/dir.c +0
-0@@ -484,10 +484,10 @@ parse_record: nr_slots =0 ;if (de->name[0 ] ==DELETED_FLAG )fs/fat/dir.c parse_record: · line 493
Quoted 10 lines
fs/fat/dir.c +2
-2continue ; +if (!de->name[0 ]) + goto end_of_dir;if (de->attr !=ATTR_EXT && (de->attr &ATTR_VOLUME ))continue ; -if (de->attr !=ATTR_EXT &&IS_FREE (de->name)) -continue ;if (de->attr ==ATTR_EXT ) {int status =fat_parse_long (inode, &cpos, &bh, &de, &unicode, &nr_slots);--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 11 lines · Namjae Jeon
2013/1/20, OGAWA Hirofumi <[email protected]>:
Quoted 10 lines
Quoted 7 lines · Namjae Jeon
From: Namjae Jeon <[email protected]>
When searching a directory for names, we can stop checking for further entries if we detect End of Directory, i.e. if (de->name[0] == 0x00).The current code traverses the cluster chain of a directory until a hit is found or till the last cluster for that directory, ignoring the EOD mark. Fix this.
Quoted 5 lines
Quoted 1 line
f_posstill works fine after this change?Hi OGAWA.
I can not findf_posusage infat_search_longfunction. Maybe, Have you seen other function such as__fat_readdir? Let me know your opinion.
Ah, I see. Only ->lookup. So, this makes behavior more strange. I.e. readdir() returns beyond 0, but lookup() can't find it?
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2013/1/21, OGAWA Hirofumi <[email protected]>:
Quoted 15 lines
Quoted 13 lines · Namjae Jeon
2013/1/20, OGAWA Hirofumi <[email protected]>:
Quoted 12 lines
Quoted 9 lines · Namjae Jeon
From: Namjae Jeon <[email protected]>
When searching a directory for names, we can stop checking for further entries if we detect End of Directory, i.e. if (de->name[0] == 0x00).The
current code traverses the cluster chain of a directory until a hit is found or till the last cluster for that directory, ignoring the EOD mark.
Fix this.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
f_posstill works fine after this change?Hi OGAWA.
I can not findf_posusage infat_search_longfunction. Maybe, Have you seen other function such as__fat_readdir? Let me know your opinion.Ah, I see. Only ->lookup. So, this makes behavior more strange. I.e.
readdir()returns beyond 0, butlookup()can't find it?
Yes, Good point. I will check other places included readdir. Thanks for review!
Quoted 5 lines
Thanks.
--
OGAWA Hirofumi <[email protected]>