Re: Ext2fs locking

From: Stephen C. Tweedie (sct@redhat.com)
Date: Fri Apr 28 2000 - 06:09:12 EST


Hi,

On Wed, Apr 26, 2000 at 04:52:52PM +0300, Benhanokh Gabriel wrote:
>
> i'm trying to write a pure block allocator(i.e. it only allocates
> blocks, and doesn't read any of them) for the ext2fs.
>
> to do this i need to lock the blocks-bitmap of the blocks-group i'm
> working on before alloacting.
>
> the problem is that i failed to find a way to lock ONLY the
> blocks-bitmap, in the ext2fs code i saw that the only lock they use is
> lock_super which locks the whole super-block( is it ?).
> this seems like an over-kill for this stuff.

Indeed. Correct locking for the block allocator can in fact be
achieved assuming no more than the big kernel lock. The main
reason for the superblock lock is to manage the bitmap cache over
IO operations.

> one more thing
> the lock_super code is as follows ( extracted from locks.h )
>
> extern inline void lock_super(struct super_block * sb)
> {
> if (sb->s_lock)
> __wait_on_super(sb);
> sb->s_lock = 1;
> }

That's perfectly safe, because the code operates in the context of
a process running with the big kernel lock.

--Stephen

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:14 EST