From patchwork Fri Apr 18 18:44:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4017941 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 8B02C9F3DF for ; Fri, 18 Apr 2014 18:46:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B667D203AC for ; Fri, 18 Apr 2014 18:46:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E381C203B5 for ; Fri, 18 Apr 2014 18:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754566AbaDRSqx (ORCPT ); Fri, 18 Apr 2014 14:46:53 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:38495 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754437AbaDRSqJ (ORCPT ); Fri, 18 Apr 2014 14:46:09 -0400 Received: by mail-ie0-f169.google.com with SMTP id to1so1907047ieb.0 for ; Fri, 18 Apr 2014 11:46: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SpDd87XBY9VpasA3hfd7/+3MI2foVyqp8qWBD8dW6Dw=; b=TPRa497GcNeFntAoeqCgP7Iu0DZGvLOiKgdrp/HpXgpFGsMEGu2bK3akfeqmInFidW nrYqx+tuKevXbGsh2nL+F0VMQYQAb8uVK1s2D4lRhkj9prxMeWgmLG+1lnbtxutw8Kgx XzY49tTY3LVSl9H+xlO7ifQ6uVgSue11q5DbwSv2w+Nxo59eW8nqpbUq6bxVkP/ikc5x znIcHc+np0c4HR/hx7Kza3jWGPzu4CfUoVQi+Ph+YqvPGpC+f/LjKYf3c2tbw8OImsXo E5S+tBJ9Xq0GQPi38Z4UtLjEWX18OtCFgkCtFWTv7QCqVzSTcJ6GpRPIOmd77JYEzye4 5GFQ== X-Gm-Message-State: ALoCoQkizxO3MiaJsq4LFRt8ultQgs6xKE4Ve7XJ2xoTLLvUZTP/QCgBUuGl2H1KaDWOqlcLm5bH X-Received: by 10.50.143.34 with SMTP id sb2mr5820066igb.11.1397846769562; Fri, 18 Apr 2014 11:46:09 -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.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Apr 2014 11:46:08 -0700 (PDT) From: Trond Myklebust To: Bruce Fields Cc: linux-nfs@vger.kernel.org Subject: [PATCH 41/70] NFSd: nfsd4_process_open2() must reference the delegation stateid Date: Fri, 18 Apr 2014 14:44:35 -0400 Message-Id: <1397846704-14567-42-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1397846704-14567-41-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> 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 delegation stateid until it is done working with it. 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 d1e4f0e07f09..634cd4de9d32 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3068,6 +3068,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); } @@ -3083,14 +3085,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; @@ -3528,6 +3534,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; }