Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965698AbbLPCfJ (ORCPT ); Tue, 15 Dec 2015 21:35:09 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:51116 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932725AbbLPCfH (ORCPT ); Tue, 15 Dec 2015 21:35:07 -0500 X-AuditID: cbfee61a-f79266d000003652-ac-5670cdd918f4 From: Chao Yu To: "'Jaegeuk Kim'" Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <00fb01d136fa$97e29d70$c7a7d850$@samsung.com> <20151215220128.GB66113@jaegeuk.local> In-reply-to: <20151215220128.GB66113@jaegeuk.local> Subject: RE: [PATCH 8/8] f2fs: fix to avoid deadlock between checkpoint and writepages Date: Wed, 16 Dec 2015 10:34:22 +0800 Message-id: <013401d137aa$5e657350$1b3059f0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQIFfceoXHr9dUit1BuJgiJV/f7EfwIYG9U0nlOX49A= Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRmVeSWpSXmKPExsVy+t9jQd2bZwvCDFreGlg8WT+L2eLSIneL y7vmsDkwe2xa1cnmsXvBZyaPz5vkApijuGxSUnMyy1KL9O0SuDIaLuQUPFaq6Hm8m6WBcYdM FyMnh4SAicTre++YIGwxiQv31rN1MXJxCAnMYpSYsKGPEcJ5xShxadMPVpAqNgEVieUd/8E6 RATUJHr3TQGzmQU8JBo7voPVCAkkSWxauoIZxOYUMJZYfOgJG4gtLBAhcXftYkYQm0VAVeJs 40MWEJtXwFJi9d5pTBC2oMSPyfdYIGZqSazfeRxqvrzE5jVvmSEuVZDYcfY1I8QNVhKvWqey Q9SIS2w8cotlAqPQLCSjZiEZNQvJqFlIWhYwsqxilEgtSC4oTkrPNcxLLdcrTswtLs1L10vO z93ECA76Z1I7GA/ucj/EKMDBqMTDqxFTECbEmlhWXJl7iFGCg1lJhLc7HijEm5JYWZValB9f VJqTWnyIUZqDRUmct/ZSZJiQQHpiSWp2ampBahFMlomDU6qBMWxz077yJPb1B30Wa/As5dqe L9T+wzg+Tnjb/voSYVO51vvsLf/TZ+nsE3iw9Ya6Sc+Lz3v9RacKxHoVLuRKT1NbuC30gkDQ PLadOwOTZuapTa0886igQmnVjwJhpoK4hLc1bGd4lMruKj7LFFPLUDh2pe5MqDDn1NwvSU0f fTfdthGs1X6rxFKckWioxVxUnAgAPQMglXYCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4579 Lines: 122 Hi Jaegeuk, > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Wednesday, December 16, 2015 6:01 AM > To: Chao Yu > Cc: linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 8/8] f2fs: fix to avoid deadlock between checkpoint and writepages > > Hi Chao, > > On Tue, Dec 15, 2015 at 01:36:08PM +0800, Chao Yu wrote: > > This patch fixes to move f2fs_balance_fs out of sbi->writepages' > > coverage to avoid potential ABBA deadlock which was found by lockdep: > > > > Possible unsafe locking scenario: > > > > CPU0 CPU1 > > ---- ---- > > lock(&sbi->writepages); > > lock(&sbi->cp_mutex); > > lock(&sbi->writepages); > > lock(&sbi->cp_mutex); > > > > *** DEADLOCK *** > > I expect it will be fine if syncing is done by f2fs_balance_fs_bg(). Yes, I will drop this patch. Thanks, > > Thanks, > > > > > stack of CPU0: > > [] __lock_acquire+0x1321/0x1770 > > [] lock_acquire+0xb7/0x130 > > [] mutex_lock_nested+0x52/0x380 > > [] f2fs_balance_fs+0x8b/0xa0 [f2fs] > > [] f2fs_write_data_page+0x33b/0x460 [f2fs] > > [] __f2fs_writepage+0x1a/0x50 [f2fs] > > [] T.1541+0x293/0x560 [f2fs] > > [] f2fs_write_data_pages+0x12c/0x230 [f2fs] > > [] do_writepages+0x23/0x40 > > [] __filemap_fdatawrite_range+0xb5/0xf0 > > [] filemap_write_and_wait_range+0xa3/0xd0 > > [] f2fs_symlink+0x180/0x300 [f2fs] > > [] vfs_symlink+0xb7/0xe0 > > [] SyS_symlinkat+0xc5/0x100 > > [] SyS_symlink+0x16/0x20 > > [] entry_SYSCALL_64_fastpath+0x12/0x6f > > > > stack of CPU1 > > [] lock_acquire+0xb7/0x130 > > [] mutex_lock_nested+0x52/0x380 > > [] f2fs_write_data_pages+0x11e/0x230 [f2fs] > > [] do_writepages+0x23/0x40 > > [] __filemap_fdatawrite_range+0xb5/0xf0 > > [] filemap_fdatawrite+0x1f/0x30 > > [] sync_dirty_inodes+0x4d/0xd0 [f2fs] > > [] block_operations+0x71/0x160 [f2fs] > > [] write_checkpoint+0xe8/0xbb0 [f2fs] > > [] f2fs_sync_fs+0x8f/0xf0 [f2fs] > > [] f2fs_balance_fs_bg+0x6f/0xd0 [f2fs] > > [] f2fs_write_node_pages+0x57/0x150 [f2fs] > > [] do_writepages+0x23/0x40 > > [] __writeback_single_inode+0x6d/0x3d0 > > [] writeback_sb_inodes+0x2c7/0x520 > > [] wb_writeback+0x133/0x330 > > [] wb_do_writeback+0xe8/0x270 > > [] wb_workfn+0x80/0x1f0 > > [] process_one_work+0x20c/0x5c0 > > [] worker_thread+0x132/0x5f0 > > [] kthread+0xde/0x100 > > [] ret_from_fork+0x3f/0x70 > > > > Signed-off-by: Chao Yu > > --- > > fs/f2fs/data.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > index 2e97057..985671d 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -506,7 +506,6 @@ static void __allocate_data_blocks(struct inode *inode, loff_t offset, > > u64 end_offset; > > > > while (len) { > > - f2fs_balance_fs(sbi); > > f2fs_lock_op(sbi); > > > > /* When reading holes, we need its node page */ > > @@ -1186,7 +1185,7 @@ out: > > if (err) > > ClearPageUptodate(page); > > unlock_page(page); > > - if (need_balance_fs) > > + if (need_balance_fs && !test_opt(sbi, DATA_FLUSH)) > > f2fs_balance_fs(sbi); > > if (wbc->for_reclaim) { > > f2fs_submit_merged_bio(sbi, DATA, WRITE); > > @@ -1617,6 +1616,8 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, > > trace_f2fs_direct_IO_enter(inode, offset, count, rw); > > > > if (rw == WRITE) { > > + f2fs_balance_fs(sbi); > > + > > if (serialized) > > mutex_lock(&sbi->writepages); > > __allocate_data_blocks(inode, offset, count); > > -- > > 2.6.3 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/