[xfs-masters] RFC: Fix f_flags races without the BKL

Christoph Hellwig hch at lst.de
Tue Dec 30 08:48:37 CST 2008


On Tue, Dec 30, 2008 at 02:37:37PM +0100, Andi Kleen wrote:
> That's not clear. Mutexes can be much slower than a spinlock
> like BKL in some situations, mostly because they schedule more and
> have generally more overhead.
> 
> As long as you don't have another BKL user contending the BKL
> is likely faster than the mutex.

Note that I did not say faster, but better.  The subtle races the
BKL semantics introduce are nasty.

That beeing said I took another look at the patch and it seems like
most places are indeed just very quick flags setting / clearing
with the only sleeping possible inside ->fasync.  So having a
file_flags_lock spinlock, and another sleeping mutex protecting
->fasync might be another options.

Jon, do you remember what we actually need to protect in -fasync?
any reason not to take the locking inside the method?  Together with
->lock and the old ->ioctl it's pretty special in fops as none of
the others have any locking at all.

> 
> -Andi
> 
> -- 
> ak at linux.intel.com
> 
> _______________________________________________
> xfs-masters mailing list
> xfs-masters at oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs-masters
---end quoted text---



More information about the xfs-masters mailing list