Added command line options -c <num_cache_entry> and -m <max_hash_collision>
to activate cache for fsck. It may significantly speed up fsck.
Signed-off-by: Robin Hsu <[email protected]>
---
fsck/main.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/fsck/main.c b/fsck/main.c
index 8c62a14..8edb177 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -10,6 +10,9 @@
* Liu Shuoran <[email protected]>
* Jaegeuk Kim <[email protected]>
* : add sload.f2fs
+ * Copyright (c) 2019 Google Inc.
+ * Robin Hsu <[email protected]>
+ * : add cache layer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -20,6 +23,7 @@
#include <ctype.h>
#include <time.h>
#include <getopt.h>
+#include <stdbool.h>
#include "quotaio.h"
struct f2fs_fsck gfsck;
@@ -54,7 +58,12 @@ void fsck_usage()
MSG(0, "\nUsage: fsck.f2fs [options] device\n");
MSG(0, "[options]:\n");
MSG(0, " -a check/fix potential corruption, reported by f2fs\n");
- MSG(0, " -C encoding[:flag1,flag2] Set options for enabling casefolding\n");
+ MSG(0, " -c <num-cache-entry> set number of cache entries"
+ " (default 0)\n");
+ MSG(0, " -m <max-hash-collision> set max cache hash collision"
+ " (default 16)\n");
+ MSG(0, " -C encoding[:flag1,flag2] Set options for enabling"
+ " casefolding\n");
MSG(0, " -d debug level [default:0]\n");
MSG(0, " -f check/fix entire partition\n");
MSG(0, " -g add default options\n");
@@ -66,6 +75,7 @@ void fsck_usage()
MSG(0, " -y fix all the time\n");
MSG(0, " -V print the version number and exit\n");
MSG(0, " --dry-run do not really fix corruptions\n");
+ MSG(0, " --debug-cache to debug cache when -c is used\n");
exit(1);
}
@@ -187,15 +197,18 @@ void f2fs_parse_options(int argc, char *argv[])
}
if (!strcmp("fsck.f2fs", prog)) {
- const char *option_string = ":aC:d:fg:O:p:q:StyV";
+ const char *option_string = ":aC:c:m:d:fg:O:p:q:StyV";
int opt = 0, val;
char *token;
struct option long_opt[] = {
{"dry-run", no_argument, 0, 1},
+ {"debug-cache", no_argument, 0, 2},
{0, 0, 0, 0}
};
c.func = FSCK;
+ c.cache_config.max_hash_collision = 16;
+ c.cache_config.dbg_en = false;
while ((option = getopt_long(argc, argv, option_string,
long_opt, &opt)) != EOF) {
switch (option) {
@@ -203,10 +216,20 @@ void f2fs_parse_options(int argc, char *argv[])
c.dry_run = 1;
MSG(0, "Info: Dry run\n");
break;
+ case 2:
+ c.cache_config.dbg_en = true;
+ break;
case 'a':
c.auto_fix = 1;
MSG(0, "Info: Fix the reported corruption.\n");
break;
+ case 'c':
+ c.cache_config.num_cache_entry = atoi(optarg);
+ break;
+ case 'm':
+ c.cache_config.max_hash_collision =
+ atoi(optarg);
+ break;
case 'g':
if (!strcmp(optarg, "android"))
c.defset = CONF_ANDROID;
--
2.24.0.rc0.303.g954a862665-goog