From patchwork Thu Jan 9 20:08:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 308939 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 215962C0078 for ; Fri, 10 Jan 2014 07:08:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932221AbaAIUIO (ORCPT ); Thu, 9 Jan 2014 15:08:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4558 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932135AbaAIUIM (ORCPT ); Thu, 9 Jan 2014 15:08:12 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s09K8C2h006518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 9 Jan 2014 15:08:12 -0500 Received: from liberator.sandeen.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s09K8Bt9020689 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 9 Jan 2014 15:08:11 -0500 Message-ID: <52CF01AB.7030704@redhat.com> Date: Thu, 09 Jan 2014 14:08:11 -0600 From: Eric Sandeen User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: ext4 development CC: james.faulkner@yale.edu Subject: [PATCH] tune2fs: allow removal of dirty journal with two "-f" options X-Enigmail-Version: 1.6 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the journal if the needs_recovery flag is set; the manpage seems to indicate that it should. And if you've lost an external journal and can no longer replay it, how should one proceed? Change tune2fs so that two "-f" options will allow removal of a dirty journal from a filesystem, even if the filesystem needs recovery. e2fsck can then do its best to pick up the pieces. Reported-by: Jim Faulkner Signed-off-by: Eric Sandeen --- -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index da21080..e07da28 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -248,7 +248,10 @@ option is useful when removing the filesystem feature from a filesystem which has an external journal (or is corrupted such that it appears to have an external journal), but that -external journal is not available. +external journal is not available. If the filesystem appears to require +journal replay, the +.B \-f +flag must be specified twice to proceed. .sp .B WARNING: Removing an external journal from a filesystem which was not cleanly unmounted diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 0eddf6d..2318dbb 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -903,8 +903,9 @@ static int update_feature_set(ext2_filsys fs, char *features) "read-only.\n"), stderr); return 1; } - if (sb->s_feature_incompat & - EXT3_FEATURE_INCOMPAT_RECOVER) { + if ((sb->s_feature_incompat & + EXT3_FEATURE_INCOMPAT_RECOVER) && + f_flag < 2) { fputs(_("The needs_recovery flag is set. " "Please run e2fsck before clearing\n" "the has_journal flag.\n"), stderr); @@ -1428,7 +1429,7 @@ static void parse_tune2fs_options(int argc, char **argv) open_flag |= EXT2_FLAG_RW; break; case 'f': /* Force */ - f_flag = 1; + f_flag++; break; case 'g': resgid = strtoul(optarg, &tmp, 0);