Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753124AbcL2Qgl (ORCPT ); Thu, 29 Dec 2016 11:36:41 -0500 Received: from b.ns.miles-group.at ([95.130.255.144]:44725 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752880AbcL2Qgk (ORCPT ); Thu, 29 Dec 2016 11:36:40 -0500 Subject: Re: [PATCH 3/6] ubifs: Use 64bit readdir cookies To: "J. Bruce Fields" References: <1480629741-18375-1-git-send-email-richard@nod.at> <1480629741-18375-4-git-send-email-richard@nod.at> <20161229025835.GC21325@fieldses.org> <20161229153407.GA29149@fieldses.org> <20161229161534.GA29261@fieldses.org> Cc: linux-mtd@lists.infradead.org, david@sigma-star.at, tytso@mit.edu, dedekind1@gmail.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, adilger.kernel@dilger.ca, akpm@linux-foundation.org, linux-ext4@vger.kernel.org From: Richard Weinberger Message-ID: <224abf2f-c820-5df1-6292-42c1e2d47933@nod.at> Date: Thu, 29 Dec 2016 17:36:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <20161229161534.GA29261@fieldses.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1616 Lines: 43 Bruce, On 29.12.2016 17:15, J. Bruce Fields wrote: > On Thu, Dec 29, 2016 at 04:49:54PM +0100, Richard Weinberger wrote: >> Bruce, >> >> On 29.12.2016 16:34, J. Bruce Fields wrote: >>>> That way UBIFS can provide a 64bit readdir() cookie which is required for NFS3. >>> >>> Sounds good. And if a matching entry isn't found (as in the case of a >>> concurrent unlink), what happens? The answer must be the same as for >>> ext4, but I've forgotten the details.... I guess it must find the next >>> highest cookie (thinking of the cookie as a 64-bit integer of some kind) >>> that exists in the directory. And that must be the same order that >>> readdir normally returns entries in. >> >> If a 64bit cookie is not found, the lookup function returns -ENOENT. >> In UBIFS we cannot just select a higher or lower key (cookie in this case), >> since it is the B-tree key and would point to a completely different >> entry. >> >> So, in case of a concurrent unlink() one would succeed and one fail with >> -ENOENT. Unless I miss something that seems okay to me. > > Unlink takes (parent directory, name), not a directory cookie. > > The problem is concurrent unlink and nfs readdir. So: > > NFS server returns readdir result with cookie X > > Somebody unlinks the entry at X. > > NFS server gets readdir request with cookie X. > > Then the NFS client will get a spurious -ENOENT. Ah yes. Sorry I misunderstood your question. UBIFS readdir() address this already, if you ask it to readdir() from pos X and X is not present it will jump to the next best entry X'. UBIFS does so since ever. Thanks, //richard