locking samba during critical VFS file operations?

James Peach jpeach at samba.org
Tue Sep 27 23:16:59 GMT 2005

On Tue, 2005-09-27 at 17:57 -0500, Sean Dunn wrote:
> Thanks for your reply James! Yeah, I thought about doing this, but
> figured the constant lock checking for every operation may slow things
> down.

It's not as bad as you make out. Take a blocking read lock on opendir()
and release it on closedir(). If you are doing a rename of the
directory, take a write lock.

> What do you think about doing locking via flock versus through
> System V semaphores (semget(), semctl(), etc)?

fcntl locks have the useful property of going away when the holding
process exits. This usually makes them easier to manage than the sysv

> Is Linux flock implemented as a memory access or a file access?

It's a system call, but whether that ends up touching a disk would
depend on the filesystem. I'd be very surprised if any disk access was
involved, however.

James Peach | jpeach at samba.org

More information about the samba-technical mailing list