lkml.org 
[lkml]   [1998]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: dcache
Magnus Ahltorp writes:
> Negative caching is done when deleting files, but I cannot see any
> negative caching when lookup returns ENOENT. Is there a reason why this
> feature is not implemented? It speeds up things like compiling and make
> quite a bit.

You're right, if lookup() returns an error, then the dentry is freed
and hence there is no negative dentry. However...

> If I want to implement this feature in my filesystem, does anyone have any
> bright ideas on how to do it, like d_allocing my own dentry, leaving the
> inode == NULL and do a d_add?

You don't need to allocate a new dentry. You simply need to do:
d_add (dentry, NULL);

on the existing dentry that was passed to lookup().

So, you see, a filesystem has the choice of whether to "return" a
negative dentry or remove the dentry. If you look at the ext2 FS
implementation, you'll see that it's lookup() method will "return" a
negative dentry. So in fact it's doing what you want.

Also note that most filesystems *must* return negative dentries,
otherwise create(2), mknod(2), mkdir(2) and other system calls which
create inodes would fail. Only a read-only filesystem could safely
return an error in it's lookup() method.

Regards,

Richard....

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.037 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site