Skip to contentSkip to conversation

fat: eliminate iterations in fat_search_long in case of EOD

PATCH Superseded Namjae Jeon 2 participants 5 messages Jan 19, 2013 – Jan 21, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 58bf744..cde0e69 100644
@@ -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
maintainer
#1 lore raw
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_pos still works fine after this change?

Quoted 23 lines
---
 fs/fat/dir.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/dir.c +2 -2
index 58bf744..cde0e69 100644
@@ -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]>
#2 lore raw

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_pos still 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
---
 fs/fat/dir.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/dir.c +0 -0
index 58bf744..cde0e69 100644
@@ -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 -2
 			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);

--
OGAWA Hirofumi <[email protected]>

maintainer
#3 lore raw
Quoted 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_pos still 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.

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]>
#4 lore raw

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_pos still 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.

Ah, I see. Only ->lookup. So, this makes behavior more strange. I.e. readdir() returns beyond 0, but lookup() 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]>