All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Olga Kornievskaia <aglo@umich.edu>
Cc: Olga Kornievskaia <kolga@netapp.com>,
	linux-nfs <linux-nfs@vger.kernel.org>,
	Anna Schumaker <Anna.Schumaker@netapp.com>
Subject: Re: handle_async_copy calling kzalloc under spinlock
Date: Fri, 16 Nov 2018 13:01:18 -0500	[thread overview]
Message-ID: <20181116180118.GB21852@fieldses.org> (raw)
In-Reply-To: <20181116175645.GA21852@fieldses.org>

On Fri, Nov 16, 2018 at 12:56:45PM -0500, J. Bruce Fields wrote:
> On Fri, Nov 16, 2018 at 11:25:50AM -0500, Olga Kornievskaia wrote:
> > On Fri, Nov 16, 2018 at 9:27 AM J. Bruce Fields <bfields@fieldses.org>
> > wrote:
> > 
> > > From bc0c9079b48d "NFS handle COPY reply CB_OFFLOAD call race":
> > >
> > > +       spin_lock(&server->nfs_client->cl_lock);
> > > +       list_for_each_entry(copy, &server->nfs_client->pending_cb_stateids,
> > > +                               copies) {
> > > +               if (memcmp(&res->write_res.stateid, &copy->stateid,
> > > +                               NFS4_STATEID_SIZE))
> > > +                       continue;
> > > +               found_pending = true;
> > > +               list_del(&copy->copies);
> > > +               break;
> > > +       }
> > > +       if (found_pending) {
> > > +               spin_unlock(&server->nfs_client->cl_lock);
> > > +               goto out;
> > > +       }
> > >
> > >         copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_NOFS);
> > >
> > > At this point we're still holding cl_lock.
> > >
> > > Best might be to allocate "copy" before taking the lock, then free it on
> > > any
> > > paths where we don't end up needing it.
> > >
> > >
> > Thanks. I'll do that.
> 
> Thanks.  And, I just noticed--nfs4_callback_offload has the same
> problem.

By the way, I don't understand the create case in that code--if you get
a CB_OFFLOAD without already having a matching copy stateid, shouldn't
you just return an error and forget about it?

I also wonder if SERVERFAULT is really the best error for a memory
allocation failure there.

--b.

  reply	other threads:[~2018-11-16 18:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 14:26 handle_async_copy calling kzalloc under spinlock J. Bruce Fields
     [not found] ` <CAN-5tyGsDAd2hkaw5nONdS2TzRy1qK7xyFDpNeT7Jsd9ZrH7+g@mail.gmail.com>
2018-11-16 17:56   ` J. Bruce Fields
2018-11-16 18:01     ` J. Bruce Fields [this message]
2018-11-16 18:30       ` Olga Kornievskaia
     [not found]         ` <CAN-5tyHX3h6TXJhFeZPGZvAWXXxwaxpAkZtRNV9+L8m5xJ3fVw@mail.gmail.com>
2018-11-16 19:30           ` J. Bruce Fields
2018-11-16 19:49             ` Olga Kornievskaia
2018-11-16 19:58               ` J. Bruce Fields
2018-11-16 20:11                 ` Olga Kornievskaia
2018-11-19 21:05                   ` J. Bruce Fields

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=20181116180118.GB21852@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Anna.Schumaker@netapp.com \
    --cc=aglo@umich.edu \
    --cc=kolga@netapp.com \
    --cc=linux-nfs@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 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.