[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTikvUvzQMjoM26PowGWVqAopdSSjKvE-NzSB2xMJ@mail.gmail.com>
Date: Mon, 17 May 2010 16:19:34 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Jan Kara <jack@...e.cz>, Alexander Viro <viro@...iv.linux.org.uk>,
David Howells <dhowells@...hat.com>,
Alexander Shishkin <virtuoso@...nd.org>,
Artem Bityutskiy <dedekind1@...il.com>,
linux-mtd@...ts.infradead.org, linux-fsdevel@...r.kernel.org,
stable@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] mtd: Do not corrupt backing device of device node
inode
On Fri, May 14, 2010 at 4:04 AM, David Woodhouse <dwmw2@...radead.org> wrote:
> 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?
Yes, it's ugly, but I don't see options.
>> @@ -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.
Ok, I'll fix it.
> 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?
inode destroys only on del_mtd_device() so it's safe to re-open chardevice.
> 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@...el.com Intel Corporation
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists