From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jaegeuk Kim Subject: Re: [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number Date: Fri, 14 Dec 2012 13:55:21 +0900 Message-ID: <1355460921.16178.21.camel@kjgkr> References: <1355409851-6389-1-git-send-email-linkinjeon@gmail.com> Reply-To: jaegeuk.kim@samsung.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-MRrfI8yc+qzD8WurtLEr" Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Namjae Jeon , Amit Sahrawat To: Namjae Jeon Return-path: In-reply-to: <1355409851-6389-1-git-send-email-linkinjeon@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org --=-MRrfI8yc+qzD8WurtLEr Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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]; > =20 > + if ((len <=3D 2) && (name[0] =3D=3D '.') && > + (name[1] =3D=3D '.' || name[1] =3D=3D '\0')) > + return 0; If len =3D=3D 1, we should avoid referencing name[1]. Likewise VFS does, I rewrote that like below. if (name[0] =3D=3D '.') { switch (len) { case 1: return 0; case 2: if (name[1] =3D=3D '.') return 0; } } So, how about this patch? =46rom 391d584afadfb177584a3a3e4a7ec97e1a674457 Mon Sep 17 00:00:00 2001 From: Namjae Jeon 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 Signed-off-by: Amit Sahrawat Signed-off-by: Jaegeuk Kim --- 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) =20 de =3D &dentry_blk->dentry[0]; de->name_len =3D cpu_to_le16(1); - de->hash_code =3D 0; + de->hash_code =3D f2fs_dentry_hash(".", 1); de->ino =3D cpu_to_le32(inode->i_ino); memcpy(dentry_blk->filename[0], ".", 1); set_de_type(de, inode); =20 de =3D &dentry_blk->dentry[1]; - de->hash_code =3D 0; + de->hash_code =3D f2fs_dentry_hash("..", 2); de->name_len =3D cpu_to_le16(2); de->ino =3D 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]; =20 + if (name[0] =3D=3D '.') { + switch (len) { + case 1: + return 0; + case 2: + if (name[1] =3D=3D '.') + return 0; + } + } + /* Initialize the default seed for the hash checksum functions */ buf[0] =3D 0x67452301; buf[1] =3D 0xefcdab89; --=20 1.8.0.1.250.gb7973fb --=20 Jaegeuk Kim Samsung --=-MRrfI8yc+qzD8WurtLEr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJQyrE5AAoJEEAUqH6CSFDSD1AP/2glo+T9RdWpgbhyQcP3Nc/F /oWN4SRtNFvHgOmRgyVvGTeMVtEIL5HZk1Hc+0NWvfIBHkGQPSvpt3mHeYbFaS28 vV/0xihI5IgV8KR2S/mIZVy55GaqZ89qkATvkxSkscn+0o7LeSd2uS88H0LG5D7a Yt4H5su0TUz5uVbL+SiE5Lb/XvSFn9DB5AQn3/ObbNihEHuHeJJ8CoPO4Bz9YMuk MwdWQqSBEvRRLzz1b0rGSrMzBVlhYidNsrUJwoCgdM6SYEK0BS6SNLOMDoMUJ7j5 TnJMppHgE3lhYcrmJt914iXiU+ynjc9VEKVtnhnzVDVccE082B4h6WmYbqDWEylc wkBr1q7+vNVXIRPdlPaupfp/kAmEnfxWwQj359X3KMgmCtsw7xQbtUFSBwrCt4GS 6c+0CydgEuRE3hqT23+8rpM5XTSgc7SAEzznTQuKo8mOM12cHHV9gWngnvOjcvfU fK+QkMV3d1VBrGOOd0Ok0bBng/Fq6B38/AHfo6MiKHrcJoTM+TaZD3gVrgg/IKto D6M6i7f6M6ahCz6cPU8PYSdgKFbzZERMNApYVzogcfxTn44B9gV0izmtlOnB+k/R MUBaJh3shF3PTNDBQ8orZrGK6YTppp28cxUqioCLzdu0Z8GXOQLfYNdPfTULJ9vI 61btVtKqtpBKsOAN1v9p =q8lX -----END PGP SIGNATURE----- --=-MRrfI8yc+qzD8WurtLEr--