Return-Path: linux-nfs-owner@vger.kernel.org Received: from mail-vc0-f179.google.com ([209.85.220.179]:48738 "EHLO mail-vc0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbaLSUqu (ORCPT ); Fri, 19 Dec 2014 15:46:50 -0500 Received: by mail-vc0-f179.google.com with SMTP id le20so619583vcb.10 for ; Fri, 19 Dec 2014 12:46:50 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <1419015154-91037-1-git-send-email-trond.myklebust@primarydata.com> Date: Fri, 19 Dec 2014 15:46:50 -0500 Message-ID: Subject: Re: [PATCH v2 1/2] NFSv4: Deal with atomic upgrades of an existing delegation From: Trond Myklebust To: Olga Kornievskaia Cc: linux-nfs Content-Type: text/plain; charset=UTF-8 Sender: linux-nfs-owner@vger.kernel.org List-ID: On Fri, Dec 19, 2014 at 3:39 PM, Olga Kornievskaia wrote: > On Fri, Dec 19, 2014 at 3:31 PM, Trond Myklebust > wrote: >> On Fri, Dec 19, 2014 at 1:52 PM, Trond Myklebust >> wrote: >>> Ensure that we deal correctly with the case where the server sends us a >>> newer instance of the same delegation. If the stateids match, but the >>> sequence numbers differ, then treat the new delegation as if it were >>> an atomic upgrade. >>> >>> Signed-off-by: Trond Myklebust >>> --- >>> fs/nfs/delegation.c | 21 ++++++++++++++++++--- >>> 1 file changed, 18 insertions(+), 3 deletions(-) >>> >>> diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c >>> index 7f3f60641344..02b5b2a6d557 100644 >>> --- a/fs/nfs/delegation.c >>> +++ b/fs/nfs/delegation.c >>> @@ -301,6 +301,19 @@ nfs_inode_detach_delegation(struct inode *inode) >>> return nfs_detach_delegation(nfsi, delegation, server); >>> } >>> >>> +static void >>> +nfs_update_inplace_delegation(struct nfs_inode *nfsi, >>> + struct nfs_delegation *delegation, >>> + struct nfs_delegation *update) >>> +{ >>> + if (nfs4_stateid_is_newer(&update->stateid, &delegation->stateid)) >> >> ...and the above comparison should be reversed. > > do you mean: if(!nfs4_stateid_is_newer()) > > but if we received a delegation stateid with sequence number lower > than what we have, shouldn't that be some kind of an error? See the v3 patch. Yes, it would be a bug if the server sent us something with a lower number, so we ignore that and don't update the delegation. Ditto if it sends us something with the same sequence number. -- Trond Myklebust Linux NFS client maintainer, PrimaryData trond.myklebust@primarydata.com