From: Shijie Luo <luoshijie1@huawei.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: <linux-fsdevel@vger.kernel.org>, <viro@zeniv.linux.org.uk>,
<lihaotian9@huawei.com>, <lutianxiong@huawei.com>, <jack@suse.cz>,
<linfeilong@huawei.com>
Subject: Re: [PATCH RESEND] fs: fix race condition oops between destroy_inode and writeback_sb_inodes
Date: Mon, 21 Sep 2020 16:29:42 +0800 [thread overview]
Message-ID: <30ea42a6-bb76-387c-1197-eabfcfca1ec7@huawei.com> (raw)
In-Reply-To: <20200919145632.GM32101@casper.infradead.org>
On 2020/9/19 22:56, Matthew Wilcox wrote:
> This part is unnecessary. We just allocated 'new' two lines above;
> nobody else can see 'new' yet. We make it visible with hlist_add_head_rcu()
> which uses rcu_assign_pointer() whch contains a memory barrier, so it's
> impossible for another CPU to see a stale i_state.
>
>> inode = inode_insert5(new, hashval, test, set, data);
>> - if (unlikely(inode != new))
>> + if (unlikely(inode != new)) {
>> + spin_lock(&new->i_lock);
>> + new->i_state |= I_FREEING;
>> + spin_unlock(&new->i_lock);
>> + inode_wait_for_writeback(new);
>> destroy_inode(new);
> This doesn't make sense either. If an inode is returned here which is not
> 'new', then adding 'new' to the hash failed, and new was never visible
> to another CPU.
>
>> @@ -1218,6 +1225,11 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino)
>> * allocated.
>> */
>> spin_unlock(&inode_hash_lock);
>> +
>> + spin_lock(&inode->i_lock);
>> + inode->i_state |= I_FREEING;
>> + spin_unlock(&inode->i_lock);
>> + inode_wait_for_writeback(inode);
>> destroy_inode(inode);
> Again, this doesn't make sense. This is also a codepath which failed to
> make 'inode' visible to any other thread.
>
> I don't understand how this patch could fix anything.
> .
Thanks for your review,the underlying filesystem is ext4,
ext4_alloc_inode doesn't
allocate a new vfs inode from slab, and I found the "new inode" was used
by another
thread in vmcore, in other words, the new inode should be a new one ,
but not.
Maybe it's not a filesystem problem, and fixing this problem in
iget_locked is not
a good way, I 'll try to find the root cause and fix it.
next prev parent reply other threads:[~2020-09-21 8:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-19 9:39 [PATCH RESEND] fs: fix race condition oops between destroy_inode and writeback_sb_inodes Shijie Luo
2020-09-19 14:56 ` Matthew Wilcox
2020-09-21 8:29 ` Shijie Luo [this message]
2020-09-21 10:25 ` Jan Kara
2020-09-24 14:00 ` Shijie Luo
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=30ea42a6-bb76-387c-1197-eabfcfca1ec7@huawei.com \
--to=luoshijie1@huawei.com \
--cc=jack@suse.cz \
--cc=lihaotian9@huawei.com \
--cc=linfeilong@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lutianxiong@huawei.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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).