From patchwork Sat Aug 13 00:12:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 1062592 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7D0CVLZ032508 for ; Sat, 13 Aug 2011 00:12:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673Ab1HMAMa (ORCPT ); Fri, 12 Aug 2011 20:12:30 -0400 Received: from natasha.panasas.com ([67.152.220.90]:57298 "EHLO natasha.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752343Ab1HMAMa (ORCPT ); Fri, 12 Aug 2011 20:12:30 -0400 Received: from zenyatta.panasas.com (zenyatta.int.panasas.com [172.17.28.63]) by natasha.panasas.com (8.13.1/8.13.1) with ESMTP id p7D0CRPd020785; Fri, 12 Aug 2011 20:12:27 -0400 Received: from [172.17.132.75] (172.17.132.75) by zenyatta.int.panasas.com (172.17.28.63) with Microsoft SMTP Server (TLS) id 14.1.289.1; Fri, 12 Aug 2011 20:12:21 -0400 Message-ID: <4E45C164.1070604@panasas.com> Date: Fri, 12 Aug 2011 17:12:20 -0700 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0 MIME-Version: 1.0 To: "J. Bruce Fields" , NFS list Subject: [PATCH] NFSD: nfsd4_open Avoid race with grace period expiration Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 13 Aug 2011 00:12:31 +0000 (UTC) locks_in_grace() was called twice one for the "yes" case second for the "no" case. If the status changes between these two calls the Server would do the wrong thing. Sample it only once. Also Add a DMESG print in the case of a bad (old) client that does *not* send a RECLAIM_COMPLETE before doing new opens. The admin might want to know it has an unsupported client at hand. Because in this case with our server the client will get stuck in an endless loop. Signed-off-by: Boaz Harrosh --- fs/nfsd/nfs4proc.c | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index a68384f..efc6369 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -301,8 +301,12 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, */ if (nfsd4_has_session(cstate) && !cstate->session->se_client->cl_firststate && - open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) + open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) { + printk(KERN_INFO + "NFSD: nfsd4_open: Broken client, " + "open sent before RECLAIM_COMPLETE done\n"); return nfserr_grace; + } if (nfsd4_has_session(cstate)) copy_clientid(&open->op_clientid, cstate->session); @@ -333,12 +337,17 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, /* Openowner is now set, so sequence id will get bumped. Now we need * these checks before we do any creates: */ - status = nfserr_grace; - if (locks_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) - goto out; - status = nfserr_no_grace; - if (!locks_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) - goto out; + if (locks_in_grace()) { + if (open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) { + status = nfserr_grace; + goto out; + } + } else { + if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) { + status = nfserr_no_grace; + goto out; + } + } switch (open->op_claim_type) { case NFS4_OPEN_CLAIM_DELEGATE_CUR: