Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2063174ybv; Fri, 14 Feb 2020 10:43:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwOz08WV670xGVISKZEJTemV4q+4daL4U3H6tazWHy0jOSppWZkQg/NP8tstlUK/p1toTVo X-Received: by 2002:aca:5f87:: with SMTP id t129mr2878243oib.36.1581705831305; Fri, 14 Feb 2020 10:43:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581705831; cv=none; d=google.com; s=arc-20160816; b=kkaF93q8ED5iE3NdtLPZnqJMWeelJSH0MDyewr4Cq+n1d/ZWmFxv5jrL27eudQw2Uz yykZzR+DFBIyntVmG3fjOLtAGeDqb0Dna/aZ6/PhzB2inyhvKowfaaAeEmBV+Izk6Nlm kc0z+UlUu+npa+KUx5RRRU6/D6QYb/GzjvXh5GyVqV4cUCZPt1Ncpe4MnePEinGO1jtF vXawB5gc1KFLJ0MNhL2QAVl+gtoorj3PHJQOUXQ1C43gQyxDUBdw41Od89rmTrx0eQJG KBWmnDpNaakOgCJO95BoU1+l7nyDcNEZINZBt1G9zYUwXt0Ogi7OsAvRpm8mt7MMtoJj gfAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ltSNlVnHM3+AaS6faxrdZt9je7qYJlUWgvz3HC2gmqw=; b=EXxBcQ++3D49xzA8KoyxXwwqIYAt26F0l41g8FsxeUFuAUFjlVQJIDHVhhSe2XRPQ7 7bDqwsyfA9TFEsJ26oKIUuYqFn/O0vsMlBdEeO7BxpHJcjI+islxbtynYoUIN9pq99e4 o+zvLgSuLCurkJ/L7QeUOUagVembBIRN9SgwZ7y4nnB4SJMrw6gGqGRfw5MFr3SrBFis kViNs8bBtHQ53KKvfW3xkpfyRDt7fOqUO5kCZ03Y37w5gOUm1DkZ59U44wNvT9FChkeQ iI1XR8zDM4ZKICMIIFk5T8lPFYayV2OxUmNipmsPmzyVC95BAM9YdngN8RQ6gSHS6XeL zhGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zvSP+nP6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si2771464oij.125.2020.02.14.10.43.38; Fri, 14 Feb 2020 10:43:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zvSP+nP6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390306AbgBNSmZ (ORCPT + 99 others); Fri, 14 Feb 2020 13:42:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:42096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389140AbgBNSmZ (ORCPT ); Fri, 14 Feb 2020 13:42:25 -0500 Received: from localhost (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 82BDE20848; Fri, 14 Feb 2020 18:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581705744; bh=4AdnTNN0gHbVkCHLDFezKZQu0UT0RSGK1lGwpIXl1FQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zvSP+nP6pVGOtksO4HTfMpzHx2jURbY/d3sn6nQmYlGOScsZ70UfCB88EQha9t+Oc +94jznNpnxPEK8sgbjUJfb26Ti86MV+DftO4Y54qxZVLUHjuhcADLLD3cO6QWhEnu+ hUOkPefGHIphY01rdfnm3eYMA9wmrCOyH10cwhIA= Date: Fri, 14 Feb 2020 10:42:24 -0800 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH 4/4] f2fs: clean up bggc mount option Message-ID: <20200214184224.GC60913@google.com> References: <20200214094413.12784-1-yuchao0@huawei.com> <20200214094413.12784-4-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200214094413.12784-4-yuchao0@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/14, Chao Yu wrote: > There are three status for background gc: on, off and sync, it's > a little bit confused to use test_opt(BG_GC) and test_opt(FORCE_FG_GC) > combinations to indicate status of background gc. > > So let's remove F2FS_MOUNT_BG_GC and F2FS_MOUNT_FORCE_FG_GC mount I don't think we can do as well. > options, and add F2FS_OPTION().bggc_mode with below three status > to clean up codes and enhance bggc mode's scalability. > > enum { > BGGC_MODE_ON, /* background gc is on */ > BGGC_MODE_OFF, /* background gc is off */ > BGGC_MODE_SYNC, /* > * background gc is on, migrating blocks > * like foreground gc > */ > }; > > Signed-off-by: Chao Yu > --- > fs/f2fs/f2fs.h | 12 ++++++++++-- > fs/f2fs/gc.c | 6 +++++- > fs/f2fs/super.c | 29 +++++++++++++---------------- > 3 files changed, 28 insertions(+), 19 deletions(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index d2d50827772c..9f65ba8057ad 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -74,7 +74,6 @@ extern const char *f2fs_fault_name[FAULT_MAX]; > /* > * For mount options > */ > -#define F2FS_MOUNT_BG_GC 0x00000001 > #define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002 > #define F2FS_MOUNT_DISCARD 0x00000004 > #define F2FS_MOUNT_NOHEAP 0x00000008 > @@ -88,7 +87,6 @@ extern const char *f2fs_fault_name[FAULT_MAX]; > #define F2FS_MOUNT_NOBARRIER 0x00000800 > #define F2FS_MOUNT_FASTBOOT 0x00001000 > #define F2FS_MOUNT_EXTENT_CACHE 0x00002000 > -#define F2FS_MOUNT_FORCE_FG_GC 0x00004000 > #define F2FS_MOUNT_DATA_FLUSH 0x00008000 > #define F2FS_MOUNT_FAULT_INJECTION 0x00010000 > #define F2FS_MOUNT_USRQUOTA 0x00080000 > @@ -137,6 +135,7 @@ struct f2fs_mount_info { > int alloc_mode; /* segment allocation policy */ > int fsync_mode; /* fsync policy */ > int fs_mode; /* fs mode: LFS or ADAPTIVE */ > + int bggc_mode; /* bggc mode: off, on or sync */ > bool test_dummy_encryption; /* test dummy encryption */ > block_t unusable_cap; /* Amount of space allowed to be > * unusable when disabling checkpoint > @@ -1170,6 +1169,15 @@ enum { > GC_URGENT, > }; > > +enum { > + BGGC_MODE_ON, /* background gc is on */ > + BGGC_MODE_OFF, /* background gc is off */ > + BGGC_MODE_SYNC, /* > + * background gc is on, migrating blocks > + * like foreground gc > + */ > +}; > + > enum { > FS_MODE_ADAPTIVE, /* use both lfs/ssr allocation */ > FS_MODE_LFS, /* use lfs allocation only */ > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > index 8aebe2b9c655..897de003e423 100644 > --- a/fs/f2fs/gc.c > +++ b/fs/f2fs/gc.c > @@ -31,6 +31,8 @@ static int gc_thread_func(void *data) > > set_freezable(); > do { > + bool sync_mode; > + > wait_event_interruptible_timeout(*wq, > kthread_should_stop() || freezing(current) || > gc_th->gc_wake, > @@ -101,8 +103,10 @@ static int gc_thread_func(void *data) > do_gc: > stat_inc_bggc_count(sbi->stat_info); > > + sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC; > + > /* if return value is not zero, no victim was selected */ > - if (f2fs_gc(sbi, test_opt(sbi, FORCE_FG_GC), true, NULL_SEGNO)) > + if (f2fs_gc(sbi, sync_mode, true, NULL_SEGNO)) > wait_ms = gc_th->no_gc_sleep_time; > > trace_f2fs_background_gc(sbi->sb, wait_ms, > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 427409eff354..4ef7e6eb37da 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -427,14 +427,11 @@ static int parse_options(struct super_block *sb, char *options) > if (!name) > return -ENOMEM; > if (strlen(name) == 2 && !strncmp(name, "on", 2)) { > - set_opt(sbi, BG_GC); > - clear_opt(sbi, FORCE_FG_GC); > + F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; > } else if (strlen(name) == 3 && !strncmp(name, "off", 3)) { > - clear_opt(sbi, BG_GC); > - clear_opt(sbi, FORCE_FG_GC); > + F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_OFF; > } else if (strlen(name) == 4 && !strncmp(name, "sync", 4)) { > - set_opt(sbi, BG_GC); > - set_opt(sbi, FORCE_FG_GC); > + F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC; > } else { > kvfree(name); > return -EINVAL; > @@ -1436,14 +1433,13 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) > { > struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb); > > - if (!f2fs_readonly(sbi->sb) && test_opt(sbi, BG_GC)) { > - if (test_opt(sbi, FORCE_FG_GC)) > - seq_printf(seq, ",background_gc=%s", "sync"); > - else > - seq_printf(seq, ",background_gc=%s", "on"); > - } else { > + if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) > + seq_printf(seq, ",background_gc=%s", "sync"); > + else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_ON) > + seq_printf(seq, ",background_gc=%s", "on"); > + else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF) > seq_printf(seq, ",background_gc=%s", "off"); > - } > + > if (test_opt(sbi, DISABLE_ROLL_FORWARD)) > seq_puts(seq, ",disable_roll_forward"); > if (test_opt(sbi, DISCARD)) > @@ -1573,8 +1569,8 @@ static void default_options(struct f2fs_sb_info *sbi) > F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZO; > F2FS_OPTION(sbi).compress_log_size = MIN_COMPRESS_LOG_SIZE; > F2FS_OPTION(sbi).compress_ext_cnt = 0; > + F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; > > - set_opt(sbi, BG_GC); > set_opt(sbi, INLINE_XATTR); > set_opt(sbi, INLINE_DATA); > set_opt(sbi, INLINE_DENTRY); > @@ -1780,7 +1776,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) > * or if background_gc = off is passed in mount > * option. Also sync the filesystem. > */ > - if ((*flags & SB_RDONLY) || !test_opt(sbi, BG_GC)) { > + if ((*flags & SB_RDONLY) || > + F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF) { > if (sbi->gc_thread) { > f2fs_stop_gc_thread(sbi); > need_restart_gc = true; > @@ -3664,7 +3661,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) > * If filesystem is not mounted as read-only then > * do start the gc_thread. > */ > - if (test_opt(sbi, BG_GC) && !f2fs_readonly(sb)) { > + if (F2FS_OPTION(sbi).bggc_mode != BGGC_MODE_OFF && !f2fs_readonly(sb)) { > /* After POR, we can run background GC thread.*/ > err = f2fs_start_gc_thread(sbi); > if (err) > -- > 2.18.0.rc1