From patchwork Tue Jul 29 20:33:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4642371 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 F158BC033A for ; Tue, 29 Jul 2014 20:34:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2200420149 for ; Tue, 29 Jul 2014 20:34:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4767D20145 for ; Tue, 29 Jul 2014 20:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754355AbaG2Ued (ORCPT ); Tue, 29 Jul 2014 16:34:33 -0400 Received: from mail-qa0-f43.google.com ([209.85.216.43]:33526 "EHLO mail-qa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754352AbaG2Uec (ORCPT ); Tue, 29 Jul 2014 16:34:32 -0400 Received: by mail-qa0-f43.google.com with SMTP id w8so249669qac.30 for ; Tue, 29 Jul 2014 13:34:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dGwMPUayG1dh4q2mtwYdf/ZOfe1ChaAmYQrYMGbxbHg=; b=SUmkG8GLi99TZEHLsrx+EP1RXF4m8uDxo77CR7wYOJczyAfDAZaTvcECzmduojeEFS ZUirMkqStOwbUgnCBV55U6MOU934KN6au6FVQRxYnclkRj8F1LFmoOfM7Iq8ihyPSILd fPgGbUhWTLxVxguo5ZQe8aHo/Trbu2eV0mS5O+ApOD3k+5qjwt1x1Nwi4LJB1iF/aizE 1g+vtz19Ao94Ss4plD2O6NQSuCNHJLiqSl2vHr9LrZX+Q7MJD2CXQH5+D8jJJNsqu0dx wzEs2yKN5rZtTR+Poc7MmGw1D9lxOzfsmemjDcI7ABz0vvInwIGS2Ewn86/AMfZSddyY pXPQ== X-Gm-Message-State: ALoCoQm34MY/6omu4u1g+m9CYHWJfhQO7HcoQxAlm3GCYB26VushCbsw5WiO5zwHkBATWyIvvSA9 X-Received: by 10.224.151.79 with SMTP id b15mr7746228qaw.42.1406666071328; Tue, 29 Jul 2014 13:34:31 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 98sm74611qgh.5.2014.07.29.13.34.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jul 2014 13:34:30 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org, Trond Myklebust Subject: [PATCH v2 01/38] nfsd: Add reference counting to the lock and open stateids Date: Tue, 29 Jul 2014 16:33:44 -0400 Message-Id: <1406666061-14175-2-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406666061-14175-1-git-send-email-jlayton@primarydata.com> References: <1406666061-14175-1-git-send-email-jlayton@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.6 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 From: Trond Myklebust When we remove the client_mutex, we'll need to be able to ensure that these objects aren't destroyed while we're not holding locks. Signed-off-by: Trond Myklebust Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs4state.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index b0f83beeca75..3b0836db8553 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -890,8 +890,10 @@ static void close_generic_stateid(struct nfs4_ol_stateid *stp) release_all_access(stp); } -static void free_generic_stateid(struct nfs4_ol_stateid *stp) +static void put_ol_stateid(struct nfs4_ol_stateid *stp) { + if (!atomic_dec_and_test(&stp->st_stid.sc_count)) + return; if (stp->st_file) put_nfs4_file(stp->st_file); remove_stid(&stp->st_stid); @@ -909,7 +911,7 @@ static void __release_lock_stateid(struct nfs4_ol_stateid *stp) if (file) filp_close(file, (fl_owner_t)lockowner(stp->st_stateowner)); close_generic_stateid(stp); - free_generic_stateid(stp); + put_ol_stateid(stp); } static void unhash_lockowner(struct nfs4_lockowner *lo) @@ -972,7 +974,7 @@ static void unhash_open_stateid(struct nfs4_ol_stateid *stp) static void release_open_stateid(struct nfs4_ol_stateid *stp) { unhash_open_stateid(stp); - free_generic_stateid(stp); + put_ol_stateid(stp); } static void unhash_openowner(struct nfs4_openowner *oo) @@ -993,7 +995,7 @@ static void release_last_closed_stateid(struct nfs4_openowner *oo) struct nfs4_ol_stateid *s = oo->oo_last_closed_stid; if (s) { - free_generic_stateid(s); + put_ol_stateid(s); oo->oo_last_closed_stid = NULL; } } @@ -3818,7 +3820,7 @@ void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status) if (open->op_file) nfsd4_free_file(open->op_file); if (open->op_stp) - free_generic_stateid(open->op_stp); + put_ol_stateid(open->op_stp); } __be32 @@ -4477,9 +4479,9 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s) unhash_open_stateid(s); if (clp->cl_minorversion) { - free_generic_stateid(s); if (list_empty(&oo->oo_owner.so_stateids)) release_openowner(oo); + put_ol_stateid(s); } else { if (s->st_file) { put_nfs4_file(s->st_file);