From patchwork Fri Jul 3 11:38:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6714611 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E60E29F38C for ; Fri, 3 Jul 2015 11:38:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE700207F6 for ; Fri, 3 Jul 2015 11:38:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF834207F3 for ; Fri, 3 Jul 2015 11:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754727AbbGCLir (ORCPT ); Fri, 3 Jul 2015 07:38:47 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:36740 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754832AbbGCLiq (ORCPT ); Fri, 3 Jul 2015 07:38:46 -0400 Received: by pdcu2 with SMTP id u2so63709239pdc.3 for ; Fri, 03 Jul 2015 04:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=mQ/JQ5OSIFmhNFaWTkM2iGR56bIT34eV9KVuZ+a1vxQ=; b=Ira0Gu/FzACt/bKgk++225jE5G0helby+aYMZhPmEvanyvGBkjK3I7s6l9vULwqKzd 3YTDWn7XQAy3JmwEBgOBAIh7X0e+iCpY3J3MXBnbuu26qNez+b9IhFPQ9jbiZz3ck5s7 +VDhA+BdOEzgfEgxxEsOtqariIa/PaHk5rDkI3YZaW60MyGH5JWsmTzRXqMgiEfPK2bv CVMPc4460IdTFLmaW27J0IzO0egTwJpFABqOs/ZOFO50KEaqknVcTWqOkHlAO0HCP+n6 3oVL+RkPGdIQ+vhPjQvV1acSe2ye6CtZD/pn2MQYrsrPUHp9lfhIXWU0blXlqcXEM71x aFPA== X-Received: by 10.70.102.11 with SMTP id fk11mr75664413pdb.144.1435923526381; Fri, 03 Jul 2015 04:38:46 -0700 (PDT) Received: from [192.168.99.20] ([104.143.41.79]) by mx.google.com with ESMTPSA id kk6sm8814270pdb.94.2015.07.03.04.38.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2015 04:38:45 -0700 (PDT) Message-ID: <5596743C.7080609@gmail.com> Date: Fri, 03 Jul 2015 19:38:36 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "J. Bruce Fields" , "linux-nfs@vger.kernel.org" CC: kinglongmee@gmail.com Subject: [PATCH 4/5] nfsd: Check stateid generation in nfsd4_lookup_stateid() References: <559672B7.4010802@gmail.com> In-Reply-To: <559672B7.4010802@gmail.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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Signed-off-by: Kinglong Mee --- fs/nfsd/nfs4layouts.c | 2 -- fs/nfsd/nfs4state.c | 30 ++++++++++++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index 367a65a..ef63244 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -264,8 +264,6 @@ nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp, ls = container_of(stid, struct nfs4_layout_stateid, ls_stid); status = nfserr_bad_stateid; - if (stateid->si_generation > stid->sc_stateid.si_generation) - goto out_put_stid; if (layout_type != ls->ls_layout_type) goto out_put_stid; } diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 61dfb33..53248cd 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4555,6 +4555,7 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s, struct nfsd_net *nn) { + struct nfs4_stid *stid; __be32 status; if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) @@ -4567,10 +4568,18 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, } if (status) return status; - *s = find_stateid_by_type(cstate->clp, stateid, typemask); - if (!*s) + stid = find_stateid_by_type(cstate->clp, stateid, typemask); + if (!stid) return nfserr_bad_stateid; - return nfs_ok; + + status = check_stateid_generation(stateid, &stid->sc_stateid, + nfsd4_has_session(cstate)); + if (status) + nfs4_put_stid(stid); + else + *s = stid; + + return status; } static struct file * @@ -4673,10 +4682,6 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, &s, nn); if (status) return status; - status = check_stateid_generation(stateid, &s->sc_stateid, - nfsd4_has_session(cstate)); - if (status) - goto out; switch (s->sc_type) { case NFS4_DELEG_STID: @@ -4694,7 +4699,6 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, done: if (!status && filpp) status = nfs4_check_file(rqstp, fhp, s, filpp, tmp_file, flags); -out: if (s) nfs4_put_stid(s); return status; @@ -5021,7 +5025,6 @@ __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_delegreturn *dr) { - struct nfs4_delegation *dp; stateid_t *stateid = &dr->dr_stateid; struct nfs4_stid *s; __be32 status; @@ -5033,14 +5036,9 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, status = nfsd4_lookup_stateid(cstate, stateid, NFS4_DELEG_STID, &s, nn); if (status) goto out; - dp = delegstateid(s); - status = check_stateid_generation(stateid, &dp->dl_stid.sc_stateid, nfsd4_has_session(cstate)); - if (status) - goto put_stateid; - destroy_delegation(dp); -put_stateid: - nfs4_put_stid(&dp->dl_stid); + destroy_delegation(delegstateid(s)); + nfs4_put_stid(s); out: return status; }