From owner-freebsd-current@FreeBSD.ORG Fri May 1 16:17:52 2015 Return-Path: Delivered-To: current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3B23DCF2; Fri, 1 May 2015 16:17:52 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A603B1957; Fri, 1 May 2015 16:17:51 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t41GHgnt015656 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 1 May 2015 19:17:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t41GHgnt015656 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t41GHgbK015655; Fri, 1 May 2015 19:17:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 1 May 2015 19:17:42 +0300 From: Konstantin Belousov To: Julian Elischer Cc: "current@freebsd.org" Subject: Re: seekdir/readdir patch .. Call for Review. Message-ID: <20150501161742.GW2390@kib.kiev.ua> References: <55432593.6050709@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55432593.6050709@freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2015 16:17:52 -0000 On Fri, May 01, 2015 at 03:04:51PM +0800, Julian Elischer wrote: > if you are interested in readdir(3), seekdir(3) and telldir(3) then > you should look at > https://reviews.freebsd.org/D2410 > > this patches around a problem in seekdir() that breaks Samba. > Seekdir(3) will not work as expected when files prior to the point of > interest in directory have been deleted since the directory was opened. > > Windows clients using Samba cause both these things to happen, causing > the next readdir(3) after the bad seekdir(3) to skip some entries and > return the wrong file. > > Samba only needs to step back a single directory entry in the case > where it reads an entry and then discovers it can't fit it into the > buffer it is sending to the windows client. It turns out we can > reliably cater to Samba's requirement because the "last returned > element" is always still in memory, so with a little care, we can > set our filepointer back to it safely. (once) > > seekdir and readdir (and telldir()) need a complete rewrite along with > getdirentries() but that is more than a small edit like this. Can you explain your expectations from the whole readdir() vs. parallel directory modifications interaction ? From what I understood so far, there is unlocked modification of the container and parallel iterator over the same container. IMO, in such situation, whatever tweaks you apply to the iterator, it is still cannot be made reliable. Before making single-purpose changes to the libc readdir and seekdir code, or to the kernel code, it would be useful to state exact behaviour of the dirent machinery we want to see. No, 'make samba works in my situation' does not sound good enough.