All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Shirish Pargaonkar
	<shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/2] cifs: Invoke id mapping functions
Date: Wed, 2 Feb 2011 11:00:47 -0500	[thread overview]
Message-ID: <20110202110047.4a3e2b26@corrin.poochiereds.net> (raw)
In-Reply-To: <AANLkTim9EEC7P8z1xNB176N+R++N7OSBE4GKAbtzg795-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Wed, 2 Feb 2011 09:40:36 -0600
Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> +
> > +static void
> > +id_rb_insert(struct rb_root *root, struct cifs_sid_id *new_sididptr,
> > +               unsigned long id)
> > +{
> > +       int rc;
> > +       struct rb_node **new = &(root->rb_node), *parent = NULL;
> > +       struct cifs_sid_id *sididptr;
> > +
> > +       while (*new) {
> > +               sididptr = rb_entry(*new, struct cifs_sid_id, rbnode);
> > +               parent = *new;
> > +
> > +               rc = compare_sids(&sididptr->sid, &new_sididptr->sid);
> > +               if (rc < 0)
> > +                       new = &((*new)->rb_left);
> > +               if (rc > 0)
> > +                       new = &((*new)->rb_right);
> > +               else {
> > +                       kfree(new_sididptr);
> > +                       return;
> > +               }
> 
> Jeff, this change is not sufficient to avoid the race in id_rb_insert()?
> If compare_sids returns 0, that means the node/mapping already exists
> i.e. the first racing thread grabbed the lock and inserted the mapping,
> so the second racing thread discovers that and returns without inserting
> that node?  All of this happening within spin lock?
> 

Ahh ok, I missed that -- perhaps some comments in the id_rb_insert
function would be helpful? It seems a little odd to just make it a
no-op in that case, but if you're certain that the idmapping will never
change then I suppose it will work.

That said, I'm still not fond of this scheme. Why do you feel it's
better to make both threads do an upcall in this situation instead of
sticking an entry in the tree and having the second thread block until
construction is complete?

Bear in mind that keys upcalls are _expensive_. It's basically a
fork-and-exec every time. Minimizing the number of upcalls seems
like it ought to be a design goal here particularly since this is
likely to happen quite a lot...

-- 
Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

      parent reply	other threads:[~2011-02-02 16:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 22:37 [PATCH 2/2] cifs: Invoke id mapping functions shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1295995034-8771-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-02 13:29   ` Jeff Layton
2011-02-02 15:40   ` Shirish Pargaonkar
     [not found]     ` <AANLkTim9EEC7P8z1xNB176N+R++N7OSBE4GKAbtzg795-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-02 16:00       ` Jeff Layton [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=20110202110047.4a3e2b26@corrin.poochiereds.net \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 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.