Repost: super block locking

Regis Duchesne (regis@via.ecp.fr)
Tue, 4 Nov 1997 02:44:42 +0100 (CET)


Hi,

in fs/ext2/super.c, in ext2_read_super(), I see :

kdev_t dev = sb->s_dev;

But the super block is not locked, and we read sb->s_dev. Is there a
possibility of race condition?

So what is the exact purpose of lock_super() and unlock_super()? What are the
fields of a super block this lock protects? In other words, when should we
take this lock when using a super block?

Another (silly) question : in include/linux/locks.h (not very commented),

extern inline void lock_super(struct super_block * sb)
{
if (sb->s_lock)
__wait_on_super(sb);
sb->s_lock = 1;
}

Now that AFAIK several kernel threads can simultaneously execute on a SMP
machine, is it possible that 2 kernel threads take this lock at the same
time (for both of them, sb->s_lock could be 0 at this time)?

PS : Sorry for the repost, but it seems that vger has eaten my
previous subscribe, so I haven't seen this post and related answers

Best regards,

Regis "HPReg" Duchesne - Engineering Student at ***** ******** *****
www http://www.via.ecp.fr/~regis/
(O o) I use Linux & 3Com (1135 KB/s over 10Mb/s ethernet)
--.oOO--(_)--OOo.-----------------------------------------------------------