Re: Super block locking

Andrew E. Mileski (aem@netcom.ca)
Wed, 12 Nov 1997 00:37:39 -0500 (EST)


> Strangely, fs/super.c doesn't use super block locking in read_super() to
> access s_dev, s_flags, s_rd_only, s_dirt, and s_type
>
> So when should we use this lock?

I wrote this once already...maybe it didn't get through.

The lock prevents access by others WAITING on the super.
If you don't wait (or try to lock the super), there is
no locking effect.

1) Lock the super when you don't want it to change.
2) Lock the super when you want to change it.
3) Lock the super when you want to access multiple
fields in an inter-dependent manner.

The super is always up-to-date, except before it is in
use (no kidding), which includes read_super() before
it returns success. Locking the super before this prevents
races from two mount operations. Note that there is a separate
lock preventing mount/umount races.

Or so it seems to me...

--
Andrew E. Mileski   mailto:aem@netcom.ca