Re: Regression introduced bybfcfaa77bdf0f775263e906015982a608df01c76 (vfs: use 'unsigned long' accessesfor dcache name comparison and hashing)

From: Al Viro
Date: Thu Mar 22 2012 - 17:59:54 EST


On Thu, Mar 22, 2012 at 02:54:37PM -0700, Linus Torvalds wrote:
> On Thu, Mar 22, 2012 at 2:41 PM, Konrad Rzeszutek Wilk
> <konrad.wilk@xxxxxxxxxx> wrote:
> >
> > Works for me! Thanks for coming up with a patch so quickly. Please add
> >
> > Reported-and-Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
>
> Goodie. Al, I can commit it as yours, but I'd want a sign-off and a
> commit message for that. Otherwise I'll take credit..

Hmm... How about

Fix full_name_hash() behaviour when length is a multiple of 8

We want it to match what hash_name() is doing, which means extra
multiply by 9 in this case...

Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
diff --git a/fs/namei.c b/fs/namei.c
index 13e6a1f..7451d6f8 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1439,10 +1439,10 @@ unsigned int full_name_hash(const unsigned char *name, unsigned int len)

for (;;) {
a = *(unsigned long *)name;
- hash *= 9;
if (len < sizeof(unsigned long))
break;
hash += a;
+ hash *= 9;
name += sizeof(unsigned long);
len -= sizeof(unsigned long);
if (!len)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/