From patchwork Fri Apr 18 18:44:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4017991 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 6062D9F3DF for ; Fri, 18 Apr 2014 18:47:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DAA6203AC for ; Fri, 18 Apr 2014 18:47:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAD00203B5 for ; Fri, 18 Apr 2014 18:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754580AbaDRSrB (ORCPT ); Fri, 18 Apr 2014 14:47:01 -0400 Received: from mail-ig0-f176.google.com ([209.85.213.176]:51161 "EHLO mail-ig0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754208AbaDRSqP (ORCPT ); Fri, 18 Apr 2014 14:46:15 -0400 Received: by mail-ig0-f176.google.com with SMTP id uy17so957965igb.3 for ; Fri, 18 Apr 2014 11:46:14 -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=aleySWYpY+sGsh6j1UlU8yYv2IhphD342P3gM3LbkfI=; b=DKVWWW9e79KqpKoHyiLRvgjbt9vhsrALlb4pIiwoKqcRkT3WoZoEesyXUeik5FjQDs 6Cz8wkxNCYdF8NjjohHOVvzoFlDCWNOOBhCslly6ysVcDE3//B6YPLe4ZKzPtLuVq86K g1pK8Ik33h/JIBnanLVxcNyVfdV+cYMZFphRLuPbdQGCCeUHoOSHU4+4/DQSnYd75M03 yUlUHXGinf2vbbZdwM93YvVAwZVXyRJ5bsHPEjkqHCbhE2v7vjnc6WAsOKY7dl0HLcTN zYNglu+n67fMt9XddLyMpNmxgqCdoIhlOHks7/HGLXbljY1KUmNivDZG6cJ9VGVzwsL/ HkVw== X-Gm-Message-State: ALoCoQljeDZeRf6yi1t49vfI5uNknfQlQm2fMfPmkpd9AtOjj8rbF95B+VobD6P+1HiCCwxppUUX X-Received: by 10.42.82.148 with SMTP id d20mr14724754icl.50.1397846774787; Fri, 18 Apr 2014 11:46:14 -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.46.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Apr 2014 11:46:14 -0700 (PDT) From: Trond Myklebust To: Bruce Fields Cc: linux-nfs@vger.kernel.org Subject: [PATCH 45/70] NFSd: Add reference counting to nfs4_preprocess_confirmed_seqid_op Date: Fri, 18 Apr 2014 14:44:39 -0400 Message-Id: <1397846704-14567-46-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1397846704-14567-45-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> <1397846704-14567-26-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-27-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-28-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-29-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-30-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-31-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-32-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-33-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-34-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-35-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-36-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-37-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-38-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-39-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-40-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-41-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-42-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-43-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-44-git-send-email-trond.myklebust@primarydata.com> <1397846704-14567-45-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 Ensure that all the callers put the open stateid after use. 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 517e08818df6..ce35edcef193 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4115,6 +4115,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; @@ -4228,12 +4230,12 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, if (!test_access(od->od_share_access, stp)) { dprintk("NFSD: access not a subset current bitmap: 0x%lx, 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 current bitmap: 0x%lx, 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); @@ -4242,6 +4244,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: + put_generic_stateid(stp); out: nfsd4_bump_seqid(cstate, status); nfs4_unlock_state(); @@ -4562,6 +4566,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 file *filp = NULL; struct file_lock *file_lock = NULL; struct file_lock *conflock = NULL; @@ -4588,8 +4593,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, @@ -4712,6 +4715,8 @@ out: fput(filp); if (lock_stp) put_generic_stateid(lock_stp); + if (open_stp) + put_generic_stateid(open_stp); if (status && new_state) release_lockowner_if_empty(lock_sop); nfsd4_bump_seqid(cstate, status);