From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932464AbdJZOWU (ORCPT ); Thu, 26 Oct 2017 10:22:20 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9430 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932410AbdJZOWN (ORCPT ); Thu, 26 Oct 2017 10:22:13 -0400 From: Yunlong Song To: , , , , CC: , , , , Subject: [PATCH] f2fs: fix out-of-free problem caused by atomic write Date: Thu, 26 Oct 2017 22:21:55 +0800 Message-ID: <1509027715-80477-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.59F1EF91.0010,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 53b355d4dfa19253cb951f3a07761696 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org f2fs_balance_fs only actives once in the commit_inmem_pages, but there are more than one page to commit, so all the other pages will miss the check. This will lead to out-of-free problem when commit a very large file. To fix it, we should do f2fs_balance_fs for each inmem page. Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 46dfbca..fa2c36b 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -384,6 +384,9 @@ static int __commit_inmem_pages(struct inode *inode, unlock_page(page); break; } + f2fs_unlock_op(sbi); + f2fs_balance_fs(sbi, true); + f2fs_lock_op(sbi); /* record old blkaddr for revoking */ cur->old_addr = fio.old_blkaddr; last_idx = page->index; @@ -409,7 +412,6 @@ int commit_inmem_pages(struct inode *inode) int err; INIT_LIST_HEAD(&revoke_list); - f2fs_balance_fs(sbi, true); f2fs_lock_op(sbi); set_inode_flag(inode, FI_ATOMIC_COMMIT); -- 1.8.5.2