From: viro@parcelfarce.linux.theplanet.co.uk
To: Nikita Danilov <Nikita@Namesys.COM>
Cc: Zan Lynx <zlynx@acm.org>,
linux-kernel@vger.kernel.org, reiserfs-list@namesys.com,
Linus Torvalds <torvalds@osdl.org>
Subject: Re: 2.6.0-test6 crash while reading files in /proc/fs/reiserfs/sda1
Date: Thu, 2 Oct 2003 11:26:45 +0100 [thread overview]
Message-ID: <20031002102644.GA7665@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <16251.63770.622805.143036@laputa.namesys.com>
On Thu, Oct 02, 2003 at 02:08:26PM +0400, Nikita Danilov wrote:
> 1. r_start() call sget() and this seems somewhat expensive (sget()
> starts by allocating new super block just for case) to be done at the
> beginning of each read operation, especially given that we already have
> pointer to the super block. Probably slook() function that only looks
> for the super block without creating it would be useful.
>
> 2. More importantly, sget() doesn't actually seem to provide protection
> against races with umount (which I think is its purpose): test_sb
> callback will succeed for any super block with the same *address*, which
> may be (and will be, given slab allocator) some completely unrelated
> super block that just happened to be allocated at the same address as
> (already freed) de->parent->data. Roughly speaking, super block in
> de->parent->data is untrusted pointer and, as such, is almost completely
> useless.
That's OK. Yes, we could get reused superblock. Which is perfectly fine,
since
a) whatever superblock we get, we know that it won't go away
b) if it had been reused, we will know that immediately - in that
case ->put_super() had already run its course and thus de->deleted had
been set before sget() had returned.
IOW, sget() alone would *not* be enough, but sget() + check for ->deleted +
desactivate_super() if ->deleted was set *is*. See how it works?
The first point is true and applies not only to that case - indeed, sget()
is pessimistic. It should be dealt with in sget() itself, though, and it's
easy to deal with. The same way as iget() does it.
diff -urN B6-rest/fs/super.c B6-current/fs/super.c
--- B6-rest/fs/super.c Sat Sep 27 22:04:57 2003
+++ B6-current/fs/super.c Thu Oct 2 06:23:22 2003
@@ -226,13 +226,10 @@
int (*set)(struct super_block *,void *),
void *data)
{
- struct super_block *s = alloc_super();
+ struct super_block *s = NULL;
struct list_head *p;
int err;
- if (!s)
- return ERR_PTR(-ENOMEM);
-
retry:
spin_lock(&sb_lock);
if (test) list_for_each(p, &type->fs_supers) {
@@ -242,9 +239,18 @@
continue;
if (!grab_super(old))
goto retry;
- destroy_super(s);
+ if (s)
+ destroy_super(s);
return old;
}
+ if (!s) {
+ spin_unlock(&sb_lock);
+ s = alloc_super();
+ if (!s)
+ return ERR_PTR(-ENOMEM);
+ goto retry;
+ }
+
err = set(s, data);
if (err) {
spin_unlock(&sb_lock);
next prev parent reply other threads:[~2003-10-02 10:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-30 15:44 2.6.0-test6 crash while reading files in /proc/fs/reiserfs/sda1 Zan Lynx
2003-09-30 15:51 ` Jonathan Briggs
2003-09-30 16:06 ` Vitaly Fertman
2003-09-30 19:18 ` Hans Reiser
2003-10-01 10:11 ` Vitaly Fertman
2003-10-01 14:44 ` Zan Lynx
2003-10-01 17:15 ` Vitaly Fertman
2003-10-01 17:54 ` Nikita Danilov
2003-10-01 18:43 ` viro
2003-10-02 10:08 ` Nikita Danilov
2003-10-02 10:26 ` viro [this message]
2003-10-02 10:35 ` viro
2003-10-02 10:51 ` Nikita Danilov
2003-10-02 12:01 ` viro
2003-10-02 15:40 ` Nikita Danilov
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=20031002102644.GA7665@parcelfarce.linux.theplanet.co.uk \
--to=viro@parcelfarce.linux.theplanet.co.uk \
--cc=Nikita@Namesys.COM \
--cc=linux-kernel@vger.kernel.org \
--cc=reiserfs-list@namesys.com \
--cc=torvalds@osdl.org \
--cc=zlynx@acm.org \
/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