Sam Lang wrote:

On Dec 19, 2005, at 6:07 PM, Rob Ross wrote:

I don't consider rmdirent to be a case that we need to highly optimize, so if it helps to lookup the name and do the getattr beforehand, that's cool by me. I'm sure somewhere out there there is a rmdir test that we'll do a little worse on, but whatever.

You'll still have to getattr again after the rmdirent to make sure that the directory is still empty though, in case someone sneaks in between the first getattr and the rmdirent and creates something.

I think I can just check if the directory is not empty. If the getattr tells me it is empty, I just do the remove, and if someone else has added an entry in the meantime, I'll get the ENOTOEMPTY from the server at that point, so I can go add the entry back in to the parent (which is what we do now).

So by this you mean to just check once, before the rmdirent, to see if it is empty. I agree; I proposed adding an unnecessary operation.

Side note to Murali: if we had vtags here, we could avoid the race :).

The race that's an issue seems to be if the getattr tells me the directory is not empty, in which case I just return ENOTEMPTY back to the caller, but in the meantime someone else could have removed all the entries (in which case the remove should have succeeded). I'm not sure that's much of an issue for our users though.

That's not a race. First thing that happens on a file removal is that the directory entry is removed, so if something is being removed, it won't be in the directory.

Right now our caching scheme is under-the-covers so to speak, where we always continue with the operation if the cache misses. It seems like we could make a decision based on a cache hit. In other words, if I know the name and attribute are cached, I can save time by checking if the directory is not empty. If its not cached, I can just go down the rmdirent path like we do now. Doing lookup/getattr will add an extra roundtrip in most cases (where the directory is empty) if things aren't being cached. Overkill?

I don't like caching negative entries without consistency, so I like the idea of going down the path if we don't have any directory contents cached.

Rob
_______________________________________________
PVFS2-developers mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-developers

Reply via email to