From patchwork Thu Sep 26 18:42:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2950501 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E7019F288 for ; Thu, 26 Sep 2013 18:42:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 784862017B for ; Thu, 26 Sep 2013 18:42:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46F4720164 for ; Thu, 26 Sep 2013 18:42:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754006Ab3IZSmy (ORCPT ); Thu, 26 Sep 2013 14:42:54 -0400 Received: from mail-qe0-f45.google.com ([209.85.128.45]:60123 "EHLO mail-qe0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005Ab3IZSmy (ORCPT ); Thu, 26 Sep 2013 14:42:54 -0400 Received: by mail-qe0-f45.google.com with SMTP id 6so1115822qea.32 for ; Thu, 26 Sep 2013 11:42:53 -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=KESJUSIHy24WjBe5aAx8Vjc6Tw9YgkqLes9lwgdBfmI=; b=F1W0B+IwT4PXvuIExAgUOcPPCi7wv+vNi7iL+FqUksu3S6j+BQdX+ePGgktZgPxLGi xSjgBkncJ34z8R/Haywh7IbV835d1m3fzjet5/deTDTZIrq4dvYIB11k3RshQqSE90ef p/qXVcKwbiYJ1T0W5DTAmR7Dd3hOaZrMxaT9eRCyqETdMYvQkzEsmN/pwpXdq68XqCJh L2ZDZr24XEUSkFgISqEZAKK6R2vjKw5dkYe6pFUIh2e6Cv3BqutZsGaqAcNLEE+bt0hh q9JdN/24r1y1N0MFfOt1IruIr7ghFqwljgHjqoUPuG8M8vV4tufUs1HPIcJwEiiv59VC TYTQ== X-Received: by 10.224.172.132 with SMTP id l4mr8245899qaz.22.1380220973435; Thu, 26 Sep 2013 11:42:53 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com.com (nat-pool-bos-u.redhat.com. [66.187.233.207]) by mx.google.com with ESMTPSA id u4sm10288822qat.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 11:42:52 -0700 (PDT) From: Benny Halevy To: " J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v0 43/49] pnfsd: release state lock around iput in put_nfs4_file Date: Thu, 26 Sep 2013 14:42:48 -0400 Message-Id: <1380220968-14669-1-git-send-email-bhalevy@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <52447EA0.7070004@primarydata.com> References: <52447EA0.7070004@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=-9.2 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 we don't want to hold the state_lock while the file system may block Signed-off-by: Benny Halevy --- fs/nfsd/nfs4pnfsd.c | 4 +++- fs/nfsd/nfs4state.c | 34 +++++++++++++++++++++++++++++++--- fs/nfsd/state.h | 1 + 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c index 8d16b85..1807455 100644 --- a/fs/nfsd/nfs4pnfsd.c +++ b/fs/nfsd/nfs4pnfsd.c @@ -166,6 +166,7 @@ struct sbid_tracker { { struct nfs4_layout_state *ls = container_of(kref, struct nfs4_layout_state, ls_ref); + struct nfs4_file *fp; nfsd4_remove_stid(&ls->ls_stid); if (!list_empty(&ls->ls_perclnt)) { @@ -173,8 +174,9 @@ struct sbid_tracker { unhash_layout_state(ls); spin_unlock(&layout_lock); } - put_nfs4_file(ls->ls_file); + fp = ls->ls_file; nfsd4_free_stid(layout_state_slab, &ls->ls_stid); + put_nfs4_file_locked(fp); } /* diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e11d96f..5d5dead 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -239,14 +239,42 @@ static void nfsd4_free_file(struct nfs4_file *f) kmem_cache_free(file_slab, f); } -void -put_nfs4_file(struct nfs4_file *fi) +static struct inode *put_nfs4_file_common(struct nfs4_file *fi) { if (atomic_dec_and_lock(&fi->fi_ref, &recall_lock)) { + struct inode *ino; + hlist_del(&fi->fi_hash); spin_unlock(&recall_lock); - iput(fi->fi_inode); + ino = fi->fi_inode; nfsd4_free_file(fi); + + return ino; + } + return NULL; +} + +void +put_nfs4_file(struct nfs4_file *fi) +{ + struct inode *ino; + + ino = put_nfs4_file_common(fi); + if (ino) + iput(ino); +} + +void +put_nfs4_file_locked(struct nfs4_file *fi) +{ + struct inode *ino; + + nfs4_assert_state_locked(); + ino = put_nfs4_file_common(fi); + if (ino) { + nfs4_unlock_state(); + iput(ino); + nfs4_lock_state(); } } diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 1ef09ae..3be7507 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -491,6 +491,7 @@ extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(const char *name, extern void nfsd4_free_slab(struct kmem_cache **); extern struct nfs4_file *find_alloc_file(struct inode *, struct svc_fh *); extern void put_nfs4_file(struct nfs4_file *); +extern void put_nfs4_file_locked(struct nfs4_file *); extern void get_nfs4_file(struct nfs4_file *); extern struct nfs4_client *find_confirmed_client(clientid_t *, bool sessions, struct nfsd_net *); extern struct nfs4_stid *nfsd4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *slab);