From: Chao Yu <yuchao0@huawei.com>
To: Sheng Yong <shengyong1@huawei.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [RFC PATCH 6/8] fsck.f2fs: introduce new option --dry-run
Date: Tue, 31 Oct 2017 15:57:52 +0800 [thread overview]
Message-ID: <9ebcb886-ae85-6cb0-2a61-df3d2a585df1@huawei.com> (raw)
In-Reply-To: <20171031013824.46544-6-shengyong1@huawei.com>
On 2017/10/31 9:38, Sheng Yong wrote:
> With --dry-run enabled, fsck.f2fs will do all checks and "fixes" except
> that all fixes will not be written to storage at last.
>
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
> ---
> fsck/main.c | 14 +++++++++++++-
> include/f2fs_fs.h | 1 +
> lib/libf2fs.c | 1 +
> lib/libf2fs_io.c | 3 +++
> 4 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/fsck/main.c b/fsck/main.c
> index 93037e1..baa8efc 100644
> --- a/fsck/main.c
> +++ b/fsck/main.c
> @@ -18,6 +18,7 @@
> #include "fsck.h"
> #include <libgen.h>
> #include <ctype.h>
> +#include <getopt.h>
>
> struct f2fs_fsck gfsck;
>
> @@ -30,6 +31,7 @@ void fsck_usage()
> MSG(0, " -f check/fix entire partition\n");
> MSG(0, " -p preen mode [default:0 the same as -a [0|1]]\n");
> MSG(0, " -t show directory tree\n");
> + MSG(0, " --dry-run do not really fix corruptions\n");
> exit(1);
> }
>
> @@ -117,10 +119,20 @@ void f2fs_parse_options(int argc, char *argv[])
>
> if (!strcmp("fsck.f2fs", prog)) {
> const char *option_string = ":ad:fp:t";
> + int opt = 0;
> + struct option long_opt[] = {
> + {"dry-run", no_argument, 0, 1},
> + {0, 0, 0, 0}
> + };
>
> c.func = FSCK;
> - while ((option = getopt(argc, argv, option_string)) != EOF) {
> + while ((option = getopt_long(argc, argv, option_string,
> + long_opt, &opt)) != EOF) {
> switch (option) {
> + case 1:
> + c.dry_run = 1;
> + MSG(0, "Info: Dry run\n");
> + break;
> case 'a':
> c.auto_fix = 1;
> MSG(0, "Info: Fix the reported corruption.\n");
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index e1e299d..64a796d 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -300,6 +300,7 @@ struct f2fs_configuration {
> int trimmed;
> int func;
> void *private;
> + int dry_run;
> int fix_on;
> int bug_on;
> int auto_fix;
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 69f5ccc..259bd17 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -598,6 +598,7 @@ void f2fs_init_configuration(void)
> c.trimmed = 0;
> c.ro = 0;
> c.kd = -1;
> + c.dry_run = 0;
> }
>
> static int is_mounted(const char *mpt, const char *device)
> diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
> index 50ff171..8a79672 100644
> --- a/lib/libf2fs_io.c
> +++ b/lib/libf2fs_io.c
> @@ -129,6 +129,9 @@ int dev_write(void *buf, __u64 offset, size_t len)
> {
> int fd;
>
> + if (c.dry_run)
> + return 0;
> +
> if (c.sparse_mode)
> return dev_write_sparse(buf, offset, len);
Do we need to cover dev_write_block?
Thanks,
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2017-10-31 7:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 1:38 [RFC PATCH 1/8] fsck.f2fs: do not set fix_on directly Sheng Yong
2017-10-31 1:38 ` [RFC PATCH 2/8] fsck.f2fs: do not fix corrupted nat entries in build_nat_area_bitmap Sheng Yong
2017-10-31 7:20 ` Chao Yu
2017-10-31 8:57 ` Sheng Yong
2017-10-31 10:43 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 3/8] dump/fsck: introduce print_xattr_entry Sheng Yong
2017-10-31 7:51 ` Chao Yu
2017-10-31 9:02 ` Sheng Yong
2017-10-31 10:44 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 4/8] dump.f2fs: introduce dump_xattr Sheng Yong
2017-10-31 7:51 ` Chao Yu
2017-10-31 9:11 ` Sheng Yong
2017-10-31 10:46 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 5/8] dump.f2fs: do not dump encrypted files Sheng Yong
2017-10-31 7:57 ` Chao Yu
2017-10-31 9:16 ` Sheng Yong
2017-10-31 11:09 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 6/8] fsck.f2fs: introduce new option --dry-run Sheng Yong
2017-10-31 7:57 ` Chao Yu [this message]
2017-10-31 9:19 ` Sheng Yong
2017-10-31 11:10 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 7/8] fsck.f2fs: introduce sanity_check_inode Sheng Yong
2017-10-31 8:04 ` Chao Yu
2017-10-31 9:21 ` Sheng Yong
2017-10-31 1:38 ` [RFC PATCH 8/8] f2fs-tools: remove unused list.h Sheng Yong
2017-10-31 8:05 ` Chao Yu
2017-10-31 7:06 ` [RFC PATCH 1/8] fsck.f2fs: do not set fix_on directly Chao Yu
2017-10-31 9:34 ` Sheng Yong
2017-10-31 11:12 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ebcb886-ae85-6cb0-2a61-df3d2a585df1@huawei.com \
--to=yuchao0@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=shengyong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).