From: David Woodhouse <dwmw2@infradead.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Jan Kara <jack@suse.cz>, Alexander Viro <viro@zeniv.linux.org.uk>,
David Howells <dhowells@redhat.com>,
Alexander Shishkin <virtuoso@slind.org>,
Artem Bityutskiy <dedekind1@gmail.com>,
linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org,
stable@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] mtd: Do not corrupt backing device of device node inode
Date: Mon, 17 May 2010 15:10:41 +0100 [thread overview]
Message-ID: <1274105441.6930.6920.camel@macbook.infradead.org> (raw)
In-Reply-To: <AANLkTimB1DsCd8HuMDc9jgVOnOAE_PVd2ktssp3TIwxc@mail.gmail.com>
On Mon, 2010-05-17 at 16:55 +0300, Kirill A. Shutemov wrote:
> + if (!mtd->inode) {
> + struct inode *mtd_inode;
> + mtd_inode = new_inode(mtd_inode_mnt->mnt_sb);
> + if (!mtd_inode) {
> + put_mtd_device(mtd);
> + ret = -ENOMEM;
> + goto out;
> + }
> + mtd_inode->i_mode = S_IFCHR;
> + mtd_inode->i_rdev = inode->i_rdev;
> + if (mtd->backing_dev_info) {
> + mtd_inode->i_data.backing_dev_info =
> + mtd->backing_dev_info;
> + }
> +
> + if (unlikely(cmpxchg(&mtd->inode, NULL, mtd_inode))) {
> + /* Somebody has already initialized mtd->inode
> */
> + iput(mtd_inode);
> + }
> + }
> +
> + igrab(mtd->inode);
Now you're just reimplementing iget().
Can we just use iget_locked() to get the appropriate inode (using the
mtd device number as the inode number)? Then we don't need to bother
storing it in mtd->inode at all, and we can iput() the last refcount on
it when the chardevice is closed -- we don't need it to stick around
until the MTD device is destroyed.
--
dwmw2
next prev parent reply other threads:[~2010-05-17 14:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-17 13:55 [PATCH v5] mtd: Do not corrupt backing device of device node inode Kirill A. Shutemov
2010-05-17 14:10 ` David Woodhouse [this message]
2010-05-18 11:27 ` David Woodhouse
2010-05-18 12:18 ` Kirill A. Shutemov
2010-05-18 12:45 ` David Woodhouse
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=1274105441.6930.6920.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).