Re: smbfs: "rm -rf" dircache problems

Urban Widmark (urban@svenskatest.se)
Fri, 12 Nov 1999 19:54:19 +0100 (CET)


On Fri, 12 Nov 1999, Petr Vandrovec Ing. VTEI wrote:

> If invalidate does not occur, dentries still have their old numbers.
> BTW in correct caching implementation there must not be need to
> invalidate cache on unlink/mkdir, you must be able to notice change
> from other clients too, so why do it twice.

Yes. Except possibly if you have detected that something looks wrong and
want to try to minimize the damage.
("Big trouble! The inode has become a new object" -- fs/smbfs/inode.c)

> And as we have pointers to dentries in dircache, even if 'ls' occurs
> in time window, when directory change is not checked (configurable
> 0-20000ms), readdir (fs/ncpfs/dir.c:ncp_d_validate, taken from nfs)
> notices that dentry in cache is invalid and whole directory cache is
> invalidated and reread. So getdents with position after unlinked files
> are still cached, but getdents with position before unlinked files
> cause cache invalidation.

I don't understand exactly how this works, I can't really see the
difference between before and after in the code. I'll look some more
later. But thanks for explaining, there are a lot of things that can be
borrowed here. :)

> > it to use the dirs mtime should be as simple as ... no, I can't get it to
> > work now. It keeps invalidating the cache for me :(
> Then remove all cache invalidation calls except one when mtime differs.
> It must then work :-)

I kept looking at it last night after writing in (who needs sleep anyway
:). It works for much larger things now, and I believe my only problem is
that it changes the mtime somewhere where I don't want it to.

rm -rf:
...
Nov 12 02:11:08 054a kernel: smb_readdir: reading drivers/net, f_pos=0

readdir to remove some entries. things are unlink'ed.

Nov 12 02:11:08 054a kernel: smb_readdir: reading drivers/net, f_pos=18
Nov 12 02:11:08 054a kernel: smb_revalidate: drivers/net changed,
old=942369062, new=942369064
Nov 12 02:11:08 054a kernel: smb_refill_dircache: mtime: 942369064

but here the mtime changed so the readdir refills the cache. You only
check mtime for fpos==2 (right?), I check it for every readdir. So if
readdir crossess a time "border" I detect the mtime change since unlink
sets mtime (the diff of 2 is probably because of smb precision).

Adding that condition makes it work for a more complex tree (the kernel
sources). I'll clean it up and post a patch for comments (and testing for
those brave enough :).

/Urban

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/