Return-Path: Received: from mail-bn3nam01on0135.outbound.protection.outlook.com ([104.47.33.135]:19456 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932186AbeARU7d (ORCPT ); Thu, 18 Jan 2018 15:59:33 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Theodore Ts'o , Sasha Levin Subject: [added to the 4.1 stable tree] ext4: preserve the needs_recovery flag when the journal is aborted Date: Thu, 18 Jan 2018 20:59:28 +0000 Message-ID: <20180118205908.3220-10-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Theodore Ts'o This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 97abd7d4b5d9c48ec15c425485f054e1c15e591b ] If the journal is aborted, the needs_recovery feature flag should not be removed. Otherwise, it's the journal might not get replayed and this could lead to more data getting lost. Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin --- fs/ext4/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 807b1df8e134..b29a7ef4953e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -774,6 +774,7 @@ static void ext4_put_super(struct super_block *sb) { struct ext4_sb_info *sbi =3D EXT4_SB(sb); struct ext4_super_block *es =3D sbi->s_es; + int aborted =3D 0; int i, err; =20 ext4_unregister_li_request(sb); @@ -783,9 +784,10 @@ static void ext4_put_super(struct super_block *sb) destroy_workqueue(sbi->rsv_conversion_wq); =20 if (sbi->s_journal) { + aborted =3D is_journal_aborted(sbi->s_journal); err =3D jbd2_journal_destroy(sbi->s_journal); sbi->s_journal =3D NULL; - if (err < 0) + if ((err < 0) && !aborted) ext4_abort(sb, "Couldn't clean up the journal"); } =20 @@ -796,7 +798,7 @@ static void ext4_put_super(struct super_block *sb) ext4_ext_release(sb); ext4_xattr_put_super(sb); =20 - if (!(sb->s_flags & MS_RDONLY)) { + if (!(sb->s_flags & MS_RDONLY) && !aborted) { EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); es->s_state =3D cpu_to_le16(sbi->s_mount_state); } --=20 2.11.0