Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2778969ybt; Mon, 22 Jun 2020 06:53:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySiubyooO/jLBKw5I51q2pFP/9KAVxmBZ+qnXKOU/nyxW7n0qaC43/HXXgYKrekXwglf39 X-Received: by 2002:a17:906:3158:: with SMTP id e24mr15236331eje.543.1592833983226; Mon, 22 Jun 2020 06:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592833983; cv=none; d=google.com; s=arc-20160816; b=YFuoob0yuENWI75q+WynkrTWnuC9TNE19DpeN00vTFOfLNdeB4G3OxMoMk5ISm2yMZ ipssLZh9g4WLhZAnwgQ/8bJs+iYjSvv1MdrQGnguNJhByY04DLWhvyW56Ehm8LS1woD9 zl5BVS99QO1SH93vnVDrrMt7iXgQwjM6cilRRL1tQI0nH1lN+frDpEmXZxhTOgT+HnIv R7jud7Js9Pyp1tM0iV1I5cZPfd9zn5yP2lziMW+7hjMarKlRZejc/CwdlSOQW5Yi6a47 /zvIsX9YZ8OpATEvDlTXJklpkJdoW7EcAu6JyRsKejhrgmVEuOcz91NUxxdmp0y0peMk DqUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=YZuecwvtXdbcKHggFQnzNXgD2edUcKE8UnU0ucAaMHI=; b=S0MWwvudgiFYXF4HQakAMBO6PenH2k1T84E52Rx+k2CBnpKEEGqwL8aMuIecm4bvJ+ IpiWF8keGDbex5X3Wpk0HK4gCLccjVItgB1d8Q5PO7VgTnKH6rGd8I235PsplEFAyR/H n/8+h+EVuGkEZkc1lsyXN9S22VjKHjy9L3BxeAgnXao+mP1O8xkPYRd3ZfO5TW6lfkb0 o71qxCJukEmGisiwLSs90mLDsquGUtmsNGcsTZGxnO8amsZoCRJr7h5RhRGCr9v5UOJB YJZTqOLLLth4YTf9Ul+c8rL2cCJQ2+L9agi+U7TSuHf4iY3NiUfY9AH0iaGJqzNZuj9b iyTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=WGpJQxeY; 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 ce24si831721ejb.156.2020.06.22.06.52.26; Mon, 22 Jun 2020 06:53:03 -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=WGpJQxeY; 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 S1728404AbgFVNwZ (ORCPT + 99 others); Mon, 22 Jun 2020 09:52:25 -0400 Received: from fieldses.org ([173.255.197.46]:46412 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728341AbgFVNwY (ORCPT ); Mon, 22 Jun 2020 09:52:24 -0400 Received: by fieldses.org (Postfix, from userid 2815) id C6D6C1BE4; Mon, 22 Jun 2020 09:52:22 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org C6D6C1BE4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1592833942; bh=YZuecwvtXdbcKHggFQnzNXgD2edUcKE8UnU0ucAaMHI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WGpJQxeY6Qj8jDIgoNYuf22ie/y7e/d187hjKX2rdcHiRpPZVtsKi8lkHsALhwuYq /ApuPxcZTbCcwP9s2RQ3U4rNefaMT4ShkYMU8AX4piO06ms/fmqSbxurmENUF0havt 22YDovxQOUYFje/uKVlyjARPNxB3cairvLAja8oc= Date: Mon, 22 Jun 2020 09:52:22 -0400 From: "bfields@fieldses.org" To: Trond Myklebust Cc: "inoguchi.yuki@fujitsu.com" , "linux-nfs@vger.kernel.org" Subject: Re: client caching and locks Message-ID: <20200622135222.GA6075@fieldses.org> References: <20200608211945.GB30639@fieldses.org> <22b841f7a8979f19009c96f31a7be88dd177a47a.camel@hammerspace.com> <20200618200905.GA10313@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618200905.GA10313@fieldses.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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. Possibly that's what it's doing and I just don't see it--I read through some of the code and don't understand it yet. --b.