From patchwork Fri Apr 18 18:44:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4017781 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 19CCA9F2BA for ; Fri, 18 Apr 2014 18:46:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 431EE203AF for ; Fri, 18 Apr 2014 18:46:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 679AD203AC for ; Fri, 18 Apr 2014 18:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754500AbaDRSqQ (ORCPT ); Fri, 18 Apr 2014 14:46:16 -0400 Received: from mail-ie0-f182.google.com ([209.85.223.182]:63164 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754212AbaDRSpo (ORCPT ); Fri, 18 Apr 2014 14:45:44 -0400 Received: by mail-ie0-f182.google.com with SMTP id y20so1904774ier.13 for ; Fri, 18 Apr 2014 11:45:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h0sJK5keaeb0fySmZJAjWd1Kg/aCBbPFZdDUbX+kGnQ=; b=dJqc5YQ23ApJAR0YcUsu6ERErIpD2/1z+wnrapfjIKHtm1+tQpk4Sa3tw6MLBzAdVm 6akZBjHFz65J7J/0V7sYW9xRmjFUDPVynt2fZpp464UJOOvZAa0M+BZfB6CKnjaVZhM+ Aze9AOmexCoxabgoxgM6L8ToK4xloSITchdtnQDKMN7Of7P7yjnCP9EcScS8v5t+KfFz FV+1OmN+lRwPb3UEQ1WZcODbHjJQgYgPbHKn9ySuCgj1AwtFhaoQ4Tvj3podeBTX6afJ IOIRrS/qH6heMrhMcoI3FNBigiC+Te2jVvMRedQ6VFgt4VEMcNNqMpXtvLGjtOmuaOgY GBmQ== X-Gm-Message-State: ALoCoQmsl96rBwHwTnAMMSLqwXz/BC8HIKpBCwgIfRI4Vyg/IKPnktxBfWoOWoDNu4QaOZ3HNouI X-Received: by 10.50.62.211 with SMTP id a19mr5847338igs.46.1397846743828; Fri, 18 Apr 2014 11:45:43 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (50-124-5-70.drr02.mskg.mi.frontiernet.net. [50.124.5.70]) by mx.google.com with ESMTPSA id j9sm6018922igu.10.2014.04.18.11.45.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Apr 2014 11:45:42 -0700 (PDT) From: Trond Myklebust To: Bruce Fields Cc: linux-nfs@vger.kernel.org Subject: [PATCH 25/70] NFSd: Simplify stateid management Date: Fri, 18 Apr 2014 14:44:19 -0400 Message-Id: <1397846704-14567-26-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1397846704-14567-25-git-send-email-trond.myklebust@primarydata.com> References: <1397846704-14567-1-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-2-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-3-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-4-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-5-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-6-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-7-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-8-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-9-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-10-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-11-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-12-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-13-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-14-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-15-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-16-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-17-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-18-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-19-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-20-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-21-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-22-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-23-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-24-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-25-git-send-email-trond.myklebust@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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Don't allow stateids to clear the open file pointer until they are being destroyed. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index afb767319f66..51ef179339ae 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -394,7 +394,7 @@ kmem_cache *slab) struct nfs4_stid *stid; int new_id; - stid = kmem_cache_alloc(slab, GFP_KERNEL); + stid = kmem_cache_zalloc(slab, GFP_KERNEL); if (!stid) return NULL; @@ -481,6 +481,8 @@ void nfs4_put_delegation(struct nfs4_delegation *dp) { if (atomic_dec_and_test(&dp->dl_stid.sc_count)) { + if (dp->dl_file) + put_nfs4_file(dp->dl_file); nfs4_free_stid(deleg_slab, &dp->dl_stid); num_delegations--; } @@ -528,10 +530,8 @@ unhash_delegation(struct nfs4_delegation *dp) spin_unlock(&fp->fi_inode->i_lock); } nfs4_put_deleg_lease(fp); - dp->dl_file = NULL; spin_unlock(&fp->fi_lock); spin_unlock(&state_lock); - put_nfs4_file(fp); } @@ -701,13 +701,13 @@ static void unhash_generic_stateid(struct nfs4_ol_stateid *stp) static void close_generic_stateid(struct nfs4_ol_stateid *stp) { release_all_access(stp); - put_nfs4_file(stp->st_file); - stp->st_file = NULL; } static void free_generic_stateid(struct nfs4_ol_stateid *stp) { remove_stid(&stp->st_stid); + if (stp->st_file) + put_nfs4_file(stp->st_file); nfs4_free_stid(stateid_slab, &stp->st_stid); } @@ -3265,8 +3265,6 @@ unlock_and_free: spin_unlock(&fp->fi_lock); spin_unlock(&state_lock); out_free: - put_nfs4_file(fp); - dp->dl_file = fp; return status; }