locking samba during critical VFS file operations?

James Peach jpeach at samba.org
Tue Sep 27 22:44:18 GMT 2005

On Mon, 2005-09-26 at 18:00 -0500, Sean Dunn wrote:
> In the rename operation of my VFS, I have to do some recursive updating
> of symbolic links in the file system that the samba share sits on top
> of. 
> Because this relinking could cause the view of the filesystem to become
> inconsistent (only during this operation), I believe I need to lock
> samba for all accesses to subdirectories of the directory being renamed.
> It'd like to wait until all pending operations have finished, do my
> critical section of code, and then unlock. Operations that happen after
> I request the lock should wait until I've unlocked. Is it possible to
> achieve this level of mutual exclusion in the samba API, or is it a
> feature that I need to implement myself using mutexes?

AFAIK there is no internal Samba API to do what you want so you will
have to implement something yourself. One easy thing to do would be to
use flock against file named (say) .vfs_mutex in each directory. You
would be able to hide its existence from clients since you are
overriding readdir.
James Peach | jpeach at samba.org

More information about the samba-technical mailing list