On Thu, 27 Jul 2000, Tigran Aivazian wrote:

> On Thu, 27 Jul 2000, Daniel Phillips wrote:
> > So now it's time to start asking questions.  Just jumping in at a place I felt I
> > knew pretty well back in 2.2.13, I'm now looking at the 2.4.0 getblk, and I see
> > it's changed somewhat.  Finding and removing a block from the free list is now
> > bracketed by a spinlock pair.  First question: why do we use atomic_set to set
> > the initial buffer use count if this is already protected by a spinlock?
> 
> have a look at other users of bh->b_count. For example __brelse() does
> atomic_dec() and it is called directly from brelse() which can be called
> by filesystem without any other protection.

actually, that was naive answer and it was wrong. The correct answer is -
in that piece of code you do _not_ actually care about atomicity of the
b_count operation as you are the only user of it. However, atomicity of
b_count is needed in general, so, to keep the same API to access it one
just sets it to 1 in the getblk() using atomic_set() rather than just
b_count.counter = 1.

Regards,
Tigran

Reply via email to