From: Tao Ma <tao.ma@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 3/3] ocfs2/xattr: Proper hash collision handle in bucket division.v2
Date: Fri, 24 Oct 2008 17:29:56 +0800 [thread overview]
Message-ID: <49019594.5060304@oracle.com> (raw)
In-Reply-To: <20081024091559.GF31082@ca-server1.us.oracle.com>
Joel Becker wrote:
> On Fri, Oct 24, 2008 at 05:02:28PM +0800, Tao Ma wrote:
>>
>> Joel Becker wrote:
>>> On Fri, Oct 24, 2008 at 12:43:53AM -0700, Joel Becker wrote:
>>>> On Fri, Oct 24, 2008 at 02:15:35PM +0800, Tao Ma wrote:
>>>>> Joel Becker wrote:
>>>>>> I have an idea to do what you're doing, but cleaner. I'll look
>>>>>> at cmp_xe and try again in the morning.
>>>>> cool, so waiting for your perfect code. ;)
>>>> Zing! You got me :-)
>>> How's this (untested)?
>>> /*
>>> * If this ocfs2_xattr_header covers more than one hash value, find a
>>> * place where the hash value changes. Try to find the most even split.
>>> * The most common case is that all entries have different hash values,
>>> * and the first check we make will find a place to split.
>>> */
>>> static int ocfs2_xattr_find_divide_pos(struct ocfs2_xattr_header *xh)
>>> {
>>> struct ocfs2_xattr_entry *entries = &xh->xh_entries;
>>> int count = le16_to_cpu(xh->xh_count);
>>> int delta, middle = count / 2;
>>> /* * We start at the middle. Each step gets farther away in both
>>> * directions. We therefore hit the change in hash value
>>> * nearest to the middle. Note that this loop does not execute for
>>> * count < 2.
>>> */
>>> for (delta = 0; delta < middle; delta++) {
>>> /* Let's check delta earlier than middle */
>>> if (!cmp_ex(&entries[middle - delta - 1], &entries[middle -
>>> delta]))
>>> return middle - delta;
>>> /* For even counts, don't walk off the end */
>>> if ((middle + delta + 1) == count)
>>> continue;
>>> /* Now try delta past middle */
>>> if (!cmp_ex(&entries[middle + delta],
>>> &entries[middle + delta + 1]))
>>> return middle + delta + 1;
>>> }
>>> /* Every entry had the same hash */
>>> return count;
>>> }
>> yeah, this looks perfect and more efficient.
>> I will modify my patch and then test it.
>
> Haha, it has a bug! Those cmp_ex() calls should not have the
> '!' in front of them. We're looking for differences, not matches. Take
> out those '!'s.
>
> Joel (sorry about the bug)
Never mind. I will just use your idea and test it. So don't worry about
any bug. I will handle it. :)
Regards,
Tao
prev parent reply other threads:[~2008-10-24 9:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-17 4:40 [Ocfs2-devel] [PATCH 0/3] ocfs2/xattr: xattr improvement Tao Ma
2008-10-17 4:44 ` [Ocfs2-devel] [PATCH 1/3] ocfs2/xattr: Remove unused restore_extent_block Tao Ma
2008-10-17 4:44 ` [Ocfs2-devel] [PATCH 2/3] ocfs2/xattr: Merge xattr set transaction Tao Ma
2008-10-23 21:40 ` Joel Becker
2008-10-24 0:44 ` Tao Ma
2008-10-24 1:09 ` Joel Becker
2008-10-24 1:17 ` Tao Ma
2008-10-24 5:59 ` Joel Becker
2008-10-17 4:44 ` [Ocfs2-devel] [PATCH 3/3] ocfs2/xattr: Proper hash collision handle in bucket division Tao Ma
2008-10-17 0:54 ` [Ocfs2-devel] [PATCH 3/3] ocfs2/xattr: Proper hash collision handle in bucket division.v2 Tao Ma
2008-10-23 23:20 ` Joel Becker
2008-10-24 0:52 ` Tao Ma
2008-10-24 1:14 ` Joel Becker
2008-10-24 1:28 ` Tao Ma
2008-10-24 6:02 ` Joel Becker
2008-10-24 6:15 ` Tao Ma
2008-10-24 7:43 ` Joel Becker
2008-10-24 8:47 ` Joel Becker
2008-10-24 9:02 ` Tao Ma
2008-10-24 9:15 ` Joel Becker
2008-10-24 9:29 ` Tao Ma [this message]
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=49019594.5060304@oracle.com \
--to=tao.ma@oracle.com \
--cc=ocfs2-devel@oss.oracle.com \
/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.