From: Nathan Fontenot <nfont@austin.ibm.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Store sysfs dirent structs in rbtree
Date: Thu, 24 Jun 2010 20:58:57 -0500 [thread overview]
Message-ID: <4C240D61.4000006@austin.ibm.com> (raw)
In-Reply-To: <20100624200424.0a7d3a57@gondolin>
On 06/24/2010 01:04 PM, Cornelia Huck wrote:
> On Wed, 23 Jun 2010 21:56:04 -0500,
> Nathan Fontenot <nfont@austin.ibm.com> wrote:
>
>> +static void sysfs_dirent_insert(struct sysfs_dirent *sd)
>> +{
>> + struct sysfs_dirent *parent_sd = sd->s_parent;
>> + struct sysfs_dirent *d;
>> + struct rb_node **p = &parent_sd->s_dir.rb_root.rb_node;
>> + struct rb_node *parent = NULL;
>> +
>> + while (*p) {
>> + int cmp_val;
>> + parent = *p;
>> + d = to_sysfs_dirent(parent);
>> +
>> + cmp_val = strcmp(d->s_name, sd->s_name);
>> + if (cmp_val < 0)
>> + p = &parent->rb_left;
>> + if (cmp_val > 0)
>> + p = &parent->rb_right;
>> + }
>> +
>> + rb_link_node(&sd->s_dir.rb_node, parent, p);
>> + rb_insert_color(&sd->s_dir.rb_node, &parent_sd->s_dir.rb_root);
>> +}
>
> This will run into trouble if you have duplicate names in different
> namespaces. You won't see it with your patch though, since...
>
>> @@ -536,14 +572,24 @@
>> const void *ns,
>> const unsigned char *name)
>> {
>> - struct sysfs_dirent *sd;
>> -
>> - for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) {
>> - if (ns && sd->s_ns && (sd->s_ns != ns))
>> - continue;
>> - if (!strcmp(sd->s_name, name))
>> - return sd;
>> + struct sysfs_dirent *d;
>> + struct rb_node **p = &parent_sd->s_dir.rb_root.rb_node;
>> + struct rb_node *parent = NULL;
>> +
>> + while (*p) {
>> + int cmp_val;
>> + parent = *p;
>> + d = to_sysfs_dirent(parent);
>> +
>> + cmp_val = strcmp(d->s_name, name);
>> + if (cmp_val == 0)
>> + return d;
>> + else if (cmp_val < 0)
>> + p = &parent->rb_left;
>> + else /* (cmp_val > 0) */
>> + p = &parent->rb_right;
>> }
>> +
>> return NULL;
>> }
>
> ...you removed the namespace check down here.
Yep, I missed namespaces completely with this patch. I'll try again.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2010-06-25 1:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 2:56 [PATCH] Store sysfs dirent structs in rbtree Nathan Fontenot
2010-06-24 18:04 ` Cornelia Huck
2010-06-25 1:58 ` Nathan Fontenot [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=4C240D61.4000006@austin.ibm.com \
--to=nfont@austin.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox