Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1114610imm; Wed, 1 Aug 2018 10:25:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeNc7Vv8IQ9TXzyuLqU1WVuoo0fAZHkTH9NpT3a290yeQn5ah9PtA3pGbrqnYGKp4OPq/s4 X-Received: by 2002:a17:902:7590:: with SMTP id j16-v6mr11872756pll.123.1533144311258; Wed, 01 Aug 2018 10:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144311; cv=none; d=google.com; s=arc-20160816; b=zouwb8+QsrjgZdhRokQUW92fQRPjylsgSLhrkujzEipXVZGAwdRk30doC5wH/QEdpm Hzl8z/INyK3hXoC9spRJsWo3xZVu0MJlteoOOnZTRETqqNiTDgwDiqJfzY8O1zHIbMbk hzepvs/WBRypgBaiKLeIyfP6c1daBZ7i7XNylLTiw9659tKaED5t2lMJN+vPg/fZUcXY 35yY1EjLcZjhjgSNO4JijaB4RoW2Z0TXbDMHlqRQmti2eE1haPC1jXL5FJf+LUxo1y/a v+uwID80z7qfytAPsJpiAvQAuve7pWNOXHfC5RKay5CuK1m0/9C4gIm/4x4i7vw3GigA hc6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NEuRnBQmOQF06dLVEotQThZLllkS0prqzx4TUJ7sb2k=; b=UGW1GuPworLv5ftNoMwr3rhrAPUfA7Imt+6pCMxZjDDOmSXq7ZBvIMHyqd9I5bmtg0 dG5fOsdfHJxndXsEgrdhDf5xhA5ZAvShuTh9ytxiXAmgzkuTD02QJGRgiRD/+h68GbK2 WG+WB82oAgcb8dfmJ0lP1A1K0ZBmgXZHMpTfLIYT1iyk3wf4xOGzfNWsotbOhcPgdBeo 7wN7wtTDnCQij5iYzAko63nNEn0Mjrq27SdRPsfl+zpLT9Zxsy34RHMIA2gNPUUhg5PU S/Kr2toPeK7eNX2MEIBtisqZwHu+QnFFFDk+DLQ+LTlq+6Td6nNTRsRRrkNm/+otEpdk 48Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18-v6si14321937plo.341.2018.08.01.10.24.56; Wed, 01 Aug 2018 10:25:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406338AbeHATJo (ORCPT + 99 others); Wed, 1 Aug 2018 15:09:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50828 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405510AbeHATJn (ORCPT ); Wed, 1 Aug 2018 15:09:43 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B0E9BCC9; Wed, 1 Aug 2018 17:23:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Whitney , Theodore Tso Subject: [PATCH 4.14 222/246] ext4: fix check to prevent initializing reserved inodes Date: Wed, 1 Aug 2018 18:52:12 +0200 Message-Id: <20180801165022.329322870@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 5012284700775a4e6e3fbe7eac4c543c4874b559 upstream. Commit 8844618d8aa7: "ext4: only look at the bg_flags field if it is valid" will complain if block group zero does not have the EXT4_BG_INODE_ZEROED flag set. Unfortunately, this is not correct, since a freshly created file system has this flag cleared. It gets almost immediately after the file system is mounted read-write --- but the following somewhat unlikely sequence will end up triggering a false positive report of a corrupted file system: mkfs.ext4 /dev/vdc mount -o ro /dev/vdc /vdc mount -o remount,rw /dev/vdc Instead, when initializing the inode table for block group zero, test to make sure that itable_unused count is not too large, since that is the case that will result in some or all of the reserved inodes getting cleared. This fixes the failures reported by Eric Whiteney when running generic/230 and generic/231 in the the nojournal test case. Fixes: 8844618d8aa7 ("ext4: only look at the bg_flags field if it is valid") Reported-by: Eric Whitney Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/ialloc.c | 5 ++++- fs/ext4/super.c | 8 +------- 2 files changed, 5 insertions(+), 8 deletions(-) --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1397,7 +1397,10 @@ int ext4_init_inode_table(struct super_b ext4_itable_unused_count(sb, gdp)), sbi->s_inodes_per_block); - if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group)) { + if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) || + ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) - + ext4_itable_unused_count(sb, gdp)) < + EXT4_FIRST_INO(sb)))) { ext4_error(sb, "Something is wrong with group %u: " "used itable blocks: %d; " "itable unused count: %u", --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3103,14 +3103,8 @@ static ext4_group_t ext4_has_uninit_itab if (!gdp) continue; - if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)) - continue; - if (group != 0) + if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED))) break; - ext4_error(sb, "Inode table for bg 0 marked as " - "needing zeroing"); - if (sb_rdonly(sb)) - return ngroups; } return group;