From patchwork Tue May 10 09:17:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mi Jinlong X-Patchwork-Id: 773602 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4A9Ffd7003111 for ; Tue, 10 May 2011 09:15:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369Ab1EJJPk (ORCPT ); Tue, 10 May 2011 05:15:40 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:61061 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751034Ab1EJJPj (ORCPT ); Tue, 10 May 2011 05:15:39 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 40EF317013C; Tue, 10 May 2011 17:15:38 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p4A9Fapp031440; Tue, 10 May 2011 17:15:36 +0800 Received: from [127.0.0.1] ([10.167.225.24]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011051017155398-241355 ; Tue, 10 May 2011 17:15:53 +0800 Message-ID: <4DC902B9.5060103@cn.fujitsu.com> Date: Tue, 10 May 2011 17:17:45 +0800 From: Mi Jinlong User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: "J. Bruce Fields" CC: NFS Subject: Re: [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done References: <4DB76D60.3010802@cn.fujitsu.com> <20110427135422.GA1618@fieldses.org> In-Reply-To: <20110427135422.GA1618@fieldses.org> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-05-10 17:15:54, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-05-10 17:15:54, Serialize complete at 2011-05-10 17:15:54 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 (demeter1.kernel.org [140.211.167.41]); Tue, 10 May 2011 09:15:41 +0000 (UTC) Hi Bruce, Sorry for so late to reply you. J. Bruce Fields: > On Wed, Apr 27, 2011 at 09:12:00AM +0800, Mi Jinlong wrote: >> Before nfs41 client's RECLAIM_COMPLETE done, nfs server should >> deny it's new lock. >> >> Signed-off-by: Mi Jinlong > > Is nfserr_grace the right error? (Honest question, I haven't looked it > up.) Yes, rfc5661 says: " Whenever a client establishes a new client ID and before it does the first non-reclaim operation that obtains a lock, it MUST send a RECLAIM_COMPLETE with rca_one_fs set to FALSE, even if there are no locks to reclaim. If non-reclaim locking operations are done before the RECLAIM_COMPLETE, an NFS4ERR_GRACE error will be returned. " > > Also I'd think this check should go in nfsd4_open: opens are also > prohibited before RECLAIM_COMPLETE, and if we check there then we don't > need to check here, as you have to have open state before you can do a > lock. Agree with you, what about the following one?? =============================== From 3b7b82cd41823a52b77fd2c4419ab635f6e5893b Mon Sep 17 00:00:00 2001 From: Mi Jinlong Date: Tue, 10 May 2011 14:07:44 +0800 Subject: [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done Before nfs41 client's RECLAIM_COMPLETE done, nfs server should deny any new locks or opens. Signed-off-by: Mi Jinlong --- fs/nfsd/nfs4proc.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 5fcb139..d71dd4d 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -291,6 +291,15 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) return nfserr_inval; + /* + * RFC5661 18.51.3 + * Before RECLAIM_COMPLETE done, server should deny new lock + */ + if (nfsd4_has_session(cstate) && + !cstate->session->se_client->cl_firststate && + open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) + return nfserr_grace; + if (nfsd4_has_session(cstate)) copy_clientid(&open->op_clientid, cstate->session);