locking samba during critical VFS file operations?

Sean Dunn sean at troublemakerstudios.com
Wed Sep 28 16:16:11 GMT 2005


Yeah, I'm kind of a cautious pessimist when I start thinking about disk
access and speed :) Thanks for all your help James.

Sean

-----Original Message-----
From: James Peach [mailto:jpeach at samba.org] 
Sent: Tuesday, September 27, 2005 6:17 PM
To: Sean Dunn
Cc: samba-technical at lists.samba.org
Subject: RE: locking samba during critical VFS file operations?

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
stuff.

> 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