From: Matt Mackall <mpm@selenic.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH,RFC] ext3: Add support for non-native signed/unsigned htree hash algorithms
Date: Wed, 22 Oct 2008 11:30:08 -0500 [thread overview]
Message-ID: <1224693008.4323.134.camel@calx> (raw)
In-Reply-To: <1224560624-9691-2-git-send-email-tytso@mit.edu>
On Mon, 2008-10-20 at 23:43 -0400, Theodore Ts'o wrote:
> The original ext3 hash algorithms assumed that variables of type char
> were signed, as God and K&R intended. Unfortunately, this assumption
> is not true on some architectures. Userspace support for marking
> filesystems with non-native signed/unsigned chars was added two years
> ago, but the kernel-side support was never added (until now).
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> Cc: akpm@linux-foundation.org
> Cc: linux-kernel@vger.kernel.org
> ---
> fs/ext3/hash.c | 42 +++++++++++++++++++++++++++++++++---------
> fs/ext3/namei.c | 7 +++++++
> fs/ext3/super.c | 15 +++++++++++++++
> include/linux/ext3_fs.h | 28 +++++++++++++++++++++++++++-
> include/linux/ext3_fs_sb.h | 1 +
> 5 files changed, 83 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ext3/hash.c b/fs/ext3/hash.c
> index c30e149..855eacb 100644
> --- a/fs/ext3/hash.c
> +++ b/fs/ext3/hash.c
> @@ -35,11 +35,20 @@ static void TEA_transform(__u32 buf[4], __u32 const in[])
>
>
> /* The old legacy hash */
> -static __u32 dx_hack_hash (const char *name, int len)
> +static __u32 dx_hack_hash (const char *name, int len, int unsigned_flag)
> {
> - __u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
> + __u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
> + const unsigned char *ucp = (const unsigned char *) name;
> + const signed char *scp = (const signed char *) name;
> + int c;
> +
> while (len--) {
> - __u32 hash = hash1 + (hash0 ^ (*name++ * 7152373));
> + if (unsigned_flag)
> + c = (int) *ucp++;
> + else
> + c = (int) *scp++;
Branch in the inner loop? Space after typecast?
> for (i=0; i < len; i++) {
> if ((i % 4) == 0)
> val = pad;
> - val = msg[i] + (val << 8);
> + if (unsigned_flag)
> + c = (int) ucp[i];
> + else
> + c = (int) scp[i];
> +
> + val = c + (val << 8);
And here.
--
Mathematics is the supreme nostalgia of our time.
next prev parent reply other threads:[~2008-10-22 18:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-21 3:43 [PATCH,RFC] ext4: Add support for non-native signed/unsigned htree hash algorithms Theodore Ts'o
2008-10-21 3:43 ` [PATCH,RFC] ext3: " Theodore Ts'o
2008-10-21 7:16 ` Daniel Phillips
2008-10-21 21:50 ` Daniel Phillips
2008-10-21 21:53 ` Daniel Phillips
2008-10-22 16:30 ` Matt Mackall [this message]
2008-10-23 0:22 ` Andrew Morton
2008-10-23 2:56 ` Theodore Tso
2008-10-23 19:26 ` Andreas Dilger
2008-10-24 18:25 ` Jeremy Fitzhardinge
2008-10-28 14:24 ` Theodore Tso
2008-10-28 17:30 ` tony.luck
2008-11-03 7:33 ` Olaf Weber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1224693008.4323.134.camel@calx \
--to=mpm@selenic.com \
--cc=akpm@linux-foundation.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.