Skip to contentSkip to conversation

f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number

PATCH In review Namjae Jeon 2 participants 3 messages Dec 11, 2012 – Dec 12, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number

From: Namjae Jeon <[email protected]>

Test Case:
[NFS Client]
ls -lR .

[NFS Server]
while [ 1 ]
do
echo 3 > /proc/sys/vm/drop_caches
done

Error on NFS Client: "No such file or directory"

When cache is dropped at the server, it results in lookup failure at the NFS client due to non-connection with the parent. The default path is it initiates a lookup by calculating the hash value for the name, even though the hash values stored on the disk for "." and ".." is maintained as zero, which results in failure from find_in_block due to not matching HASH values. Fix up, by using the correct hashing values for these entries and then initiating lookup request.

---
 fs/f2fs/dir.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/dir.c +3 -2
index b4e24f3..6cf39db 100644
@@ -184,7 +184,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
 	int namelen = child->len;
 	unsigned long npages = dir_blocks(dir);
 	struct f2fs_dir_entry *de = NULL;
-	f2fs_hash_t name_hash;
+	f2fs_hash_t name_hash = 0;
 	unsigned int max_depth;
 	unsigned int level;
 
@@ -193,7 +193,8 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
 
 	*res_page = NULL;
 
-	name_hash = f2fs_dentry_hash(name, namelen);
+	if (strcmp(name, ".") && (strcmp(name, "..")))
+		name_hash = f2fs_dentry_hash(name, namelen);
 	max_depth = F2FS_I(dir)->i_current_depth;
 
 	for (level = 0; level < max_depth; level++) {
Signature · 1 line
1.7.9.5
#1 lore raw

2012-12-12 (수), 00:10 +0900, Namjae Jeon:

Quoted 42 lines

From: Namjae Jeon <[email protected]>

Test Case:
[NFS Client]
ls -lR .

[NFS Server]
while [ 1 ]
do
echo 3 > /proc/sys/vm/drop_caches
done

Error on NFS Client: "No such file or directory"

When cache is dropped at the server, it results in lookup failure at the NFS client due to non-connection with the parent. The default path is it initiates a lookup by calculating the hash value for the name, even though the hash values stored on the disk for "." and ".." is maintained as zero, which results in failure from find_in_block due to not matching HASH values. Fix up, by using the correct hashing values for these entries and then initiating lookup request.

---
 fs/f2fs/dir.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/dir.c +1 -1
index b4e24f3..6cf39db 100644
@@ -184,7 +184,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
 	int namelen = child->len;
 	unsigned long npages = dir_blocks(dir);
 	struct f2fs_dir_entry *de = NULL;
-	f2fs_hash_t name_hash;
+	f2fs_hash_t name_hash = 0;
 	unsigned int max_depth;
 	unsigned int level;
 

fs/f2fs/dir.c struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, · line 197

Quoted 6 lines
fs/f2fs/dir.c +2 -1
@@ -193,7 +193,8 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
 
 	*res_page = NULL;
 
-	name_hash = f2fs_dentry_hash(name, namelen);
+	if (strcmp(name, ".") && (strcmp(name, "..")))
+		name_hash = f2fs_dentry_hash(name, namelen);

Got it.
For code consistency, could you rewrite the patch like below? Thanks,

fs/f2fs/dir.c +0 -0
index b4e24f3..e1f66df 100644
@@ -540,13 +540,13 @@ int f2fs_make_empty(struct inode *inode, struct

inode *parent)

de = &dentry_blk->dentry[0];
de->name_len = cpu_to_le16(1);
- de->hash_code = 0;
+ de->hash_code = f2fs_dentry_hash(".", 1);
de->ino = cpu_to_le32(inode->i_ino);
memcpy(dentry_blk->filename[0], ".", 1);
set_de_type(de, inode);

de = &dentry_blk->dentry[1];
- de->hash_code = 0;
+ de->hash_code = f2fs_dentry_hash("..", 2);
de->name_len = cpu_to_le16(2);
de->ino = cpu_to_le32(parent->i_ino);
memcpy(dentry_blk->filename[1], "..", 2);

fs/f2fs/hash.c +0 -0
index a60f042..30ca4a2 100644
@@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int

len)
const char *p;
__u32 in[8], buf[4];

+ /* dot and dotdot dentries should have zero-value hash code */
+ if (!memcmp(name, ".", 1) || !memcmp(name, "..", 2))
+ return 0;
+
/* Initialize the default seed for the hash checksum functions */ buf[0] = 0x67452301;
buf[1] = 0xefcdab89;

Signature · 7 lines
1.8.0.1.250.gb7973fb



-- 
Jaegeuk Kim
Samsung
#2 lore raw

2012/12/12, Jaegeuk Kim <[email protected]>:

Quoted 51 lines

2012-12-12 (수), 00:10 +0900, Namjae Jeon:

Quoted 50 lines

From: Namjae Jeon <[email protected]>

Test Case:
[NFS Client]
ls -lR .

[NFS Server]
while [ 1 ]
do
echo 3 > /proc/sys/vm/drop_caches
done

Error on NFS Client: "No such file or directory"

When cache is dropped at the server, it results in lookup failure at the NFS client due to non-connection with the parent. The default path is it initiates a lookup by calculating the hash value for the name, even though
the hash values stored on the disk for "." and ".." is maintained as zero,
which results in failure from find_in_block due to not matching HASH values.
Fix up, by using the correct hashing values for these entries and then initiating lookup request.

---
 fs/f2fs/dir.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/dir.c +1 -1
index b4e24f3..6cf39db 100644
@@ -184,7 +184,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode
 *dir,
 	int namelen = child->len;
 	unsigned long npages = dir_blocks(dir);
 	struct f2fs_dir_entry *de = NULL;
-	f2fs_hash_t name_hash;
+	f2fs_hash_t name_hash = 0;
 	unsigned int max_depth;
 	unsigned int level;
@@ -193,7 +193,8 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode
 *dir,
 
 	*res_page = NULL;
 
Quoted 7 lines

fs/f2fs/dir.c struct f2fs_dir_entry *f2fs_find_entry(struct inode · line 198

Quoted 3 lines
fs/f2fs/dir.c +2 -1
-	name_hash = f2fs_dentry_hash(name, namelen);
+	if (strcmp(name, ".") && (strcmp(name, "..")))
+		name_hash = f2fs_dentry_hash(name, namelen);

Got it.
For code consistency, could you rewrite the patch like below? Thanks,

Sure, I will resend the patch at tonight.
Thanks!

Quoted 43 lines
fs/f2fs/dir.c +2 -2
index b4e24f3..e1f66df 100644
@@ -540,13 +540,13 @@ int f2fs_make_empty(struct inode *inode, struct
 inode *parent)
 
 	de = &dentry_blk->dentry[0];
 	de->name_len = cpu_to_le16(1);
-	de->hash_code = 0;
+	de->hash_code = f2fs_dentry_hash(".", 1);
 	de->ino = cpu_to_le32(inode->i_ino);
 	memcpy(dentry_blk->filename[0], ".", 1);
 	set_de_type(de, inode);
 
 	de = &dentry_blk->dentry[1];
-	de->hash_code = 0;
+	de->hash_code = f2fs_dentry_hash("..", 2);
 	de->name_len = cpu_to_le16(2);
 	de->ino = cpu_to_le32(parent->i_ino);
fs/f2fs/dir.c +0 -0
 	memcpy(dentry_blk->filename[1], "..", 2);
fs/f2fs/hash.c +4 -0
index a60f042..30ca4a2 100644
@@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int
 len)
 	const char *p;
 	__u32 in[8], buf[4];
 
+	/* dot and dotdot dentries should have zero-value hash code */
+	if (!memcmp(name, ".", 1) || !memcmp(name, "..", 2))
+		return 0;
+
 	/* Initialize the default seed for the hash checksum functions */
 	buf[0] = 0x67452301;

buf[1] = 0xefcdab89;
--
1.8.0.1.250.gb7973fb

Quoted 4 lines

--
Jaegeuk Kim
Samsung

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html