Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp929379ybk; Fri, 15 May 2020 18:06:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQtUYfFj+5igYDJrQIkpf6IOF7OgAA3wNvr7799LKaULwbFFum8b72zxIQseZfO9UX0FDN X-Received: by 2002:aa7:cd5a:: with SMTP id v26mr5557059edw.320.1589591217489; Fri, 15 May 2020 18:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589591217; cv=none; d=google.com; s=arc-20160816; b=C6Sa49RPk7N4PqjTNQr9L7hQhzhrbyEwPvK0nVPZFPdhaUYdrBlNLlYbgHXlWVhVxv gt9jBHCO27Zh+kvqX/dF8qIppWvFjcgh1iUhhHYUx34cxuqvyoshTg7Q8ZushmfrmAzs sBwQlv5uPwJqVJPPvXDAiXqa1ffom2u3c5+T67j4ZTkfg02vWGbsQZHwBFwK/vVNje25 XiEhz2m9ACTluOqaVKLswfurRFVSikCoLMLyLRhvt9e7tyr6Y+3G0wnn2NE9tzmZltT+ iTuLqeXHd96aotAFXXknHhWtSrDIgKyOv/Fj8WaROy5V3uyqr1VW6jt4aYxeKxszYmpQ C9pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CpOoxys/ZN+Cpt1dwiPQ375eB2mOVKnFdQkSJKM/VYU=; b=DM7N/2LJVaPRNsAsBETIMcFTPiYT3kl0Zy6HgHaJmqZQuM5zExritp7o/gbYJAVBZ+ OVJV5cg0m8XLONrwlkYOU4ifGlvQnibpJC6wesHpvfC++/8kiCB7SxqQ1jONDesrG6Ab 91D+CmXF+KmfRXvbLREWmU6B1ZsLMxSnlswKAk0ZAvaJHLe5n+/GKwNaFv0N++uA05pr JHBq+/k5iS1QT0HK2CTQa/EbWU1DQSEJmw2ageISHJDNfw/WppFCeFZOeV34bI18BN74 epMzRNwjK7GqAhEAZ3zIW+aw9wyY9i+k6TECxXTIMqQ1NE9/NHYBoiwXwJM7oj/GCKGR W5Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zzTXUDS0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id j4si2522662ejn.341.2020.05.15.18.06.34; Fri, 15 May 2020 18:06:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zzTXUDS0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727059AbgEPBEU (ORCPT + 99 others); Fri, 15 May 2020 21:04:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbgEPBEU (ORCPT ); Fri, 15 May 2020 21:04:20 -0400 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 810FA20671; Sat, 16 May 2020 01:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589591059; bh=YxpuI17mMTnCsgPgr4+idWQJpE0CThxM8O7KvpRZj9o=; h=From:To:Cc:Subject:Date:From; b=zzTXUDS0VoiW9kPvGtDXz+emZ5aDm3SUE+Jo9Q9VFtrWok1oDDY6ZtOsTliuYBKcG +FiZZYoV/lqQiq3c+M/Q/PjLiHTxmMtfSEP9q/eQxFdgtoP5X98fxQorwIFn1b6UAx OsMpjAcVdB8qovjQHw8TYuJZoWYm8G2SydZIYRS8= From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Jaegeuk Kim Subject: [PATCH] f2fs: fix checkpoint=disable:%u%% Date: Fri, 15 May 2020 18:04:16 -0700 Message-Id: <20200516010416.116281-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When parsing the mount option, we don't have sbi->user_block_count. Should do it after getting it. Signed-off-by: Jaegeuk Kim --- fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 51863e4f5d4e0..fb180020e175c 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -139,6 +139,7 @@ struct f2fs_mount_info { 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_perc; /* percentage for cap */ block_t unusable_cap; /* Amount of space allowed to be * unusable when disabling checkpoint */ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 441eaaf9739c4..a71da699cb2d5 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -284,6 +284,22 @@ static inline void limit_reserve_root(struct f2fs_sb_info *sbi) F2FS_OPTION(sbi).s_resgid)); } +static inline void adjust_unusable_cap_perc(struct f2fs_sb_info *sbi) +{ + if (!F2FS_OPTION(sbi).unusable_cap_perc) + return; + + if (F2FS_OPTION(sbi).unusable_cap_perc == 100) + F2FS_OPTION(sbi).unusable_cap = sbi->user_block_count; + else + F2FS_OPTION(sbi).unusable_cap = (sbi->user_block_count / 100) * + F2FS_OPTION(sbi).unusable_cap_perc; + + f2fs_info(sbi, "Adjust unusable cap for checkpoint=disable = %u / %u%%", + F2FS_OPTION(sbi).unusable_cap, + F2FS_OPTION(sbi).unusable_cap_perc); +} + static void init_once(void *foo) { struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo; @@ -785,12 +801,7 @@ static int parse_options(struct super_block *sb, char *options) return -EINVAL; if (arg < 0 || arg > 100) return -EINVAL; - if (arg == 100) - F2FS_OPTION(sbi).unusable_cap = - sbi->user_block_count; - else - F2FS_OPTION(sbi).unusable_cap = - (sbi->user_block_count / 100) * arg; + F2FS_OPTION(sbi).unusable_cap_perc = arg; set_opt(sbi, DISABLE_CHECKPOINT); break; case Opt_checkpoint_disable_cap: @@ -1840,6 +1851,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0); limit_reserve_root(sbi); + adjust_unusable_cap_perc(sbi); *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME); return 0; restore_gc: @@ -3516,6 +3528,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) sbi->reserved_blocks = 0; sbi->current_reserved_blocks = 0; limit_reserve_root(sbi); + adjust_unusable_cap_perc(sbi); for (i = 0; i < NR_INODE_TYPE; i++) { INIT_LIST_HEAD(&sbi->inode_list[i]); -- 2.26.2.761.g0e0b3e54be-goog