From mboxrd@z Thu Jan 1 00:00:00 1970 From: tridge@samba.org Subject: Re: Expected getdents behaviour Date: Fri, 16 Sep 2005 11:28:43 +1000 Message-ID: <17194.8139.88980.19088@samba.org> References: <1126793268.1676.9.camel@imp.csi.cam.ac.uk> Reply-To: tridge@samba.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Akshat Aranya , linux-fsdevel@vger.kernel.org Return-path: Received: from dp.samba.org ([66.70.73.150]:3804 "EHLO lists.samba.org") by vger.kernel.org with ESMTP id S1161018AbVIPB20 (ORCPT ); Thu, 15 Sep 2005 21:28:26 -0400 To: Anton Altaparmakov In-Reply-To: <1126793268.1676.9.camel@imp.csi.cam.ac.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org At the risk of thowing a spanner in the works, Samba relies pretty heavily on seekdir()/telldir()/unlink() interacting in "nice" ways. The most problematic case is OS/2 clients, which use a bizarre pattern for removing all files in a directory. I've coded up the equivalent set of posix directory operations for a OS/2 client deleting a directory in: http://samba.org/ftp/unpacked/junkcode/os2_delete.c what they do is: 1) open directory 2) read 100 entries, asking for the 'telldir' location of each 3) delete the first 4 of those entries 4) seekdir to the offset returned by the 4th entry (now deleted) 5) read another 100 entries 6) go to step 3 this continues until the read of the directory returns no entries. At this point the client assumes the directory is empty. This works fine on Linux. On FreeBSD systems the way libc telldir() works means that the above pattern uses a huge amount of memory, and ends up not deleting all entries in the directory, so we ended up replacing telldir() on FreeBSD inside Samba4. See: http://samba.org/ftp/unpacked/samba4/source/lib/replace/repdir/ So if this discussion leads to any changes in getdents(), please don't use the FreeBSD method (it allocates a linked list of all telldir() results, and doesn't correctly cope with deletions during a directory scan). Cheers, Tridge