From: David Woodhouse <dwmw2@infradead.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Jan Kara <jack@suse.cz>, Artem Bityutskiy <dedekind1@gmail.com>,
linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>,
Alexander Shishkin <virtuoso@slind.org>,
linux-mtd@lists.infradead.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH v4] mtd: Do not corrupt backing device of device node inode
Date: Fri, 14 May 2010 02:04:34 +0100 [thread overview]
Message-ID: <1273799074.9999.653.camel@macbook.infradead.org> (raw)
In-Reply-To: <1273074054-11849-1-git-send-email-kirill@shutemov.name>
On Wed, 2010-05-05 at 18:40 +0300, Kirill A. Shutemov wrote:
> We cannot modify file->f_mapping->backing_dev_info, because it will corrupt
> backing device of device node inode, since file->f_mapping is equal to
> inode->i_mapping (see __dentry_open() in fs/open.c).
>
> Let's introduce separate inode for MTD device with appropriate backing
> device.
I hate the fact that we have to do this -- is it really the only option?
Is it _just_ for the backing_device_info? Can't that be done
differently?
> @@ -85,11 +88,27 @@ static int mtd_open(struct inode *inode, struct file *file)
> goto out;
> }
>
> - if (mtd->backing_dev_info)
> - file->f_mapping->backing_dev_info = mtd->backing_dev_info;
> + if (!mtd->inode) {
> + mtd->inode = new_inode(mtd_inode_mnt->mnt_sb);
I believe that would be a race condition, if it wasn't for the BKL.
And what happens when you close the chardevice and call iput() on the
inode so it's destroyed, and then you re-open the device? You never set
mtd->inode = NULL, so won't it now try to igrab a stale pointer?
You won't have seen this in your testing unless you made it prune the
icache between the close and open calls.
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
next prev parent reply other threads:[~2010-05-14 1:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 15:40 [PATCH v4] mtd: Do not corrupt backing device of device node inode Kirill A. Shutemov
2010-05-06 6:39 ` Artem Bityutskiy
2010-05-14 1:04 ` David Woodhouse [this message]
2010-05-17 13:19 ` Kirill A. Shutemov
2010-05-17 21:56 ` Jan Kara
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=1273799074.9999.653.camel@macbook.infradead.org \
--to=dwmw2@infradead.org \
--cc=dedekind1@gmail.com \
--cc=dhowells@redhat.com \
--cc=jack@suse.cz \
--cc=kirill@shutemov.name \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=stable@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=virtuoso@slind.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;
as well as URLs for NNTP newsgroup(s).