On Tue, 22 Oct 2002, Luben Tuikov wrote:
> Also, why is there 2 identical if() checks for pb_resv_bh_cnt?
> One inside the lock and one outside? Isn't this begging for
> a race condition?
Actually, this was recently changed to be this way to -avoid-
a race, as suggested by another third party (see TAKE message from a day
or two ago...)
It used to say (pseudo-code):
if reserved bh pool seems full (not checking under spinlock)
just free the bh
else
spin_lock the reserved pool lock
add the bh back to the reserved pool
wake up waiters
spin_unlock the reserved pool lock
but, in between checking whether the pool is full, and taking action,
pool could actually have emptied or filled, so we could either free
when it should be added to the pool, or vice versa.
So now, we do:
if reserved pool seems to not be full (spinlock not held)
spin_lock the reserved pool lock
check whether the reserved pool is -really- not full
if it is really not full,
add the bh back to the pool
wake up waiters
spin_unlock
if the pool is probably full, or is definitely full,
free the bh
I guess this still could race in the case where the pool seems to be
full when not under the spinlock, and we free it when we shouldn't...
although I'd have to think what the implications of that might be. :)
We really don't want to have to aquire a lock every time we free a buffer
head here, this all only matters for a low-memory case.
And, for all the attention this code has received in the past few days,
it actually should rarely be executed in the "not full" case.
> After the attidute I've seen here, I'd better put everything
> in question form, else woe is me.
Eh, just don't accuse the SGI fs gurus (which is a position to which
I aspire, but do not claim to have attained) of failing C 101, and we'll all
get along fine. ;-)
The XFS code is vast and complex, and there are only
a handful of people working on it for Linux, and development stretches back
into time... and yes, there are bugs. If you find one, just report it,
and send patches if you can. And if you are using XFS commercially, remember
what you paid for it, and refrain from agitating the people who provide
it to you.
This is a pretty friendly place in general.
-Eric
|