Re: [Patch 7/10]: ext3 online resize: SMP locking for groupmetadata

From: Stephen C. Tweedie
Date: Fri Oct 01 2004 - 06:42:19 EST


Hi,

On Fri, 2004-10-01 at 11:18, Pavel Machek wrote:

> > The precise rules we use are:

> > * Readers must hold lock_super() over the access
> > OR
> > * Readers must perform an smp_rmb() after reading the groups count
> > and before reading any dependent data.
> > This leaves the hot path, where s_groups_count is referenced, requiring
> > an smp_rmb(); but no other locking on that hot path is required.
>
> Should not s_groups_count be atomic_t, then? Is it possible that
> normal read sees only half-updated value?

Resize is very rare, whereas the s_groups_count is checked all the
time. So I really want to use the most lightweight primitives possible
on the read path. It may even be possible to downgrade the smp_rmb() to
an smp_read_data_depends().

So I don't want to make it atomic if I can avoid it. It's just an
unsigned long, and I don't know of any cases where a simple read
colliding with a write is going to give the reader a corrupt value. As
long as I get either the old or new value, everything should be fine
with the read/write barriers as they are.

There are a couple of other values being updated by resize: the reserved
block count, and the s_group_desc index into the group descriptor
buffer_heads. Unfortunately, the latter simply can't be an atomic_t
(it's a pointer).

So if you really think there's a risk of getting inconsistent reads,
atomic_t isn't going to be enough to fix it.

Cheers,
Stephen

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