Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1775821imm; Thu, 27 Sep 2018 02:15:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV60uoVqXuYxRM2DwxXtPPCtmKQjFM7bDjzdpx1JTBbj4Z/5u57GPErCcQgsmnCyQJAyi7ZHA X-Received: by 2002:a17:902:b68a:: with SMTP id c10-v6mr9898786pls.167.1538039752145; Thu, 27 Sep 2018 02:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039752; cv=none; d=google.com; s=arc-20160816; b=Lrea6v4DR2SpuYRnpfwczmjsP4PxxFPLqQ+3B0fgRXR0e5J4rCFD0SL5N7jvFKiz7T twniItFOohXZet4qb/M4qGwS7D3SDeV9vNOwWJsyIfjVpaIoxDwxBnFbOPVpzy21czSX O5xg3dA+PFC3v5M0u48H3IN7xsabjgQ3ZEq0SqRhVp1FoI6gUJPSC5NhN/nRnEFMntAr XUsnCcKaxl3iVoz7sXALeFrSGa1L/PWjnUxwWNvrH5es8ISJdeR1ffvYwf1RSKE3B3Zf jA4pJDDJhcLWYfIMj8pdEbmM8NIWM0clCA27pwzSa2Af024Z4zQSIj+pKOU20KSvxjnN V9Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=xv6s7/aquAfG/0cZWt8fC+MZf/cJKGm5R8lKk3qDKxQ=; b=r40HUtRD9oe/Fb25n7zeK/HgkTvsYOF/1pTam7ohsG6Xs2qCAmC970eh340zMHHi4I tMNMhzBFfsefljZu9UUn0ripEnVdEqPGDzCNe1Fn1jDAW9yigADdkB5Bbu6daOavrvy9 ufhCrBL19XHSgktGZXrw2K36dv1o5EffrTZJ+F4mzSO/CK3iumxeHhjna+20e8B0sU8f fmpWQmK9oKoGEgZBnQ+vgnGc/IFij6UbYNJwFcMXhAw9cIz8GP8nNMM153f4Yn6omdTm oHCfaqWRTRkZ2jk70YTCYjWuSlJ2ITduu6K/TyWE9p0ZrKp1rnvbg1PQVHAVryydKfDk P74Q== 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 q12-v6si1500849pgl.531.2018.09.27.02.15.37; Thu, 27 Sep 2018 02:15:52 -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 S1728352AbeI0Pb5 (ORCPT + 99 others); Thu, 27 Sep 2018 11:31:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55534 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbeI0Pb4 (ORCPT ); Thu, 27 Sep 2018 11:31:56 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B12F51117; Thu, 27 Sep 2018 09:14:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chengguang Xu , Theodore Tso Subject: [PATCH 4.18 79/88] ext4: recalucate superblock checksum after updating free blocks/inodes Date: Thu, 27 Sep 2018 11:04:00 +0200 Message-Id: <20180927090310.193618233@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 4274f516d4bc50648a4d97e4f67ecbd7b65cde4a upstream. When mounting the superblock, ext4_fill_super() calculates the free blocks and free inodes and stores them in the superblock. It's not strictly necessary, since we don't use them any more, but it's nice to keep them roughly aligned to reality. Since it's not critical for file system correctness, the code doesn't call ext4_commit_super(). The problem is that it's in ext4_commit_super() that we recalculate the superblock checksum. So if we're not going to call ext4_commit_super(), we need to call ext4_superblock_csum_set() to make sure the superblock checksum is consistent. Most of the time, this doesn't matter, since we end up calling ext4_commit_super() very soon thereafter, and definitely by the time the file system is unmounted. However, it doesn't work in this sequence: mke2fs -Fq -t ext4 /dev/vdc 128M mount /dev/vdc /vdc cp xfstests/git-versions /vdc godown /vdc umount /vdc mount /dev/vdc tune2fs -l /dev/vdc With this commit, the "tune2fs -l" no longer fails. Reported-by: Chengguang Xu Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4357,11 +4357,13 @@ no_journal: block = ext4_count_free_clusters(sb); ext4_free_blocks_count_set(sbi->s_es, EXT4_C2B(sbi, block)); + ext4_superblock_csum_set(sb); err = percpu_counter_init(&sbi->s_freeclusters_counter, block, GFP_KERNEL); if (!err) { unsigned long freei = ext4_count_free_inodes(sb); sbi->s_es->s_free_inodes_count = cpu_to_le32(freei); + ext4_superblock_csum_set(sb); err = percpu_counter_init(&sbi->s_freeinodes_counter, freei, GFP_KERNEL); }