Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@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 (try #16)
Date: Wed, 20 Apr 2011 12:27:31 -0500	[thread overview]
Message-ID: <BANLkTimyAx0YmYFuXPT0CdfdD4CYJDD7rw@mail.gmail.com> (raw)
In-Reply-To: <20110420130752.06d6397d-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>

On Wed, Apr 20, 2011 at 12:07 PM, Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org> wrote:
> On Tue, 19 Apr 2011 08:21:09 -0500
> shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>> From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>
>>
>> rb tree search and insertion routines.
>>
>> A SID which needs to be mapped, is looked up in one of the rb trees
>> depending whether SID is either owner or group SID.
>> If found in the tree, a (mapped) id from that node is assigned to
>> uid or gid as appropriate.  If unmapped, an upcall is attempted to
>> map the SID to an id.  If upcall is successful, node is marked as
>> mapped.  If upcall fails, node stays marked as unmapped and a mapping
>> is attempted again only after an arbitrary time period has passed.
>>
>> To map a SID, which can be either a Owner SID or a Group SID, key
>> description starts with the string "os" or "gs" followed by SID converted
>> to a string. Without "os" or "gs", cifs.upcall does not know whether
>> SID needs to be mapped to either an uid or a gid.
>>
>> Nodes in rb tree have fields to prevent multiple upcalls for
>> a SID.  Adding and removing nodes is done within global locks.
>> Shrinker routine prunes a node if it has expired but does not prne
>> an expired node if its refcount is not zero (i.e. sid of that node
>> is being mapped via an upcall).
>> Every time an existing node is accessed, its timestamp is updated
>> to prevent it from getting erased.
>>
>> For now, cifs.upcall is only used to map a SID to an id (uid or gid) but
>> it would be used to obtain an SID for an id.
>>
>>
>> Signed-off-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  fs/cifs/cifsacl.c |  332 +++++++++++++++++++++++++++++++++++++++++++++++++----
>>  fs/cifs/cifsacl.h |   25 ++++
>>  2 files changed, 333 insertions(+), 24 deletions(-)
>>
>> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
>> index cad8d9b..bbc29b8 100644
>> --- a/fs/cifs/cifsacl.c
>> +++ b/fs/cifs/cifsacl.c
>
> [...]
>
>> +     /*
>> +      * Shrinker could be accessing this entry but it will not
>> +      * get erased at this point in time and to make it stay further,
>> +      * pretty soon we will take a reference on it only to
>> +      * release the reference only after upcall returns (or we are
>> +      * woken up), however longer that upcall may take to return.
>> +      */
>> +     if (!test_and_set_bit(SID_ID_PENDING, &psidid->state)) {
>> +             /* paidid and its fields are being accessed sans spinlock */
>> +             ++psidid->refcount;
>                ^^^
>                Huh? You're incrementing and decrementing the
>                refcount without any locking at all? What prevents the
>                shrinker from finding the entry just before you bump
>                the refcount and wiping it out anyway?
>

Becaue we just updated the timestamp so shrinker will not evict the
entry at least for the duration of  SID_MAP_EXPIRE.
The refcount is to account for an lenghty upcall.

>> +struct cifs_sid_id {
>> +     unsigned int refcount;
>> +     unsigned long id;
>> +     unsigned long time;
>> +     unsigned long retry;
>
> Why, exactly do we need "time" and "retry"? Wouldn't one timestamp
> field do here?
>

One timestamp is to make an entry eligible for eviction and the other
one is to attempt mapping again if previous attempt to map a sid had
failed.

>> +     unsigned long state;
>> +     char *sidstr;
>> +     struct rb_node rbnode;
>> +     struct cifs_sid sid;
>> +};
>> +
>
> --
> Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
>

  parent reply	other threads:[~2011-04-20 17:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 13:21 [PATCH 2/2] cifs: Invoke id mapping functions (try #16) shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1303219269-31144-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-04-20 17:07   ` Jeff Layton
     [not found]     ` <20110420130752.06d6397d-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-04-20 17:27       ` Shirish Pargaonkar [this message]
     [not found]         ` <BANLkTimyAx0YmYFuXPT0CdfdD4CYJDD7rw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-20 18:10           ` Jeff Layton

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=BANLkTimyAx0YmYFuXPT0CdfdD4CYJDD7rw@mail.gmail.com \
    --to=shirishpargaonkar-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox