Re: explicit dcache <-> user-space cache coherency, sys_mark_dir_clean(), O_CLEAN

From: Christer Weinigel
Date: Sun Feb 22 2004 - 07:18:03 EST


Ingo Molnar <mingo@xxxxxxx> writes:

> * Linus Torvalds <torvalds@xxxxxxxx> wrote:
>
> i believe Samba's problems can be solved in an even simpler way, by
> using only a single bit associated with the directory dentry, and by not
> putting any case-insensitivity code into the kernel. (not even as a
> separate module.)
>
> One 'user-space cache is valid/clean' bit should be enough - where all
> non-Samba accesses clear the 'valid bit', and Samba sets the bit
> manually.
>
> What Samba needs is a way to tell between two points in time whether the
> directory contents have changed in any way - nothing more. Only one new
> syscall is used to maintain the Samba dcache:
>
> long sys_mark_dir_clean(dirfd);
>
> the syscall returns whether the directory was valid/clean already.

Isn't this rather bad, it's only possible to have one process that
does this magic clean bit thing. Other applications such as Wine or a
DOS emulator might want to get the same speedups.

Instead of a bit, why don't just use the generation number idea that
have been tossed around? Let each directory have a generation number
which can be read with a function:

long sys_get_generation(dirfd);

Then the name lookup would work with multiple processes and with some
code like this:

repeat:
new_generation = sys_get_generation(dirfd);
if (new_generation == old_generation) {
... pure user-space fast path, use Samba dcache ...
return;
}
old_generation = generation;
... fill Samba dcache ...
readdir() loop

goto repeat;

Add a new create syscall with the same idea as your one bit syscall,
which checks that the generation number matches. If the generation
number doesn't match the create call fails.

int create_synchronized(name, mode, generation);

/Christer

--
"Just how much can I get away with and still go to heaven?"

Freelance consultant specializing in device driver programming for Linux
Christer Weinigel <christer@xxxxxxxxxxx> http://www.weinigel.se
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/