From patchwork Tue Oct 29 09:39:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 3107051 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6FC4BF924 for ; Tue, 29 Oct 2013 09:39:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82E0220304 for ; Tue, 29 Oct 2013 09:39:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 746E8202B8 for ; Tue, 29 Oct 2013 09:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753796Ab3J2Jjn (ORCPT ); Tue, 29 Oct 2013 05:39:43 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:39307 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753786Ab3J2Jjn (ORCPT ); Tue, 29 Oct 2013 05:39:43 -0400 Received: by mail-wi0-f175.google.com with SMTP id hm4so4876363wib.2 for ; Tue, 29 Oct 2013 02:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GN8N7EqctyVopI1uVNGJj+Vd5rgt+R/g9HJEUH4YFeI=; b=cS6H2GaM2pK8Nhi/0Ney8ikI8c3EY862+pj5VHk7bNsPSvF77m76VmVQwXntlI7fno I/CXuJqrVVUwAI+1MVIsazap4LhQY7X+hTSNEmG0CblazDj2vbAu64p/MqWhXY2VjzdB uI3e5r8rnXCUzV+hhhHcWRXvUFx0+kKos4T1D9rvGqrhKk1rsB7ijSfjP+N6S/+UEDIO TZnH0itTJDdh6VMkWD1uy4aSNxdnC48ShuLOxwECZinyFlU9JMOeQES5WKJ86K+t0WHb gMNZ3eEpzHVyIxq9JhwvrgykErR5JabqNuQMGE/PyqpsSghM3SviXJGXiP3XyTgZLZUZ DbBg== X-Received: by 10.194.171.34 with SMTP id ar2mr591866wjc.81.1383039582126; Tue, 29 Oct 2013 02:39:42 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com (bzq-80-49-130.static.bezeqint.net. [82.80.49.130]) by mx.google.com with ESMTPSA id c10sm2975250wie.11.2013.10.29.02.39.38 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Tue, 29 Oct 2013 02:39:41 -0700 (PDT) From: Benny Halevy To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org, Benny Halevy Subject: [PATCH 7/7] nfsd4: hold recall_lock while accessing nfs4_delegation.dl_recall_lru Date: Tue, 29 Oct 2013 11:39:36 +0200 Message-Id: <1383039576-27451-1-git-send-email-bhalevy@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <526F81DE.6060704@primarydata.com> References: <526F81DE.6060704@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Benny Halevy --- fs/nfsd/nfs4state.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 7f78ff5..d9161ea 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -441,24 +441,29 @@ static void unhash_stid(struct nfs4_stid *s) dp->dl_stid.sc_type = NFS4_DELEG_STID; } -/* Called under the state lock. */ static void -unhash_delegation(struct nfs4_delegation *dp) +unhash_delegation_locked(struct nfs4_delegation *dp) { - spin_lock(&recall_lock); list_del_init(&dp->dl_perclnt); list_del_init(&dp->dl_perfile); list_del_init(&dp->dl_recall_lru); dp->dl_stid.sc_type = 0; nfs4_put_deleg_lease(dp->dl_file); - spin_unlock(&recall_lock); } - +static void +unhash_delegation(struct nfs4_delegation *dp) +{ + spin_lock(&recall_lock); + unhash_delegation_locked(dp); + spin_unlock(&recall_lock); +} static void destroy_revoked_delegation(struct nfs4_delegation *dp) { + spin_lock(&recall_lock); list_del_init(&dp->dl_recall_lru); + spin_unlock(&recall_lock); nfs4_put_delegation(dp); } @@ -475,9 +480,11 @@ static void revoke_delegation(struct nfs4_delegation *dp) if (clp->cl_minorversion == 0) destroy_delegation(dp); else { - unhash_delegation(dp); + spin_lock(&recall_lock); + unhash_delegation_locked(dp); dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; list_add(&dp->dl_recall_lru, &clp->cl_revoked); + spin_unlock(&recall_lock); } } @@ -2729,6 +2736,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) struct nfs4_client *clp = dp->dl_stid.sc_client; struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); + lockdep_assert_held(&recall_lock); /* We're assuming the state code never drops its reference * without first removing the lease. Since we're in this lease * callback (and since the lease code is serialized by the kernel