linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
@ 2012-12-13 14:44 Namjae Jeon
  2012-12-13 23:09 ` [f2fs-dev] " 이창만
  2012-12-14  4:55 ` Jaegeuk Kim
  0 siblings, 2 replies; 6+ messages in thread
From: Namjae Jeon @ 2012-12-13 14:44 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, Namjae Jeon,
	Namjae Jeon, Amit Sahrawat

From: Namjae Jeon <namjae.jeon@samsung.com>

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.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
---
 fs/f2fs/dir.c  |    4 ++--
 fs/f2fs/hash.c |    4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index b4e24f3..a158406 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -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);
diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
index a60f042..5e48bac 100644
--- a/fs/f2fs/hash.c
+++ b/fs/f2fs/hash.c
@@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len)
 	const char *p;
 	__u32 in[8], buf[4];
 
+	if ((len <= 2) && (name[0] == '.') &&
+		(name[1] == '.' || name[1] == '\0'))
+		return 0;
+
 	/* Initialize the default seed for the hash checksum functions */
 	buf[0] = 0x67452301;
 	buf[1] = 0xefcdab89;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [f2fs-dev] [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
  2012-12-13 14:44 [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number Namjae Jeon
@ 2012-12-13 23:09 ` 이창만
  2012-12-13 23:17   ` 이창만
  2012-12-14  4:55 ` Jaegeuk Kim
  1 sibling, 1 reply; 6+ messages in thread
From: 이창만 @ 2012-12-13 23:09 UTC (permalink / raw)
  To: 'Namjae Jeon', jaegeuk.kim
  Cc: 'Amit Sahrawat', 'Namjae Jeon',
	linux-kernel, linux-f2fs-devel, linux-fsdevel



> -----Original Message-----
> From: Namjae Jeon [mailto:linkinjeon@gmail.com]
> Sent: Thursday, December 13, 2012 11:44 PM
> To: jaegeuk.kim@samsung.com
> Cc: Namjae Jeon; Amit Sahrawat; Namjae Jeon; linux-kernel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net; linux-fsdevel@vger.kernel.org
> Subject: [f2fs-dev] [PATCH v2] f2fs: fix up f2fs_get_parent issue to
> retrieve correct parent inode number
> 
> From: Namjae Jeon <namjae.jeon@samsung.com>
> 
> 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.
> 
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> ---
>  fs/f2fs/dir.c  |    4 ++--
>  fs/f2fs/hash.c |    4 ++++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index b4e24f3..a158406 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -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);
> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
> index a60f042..5e48bac 100644
> --- a/fs/f2fs/hash.c
> +++ b/fs/f2fs/hash.c
> @@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len)
>  	const char *p;
>  	__u32 in[8], buf[4];
> 
> +	if ((len <= 2) && (name[0] == '.') &&
> +		(name[1] == '.' || name[1] == '\0'))
> +		return 0;
> +

How about this?
if (!memcmp(name, ".", len) || !memcmp(name, "..", len))
	return 0;


>  	/* Initialize the default seed for the hash checksum functions */
>  	buf[0] = 0x67452301;
>  	buf[1] = 0xefcdab89;
> --
> 1.7.9.5
> 
> 
> ---------------------------------------------------------------------------
> ---
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [f2fs-dev] [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
  2012-12-13 23:09 ` [f2fs-dev] " 이창만
@ 2012-12-13 23:17   ` 이창만
  0 siblings, 0 replies; 6+ messages in thread
From: 이창만 @ 2012-12-13 23:17 UTC (permalink / raw)
  To: '이창만', 'Namjae Jeon', jaegeuk.kim
  Cc: 'Namjae Jeon', linux-fsdevel, 'Amit Sahrawat',
	linux-kernel, linux-f2fs-devel

Sorry, I've missed too. Forget this, please.

> -----Original Message-----
> From: 이창만 [mailto:cm224.lee@samsung.com]
> Sent: Friday, December 14, 2012 8:09 AM
> To: 'Namjae Jeon'; jaegeuk.kim@samsung.com
> Cc: 'Namjae Jeon'; linux-fsdevel@vger.kernel.org; 'Amit Sahrawat'; linux-
> kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH v2] f2fs: fix up f2fs_get_parent issue to
> retrieve correct parent inode number
> 
> 
> 
> > -----Original Message-----
> > From: Namjae Jeon [mailto:linkinjeon@gmail.com]
> > Sent: Thursday, December 13, 2012 11:44 PM
> > To: jaegeuk.kim@samsung.com
> > Cc: Namjae Jeon; Amit Sahrawat; Namjae Jeon; linux-kernel@vger.kernel.org;
> > linux-f2fs-devel@lists.sourceforge.net; linux-fsdevel@vger.kernel.org
> > Subject: [f2fs-dev] [PATCH v2] f2fs: fix up f2fs_get_parent issue to
> > retrieve correct parent inode number
> >
> > From: Namjae Jeon <namjae.jeon@samsung.com>
> >
> > 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.
> >
> > Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> > Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
> > Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> > ---
> >  fs/f2fs/dir.c  |    4 ++--
> >  fs/f2fs/hash.c |    4 ++++
> >  2 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> > index b4e24f3..a158406 100644
> > --- a/fs/f2fs/dir.c
> > +++ b/fs/f2fs/dir.c
> > @@ -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);
> > diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
> > index a60f042..5e48bac 100644
> > --- a/fs/f2fs/hash.c
> > +++ b/fs/f2fs/hash.c
> > @@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len)
> >  	const char *p;
> >  	__u32 in[8], buf[4];
> >
> > +	if ((len <= 2) && (name[0] == '.') &&
> > +		(name[1] == '.' || name[1] == '\0'))
> > +		return 0;
> > +
> 
> How about this?
> if (!memcmp(name, ".", len) || !memcmp(name, "..", len))
> 	return 0;
> 
> 
> >  	/* Initialize the default seed for the hash checksum functions */
> >  	buf[0] = 0x67452301;
> >  	buf[1] = 0xefcdab89;
> > --
> > 1.7.9.5
> >
> >
> > -------------------------------------------------------------------------
> --
> > ---
> > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> > Remotely access PCs and mobile devices and provide instant support
> > Improve your efficiency, and focus on delivering more value-add services
> > Discover what IT Professionals Know. Rescue delivers
> > http://p.sf.net/sfu/logmein_12329d2d
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 
> 
> ---------------------------------------------------------------------------
> ---
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
  2012-12-13 14:44 [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number Namjae Jeon
  2012-12-13 23:09 ` [f2fs-dev] " 이창만
@ 2012-12-14  4:55 ` Jaegeuk Kim
  2012-12-14  5:41   ` Namjae Jeon
  1 sibling, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2012-12-14  4:55 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, Namjae Jeon,
	Amit Sahrawat

[-- Attachment #1: Type: text/plain, Size: 3001 bytes --]

Hi,

> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
> index a60f042..5e48bac 100644
> --- a/fs/f2fs/hash.c
> +++ b/fs/f2fs/hash.c
> @@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len)
>  	const char *p;
>  	__u32 in[8], buf[4];
>  
> +	if ((len <= 2) && (name[0] == '.') &&
> +		(name[1] == '.' || name[1] == '\0'))
> +		return 0;

If len == 1, we should avoid referencing name[1].
Likewise VFS does, I rewrote that like below.

	if (name[0] == '.') {
		switch (len) {
		case 1:
			return 0;
		case 2:
			if (name[1] == '.')
				return 0;
		}
	}

So, how about this patch?

From 391d584afadfb177584a3a3e4a7ec97e1a674457 Mon Sep 17 00:00:00 2001
From: Namjae Jeon <namjae.jeon@samsung.com>
Date: Thu, 13 Dec 2012 23:44:11 +0900
Subject: [PATCH] f2fs: fix up f2fs_get_parent issue to retrieve correct
parent
 inode number

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.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
---
 fs/f2fs/dir.c  |  4 ++--
 fs/f2fs/hash.c | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index b4e24f3..e1f66df 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -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);
diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
index a60f042..9d7a7c6 100644
--- a/fs/f2fs/hash.c
+++ b/fs/f2fs/hash.c
@@ -76,6 +76,16 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int
len)
 	const char *p;
 	__u32 in[8], buf[4];
 
+	if (name[0] == '.') {
+		switch (len) {
+		case 1:
+			return 0;
+		case 2:
+			if (name[1] == '.')
+				return 0;
+		}
+	}
+
 	/* Initialize the default seed for the hash checksum functions */
 	buf[0] = 0x67452301;
 	buf[1] = 0xefcdab89;
-- 
1.8.0.1.250.gb7973fb

-- 
Jaegeuk Kim
Samsung

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
  2012-12-14  4:55 ` Jaegeuk Kim
@ 2012-12-14  5:41   ` Namjae Jeon
  2012-12-14  6:42     ` Jaegeuk Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Namjae Jeon @ 2012-12-14  5:41 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, Namjae Jeon,
	Amit Sahrawat

2012/12/14, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> Hi,
>
>> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
>> index a60f042..5e48bac 100644
>> --- a/fs/f2fs/hash.c
>> +++ b/fs/f2fs/hash.c
>> @@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int
>> len)
>>  	const char *p;
>>  	__u32 in[8], buf[4];
>>
>> +	if ((len <= 2) && (name[0] == '.') &&
>> +		(name[1] == '.' || name[1] == '\0'))
>> +		return 0;
>
> If len == 1, we should avoid referencing name[1].
> Likewise VFS does, I rewrote that like below.
>
> 	if (name[0] == '.') {
> 		switch (len) {
> 		case 1:
> 			return 0;
> 		case 2:
> 			if (name[1] == '.')
> 				return 0;
> 		}
> 	}
>
> So, how about this patch?

I think that there is no issue on current patch. Since, the strings
are always expected to be NULL terminated.

"." should include '\0', So we can distingsh by checking only name[0], name[1].

When we do:
char *ptr="hello"; -> it will always be NULL terminated -> "hello" in
memory followed by '\0';
when we reserver space
char ptr[5];-> We need to reserver space for '\0' at the end.

Also, even if we donot encounter NULL at the end.
there should be no problem referencing the memory, it is just we can
get garbage value from that refrencing.

May be I am not able to think the code path which will cause the problem.
Is it possible that "." is not null termindated ?

Otherwise, in my opinion - we can retain the suggested changes, there
is no need to introducing switch case, even
though technically there is no issues in the code you suggested also.

So, final decision is yours.

Thanks.

>
> From 391d584afadfb177584a3a3e4a7ec97e1a674457 Mon Sep 17 00:00:00 2001
> From: Namjae Jeon <namjae.jeon@samsung.com>
> Date: Thu, 13 Dec 2012 23:44:11 +0900
> Subject: [PATCH] f2fs: fix up f2fs_get_parent issue to retrieve correct
> parent
>  inode number
>
> 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.
>
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> ---
>  fs/f2fs/dir.c  |  4 ++--
>  fs/f2fs/hash.c | 10 ++++++++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index b4e24f3..e1f66df 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -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);
> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
> index a60f042..9d7a7c6 100644
> --- a/fs/f2fs/hash.c
> +++ b/fs/f2fs/hash.c
> @@ -76,6 +76,16 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int
> len)
>  	const char *p;
>  	__u32 in[8], buf[4];
>
> +	if (name[0] == '.') {
> +		switch (len) {
> +		case 1:
> +			return 0;
> +		case 2:
> +			if (name[1] == '.')
> +				return 0;
> +		}
> +	}
> +
>  	/* Initialize the default seed for the hash checksum functions */
>  	buf[0] = 0x67452301;
>  	buf[1] = 0xefcdab89;
> --
> 1.8.0.1.250.gb7973fb
>
> --
> Jaegeuk Kim
> Samsung
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
  2012-12-14  5:41   ` Namjae Jeon
@ 2012-12-14  6:42     ` Jaegeuk Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2012-12-14  6:42 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, Namjae Jeon,
	Amit Sahrawat

[-- Attachment #1: Type: text/plain, Size: 1565 bytes --]

2012-12-14 (금), 14:41 +0900, Namjae Jeon:
> 2012/12/14, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> > Hi,
> >
> >> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
> >> index a60f042..5e48bac 100644
> >> --- a/fs/f2fs/hash.c
> >> +++ b/fs/f2fs/hash.c
> >> @@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int
> >> len)
> >>  	const char *p;
> >>  	__u32 in[8], buf[4];
> >>
> >> +	if ((len <= 2) && (name[0] == '.') &&
> >> +		(name[1] == '.' || name[1] == '\0'))
> >> +		return 0;
> >
> > If len == 1, we should avoid referencing name[1].
> > Likewise VFS does, I rewrote that like below.
> >
> > 	if (name[0] == '.') {
> > 		switch (len) {
> > 		case 1:
> > 			return 0;
> > 		case 2:
> > 			if (name[1] == '.')
> > 				return 0;
> > 		}
> > 	}
> >
> > So, how about this patch?
> 
> I think that there is no issue on current patch. Since, the strings
> are always expected to be NULL terminated.
> 
> "." should include '\0', So we can distingsh by checking only name[0], name[1].
> 
> When we do:
> char *ptr="hello"; -> it will always be NULL terminated -> "hello" in
> memory followed by '\0';
> when we reserver space
> char ptr[5];-> We need to reserver space for '\0' at the end.

Got it.
I found that NULL is added to the dentry->d_name as follows.

In __d_alloc(),
        dentry->d_name.len = name->len;
        dentry->d_name.hash = name->hash;
        memcpy(dname, name->name, name->len);
        dname[name->len] = 0; 

I'll merge your patch. :)
Thanks,

-- 
Jaegeuk Kim
Samsung

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-12-14  6:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 14:44 [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number Namjae Jeon
2012-12-13 23:09 ` [f2fs-dev] " 이창만
2012-12-13 23:17   ` 이창만
2012-12-14  4:55 ` Jaegeuk Kim
2012-12-14  5:41   ` Namjae Jeon
2012-12-14  6:42     ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).