public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 13:01:33 +0100	[thread overview]
Message-ID: <20031002120133.GC7665@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <16252.798.375208.261677@laputa.namesys.com>

[Linus, please wait with applying the patch below until ACK from Nikita, OK?]

On Thu, Oct 02, 2003 at 02:51:10PM +0400, Nikita Danilov wrote:
> viro@parcelfarce.linux.theplanet.co.uk writes:
>  > On Thu, Oct 02, 2003 at 02:08:26PM +0400, Nikita Danilov wrote:
>  > > What about creating fake struct vfsmount for /proc/fs/reiserfs/<devname>
>  > > and attaching it to the super block of /<mountpoint>? After all
>  > > /proc/fs/reiserfs/<devname> is just a view into /<mountpoint>. This will
>  > > automatically guarantee that /<mountpoint> cannot be unmounted while
>  > > files in /proc/fs/reiserfs/<devname> are opened. Will this screw up
>  > > dcache?
>  > 
>  > I don't see what it would buy you - you get to revalidate the pointer to
>  > vfsmount instead of revalidating pointer to superblock, which is not easier.
> 
> I thought that opening procfs file would do mntget() that will pin super
> block of host file system. Wouldn't it?

That wouldn't help.  Look, the real problem here is that at some point
you need to decide that filesystem is getting shut down.  Doesn't really
matter how you do it - until some moment superblock is up and running,
after it we start shutting the things down.

Now, you want two places that would get access to superblock (directly or
not, again, it doesn't matter): mountpoint and file in procfs.  Mountpoint
is given up by explicit action - umount.  You want that action to trigger
removal of file in procfs.  I.e. you don't want simple presense of that
file to pin the thing down.  OTOH, you want IO on that file to hold
the filesystem until we are done.  Whether we do that in open() or in
read(), we still have a transition point somewhere.

And that transition is where the trouble is.  The object you want to access
is superblock.  So no matter what you do, you will need to get hold of it.
Which brings us back to revalidation of pointers to superblocks...

There *is* an alternative, and it might be worth considering, but it's much
more intrusive.  We might give these files a separate superblock and have
them mounted explicitly.  Then we are fine - this superblock would have
a pointer to vfsmount or reiserfs superblock directly and would pin it
down as long as it's mounted.  It would look like that:

mount -t reisermeta <pathname of reiserfs mountpoint> <some directory>

and we get these files under <some directory>.  That would avoid all problems
nicely and it's not hard to implement, but it's definitely more intrusive than
sget()-based revalidation and it creates a user-visible interface change.

It might be worth doing as an alternative interface (Jeff Garzik had played
with similar stuff for ext2 metadata/defragmenting/etc., so there's even
some existing code), but I would rather go for minimally intrusive correct
fix right now.


Speaking of seq_file...  It's not impossible to do if this context is kept
on stack of ->start()/->next()/->stop()/->show() callers, but I'm not sure
it buys us enough to be worth doing.


If you are OK with the patch below - please ACK it.  AFAICS it's the minimal
fix and combined with optimistic sget() patch it should address all objections.

diff -urN B6-rest/fs/reiserfs/procfs.c B6-current/fs/reiserfs/procfs.c
--- B6-rest/fs/reiserfs/procfs.c	Sat Sep 27 22:04:57 2003
+++ B6-current/fs/reiserfs/procfs.c	Thu Oct  2 07:57:31 2003
@@ -478,14 +478,15 @@
 static void *r_next(struct seq_file *m, void *v, loff_t *pos)
 {
 	++*pos;
+	if (v)
+		deactivate_super(v);
 	return NULL;
 }
 
 static void r_stop(struct seq_file *m, void *v)
 {
-	struct proc_dir_entry *de = m->private;
-	struct super_block *s = de->data;
-	deactivate_super(s);
+	if (v)
+		deactivate_super(v);
 }
 
 static int r_show(struct seq_file *m, void *v)

  reply	other threads:[~2003-10-02 12:01 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
2003-10-02 10:35           ` viro
2003-10-02 10:51             ` Nikita Danilov
2003-10-02 12:01               ` viro [this message]
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=20031002120133.GC7665@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