Received: by 10.192.165.148 with SMTP id m20csp2488456imm; Sun, 22 Apr 2018 08:04:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/jq49dzDpIBAa9o5Xac2wG70kGF8yHV3dDv6aiCccIp7vb7LGSQFJ9lNXmeHq7bg+9luPo X-Received: by 10.99.191.12 with SMTP id v12mr14520017pgf.54.1524409477449; Sun, 22 Apr 2018 08:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409477; cv=none; d=google.com; s=arc-20160816; b=u9miR9cs+HzJOsfPX+LokXDIHEfH9V+B+8Z8uCyTVu7Nhx+GdfJp47J3zkghUAgE0U MtO02OZ3Kx9kF4VGXK6A7aH8oi1v+jYJn9A2DN2VMnyzPbPdEkOg6S+ID/quG1/e0Sv0 nsSK/7he4/BvhKqeWZVS7BYZKpS++izLbI7uU2GfD9OCucSM+Fc2TNLkuZe7TsiPqKdc qX51Abq2Od/+yCvvnFDnL9HytgsrauTdNAx+k4H/K3in1a89B0kWW51pFUuyzM+YZZqs RoppGBRL4WRuYj81C9Z9qBAqLAP9XE5ZXMpSHpg/ayeHvEJaWG8UvPutQeNwf8IXw9Ty V0Uw== 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=ajofFjMnvg+F3MKbnQfeLdkDXZ4E4HI3cAq+u/j4ODw=; b=M/WXCOxOaSA5R9hH4LyNEQFtapq6uU1xVdod9SB6LuJxSMzYUA3xtMtb/89CKuMV/2 9bnAbaxMrw2tI+Mg5JU08SNmjovV+tv0W6ZMKr283WVliLy3Auxbt6Zzh7Hkyy4xan9J tE2/lDyGgpmPg0vrp40EuwpMXI3HaqUF6B9aaAa19NpgYq19/bGq7/K7kpWsQak5ZfIx f7VGMtvAYi1XFqiEfJ/vgqAb5c3M+5oafh+bQqsX4sXoKv4XG8nyFnawVfoctc33uJ4s 7eQlxdaIXnQ4sTv1FK6w64jVIxtJ/S5JxsJKTLh7Pkwjf8IjolHn7vBZdFQ5YGdcNHa8 2OKA== 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 bd8-v6si4125418plb.156.2018.04.22.08.04.23; Sun, 22 Apr 2018 08:04:37 -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 S1754265AbeDVPDY (ORCPT + 99 others); Sun, 22 Apr 2018 11:03:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54960 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756650AbeDVOMS (ORCPT ); Sun, 22 Apr 2018 10:12:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 927A2C3D; Sun, 22 Apr 2018 14:12:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso Subject: [PATCH 4.9 35/95] ext4: dont update checksum of new initialized bitmaps Date: Sun, 22 Apr 2018 15:53:04 +0200 Message-Id: <20180422135211.864586360@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 044e6e3d74a3d7103a0c8a9305dfd94d64000660 upstream. When reading the inode or block allocation bitmap, if the bitmap needs to be initialized, do not update the checksum in the block group descriptor. That's because we're not set up to journal those changes. Instead, just set the verified bit on the bitmap block, so that it's not necessary to validate the checksum. When a block or inode allocation actually happens, at that point the checksum will be calculated, and update of the bg descriptor block will be properly journalled. Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/balloc.c | 3 +-- fs/ext4/ialloc.c | 47 +++-------------------------------------------- 2 files changed, 4 insertions(+), 46 deletions(-) --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -242,8 +242,6 @@ static int ext4_init_block_bitmap(struct */ ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group), sb->s_blocksize * 8, bh->b_data); - ext4_block_bitmap_csum_set(sb, block_group, gdp, bh); - ext4_group_desc_csum_set(sb, block_group, gdp); return 0; } @@ -447,6 +445,7 @@ ext4_read_block_bitmap_nowait(struct sup err = ext4_init_block_bitmap(sb, bh, block_group, desc); set_bitmap_uptodate(bh); set_buffer_uptodate(bh); + set_buffer_verified(bh); ext4_unlock_group(sb, block_group); unlock_buffer(bh); if (err) { --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -63,44 +63,6 @@ void ext4_mark_bitmap_end(int start_bit, memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3); } -/* Initializes an uninitialized inode bitmap */ -static int ext4_init_inode_bitmap(struct super_block *sb, - struct buffer_head *bh, - ext4_group_t block_group, - struct ext4_group_desc *gdp) -{ - struct ext4_group_info *grp; - struct ext4_sb_info *sbi = EXT4_SB(sb); - J_ASSERT_BH(bh, buffer_locked(bh)); - - /* If checksum is bad mark all blocks and inodes use to prevent - * allocation, essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { - grp = ext4_get_group_info(sb, block_group); - if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) - percpu_counter_sub(&sbi->s_freeclusters_counter, - grp->bb_free); - set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); - if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { - int count; - count = ext4_free_inodes_count(sb, gdp); - percpu_counter_sub(&sbi->s_freeinodes_counter, - count); - } - set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); - return -EFSBADCRC; - } - - memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8); - ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, - bh->b_data); - ext4_inode_bitmap_csum_set(sb, block_group, gdp, bh, - EXT4_INODES_PER_GROUP(sb) / 8); - ext4_group_desc_csum_set(sb, block_group, gdp); - - return 0; -} - void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate) { if (uptodate) { @@ -184,17 +146,14 @@ ext4_read_inode_bitmap(struct super_bloc ext4_lock_group(sb, block_group); if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) { - err = ext4_init_inode_bitmap(sb, bh, block_group, desc); + memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8); + ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), + sb->s_blocksize * 8, bh->b_data); set_bitmap_uptodate(bh); set_buffer_uptodate(bh); set_buffer_verified(bh); ext4_unlock_group(sb, block_group); unlock_buffer(bh); - if (err) { - ext4_error(sb, "Failed to init inode bitmap for group " - "%u: %d", block_group, err); - goto out; - } return bh; } ext4_unlock_group(sb, block_group);