qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/6] hw/9pfs: Don't free fid in clunk
Date: Fri, 10 Jun 2011 11:49:11 +0530	[thread overview]
Message-ID: <87oc26mco0.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <4DF164D4.5070902@linux.vnet.ibm.com>

On Thu, 09 Jun 2011 17:27:00 -0700, Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> wrote:
> On 06/06/2011 10:16 AM, Aneesh Kumar K.V wrote:
> > On interrupted syscall on client we can end up having fid
> > being acted upon by glib pool but still get a clunk request on that
> 
> Couple of comments below.
> 
> - JV
> 
> > Signed-off-by: Aneesh Kumar K.V<aneesh.kumar@linux.vnet.ibm.com>
> > ---
> >   hw/9pfs/virtio-9p.c |  139 +++++++++++++++++++++++++++-----------------------
> >   hw/9pfs/virtio-9p.h |    7 +--
> >   2 files changed, 76 insertions(+), 70 deletions(-)
> >
> > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
> > index 03d8664..f3127a5 100644
> > --- a/hw/9pfs/virtio-9p.c
> > +++ b/hw/9pfs/virtio-9p.c
> > @@ -237,12 +237,11 @@ static V9fsFidState *get_fid(V9fsState *s, int32_t fid)
> >       V9fsFidState *f;
> >
> >       for (f = s->fid_list; f; f = f->next) {
> > -        if (f->fid == fid) {
> > +        if (f->fid == fid&&  !f->clunked) {
> >               f->ref++;
> >               return f;
> >           }
> >       }
> > -
> >       return NULL;
> >   }
> >
> > @@ -250,12 +249,12 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t fid)
> >   {
> >       V9fsFidState *f;
> >
> > -    f = get_fid(s, fid);
> > -    if (f) {
> > -        f->ref--;
> > -        return NULL;
> > +    for (f = s->fid_list; f; f = f->next) {
> > +        /* If fid is already there return NULL */
> > +        if (f->fid == fid&&  !f->clunked) {
> > +            return NULL;
> > +        }
> >       }
> > -
> >       f = qemu_mallocz(sizeof(V9fsFidState));
> Memory leak if we find a cluncked fid here?
> More than that how do you handle this?

clunk request happening parallel to alloc request ? is that 
possible. Only when the alloc succeed the client will find the
fid initialized and only on initialized fid we send clunk request.

> >       f->fid = fid;
> >       f->fid_type = P9_FID_NONE;
> > @@ -300,9 +299,33 @@ free_value:
> >       return retval;
> >   }
> >
> > -static int free_fid(V9fsState *s, int32_t fid)
> > +static int release_fid(V9fsState *s, V9fsFidState *fidp)
> >   {
> >       int retval = 0;
> > +
> > +    if (fidp->fid_type == P9_FID_FILE) {
> > +        retval = v9fs_co_close(s, fidp);
> > +    } else if (fidp->fid_type == P9_FID_DIR) {
> > +        retval = v9fs_co_closedir(s, fidp);
> > +    } else if (fidp->fid_type == P9_FID_XATTR) {
> > +        retval = v9fs_xattr_fid_clunk(s, fidp);
> > +    }
> > +    v9fs_string_free(&fidp->path);
> > +    qemu_free(fidp);
> > +    return retval;
> > +}
> > +
> > +static void put_fid(V9fsState *s, V9fsFidState *fidp)
> > +{
> > +    BUG_ON(!fidp->ref);
> > +    fidp->ref--;
> > +    if (!fidp->ref&&  fidp->clunked) {
> > +        release_fid(s, fidp);
> > +    }
> > +}
> > +
> > +static int free_fid(V9fsState *s, int32_t fid)
> With the changed semantics; I would suggest you to swap the names of
> release_fid() and free_fid()
> 
> Or even better
> free_fid() -> clunk_fid()
> release_fid() -> free_fid()

ok 

-aneesh

  reply	other threads:[~2011-06-10  6:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 17:16 [Qemu-devel] [PATCH 1/6] hw/9pfs: Add reference counting for fid Aneesh Kumar K.V
2011-06-06 17:16 ` [Qemu-devel] [PATCH 2/6] hw/9pfs: Don't free fid in clunk Aneesh Kumar K.V
2011-06-10  0:27   ` Venkateswararao Jujjuri
2011-06-10  6:19     ` Aneesh Kumar K.V [this message]
2011-06-06 17:16 ` [Qemu-devel] [PATCH 3/6] hw/9pfs: Add file descriptor reclaim support Aneesh Kumar K.V
2011-06-10  1:27   ` Venkateswararao Jujjuri
2011-06-06 17:16 ` [Qemu-devel] [PATCH 4/6] hw/9pfs: init fid list properly Aneesh Kumar K.V
2011-06-06 17:16 ` [Qemu-devel] [PATCH 5/6] hw/9pfs: Use v9fs_do_close instead of close Aneesh Kumar K.V
2011-06-10  1:32   ` Venkateswararao Jujjuri
2011-06-06 17:16 ` [Qemu-devel] [PATCH 6/6] hw/9pfs: Add directory reclaim support Aneesh Kumar K.V
2011-06-10  1:36   ` Venkateswararao Jujjuri
2011-06-09 23:10 ` [Qemu-devel] [PATCH 1/6] hw/9pfs: Add reference counting for fid Venkateswararao Jujjuri
2011-06-10  6:27   ` Aneesh Kumar K.V

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=87oc26mco0.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=jvrao@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).