From patchwork Wed Jul 30 01:34:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4644171 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 E9D409F440 for ; Wed, 30 Jul 2014 01:35:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E8922012D for ; Wed, 30 Jul 2014 01:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 393072012B for ; Wed, 30 Jul 2014 01:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754738AbaG3BfV (ORCPT ); Tue, 29 Jul 2014 21:35:21 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]:46867 "EHLO mail-qg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754491AbaG3BfQ (ORCPT ); Tue, 29 Jul 2014 21:35:16 -0400 Received: by mail-qg0-f42.google.com with SMTP id j5so678264qga.1 for ; Tue, 29 Jul 2014 18:35:15 -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=HpfZkA208lGMKznWFOtjmHdN0xD/vGJ9sltjubLJJDg=; b=HvtqTuxcNkzvZZMaWhgcF9ooGzu9ZywRGDGqPiu/SGHHg1Mo4SmmIlieVrMnAufrnR 3EerMT8R469wzNGvLHG/0zEvRiMPXgcWuTVOdkR7jchlLKoYXHG3HAD/q82pgTxeV7IQ Si7odAAFk+6qpIeXBgeRU2F89iAukk9grFQnv6xdGsRUw3HcHsbbg02Btu9j4IkZVqDv HOJq7WknpF05C68lV8bGXXfre/tbeJZFCUQXLQD7EKsnXRA+4DB5rxUV44ILed6XpNAW JvJdHZX9Vg+/iJO0YfkyDdY2cQ8Nmf4iLMPlpNZTfKwEiC5kB72u1IV1sVlxFFeZjLLo e/KQ== X-Gm-Message-State: ALoCoQl/62Mu7OMVaS9wWsrKVaVKvoF8k00TcGeF/gIsCm4ta3PhGjufMvrets92zoceVJ0hXq9w X-Received: by 10.140.91.164 with SMTP id z33mr1034913qgd.65.1406684115738; Tue, 29 Jul 2014 18:35:15 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 81sm860946qgw.21.2014.07.29.18.35.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jul 2014 18:35:14 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org, Trond Myklebust Subject: [PATCH v3 17/38] nfsd: Add reference counting to nfs4_preprocess_confirmed_seqid_op Date: Tue, 29 Jul 2014 21:34:22 -0400 Message-Id: <1406684083-19736-18-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406684083-19736-1-git-send-email-jlayton@primarydata.com> References: <1406684083-19736-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 Ensure that all the callers put the open stateid after use. Necessary step toward client_mutex removal. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8e18ca49555f..a777666044f1 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4405,6 +4405,8 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs NFS4_OPEN_STID, stpp, nn); if (status) return status; + /* FIXME: move into nfs4_preprocess_seqid_op */ + atomic_inc(&(*stpp)->st_stid.sc_count); oo = openowner((*stpp)->st_stateowner); if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) return nfserr_bad_stateid; @@ -4509,12 +4511,12 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, if (!test_access(od->od_share_access, stp)) { dprintk("NFSD: access not a subset of current bitmap: 0x%hhx, input access=%08x\n", stp->st_access_bmap, od->od_share_access); - goto out; + goto put_stateid; } if (!test_deny(od->od_share_deny, stp)) { dprintk("NFSD: deny not a subset of current bitmap: 0x%hhx, input deny=%08x\n", stp->st_deny_bmap, od->od_share_deny); - goto out; + goto put_stateid; } nfs4_stateid_downgrade(stp, od->od_share_access); @@ -4523,6 +4525,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, update_stateid(&stp->st_stid.sc_stateid); memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); status = nfs_ok; +put_stateid: + nfs4_put_stid(&stp->st_stid); out: nfsd4_bump_seqid(cstate, status); if (!cstate->replay_owner) @@ -4883,6 +4887,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfs4_openowner *open_sop = NULL; struct nfs4_lockowner *lock_sop = NULL; struct nfs4_ol_stateid *lock_stp = NULL; + struct nfs4_ol_stateid *open_stp = NULL; struct nfs4_file *fp; struct file *filp = NULL; struct file_lock *file_lock = NULL; @@ -4910,8 +4915,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfs4_lock_state(); if (lock->lk_is_new) { - struct nfs4_ol_stateid *open_stp = NULL; - if (nfsd4_has_session(cstate)) /* See rfc 5661 18.10.3: given clientid is ignored: */ memcpy(&lock->v.new.clientid, @@ -5039,6 +5042,8 @@ out: fput(filp); if (lock_stp) nfs4_put_stid(&lock_stp->st_stid); + if (open_stp) + nfs4_put_stid(&open_stp->st_stid); if (status && new_state) release_lock_stateid(lock_stp); nfsd4_bump_seqid(cstate, status);