From: Andrew Morton <akpm@osdl.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@lst.de>, Greg KH <greg@kroah.com>
Subject: Re: Naughty ramdrives
Date: Thu, 7 Sep 2006 15:20:37 -0700 [thread overview]
Message-ID: <20060907152037.a4e1437b.akpm@osdl.org> (raw)
In-Reply-To: <20060907220852.GA5192@martell.zuzino.mipt.ru>
On Fri, 8 Sep 2006 02:08:53 +0400
Alexey Dobriyan <adobriyan@gmail.com> wrote:
> > So I assume udev is still madly crunching on its message backlog while
> > this is happening?
> >
> > If so, ug.
>
> OK. I'll let it stabilize, sorry.
You shouldn't have to.
> > > This was noticed while investigating #4899
> > > http://bugme.osdl.org/show_bug.cgi?id=4899
> > > where /dev/ram0 when opened, pins module indefinitely. It seems that
> > > adding ->release() which undoes
> > >
> > > inode = igrab(bdev->bd_inode);
> > >
> > > should do the trick. Am I right?
>
> > Looks right.
> >
> > I'm not sure that igrab() is needed though. Probably bd_openers is
> > sufficient.
> >
> > I'm also not sure that rd_open() needs to play with bd_openers.
> > fs/block_dev.c:do_open() already does that.
>
> Maybe start with closing open/open race?
> That's what drivers/char/raw.c does...
> ------------------------------------------------
> [PATCH 1/2] rd: protect rd_bdev[] with mutex
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
>
> drivers/block/rd.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> --- a/drivers/block/rd.c
> +++ b/drivers/block/rd.c
> @@ -56,6 +56,7 @@ #include <linux/buffer_head.h> /* for i
> #include <linux/backing-dev.h>
> #include <linux/blkpg.h>
> #include <linux/writeback.h>
> +#include <linux/mutex.h>
>
> #include <asm/uaccess.h>
>
> @@ -63,6 +64,7 @@ #include <asm/uaccess.h>
> */
>
> static struct gendisk *rd_disks[CONFIG_BLK_DEV_RAM_COUNT];
> +static DEFINE_MUTEX(rd_mutex);
This could be static to rd_open().
> static struct block_device *rd_bdev[CONFIG_BLK_DEV_RAM_COUNT];/* Protected device data */
> static struct request_queue *rd_queue[CONFIG_BLK_DEV_RAM_COUNT];
>
> @@ -343,6 +345,7 @@ static int rd_open(struct inode *inode,
> {
> unsigned unit = iminor(inode);
>
> + mutex_lock(&rd_mutex);
I suspect that we've inherited enough locking from the caller to not need
this. That's if fs/block_dev.c:do_open() is the only caller. Not sure if
that's true if someone goes and partitions a ramdisk (is that possible?).
All this gendisk/blockdev/contains/partitions/bd_inode stuff is quite
ghastly. Every six months I spend long enough staring at it to
half-understand it and then promptly forget how it all works.
next prev parent reply other threads:[~2006-09-07 22:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-07 20:59 Naughty ramdrives Alexey Dobriyan
2006-09-07 21:54 ` Andrew Morton
2006-09-07 22:05 ` Greg KH
2006-09-07 22:08 ` Alexey Dobriyan
2006-09-07 22:20 ` Andrew Morton [this message]
2006-09-07 23:01 ` Greg KH
2006-09-07 23:28 ` Andrew Morton
2006-09-07 23:49 ` Greg KH
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=20060907152037.a4e1437b.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=adobriyan@gmail.com \
--cc=greg@kroah.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.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