From patchwork Wed Jul 30 01:34:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4644411 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 96A6F9F36A for ; Wed, 30 Jul 2014 01:36:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C88A42012B for ; Wed, 30 Jul 2014 01:36:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0058820142 for ; Wed, 30 Jul 2014 01:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754709AbaG3BfN (ORCPT ); Tue, 29 Jul 2014 21:35:13 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]:36117 "EHLO mail-qg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754663AbaG3BfK (ORCPT ); Tue, 29 Jul 2014 21:35:10 -0400 Received: by mail-qg0-f42.google.com with SMTP id j5so678171qga.1 for ; Tue, 29 Jul 2014 18:35:09 -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=s41uLujMm8ylksU2pA0z1OSsBI4rVb/nFGMUEehDdxw=; b=Ch/FPKT1K2iqu+/XSafp/apnB8oHvN/Yg3z2TIETHvARSIpfsil6AOYwt/4bYcoD5S axr04qNwlbs4mhKi35BSsdHTZOyKMuQKmz3NpipyW4mnGoeVB0LPdmeFpBKxzw8PCrII j5qxEFIRl+X5o2Ono0m6v8Hms6YI8o58GcOfX+C8AfBTp2naO4U5qjEnuvoGr0ks7i/G nHLkp/kKKVhE8SQFcwm21zCncZDHVD0IOK8K/Msh9AWgLP4z9A2PxNoHvKpN8WRafUhO SPU1p5g0tJhjqQcxKkX0G8RWEnROswzw/Hj2hgFehDvOv7/mdsCrDVy6BepmfiVDK+/L H4jA== X-Gm-Message-State: ALoCoQmlDXxj9sElHn/Geea4ncbM4NN0r/yjLvzg3VG9oJyvPokmO+/xKaBwBoZ5BCT4CWMptniD X-Received: by 10.229.221.201 with SMTP id id9mr1334971qcb.30.1406684109432; Tue, 29 Jul 2014 18:35:09 -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.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jul 2014 18:35:08 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org, Trond Myklebust Subject: [PATCH v3 13/38] nfsd: nfsd4_process_open2() must reference the delegation stateid Date: Tue, 29 Jul 2014 21:34:18 -0400 Message-Id: <1406684083-19736-14-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 nfsd4_process_open2() keeps a reference to the delegation stateid until it is done working with it. Necessary step toward client_mutex removal. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2df6af93120e..5cb6305036cd 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3325,6 +3325,8 @@ static struct nfs4_delegation *find_deleg_stateid(struct nfs4_client *cl, statei ret = find_stateid_by_type(cl, s, NFS4_DELEG_STID); if (!ret) return NULL; + /* FIXME: move into find_stateid_by_type */ + atomic_inc(&ret->sc_count); return delegstateid(ret); } @@ -3340,14 +3342,18 @@ nfs4_check_deleg(struct nfs4_client *cl, struct nfsd4_open *open, { int flags; __be32 status = nfserr_bad_stateid; + struct nfs4_delegation *deleg; - *dp = find_deleg_stateid(cl, &open->op_delegate_stateid); - if (*dp == NULL) + deleg = find_deleg_stateid(cl, &open->op_delegate_stateid); + if (deleg == NULL) goto out; flags = share_access_to_flags(open->op_share_access); - status = nfs4_check_delegmode(*dp, flags); - if (status) - *dp = NULL; + status = nfs4_check_delegmode(deleg, flags); + if (status) { + nfs4_put_stid(&deleg->dl_stid); + goto out; + } + *dp = deleg; out: if (!nfsd4_is_deleg_cur(open)) return nfs_ok; @@ -3828,6 +3834,8 @@ out: if (!(open->op_openowner->oo_flags & NFS4_OO_CONFIRMED) && !nfsd4_has_session(&resp->cstate)) open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM; + if (dp) + nfs4_put_stid(&dp->dl_stid); return status; }