Re: [PATCH] tune2fs: warn if the filesystem journal is dirty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 24, 2015 at 03:57:14PM -0700, Andreas Dilger wrote:
> From: Jim Garlick <garlick@xxxxxxxx>
> 
> Running tune2fs on a filesystem with an unrecovered journal can
> cause the tune2fs settings changes in the superblock to be reverted
> when the journal is replayed if it contains an uncommitted copy of
> the superblock.  Print a warning if this is detected so that the
> user isn't surprised if it happens.
> 
> Signed-off-by: Jim Garlick <garlick@xxxxxxxx>
> Signed-off-by: Andreas Dilger <andreas.dilger@xxxxxxxxx>
> ---
>  misc/tune2fs.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/misc/tune2fs.c b/misc/tune2fs.c
> index cd1d17f..fcb963a 100644
> --- a/misc/tune2fs.c
> +++ b/misc/tune2fs.c
> @@ -2397,6 +2397,7 @@ retry_open:
>  		ext2fs_mark_super_dirty(fs);
>  		printf(_("Setting stripe width to %d\n"), stripe_width);
>  	}
> +
>  	if (ext_mount_opts) {
>  		strncpy((char *)(fs->super->s_mount_opts), ext_mount_opts,
>  			sizeof(fs->super->s_mount_opts));
> @@ -2406,6 +2407,17 @@ retry_open:
>  		       ext_mount_opts);
>  		free(ext_mount_opts);
>  	}
> +
> +	/* Warn if file system needs recovery and it is opened for writing. */
> +	if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
> +	    (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
> +	    (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER)) {

ext2fs_has_feature_journal(sb) &&
ext2fs_has_feature_journal_needs_recovery(sb)

> +		fprintf(stderr,
> +			_("Warning: needs_recovery flag is set. You may wish\n"
> +			  "replay the journal then rerun this command, or any\n"

"You may wish to replay the journal..."

> +			  "changes may be overwritten by journal recovery.\n"));

I wonder if we ought simply to replay the journal in this situation, since
debugfs/fuse2fs can do it.

...or at least tell the user how to replay? ("e2fsck -E journal_only"/mount)

--D

> +	}
> +
>  	free(device_name);
>  	remove_error_table(&et_ext2_error_table);
>  
> -- 
> 1.7.3.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux