All of lore.kernel.org
 help / color / mirror / Atom feed
From: bfields@fieldses.org (J. Bruce Fields)
To: Olga Kornievskaia <kolga@netapp.com>
Cc: linux-nfs@vger.kernel.org, Anna Schumaker <Anna.Schumaker@Netapp.com>
Subject: handle_async_copy calling kzalloc under spinlock
Date: Fri, 16 Nov 2018 09:26:27 -0500	[thread overview]
Message-ID: <20181116142627.GA19946@fieldses.org> (raw)

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.

--b.

             reply	other threads:[~2018-11-16 14:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 14:26 J. Bruce Fields [this message]
     [not found] ` <CAN-5tyGsDAd2hkaw5nONdS2TzRy1qK7xyFDpNeT7Jsd9ZrH7+g@mail.gmail.com>
2018-11-16 17:56   ` handle_async_copy calling kzalloc under spinlock J. Bruce Fields
2018-11-16 18:01     ` J. Bruce Fields
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=20181116142627.GA19946@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Anna.Schumaker@Netapp.com \
    --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.