From patchwork Fri Apr 18 18:44:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4017951 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 37F5CBFF02 for ; Fri, 18 Apr 2014 18:47:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E438203B5 for ; Fri, 18 Apr 2014 18:46:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8AA44203AC for ; Fri, 18 Apr 2014 18:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754437AbaDRSqz (ORCPT ); Fri, 18 Apr 2014 14:46:55 -0400 Received: from mail-ie0-f171.google.com ([209.85.223.171]:48161 "EHLO mail-ie0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754445AbaDRSqL (ORCPT ); Fri, 18 Apr 2014 14:46:11 -0400 Received: by mail-ie0-f171.google.com with SMTP id ar20so1904510iec.30 for ; Fri, 18 Apr 2014 11:46:10 -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=C7Nykha73Za8tNaXGgYwcpfyvrG7F6jdJeVLd82u7xc=; b=WJ12KWwFWTKOgaG+TETwv8i+qGWvPxupMImiALmjPN4GG8vtmwkugtGGYBvOkqx4oB jcrludHAYjtx+m4CVIulMB2lXtB+t6hMtaFVHq19F54VaTy3HB11Ap1nIKaJgyuGjPyw QgHM3F46VB7HBwDBTYN2qMPHteWTndFIt/aoaXV/9cr1sFXZYRmEEU/Uf2tRZ7JCoHL9 EkTm3rXXRKUPIxcksfDg3lh4LY8IemKfduA8ZgGHL7+aE/Ya2tjiMlrj4kAMaezWCps+ BJZhegrdZCSYnzFkRq4+LlqcZ2DUMkpLQUX8BlmAavyHGPnoP/rRLHrsBN6fkIDJREes 1chw== X-Gm-Message-State: ALoCoQlVTCb4xZfTCsIm1rMqwoqqdIefzhBZx92zJnz2uxhYa/sydfDP4MyJsG+da9c9VsNE3Psx X-Received: by 10.43.155.84 with SMTP id lh20mr3643595icc.81.1397846770683; Fri, 18 Apr 2014 11:46:10 -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.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Apr 2014 11:46:10 -0700 (PDT) From: Trond Myklebust To: Bruce Fields Cc: linux-nfs@vger.kernel.org Subject: [PATCH 42/70] NFSd: nfsd4_process_open2() must reference the open stateid Date: Fri, 18 Apr 2014 14:44:36 -0400 Message-Id: <1397846704-14567-43-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1397846704-14567-42-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> 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 nfsd4_process_open2() keeps a reference to the open stateid until it is done working with it. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 634cd4de9d32..ec7cc90de03a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2806,6 +2806,7 @@ alloc_init_open_stateowner(unsigned int strhashval, struct nfs4_client *clp, str static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) { struct nfs4_openowner *oo = open->op_openowner; + atomic_inc(&stp->st_stid.sc_count); stp->st_stid.sc_type = NFS4_OPEN_STID; INIT_LIST_HEAD(&stp->st_locks); list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); @@ -3111,6 +3112,7 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_ol_st { struct nfs4_ol_stateid *local; struct nfs4_openowner *oo = open->op_openowner; + struct nfs4_ol_stateid *ret = NULL; spin_lock(&fp->fi_lock); list_for_each_entry(local, &fp->fi_stateids, st_perfile) { @@ -3119,13 +3121,17 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_ol_st continue; /* remember if we have seen this open owner */ if (local->st_stateowner == &oo->oo_owner) - *stpp = local; + ret = local; /* check for conflicting share reservations */ if (!test_share(local, open)) { spin_unlock(&fp->fi_lock); return nfserr_share_denied; } } + if (ret) { + atomic_inc(&ret->st_stid.sc_count); + *stpp = ret; + } spin_unlock(&fp->fi_lock); return nfs_ok; } @@ -3536,6 +3542,8 @@ out: open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM; if (dp) nfs4_put_delegation(dp); + if (stp) + put_generic_stateid(stp); return status; }