From patchwork Wed Jan 25 00:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 1731480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=opjBUMi3; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P1kdv4RBFz23hf for ; Wed, 25 Jan 2023 11:06:26 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pKTIr-0003ey-I9; Wed, 25 Jan 2023 00:06:13 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pKTIp-0003eX-U5 for kernel-team@lists.ubuntu.com; Wed, 25 Jan 2023 00:06:11 +0000 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id BAC653F51A for ; Wed, 25 Jan 2023 00:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1674605171; bh=0Y52aFVgEe0tRSdNQgUqLg7PyEcNmtSrH82CCn3BMl0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=opjBUMi3RsRtnyjstigPT3czFYP3UWN204hQPoIViPb+MqI7w4BIiN6KWAoCtO03+ dim0238c4EpC7RcL2QBSdsUU2FrvCnMB98Qos8d+v6Qs1mdOTcxzYzRokqCNTtt0Yb lATANSd6PJe9abuZKWAH60tCjhw7+lHZz0Caoq1fAjaiSa3ocTumCbs6EgRzXqTxvi x1z9G9czEP0acnuZAsCtHe6n9/bdv3vL170D6DtT6z2U7QzZ7VZXFgubFKRo4ERLeY L3smwNX/Tte55+KkRw8Vn49qkHMdTBmhypiddBwr8LlWTAsW2f40JMrdcnVClIcwaW PVp/I2E8shViw== Received: by mail-qk1-f197.google.com with SMTP id bl13-20020a05620a1a8d00b00709117e3125so9863954qkb.18 for ; Tue, 24 Jan 2023 16:06:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Y52aFVgEe0tRSdNQgUqLg7PyEcNmtSrH82CCn3BMl0=; b=JWoppkGzTPx/bw+RoFpETWJyW6ssJjVzi0tapocCG9tiaJtNSiDDUgPnX0VXkyYOJK CsKz4kctFRBApWPFy0BUpbqMtR9h/22lCfoA5nwbie3eJk/lIR3ok0EHtWPEW7jv6u6k 15PIb/GGQjw8G2Ov0IdRSuCYd+4NeVcHoOA/gAV0Ar2B9OD4wm9bwTqZdikBbSGgRaMR UzfSmK4tfOnW0WuZG52QTkxRqg86fq80l99h2AposWcWOUjeZ98vtxV2Dzw9F9vOisk3 HArw2lfkBm9ImTv86I24i+h45NIsXx9Ky4gbWEaMnXwCNzAoEQhT/4QQuTMH3DusSQ8B MTqQ== X-Gm-Message-State: AFqh2kqUjlxEFvmRsiMmR29CX6X5hRH8RkKFgy+eaYvd2lqY1VZudWRw LIjDkD12R3y3l6M7ICmzGfqm2VKo7fPM8cH/UUFNDtS59TSMamyur8Yq3FnQPKreQScGksOnw2r 8sGST7Efmh4EhjMM4NoL2zaOVR3/huC8wL6eZm21e9g== X-Received: by 2002:ac8:739a:0:b0:3b6:3427:a672 with SMTP id t26-20020ac8739a000000b003b63427a672mr38977251qtp.57.1674605170163; Tue, 24 Jan 2023 16:06:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXuYeCY/T7Kh8sVw3Thb+M7YYmFBsetiMOIyqv/SRXVekY5L5fwd8NC2i1ysBsOUBuS3aI4pWQ== X-Received: by 2002:ac8:739a:0:b0:3b6:3427:a672 with SMTP id t26-20020ac8739a000000b003b63427a672mr38977216qtp.57.1674605169845; Tue, 24 Jan 2023 16:06:09 -0800 (PST) Received: from localhost.localdomain ([38.147.253.164]) by smtp.gmail.com with ESMTPSA id ay30-20020a05620a179e00b007062139ecb3sm2417422qkb.95.2023.01.24.16.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 16:06:09 -0800 (PST) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4] ext4: fix bad checksum after online resize Date: Tue, 24 Jan 2023 19:05:59 -0500 Message-Id: <20230125000602.1166517-2-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125000602.1166517-1-khalid.elmously@canonical.com> References: <20230125000602.1166517-1-khalid.elmously@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Baokun Li BugLink: https://bugs.launchpad.net/bugs/2003816 When online resizing is performed twice consecutively, the error message "Superblock checksum does not match superblock" is displayed for the second time. Here's the reproducer: mkfs.ext4 -F /dev/sdb 100M mount /dev/sdb /tmp/test resize2fs /dev/sdb 5G resize2fs /dev/sdb 6G To solve this issue, we moved the update of the checksum after the es->s_overhead_clusters is updated. Fixes: 026d0d27c488 ("ext4: reduce computation of overhead during resize") Fixes: de394a86658f ("ext4: update s_overhead_clusters in the superblock during an on-line resize") Signed-off-by: Baokun Li Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara Cc: stable@kernel.org Link: https://lore.kernel.org/r/20221117040341.1380702-2-libaokun1@huawei.com Signed-off-by: Theodore Ts'o (cherry picked from commit a408f33e895e455f16cf964cb5cd4979b658db7b) Signed-off-by: Khalid Elmously --- fs/ext4/resize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 62bbfe8960f3b..58fb108a81cc6 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -1445,8 +1445,6 @@ static void ext4_update_super(struct super_block *sb, * active. */ ext4_r_blocks_count_set(es, ext4_r_blocks_count(es) + reserved_blocks); - ext4_superblock_csum_set(sb); - unlock_buffer(sbi->s_sbh); /* Update the free space counts */ percpu_counter_add(&sbi->s_freeclusters_counter, @@ -1474,6 +1472,8 @@ static void ext4_update_super(struct super_block *sb, ext4_calculate_overhead(sb); es->s_overhead_clusters = cpu_to_le32(sbi->s_overhead); + ext4_superblock_csum_set(sb); + unlock_buffer(sbi->s_sbh); if (test_opt(sb, DEBUG)) printk(KERN_DEBUG "EXT4-fs: added group %u:" "%llu blocks(%llu free %llu reserved)\n", flex_gd->count,