From: "Stephen C. Tweedie" <sct@redhat.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
"ext2-devel@lists.sourceforge.net"
<ext2-devel@lists.sourceforge.net>
Cc: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
Stephen Tweedie <sct@redhat.com>, Andrew Morton <akpm@osdl.org>
Subject: ext2/3: Incomplete/buggy use of s_debts in Orlov
Date: 10 Sep 2004 17:49:49 +0100 [thread overview]
Message-ID: <1094834989.2047.171.camel@sisko.scot.redhat.com> (raw)
Hi all,
I've been tidying up the online resize code for -mm and come across one
nasty item. The s_debts array is the only dynamic, fs-sized array in
the entirety of ext2/3, so it's the only dynamic array we need to grow
when we resize.
But to get the locking for that right, we need to know what the locking
for s_debts is in the first place. Looking at that I found two rather
odd things:
On ext2, s_debts is modified with only the per-group lock:
spin_lock(sb_bgl_lock(sbi, group));
if (S_ISDIR(mode)) {
if (sbi->s_debts[group] < 255)
sbi->s_debts[group]++;
where s_debts is defined as
u8 *s_debts;
in the superblock. That was OK when we had a global lock_super(sb)
round every allocation, but it's extremely dangerous to perform byte
accesses like this when the rest of the memory word is shared with other
CPUs. It certainly risks word-tearing on machines like Alpha; I think
it's theoretically unsafe even on x86.
On ext3, the situation is actually much simpler:
s_debts is never modified at all.
Ever.
It's allocated, carefully checked, then freed. But never modified.
Now, that's fine with me --- it makes the locking for s_debts *really*
easy to get right. :-) And in my current resize patches, I just nuke
s_debts entirely.
But if anybody thinks it really needs to stay, then a Plan B is
required, and we probably need to start off by fixing the locking in
ext2 itself.
--Stephen
reply other threads:[~2004-09-10 16:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1094834989.2047.171.camel@sisko.scot.redhat.com \
--to=sct@redhat.com \
--cc=akpm@osdl.org \
--cc=ext2-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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
all inboxes | Powered by JetHome®