mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>,
	Andreas Dilger <adilger@clusterfs.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"ext2-devel@lists.sourceforge.net"
	<ext2-devel@lists.sourceforge.net>,
	Stephen Tweedie <sct@redhat.com>
Subject: Re: [Patch 7/10]: ext3 online resize: SMP locking for group metadata
Date: 01 Oct 2004 12:40:38 +0100	[thread overview]
Message-ID: <1096630838.2001.14.camel@sisko.scot.redhat.com> (raw)
In-Reply-To: <20041001101822.GA18786@elf.ucw.cz>

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


  reply	other threads:[~2004-10-01 11:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-30 13:23 Stephen Tweedie
2004-10-01 10:18 ` Pavel Machek
2004-10-01 11:40   ` Stephen C. Tweedie [this message]
2004-10-01 12:42     ` [Ext2-devel] " Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1096630838.2001.14.camel@sisko.scot.redhat.com \
    --to=sct@redhat.com \
    --cc=adilger@clusterfs.com \
    --cc=akpm@osdl.org \
    --cc=ext2-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome