From: Andrew Morton <akpm@linux-foundation.org>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: linux-kernel@vger.kernel.org, miklos@szeredi.hu,
hch@infradead.org, serue@us.ibm.com
Subject: Re: [PATCH] track number of mnts writing to superblocks
Date: Wed, 9 Jan 2008 23:42:50 -0800 [thread overview]
Message-ID: <20080109234250.baa3b13b.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080102215110.F3A0B1DC@kernel>
On Wed, 02 Jan 2008 13:51:10 -0800 Dave Hansen <haveblue@us.ibm.com> wrote:
>
> One of the benefits of the r/o bind mount patches is that they
> make it explicit when a write to a superblock might occur.
> We currently search sb->s_files when remounting rw->ro to look
> for writable files. But, that search is not comprehensive, and
> it is racy. This replaces that search.
>
> The idea is to keep a bit in each mount saying whether the
> mount has any writers on it. When the bit is set the first
> time, we also increment a counter in the superblock. That
> sb counter is the number of mounts with that bit set and
> thus, potential writers.
>
> The other problem is that, after we make this check for
> the number of writable mounts, we need to exclude all new
> writers on those mounts. We do this by requring that the
> superblock mnt writer count be incremented under a
> lock_super() and also holding that lock over the remount
> operation. Effectively, this keeps us from *adding* to
> the sb's writable mounts during a remount.
>
> The alternative to doing this is to do a much simpler list
> of mounts for each superblock. I could also code that up
> to see what it look like. Shouldn't be too bad.
>
> ...
>
> -static inline void __clear_mnt_count(struct mnt_writer *cpu_writer)
> +static int mark_mnt_has_writer(struct vfsmount *mnt,
> + struct mnt_writer *cpu_writer)
> +{
> + /*
> + * Ensure that if there are people racing to set
> + * the bit that only one of them succeeds and can
> + * increment the sb count.
> + */
> + if (test_and_set_bit(ilog2(MNT_MAY_HAVE_WRITERS), &mnt->mnt_flags))
> + return 0;
boggle.
a) bitops are to be used on unsigned long only, and mnt_flags is int.
b) nowhere else is mnt_flags used as a bitfield. Presumably (hopefully)
it already has some locking. Suggest that the same locking be used
here.
c) Given that all other modifiers of mnt_flags are using non-atomic
rmw's, they can trash this function's rmw. What happens then?
> +static void __mark_sb_if_writable(struct vfsmount *mnt)
> +{
> + int bitnr = ilog2(MNT_MAY_HAVE_WRITERS);
> +
> + if (atomic_read(&mnt->__mnt_writers))
> + mark_mnt_has_writer(mnt, NULL);
> + else if (test_and_clear_bit(bitnr, &mnt->mnt_flags))
> + atomic_dec(&mnt->mnt_sb->__s_mnt_writers);
> +}
and elsewhere.
I'm a bit surprised to see such a thing coming from your direction, Dave.
prev parent reply other threads:[~2008-01-10 7:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-02 21:51 [PATCH] track number of mnts writing to superblocks Dave Hansen
2008-01-03 4:02 ` Serge E. Hallyn
2008-01-03 19:37 ` Dave Hansen
2008-01-10 7:42 ` Andrew Morton [this message]
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=20080109234250.baa3b13b.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=haveblue@us.ibm.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=serue@us.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.