From patchwork Tue Jun 2 10:59:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6528321 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 7A1859F1C1 for ; Tue, 2 Jun 2015 10:59:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D9D32051F for ; Tue, 2 Jun 2015 10:59:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DDBE204FB for ; Tue, 2 Jun 2015 10:59:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754295AbbFBK7e (ORCPT ); Tue, 2 Jun 2015 06:59:34 -0400 Received: from mail-qc0-f175.google.com ([209.85.216.175]:35131 "EHLO mail-qc0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891AbbFBK7d (ORCPT ); Tue, 2 Jun 2015 06:59:33 -0400 Received: by qczw4 with SMTP id w4so33424269qcz.2 for ; Tue, 02 Jun 2015 03:59:33 -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 :content-type:content-transfer-encoding; bh=xCyh49/imbeZ5oUf7NtSnzKgx8NQxSW53OS9sSbpnx0=; b=i8XKDm/wYZogQsY2yzjHH1Zr4eS3ZTI7jkQ/IUJVn/jWcUtmUikyLMKu9k7w0JxvLF OF2uiUW7B9pcFYJvyqS3AY7USfPhgau5jYvYqHLHBOR2o3nF4mwOtSJnpHf5wsBai4zm Zt56a7HVqOP31t9yB+6KINmNN4ulf0mTzXXsz40WjR9rR740Exgrfcmb51lRQz9iN7bo LRIYfLPGNrow//NXx0TtV0ScrHfXrqV8YgOGJHodH6mLYvE70aMSGeQ5V/cZV0yan8fu DQSqvS3YC5+E//uCz7n+tBT3maePZIX+EyhIdURC1/3lG+vkvItHXJhVg185gGJ2b1KD U9Pg== X-Received: by 10.140.237.68 with SMTP id i65mr29539733qhc.42.1433242773350; Tue, 02 Jun 2015 03:59:33 -0700 (PDT) Received: from [192.168.99.20] ([104.143.41.79]) by mx.google.com with ESMTPSA id g15sm7204566qge.17.2015.06.02.03.59.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 03:59:32 -0700 (PDT) Message-ID: <556D8C8D.50205@gmail.com> Date: Tue, 02 Jun 2015 18:59:25 +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: Christoph Hellwig , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 2/2] nfsd: Update callback sequnce id only CB_SEQUENCE success 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 When testing pnfs layout, nfsd got error NFS4ERR_SEQ_MISORDERED. It is caused by nfs return NFS4ERR_DELAY before validate_seqid(), don't update the sequnce id, but nfsd updates the sequnce id !!! According to RFC5661 20.9.3, " If CB_SEQUENCE returns an error, then the state of the slot (sequence ID, cached reply) MUST NOT change. " Signed-off-by: Kinglong Mee --- fs/nfsd/nfs4callback.c | 14 ++++++++++++-- fs/nfsd/state.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 8b1ac8d..a492018 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -455,6 +455,7 @@ static int decode_cb_sequence4res(struct xdr_stream *xdr, if (unlikely(status || cb->cb_status)) return status; + cb->cb_update_seq_nr = true; return decode_cb_sequence4resok(xdr, cb); } @@ -875,6 +876,7 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) u32 minorversion = clp->cl_minorversion; cb->cb_minorversion = minorversion; + cb->cb_update_seq_nr = false; cb->cb_status = 0; if (minorversion) { if (!nfsd41_cb_get_slot(clp, task)) @@ -892,9 +894,16 @@ static void nfsd4_cb_done(struct rpc_task *task, void *calldata) clp->cl_minorversion); if (clp->cl_minorversion) { - /* No need for lock, access serialized in nfsd4_cb_prepare */ - if (!task->tk_status) + /* + * No need for lock, access serialized in nfsd4_cb_prepare + * + * RFC5661 20.9.3 + * If CB_SEQUENCE returns an error, then the state of the slot + * (sequence ID, cached reply) MUST NOT change. + */ + if (cb->cb_update_seq_nr) ++clp->cl_cb_session->se_cb_seq_nr; + clear_bit(0, &clp->cl_cb_slot_busy); rpc_wake_up_next(&clp->cl_cb_waitq); dprintk("%s: freed slot, new seqid=%d\n", __func__, @@ -1091,6 +1100,7 @@ void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp, cb->cb_ops = ops; INIT_WORK(&cb->cb_work, nfsd4_run_cb_work); cb->cb_status = 0; + cb->cb_update_seq_nr = false; cb->cb_need_restart = false; } diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index dbc4f85..4ed7c2a 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -68,6 +68,7 @@ struct nfsd4_callback { struct nfsd4_callback_ops *cb_ops; struct work_struct cb_work; int cb_status; + bool cb_update_seq_nr; bool cb_need_restart; };