Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp2905702pxb; Mon, 6 Sep 2021 07:58:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybD/z0xVgPrVn10OZZPFfVeerzqr/yPRpEhcVxdIyQm0IX4NKQFc5z1n8dGGmtv1muqZwv X-Received: by 2002:a17:906:6943:: with SMTP id c3mr13876175ejs.550.1630940297640; Mon, 06 Sep 2021 07:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630940297; cv=none; d=google.com; s=arc-20160816; b=TlATH1aWLlWsWlFwsuYiSWNoI3I0cdmSQwMtEu4+cka6JTYdaJeCzstc5obnSyXT2X 1KtW2ACgrzTZfS2k0qXDpR0hjh+sJicOHpCTbLnFWzXKoWjBAOQRpnMLxokKtrzr51jF khEIfU61jMz4eWmUWN5oPIC0RrWUGUGfSrp/mmP1bbGTAesAuR2GIgWeiC/OOH+JKqlw BzAa08fwfnivGcUdHWCpIss3owQvb5Vps59/NnBttUqCukx4hftQZClsy3aQ/B6+lSSf iTanYUlipge4AjL6Ywh3bqTecY2E+BNgbOkhm7hwWQ6kSdAv5IVZzso5Ka4LxZS4sPXX b9qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JXNGX8jHWV+I/FhUvbpxGumdNcVoQ4CmUQNU2FvYEf4=; b=Z/wq3HzaA4Mvkdabj64Y82ZObx8bhSPzSgoIVUeH96sXHe24IRfydOB6KkXm2wvqn0 3w13QbovDf6u6aNpB6ryJ7jONxWwLJHv5o3qWbA0i5hEiZumi1UO/LcTRxr+4ObY4h0r 9KmChd6u1j322Xi9Y9p7QqFpv3YXjwJ/clNCnCcUcWtQR0Gfq7Nc9IE5//JH+er8s5gu McJYrRrEhqV4Cfp+9TKn41cnFvwPTC7lckX36OLOIjR/afeGPqVfKPPALP528fzaQLho 7E6krSjHG/lHQjlJwmD/xQdu6zijMrzlRs0fX88zm6GpkgW5e2RSvE7ALBxAyPzuMJP4 6PsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rIz27bVQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si2426957edv.459.2021.09.06.07.57.42; Mon, 06 Sep 2021 07:58:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rIz27bVQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243878AbhIFNAn (ORCPT + 99 others); Mon, 6 Sep 2021 09:00:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:35894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243258AbhIFM7j (ORCPT ); Mon, 6 Sep 2021 08:59:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E9C566105A; Mon, 6 Sep 2021 12:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630933114; bh=rp7vDUL6sKAqNXAQOnLfxXDYz3lqlgEwihphZXyF4O8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIz27bVQwt/4iPlLE+rW8unuSJyMHvacJewpUJViRGyWg23nbAC6+nkyiwWA+WkRK +3ZoYVZM7FumbDn0+ChcoXosC0q9moQ8M9ZpKw9E+DNCbCl4wuwZDk0PwV6vL9LB+z w2vW9tZb55OHhFI2XSoo/rWUMe9pDq7TG7khs2IE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Boyang Xue , Jan Kara , Theodore Tso Subject: [PATCH 5.14 02/14] ext4: fix e2fsprogs checksum failure for mounted filesystem Date: Mon, 6 Sep 2021 14:55:48 +0200 Message-Id: <20210906125448.240195770@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210906125448.160263393@linuxfoundation.org> References: <20210906125448.160263393@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit b2bbb92f7042e8075fb036bf97043339576330c3 upstream. Commit 81414b4dd48 ("ext4: remove redundant sb checksum recomputation") removed checksum recalculation after updating superblock free space / inode counters in ext4_fill_super() based on the fact that we will recalculate the checksum on superblock writeout. That is correct assumption but until the writeout happens (which can take a long time) the checksum is incorrect in the buffer cache and if programs such as tune2fs or resize2fs is called shortly after a file system is mounted can fail. So return back the checksum recalculation and add a comment explaining why. Fixes: 81414b4dd48f ("ext4: remove redundant sb checksum recomputation") Cc: stable@kernel.org Reported-by: Boyang Xue Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Link: https://lore.kernel.org/r/20210812124737.21981-1-jack@suse.cz Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5032,6 +5032,14 @@ no_journal: err = percpu_counter_init(&sbi->s_freeinodes_counter, freei, GFP_KERNEL); } + /* + * Update the checksum after updating free space/inode + * counters. Otherwise the superblock can have an incorrect + * checksum in the buffer cache until it is written out and + * e2fsprogs programs trying to open a file system immediately + * after it is mounted can fail. + */ + ext4_superblock_csum_set(sb); if (!err) err = percpu_counter_init(&sbi->s_dirs_counter, ext4_count_dirs(sb), GFP_KERNEL);