From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932611AbcEKQmZ (ORCPT ); Wed, 11 May 2016 12:42:25 -0400 Received: from mail.kernel.org ([198.145.29.136]:35627 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbcEKQmX (ORCPT ); Wed, 11 May 2016 12:42:23 -0400 Date: Wed, 11 May 2016 09:42:22 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs: fix deadlock when flush inline data Message-ID: <20160511164222.GA18057@jaegeuk.gateway> References: <20160511114844.8380-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160511114844.8380-1-yuchao0@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chao, On Wed, May 11, 2016 at 07:48:44PM +0800, Chao Yu wrote: > Below backtrace info was reported by Yunlei He: > > Call Trace: > [] schedule+0x35/0x80 > [] rwsem_down_read_failed+0xed/0x130 > [] call_rwsem_down_read_failed+0x18/0x > [] down_read+0x20/0x30 > [] f2fs_evict_inode+0x242/0x3a0 [f2fs] > [] evict+0xc7/0x1a0 > [] iput+0x196/0x200 > [] __dentry_kill+0x179/0x1e0 > [] dput+0x199/0x1f0 > [] __fput+0x18b/0x220 > [] ____fput+0xe/0x10 > [] task_work_run+0x77/0x90 > [] exit_to_usermode_loop+0x73/0xa2 > [] do_syscall_64+0xfa/0x110 > [] entry_SYSCALL64_slow_path+0x25/0x25 > > Call Trace: > [] schedule+0x35/0x80 > [] __wait_on_freeing_inode+0xa3/0xd0 > [] ? autoremove_wake_function+0x40/0x4 > [] find_inode_fast+0x7d/0xb0 > [] ilookup+0x6a/0xd0 > [] sync_node_pages+0x210/0x650 [f2fs] > [] ? do_fsync+0x70/0x70 > [] block_operations+0x9e/0xf0 [f2fs] > [] ? bio_endio+0x55/0x60 > [] write_checkpoint+0x92/0xba0 [f2fs] > [] ? mempool_free_slab+0x17/0x20 > [] ? mempool_free+0x2b/0x80 > [] ? do_fsync+0x70/0x70 > [] f2fs_sync_fs+0x63/0xd0 [f2fs] > [] ? ext4_sync_fs+0xbf/0x190 > [] sync_fs_one_sb+0x20/0x30 > [] iterate_supers+0xb9/0x110 > [] sys_sync+0x55/0x90 > [] do_syscall_64+0x69/0x110 > [] entry_SYSCALL64_slow_path+0x25/0x25 > > With following excuting serials, we will set inline_node in inode page > after inode was unlinked, result in a deadloop described as below: > 1. open file > 2. write file > 3. unlink file > 4. write file > 5. close file Oh, I also tried this scenario before, but it seems I missed something. I've seen writepages() was called to clear the flag between #4 and #5, but it seems there was a timing difference. Anyway, I could reproduce this and confirm that this patch fixed the issue. :) Thanks, > > Thread A Thread B > - dput > - iput_final > - inode->i_state |= I_FREEING > - evict > - f2fs_evict_inode > - f2fs_sync_fs > - write_checkpoint > - block_operations > - f2fs_lock_all (down_write(cp_rwsem)) > - f2fs_lock_op (down_read(cp_rwsem)) > - sync_node_pages > - ilookup > - find_inode_fast > - __wait_on_freeing_inode > (wait on I_FREEING clear) > > Here, we change to set inline_node flag only for linked inode for fixing. > > Reported-by: Yunlei He > Signed-off-by: Chao Yu > --- > fs/f2fs/data.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index eb6ce31..7805736 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1544,7 +1544,8 @@ restart: > if (pos + len <= MAX_INLINE_DATA) { > read_inline_data(page, ipage); > set_inode_flag(F2FS_I(inode), FI_DATA_EXIST); > - set_inline_node(ipage); > + if (inode->i_nlink) > + set_inline_node(ipage); > } else { > err = f2fs_convert_inline_page(&dn, page); > if (err) > -- > 2.8.2.311.gee88674