From patchwork Fri Sep 12 20:39:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Dilger X-Patchwork-Id: 388797 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 67F3F14011B for ; Sat, 13 Sep 2014 06:49:11 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752392AbaILUtK (ORCPT ); Fri, 12 Sep 2014 16:49:10 -0400 Received: from smtp-out-03.shaw.ca ([64.59.136.139]:10106 "EHLO smtp-out-02.shaw.ca" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751518AbaILUtJ (ORCPT ); Fri, 12 Sep 2014 16:49:09 -0400 X-Greylist: delayed 567 seconds by postgrey-1.27 at vger.kernel.org; Fri, 12 Sep 2014 16:49:09 EDT X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=tLeJwtg1FCvAouMblIYY1Z5/U6XdMrtw4y2B9g+QINc= c=1 sm=1 a=_4VI9oTqqlwA:10 a=nMIouzlOWdwA:10 a=PcMCqbNk7xoA:10 a=BLceEmwcHowA:10 a=sQcIUxX0G8DGr1HsvJ29bQ==:17 a=QyXUC8HyAAAA:8 a=X8pqu0GcVLOQgEZn3TAA:9 a=dGJ0OcVc7YAA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Received: from unknown (HELO sookie-gig.adilger.int) ([96.51.76.157]) by smtp-out-02.shaw.ca with ESMTP; 12 Sep 2014 14:39:41 -0600 From: Andreas Dilger To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Jim Garlick , Andreas Dilger Subject: [PATCH] tune2fs: warn if the filesystem journal is dirty Date: Fri, 12 Sep 2014 14:39:40 -0600 Message-Id: <1410554380-2014-1-git-send-email-andreas.dilger@intel.com> X-Mailer: git-send-email 1.7.3.4 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Jim Garlick 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 Signed-off-by: Andreas Dilger --- misc/tune2fs.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index b65dab9..e5ec8a4 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -2395,6 +2395,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)); @@ -2404,6 +2405,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);