From patchwork Mon Jul 13 09:31:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6776871 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 4782E9F2E8 for ; Mon, 13 Jul 2015 09:31:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 710F620547 for ; Mon, 13 Jul 2015 09:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63F5A204AE for ; Mon, 13 Jul 2015 09:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbbGMJb1 (ORCPT ); Mon, 13 Jul 2015 05:31:27 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:34194 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbbGMJb1 (ORCPT ); Mon, 13 Jul 2015 05:31:27 -0400 Received: by pdbep18 with SMTP id ep18so222591885pdb.1 for ; Mon, 13 Jul 2015 02:31:26 -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=qKdDlvwhObrx/XN71IUY65CxCUuk6g3ODEAjEx853hw=; b=JEm2RAiniphogEVdLWqY1UC5J0A8n8GQDZkO5gV+imHlAMVs+S7VQtO2i4AeLBI26W CSJXXK5Qqi+SC3T4mReJ51chgOHUwJSaXxk6y7ZvxRvQCiqJ6A8Z6m3Awnchutsx2zr6 O7ezk5UCys75JXD15/hALiRv1nsFohbC3mJXBAP3Gj6FovkJ6UxBVYacWsBYzZ4Edjz6 30x1CYeVWZXDABJG1ypb25+jWqp2E/xOC2TeuZ1MDAlpLmADdYl8lcqdgW7ua7Vbn7fE 5oq8btGF2HWS6bEFlWCsFXe2otj3RefTeL9sRDU2OToLqZEzbQdp+zgIVrWPPsCWWBIF exgQ== X-Received: by 10.66.144.40 with SMTP id sj8mr1614139pab.55.1436779886597; Mon, 13 Jul 2015 02:31:26 -0700 (PDT) Received: from [192.168.99.19] ([104.143.41.79]) by smtp.googlemail.com with ESMTPSA id qo1sm17765444pbc.89.2015.07.13.02.31.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2015 02:31:26 -0700 (PDT) Message-ID: <55A38569.8070405@gmail.com> Date: Mon, 13 Jul 2015 17:31:21 +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 05/14] nfsd: Use check_stateid_generation() for generation checking References: <55A384B1.8030207@gmail.com> In-Reply-To: <55A384B1.8030207@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=-8.2 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 | 5 ++--- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/state.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index 6904213..5c0f1d6 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -263,9 +263,8 @@ nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp, goto out; } else { ls = container_of(stid, struct nfs4_layout_stateid, ls_stid); - - status = nfserr_bad_stateid; - if (stateid->si_generation > stid->sc_stateid.si_generation) + status = check_stateid_generation(stateid, &stid->sc_stateid, 1); + if (status) 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 998166d..2edfedc 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4474,7 +4474,7 @@ static bool stateid_generation_after(stateid_t *a, stateid_t *b) return (s32)(a->si_generation - b->si_generation) > 0; } -static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session) +__be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session) { /* * When sessions are used the stateid generation number is ignored diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 4874ce5..18d015d 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -589,6 +589,7 @@ extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, __be32 nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s, struct nfsd_net *nn); +__be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session); struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *slab); void nfs4_unhash_stid(struct nfs4_stid *s);