From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966375AbdGUDhD (ORCPT ); Thu, 20 Jul 2017 23:37:03 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:10238 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966051AbdGUDhC (ORCPT ); Thu, 20 Jul 2017 23:37:02 -0400 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: let background GC being aware of freezing Date: Fri, 21 Jul 2017 11:36:35 +0800 Message-ID: <20170721033635.6277-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.13.1.388.g69e6b9b4f4a9 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.597176CF.007C,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: 6af09a5814cddeb654fdc01a65b2b59d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When ->freeze_fs is called from lvm for doing snapshot, it needs to make sure there will be no more changes in filesystem's data, however, previously, background GC wasn't aware of freezing, so in environment with active background GC thread, data of snapshot becomes unstable. This patch fixes this issue by adding sb_{start,end}_intwrite in GC flow. Signed-off-by: Chao Yu --- fs/f2fs/gc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 76ad2c3d88db..1c0117f60083 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -55,6 +55,8 @@ static int gc_thread_func(void *data) } #endif + sb_start_intwrite(sbi->sb); + /* * [GC triggering condition] * 0. GC is not conducted currently. @@ -69,12 +71,12 @@ static int gc_thread_func(void *data) * So, I'd like to wait some time to collect dirty segments. */ if (!mutex_trylock(&sbi->gc_mutex)) - continue; + goto next; if (!is_idle(sbi)) { increase_sleep_time(gc_th, &wait_ms); mutex_unlock(&sbi->gc_mutex); - continue; + goto next; } if (has_enough_invalid_blocks(sbi)) @@ -93,6 +95,8 @@ static int gc_thread_func(void *data) /* balancing f2fs's metadata periodically */ f2fs_balance_fs_bg(sbi); +next: + sb_end_intwrite(sbi->sb); } while (!kthread_should_stop()); return 0; -- 2.13.1.388.g69e6b9b4f4a9