diff mbox series

[1/4] tune2fs: allow setting the filesystem error bit

Message ID 152054000138.29838.920751580862408052.stgit@magnolia
State Superseded, archived
Headers show
Series e2scrub: online fsck for ext4 | expand

Commit Message

Darrick Wong March 8, 2018, 8:13 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Allow the administrator to mark the filesystem's error bit to force a
fsck at the next mount.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 misc/tune2fs.8.in |    4 ++++
 misc/tune2fs.c    |    5 +++++
 2 files changed, 9 insertions(+)

Comments

Andreas Dilger March 9, 2018, 3:49 a.m. UTC | #1
On Mar 8, 2018, at 1:13 PM, Darrick J. Wong <darrick.wong@oracle.com> wrote:
> 
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Allow the administrator to mark the filesystem's error bit to force a
> fsck at the next mount.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Nice and simple.  We should have added something like this years ago.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> misc/tune2fs.8.in |    4 ++++
> misc/tune2fs.c    |    5 +++++
> 2 files changed, 9 insertions(+)
> 
> 
> diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in
> index 740d166..f1def2b 100644
> --- a/misc/tune2fs.8.in
> +++ b/misc/tune2fs.8.in
> @@ -238,6 +238,10 @@ program.
> This superblock setting is only honored in 2.6.35+ kernels;
> and not at all by the ext2 and ext3 file system drivers.
> .TP
> +.B force_fsck
> +Set a flag in the filesystem superblock indicating that errors have been found.
> +This will force fsck to run at the next mount.
> +.TP
> .B test_fs
> Set a flag in the filesystem superblock indicating that it may be
> mounted using experimental kernel code, such as the ext4dev filesystem.
> diff --git a/misc/tune2fs.c b/misc/tune2fs.c
> index 93160c9..ea84e1e 100644
> --- a/misc/tune2fs.c
> +++ b/misc/tune2fs.c
> @@ -2117,6 +2117,10 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
> 			       intv);
> 			fs->super->s_mmp_update_interval = intv;
> 			ext2fs_mark_super_dirty(fs);
> +		} else if (!strcmp(token, "force_fsck")) {
> +			fs->super->s_state |= EXT2_ERROR_FS;
> +			printf(_("Setting filesystem error flag to force fsck.\n"));
> +			ext2fs_mark_super_dirty(fs);
> 		} else if (!strcmp(token, "test_fs")) {
> 			fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
> 			printf("Setting test filesystem flag\n");
> @@ -2199,6 +2203,7 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
> 			"\tmmp_update_interval=<mmp update interval in seconds>\n"
> 			"\tstride=<RAID per-disk chunk size in blocks>\n"
> 			"\tstripe_width=<RAID stride*data disks in blocks>\n"
> +			"\tforce_fsck\n"
> 			"\ttest_fs\n"
> 			"\t^test_fs\n"));
> 		free(buf);
> 


Cheers, Andreas
Lukas Czerner March 9, 2018, 12:31 p.m. UTC | #2
On Thu, Mar 08, 2018 at 12:13:21PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Allow the administrator to mark the filesystem's error bit to force a
> fsck at the next mount.

Looks good.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  misc/tune2fs.8.in |    4 ++++
>  misc/tune2fs.c    |    5 +++++
>  2 files changed, 9 insertions(+)
> 
> 
> diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in
> index 740d166..f1def2b 100644
> --- a/misc/tune2fs.8.in
> +++ b/misc/tune2fs.8.in
> @@ -238,6 +238,10 @@ program.
>  This superblock setting is only honored in 2.6.35+ kernels;
>  and not at all by the ext2 and ext3 file system drivers.
>  .TP
> +.B force_fsck
> +Set a flag in the filesystem superblock indicating that errors have been found.
> +This will force fsck to run at the next mount.
> +.TP
>  .B test_fs
>  Set a flag in the filesystem superblock indicating that it may be
>  mounted using experimental kernel code, such as the ext4dev filesystem.
> diff --git a/misc/tune2fs.c b/misc/tune2fs.c
> index 93160c9..ea84e1e 100644
> --- a/misc/tune2fs.c
> +++ b/misc/tune2fs.c
> @@ -2117,6 +2117,10 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
>  			       intv);
>  			fs->super->s_mmp_update_interval = intv;
>  			ext2fs_mark_super_dirty(fs);
> +		} else if (!strcmp(token, "force_fsck")) {
> +			fs->super->s_state |= EXT2_ERROR_FS;
> +			printf(_("Setting filesystem error flag to force fsck.\n"));
> +			ext2fs_mark_super_dirty(fs);
>  		} else if (!strcmp(token, "test_fs")) {
>  			fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
>  			printf("Setting test filesystem flag\n");
> @@ -2199,6 +2203,7 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
>  			"\tmmp_update_interval=<mmp update interval in seconds>\n"
>  			"\tstride=<RAID per-disk chunk size in blocks>\n"
>  			"\tstripe_width=<RAID stride*data disks in blocks>\n"
> +			"\tforce_fsck\n"
>  			"\ttest_fs\n"
>  			"\t^test_fs\n"));
>  		free(buf);
>
diff mbox series

Patch

diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in
index 740d166..f1def2b 100644
--- a/misc/tune2fs.8.in
+++ b/misc/tune2fs.8.in
@@ -238,6 +238,10 @@  program.
 This superblock setting is only honored in 2.6.35+ kernels;
 and not at all by the ext2 and ext3 file system drivers.
 .TP
+.B force_fsck
+Set a flag in the filesystem superblock indicating that errors have been found.
+This will force fsck to run at the next mount.
+.TP
 .B test_fs
 Set a flag in the filesystem superblock indicating that it may be
 mounted using experimental kernel code, such as the ext4dev filesystem.
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 93160c9..ea84e1e 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -2117,6 +2117,10 @@  static int parse_extended_opts(ext2_filsys fs, const char *opts)
 			       intv);
 			fs->super->s_mmp_update_interval = intv;
 			ext2fs_mark_super_dirty(fs);
+		} else if (!strcmp(token, "force_fsck")) {
+			fs->super->s_state |= EXT2_ERROR_FS;
+			printf(_("Setting filesystem error flag to force fsck.\n"));
+			ext2fs_mark_super_dirty(fs);
 		} else if (!strcmp(token, "test_fs")) {
 			fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;
 			printf("Setting test filesystem flag\n");
@@ -2199,6 +2203,7 @@  static int parse_extended_opts(ext2_filsys fs, const char *opts)
 			"\tmmp_update_interval=<mmp update interval in seconds>\n"
 			"\tstride=<RAID per-disk chunk size in blocks>\n"
 			"\tstripe_width=<RAID stride*data disks in blocks>\n"
+			"\tforce_fsck\n"
 			"\ttest_fs\n"
 			"\t^test_fs\n"));
 		free(buf);