Subject: Re: Caching status between VOP_READDIR calls
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 09/10/2005 17:57:13
In article <6b2d1e19050909113610b2ec26@mail.gmail.com>,
Julio M. Merino Vidal <jmmv84@gmail.com> wrote:
>On 9/9/05, Joerg Sonnenberger <joerg@britannica.bec.de> wrote:
>> On Thu, Sep 08, 2005 at 05:50:48PM +0200, Julio M. Merino Vidal wrote:
>> > So the question is...  are the cookies used in all kinds of reads?
>> > Or maybe they aren't, butl the system know where to restart a
>> > readdir operation in some other way?  If so, I will simply get rid
>> > of my custom variables.
>> 
>> The cookies just store the "offset" for each entry, not only the last as
>> would be returned to userland. It is not used by anything but NFS. On
>> the other hand, if there was a bug in the handling of seeking, it would
>> be exposed by normal readdir as well.
>
>OK.  Thanks for the explanations (to Christos too).
>
>Now I realize that my question was not very accurate...  I mean, I must
>keep my caching variables because what I'm keeping track of is a
>pointer, not an offset.

I would leave it un-optimized for now (re-scan on each pass).

>I wonder if the readdir operation could be modified to return a fs-specifc
>cookie to ease restarts.  The problem is, this could be used by few
>file-systems... or maybe only tmpfs.  I'll better forget about this for a while
>;)

The way the directory code is handled, it encourages dirents to be in
contiguous memory... You could abuse the cookie code to store pointers,
but I think that this is a bad idea in the long run.

christos