From patchwork Tue Jun 2 10:58:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6528291 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 646C09F1C1 for ; Tue, 2 Jun 2015 10:59:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A7F72051F for ; Tue, 2 Jun 2015 10:59:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80D0B204FB for ; Tue, 2 Jun 2015 10:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753918AbbFBK66 (ORCPT ); Tue, 2 Jun 2015 06:58:58 -0400 Received: from mail-qk0-f177.google.com ([209.85.220.177]:33331 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754127AbbFBK65 (ORCPT ); Tue, 2 Jun 2015 06:58:57 -0400 Received: by qkhg32 with SMTP id g32so98545554qkh.0 for ; Tue, 02 Jun 2015 03:58:56 -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=6R7PozLpx3LY1TWC7ap3/O+2I91SfOqfEXVbHXf5p/s=; b=FwYJQ44lQDJOuCw2WDj1PxChKizvSNmi1CauWA+ZwH9nA5V4xxf8C7TNCcnQfc0jJg b6+67+cLJT2Pzo+1TKJCe0TeMhUTVWcoxpkQDkjcJ3D5QFFxdZHENaJzL1B9abCMT3uH J4xUNPUYO38bf7SKvnBIkPeAxaVULuwAHH47RRIGJgz3NYJR9QAIj4NyuQJgum6yFI04 bnrdGagfa+9KTAa0KH31qAI4Odm7GGuvWwuhf3M4u+Vos1jbxJ69vGjUEYrhrDeGq1Se PppTx+cj1hJ1VbsASc6pioepPMFh2vpioB6oYKLHebwlpt6eTEFCFbtuqnXb6pM4fyyG 5gyg== X-Received: by 10.55.49.73 with SMTP id x70mr2805570qkx.49.1433242736586; Tue, 02 Jun 2015 03:58:56 -0700 (PDT) Received: from [192.168.99.20] ([104.143.41.79]) by mx.google.com with ESMTPSA id o32sm7271999qko.49.2015.06.02.03.58.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 03:58:55 -0700 (PDT) Message-ID: <556D8C66.8080203@gmail.com> Date: Tue, 02 Jun 2015 18:58:46 +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: Trond Myklebust , "linux-nfs@vger.kernel.org" CC: Weston Andros Adamson , "J. Bruce Fields" , kinglongmee@gmail.com, Christoph Hellwig Subject: [PATCH 1/2] nfs: Only update callback sequnce id when 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/nfs/callback_proc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 197806f..7e9653a 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -327,10 +327,8 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr); /* Normal */ - if (likely(args->csa_sequenceid == slot->seq_nr + 1)) { - slot->seq_nr++; + if (likely(args->csa_sequenceid == slot->seq_nr + 1)) goto out_ok; - } /* Replay */ if (args->csa_sequenceid == slot->seq_nr) { @@ -418,6 +416,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, struct cb_process_state *cps) { struct nfs4_slot_table *tbl; + struct nfs4_slot *slot; struct nfs_client *clp; int i; __be32 status = htonl(NFS4ERR_BADSESSION); @@ -429,7 +428,9 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, if (!(clp->cl_session->flags & SESSION4_BACK_CHAN)) goto out; + tbl = &clp->cl_session->bc_slot_table; + slot = tbl->slots + args->csa_slotid; spin_lock(&tbl->slot_tbl_lock); /* state manager is resetting the session */ @@ -444,7 +445,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, goto out; } - status = validate_seqid(&clp->cl_session->bc_slot_table, args); + status = validate_seqid(tbl, args); spin_unlock(&tbl->slot_tbl_lock); if (status) goto out; @@ -468,6 +469,13 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; + /* + * RFC5661 20.9.3 + * If CB_SEQUENCE returns an error, then the state of the slot + * (sequence ID, cached reply) MUST NOT change. + */ + slot->seq_nr++; + out: cps->clp = clp; /* put in nfs4_callback_compound */ for (i = 0; i < args->csa_nrclists; i++)