From: Andreas Dilger <adilger@dilger.ca>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, Jim Garlick <garlick@llnl.gov>,
Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH] tune2fs: warn if the filesystem journal is dirty
Date: Tue, 24 Nov 2015 15:57:14 -0700 [thread overview]
Message-ID: <1448405834-25328-1-git-send-email-adilger@dilger.ca> (raw)
From: Jim Garlick <garlick@llnl.gov>
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@llnl.gov>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
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)) {
+ fprintf(stderr,
+ _("Warning: needs_recovery flag is set. You may wish\n"
+ "replay the journal then rerun this command, or any\n"
+ "changes may be overwritten by journal recovery.\n"));
+ }
+
free(device_name);
remove_error_table(&et_ext2_error_table);
--
1.7.3.4
next reply other threads:[~2015-11-24 22:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-24 22:57 Andreas Dilger [this message]
2015-11-24 23:26 ` [PATCH] tune2fs: warn if the filesystem journal is dirty Darrick J. Wong
2015-11-24 23:42 ` Andreas Dilger
2015-11-25 0:18 ` Andreas Dilger
-- strict thread matches above, loose matches on Subject: below --
2014-09-12 20:39 Andreas Dilger
2014-09-12 21:18 ` Darrick J. Wong
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=1448405834-25328-1-git-send-email-adilger@dilger.ca \
--to=adilger@dilger.ca \
--cc=andreas.dilger@intel.com \
--cc=garlick@llnl.gov \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).