From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754904AbdGVAs0 (ORCPT ); Fri, 21 Jul 2017 20:48:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:60986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753602AbdGVAsV (ORCPT ); Fri, 21 Jul 2017 20:48:21 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5219D22C96 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=chao@kernel.org Subject: Re: [PATCH] f2fs: let background GC being aware of freezing To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20170721033635.6277-1-yuchao0@huawei.com> <20170721205418.GA14361@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: Date: Sat, 22 Jul 2017 08:47:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170721205418.GA14361@jaegeuk-macbookpro.roam.corp.google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jaegeuk, On 2017/7/22 4:54, Jaegeuk Kim wrote: > Hi Chao, > > On 07/21, Chao Yu wrote: >> 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. > > What about flush/discard threads? Updated. Thanks, > > Thanks, > >> >> 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