From patchwork Thu Jun 26 19:12:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4430691 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 484009F2C8 for ; Thu, 26 Jun 2014 19:15:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0760201BB for ; Thu, 26 Jun 2014 19:15:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC385202AE for ; Thu, 26 Jun 2014 19:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751814AbaFZTPD (ORCPT ); Thu, 26 Jun 2014 15:15:03 -0400 Received: from mail-qa0-f43.google.com ([209.85.216.43]:50539 "EHLO mail-qa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751511AbaFZTPB (ORCPT ); Thu, 26 Jun 2014 15:15:01 -0400 Received: by mail-qa0-f43.google.com with SMTP id k15so3159207qaq.2 for ; Thu, 26 Jun 2014 12:15:00 -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=X979iGAmWWUFSx4Rk+vr/fvh1h+Js5a09CcUBFeMlhk=; b=L+dRHOLKAWTMg+chJYsl3tuQPs1j2Kiubh0Hi61bhd0FBS/9dh0Z3H9zQ3DMmgTtxO +NCHXN8O9Bt32oaGKORJGleIWq1OlWhhlJOqgUmMRJqq0/EDryUmV5SYYLfAu39KFr4G 2loSNOcgGUj6i0oHbOEfaDyWhSoXPaSWYIrKIBigECzcSd5ojM3BeeKVVRcY6jAA1EeR r1iMZaNSUCgJE9QPzmoUABJZEJM2QBgLXWFeu4+kaWv5kXmV+V0uuMs/j7V6v+pXCmcR h8Nar/DP9YVE+MCpAsSewM/u3c/qoOxbcrDDn0NoEozTZlpcaAgz4sZa/c1iqjIJG5TV W5hA== X-Gm-Message-State: ALoCoQlqmO1oz8qGAQj3Gqq8soMxm5p+ik5gU7dMFciR+eyDneaceP54QWD4gGC0GtYgzOC2jVRu X-Received: by 10.140.106.202 with SMTP id e68mr23298710qgf.83.1403810100694; Thu, 26 Jun 2014 12:15:00 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 88sm4763039qgh.5.2014.06.26.12.14.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jun 2014 12:14:59 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH v2 055/117] nfsd: nfsd4_process_open2() must reference the delegation stateid Date: Thu, 26 Jun 2014 15:12:35 -0400 Message-Id: <1403810017-16062-56-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403810017-16062-1-git-send-email-jlayton@primarydata.com> References: <1403810017-16062-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 ed5091e0abec..5b88cb314b99 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3287,6 +3287,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); } @@ -3302,14 +3304,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_delegation(deleg); + goto out; + } + *dp = deleg; out: if (!nfsd4_is_deleg_cur(open)) return nfs_ok; @@ -3768,6 +3774,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_delegation(dp); return status; }