Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp461705pxu; Tue, 6 Oct 2020 10:26:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2g4viKnk3jE3EEUcL/WPtg/zj/R82UqHE6GHcD9fhyviB4sCB1zjGmVqhjMJWyl+Md4Fg X-Received: by 2002:aa7:cc02:: with SMTP id q2mr6484525edt.196.1602005215600; Tue, 06 Oct 2020 10:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602005215; cv=none; d=google.com; s=arc-20160816; b=aQVDxINrYjcg27I255XVW98Bfnqx8kzRn4vaSHftE6VMIu/DwAT3VbHxGiyvlbY42B vg6y9pGRPiNNNwmsKEnMarGpkQznIHovWAiZeaOnrvgYVJ8mj69MxCAiRvRL25kpczVw nZ2C86wfAtW1ayCx+BHqN50o4xtKKJWZWtPuZbY7T90MC2B9886qwZ/jciILti0dqCp0 q8ax2ypSfSnQux+S63qVBgyDxgqxAgPZBpqvgD3b8ZNls4RRuYWOlMmXMM7gGVeNz9OY 6N3vW5Ju+lmjAJ3YtmqGDihIeUhxnbf5L9XPQtxT1xW496MV5rq2pGmDUEqgPvfNFm3u +u/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=M4fachXUpRc9S+ieKkFnargtA7yodP3XYujMtpIY3lY=; b=vsDgozEqWgnwBMvAsCRNd2kCvgmbZKluUDE4hBoDoLkcA7N1xgUFfGntBAuM0W+WbL KWbWDjn78akas0x+eBMuL85/stL97I8gXLcCA98g3we1i4lXXvqXwcJOAxRly7hB8UUK v/DgwmHiHM+sOkN8VrqBvvGOoJJjjSUTjD2CQlWWaqtxclI9qd9wcFAujgLD3IzyAvZr Dlf9QuDkQK0El76di2pOLjuykQI4p0arHANZMMC/5V/LWMoWbHLhGFTpj+sdvR3ko7se znxc0zb7eADkgcmteNsneSP3twkWf66e+6NliIQcTy/8ZF+T33qKZs5QJ5qrhli2Lvvv 1d1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b="X//ZOCSz"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si2915560edy.580.2020.10.06.10.26.17; Tue, 06 Oct 2020 10:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b="X//ZOCSz"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725925AbgJFR0I (ORCPT + 99 others); Tue, 6 Oct 2020 13:26:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725902AbgJFR0I (ORCPT ); Tue, 6 Oct 2020 13:26:08 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FAE3C061755 for ; Tue, 6 Oct 2020 10:26:08 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 9603D367; Tue, 6 Oct 2020 13:26:07 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 9603D367 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1602005167; bh=M4fachXUpRc9S+ieKkFnargtA7yodP3XYujMtpIY3lY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X//ZOCSzaPb3n9LeJHJHX2acFHh4C+eFt433QxBcUyK0Jhiuj4WQgJSv/btxhFGO9 0uhkLjKePhWdryZFDp8f21MkTbKifcAuiW0so1+mPl91u4+oMROR2qrQdY5HHBhnqK bNU074lCMYKEjFNZh6Vt1kKDpqi5pEczO2Vr+VTM= Date: Tue, 6 Oct 2020 13:26:07 -0400 From: "bfields@fieldses.org" To: Matt Benjamin Cc: Trond Myklebust , "inoguchi.yuki@fujitsu.com" , "linux-nfs@vger.kernel.org" Subject: Re: client caching and locks Message-ID: <20201006172607.GA32640@fieldses.org> References: <20200608211945.GB30639@fieldses.org> <22b841f7a8979f19009c96f31a7be88dd177a47a.camel@hammerspace.com> <20200618200905.GA10313@fieldses.org> <20200622135222.GA6075@fieldses.org> <20201001214749.GK1496@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Oct 01, 2020 at 06:26:25PM -0400, Matt Benjamin wrote: > I'm not sure. My understanding has been that, NFSv4 does not mandate > a mechanism to update clients of changes outside of any locked range. > In AFS (and I think DCE DFS?) this role is played by DataVersion. If > I recall correctly, David Noveck provided an errata that addresses > this, that servers could use in a similar manner to DV, but I don't > recall the details. Maybe you're thinking of the change_attr_type that's new to 4.2? I think that was Trond's proposal originally. In the CHANGE_TYPE_IS_VERSION_COUNTER case it would in theory allow you to tell whether a file that you'd written to was also written to by someone else by counting WRITE operations. But we still have to ensure consistency whether the server implements that. (I doubt any server currently does.) --b. > > Matt > > On Thu, Oct 1, 2020 at 5:48 PM bfields@fieldses.org > wrote: > > > > On Mon, Jun 22, 2020 at 09:52:22AM -0400, bfields@fieldses.org wrote: > > > On Thu, Jun 18, 2020 at 04:09:05PM -0400, bfields@fieldses.org wrote: > > > > I probably don't understand the algorithm (in particular, how it > > > > revalidates caches after a write). > > > > > > > > How does it avoid a race like this?: > > > > > > > > Start with a file whose data is all 0's and change attribute x: > > > > > > > > client 0 client 1 > > > > -------- -------- > > > > take write lock on byte 0 > > > > take write lock on byte 1 > > > > write 1 to offset 0 > > > > change attribute now x+1 > > > > write 1 to offset 1 > > > > change attribute now x+2 > > > > getattr returns x+2 > > > > getattr returns x+2 > > > > unlock > > > > unlock > > > > > > > > take readlock on byte 1 > > > > > > > > At this point a getattr will return change attribute x+2, the same as > > > > was returned after client 0's write. Does that mean client 0 assumes > > > > the file data is unchanged since its last write? > > > > > > Basically: write-locking less than the whole range doesn't prevent > > > concurrent writes outside that range. And the change attribute gives us > > > no way to identify whether concurrent writes have happened. (At least, > > > not without NFS4_CHANGE_TYPE_IS_VERSION_COUNTER.) > > > > > > So as far as I can tell, a client implementation has no reliable way to > > > revalidate its cache outside the write-locked area--instead it needs to > > > just throw out that part of the cache. > > > > Does my description of that race make sense? > > > > --b. > > > > > -- > > Matt Benjamin > Red Hat, Inc. > 315 West Huron Street, Suite 140A > Ann Arbor, Michigan 48103 > > http://www.redhat.com/en/technologies/storage > > tel. 734-821-5101 > fax. 734-769-8938 > cel. 734-216-5309