From: Rev L. <RLe...@nv...> - 2008-06-19 02:00:36
|
Caching helps, unless your access pattern is random access to files spread throughout different parts of the filesystem. The deeper the files are in the directory tree, the worse it gets with high round-trip times. Does anybody know what NFS does in this case? Does it take the full round-trip hit times the directory depth, every time a file is accessed without its parent directories stats cached? Rev -----Original Message----- From: Jonathan Pryor [mailto:jon...@vt...] Sent: Thursday, June 19, 2008 09:39 To: Fi Dot Cc: fus...@li...; Fedor Fomichev; Sergey Nozhkin; Rev Lebaredian Subject: Re: [fuse-devel] getattr() called recursively when doing stat() on afile? On Thu, 2008-06-19 at 01:33 +0400, Fi Dot wrote: > I am trying to understand the behaviour of FUSE / Linux VFS when doing > getattr() calls to my filesystem.... <snip/> > and i'm calling stat() on my file that's being exposed by this > filesystem. Path to this file is /one/foo/1. <snip/> > Here's what I see in my debug log: > > GetAttr called. > /one > GetAttr called. > /one/foo > GetAttr called. > /one/foo/1 > > So, it seems that getattr() is called recursively for every element of > the path!!! I wouldn't call this "recursive" (getattr isn't calling getattr), but yes, getattr is being invoked for each piece of the path. This is By (Unix) Design. getattr() needs to be called to: 1. check that the path component exists (if getattr() returns an error, it doesn't exist), and 2. check that the caller can access the contents of that directory. (Consider a directory /tmp/foo with 000 permissions -- no non-root user should be able to access the contents of that directory, and a getattr() call is needed in order to make this check.) > The problem is that this filesystem is designed to expose remote > files, possibly via links with high latency, so every getattr() call > costs me the roundtrip time to remote host (which can be up to a > second!!!), effectively making highly nested directory structures very > inefficient. The answer: local caching -- every getattr() call shouldn't be a round trip, you should cache the results of previous trips (and/or better, when you make your remote call get the results for several files at once, as you can be reasonably sure more getattr() calls will be coming soon...). - Jon ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ----------------------------------------------------------------------------------- |