Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1783697imm; Thu, 27 Sep 2018 02:24:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV63lZA7Ziu5EAZ+W4k4WmHsWAQ2Nsfg3EwZenCvQW8m/ARHbi3tF/GDWMYyP7CguMFz10TMC X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr9880297plb.223.1538040282842; Thu, 27 Sep 2018 02:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538040282; cv=none; d=google.com; s=arc-20160816; b=QlkSaPmuspkFsZom6jYcpAZSO/QtbvpaiC4mNe8YN1I1xE9kC9c15ot/rSpprySVBE o7+IjUCQvBTuFdRsgl9LbXncf+mD4S0Rkva9fs5bHuox3VWq/Rn63nK+NSng/4Vm2cOO i6Dv5ps2keoeWxwwlkaYln2wM8gPGjRQpIMN/dF/z7RTs1vDxaxVuqvod8jz0CbouVJ0 9Am/4+3aiWNJqDDvQcBlkro2MMbvtHhSklOMw2ENiij8Dw1kYxYspEEEQpY6EmgBJFhW yqYo/YVQ7pG7mcb0D+1F9QdCNs8pGU0DwkPEet45utrECCY++7x27b0DdkUNOM1PJDBZ NQRg== 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=MGjpWI7Wc44osQ63idSjC7BBOd6JPvfUkw09pXqx10o=; b=N/c0Z3mYRsW3upoApTAnaAXfGo55X+47Qz81Yj/ZlkRksBgkNsOh6hMej0JJDdum0V mEekYEGaNZbbz6K+8F8VhgJylZ+cMg/Cmz/nV9O7CsCikLOxDKsr38Op0Dnvy0sTwZRY KcCbD0YE3qI1/vDTED/v+JmQCxvi9DDiv0QM0MHqZlo6uejzK4oISgwhAxqLvKmFvvLX z8J80R7exXSHwMh/hGm7VyfhQ32+1Cg8gnh87y1qdc4c68GQNGogU5VYhsIclS9BvT/y ITnXBRz1e74hoWAG3ii7Mwdx9kt2aVJI6+Y1n6AEBaAptKI1AgHO0L2YP3Xj9IfU8wNk UbWw== 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 c20-v6si1685321pfc.18.2018.09.27.02.24.28; Thu, 27 Sep 2018 02:24:42 -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 S1728236AbeI0PlZ (ORCPT + 99 others); Thu, 27 Sep 2018 11:41:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56648 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727276AbeI0PlZ (ORCPT ); Thu, 27 Sep 2018 11:41:25 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9E9B11113; Thu, 27 Sep 2018 09:24:04 +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.14 54/64] ext4: recalucate superblock checksum after updating free blocks/inodes Date: Thu, 27 Sep 2018 11:04:11 +0200 Message-Id: <20180927090257.444716641@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090249.801943776@linuxfoundation.org> References: <20180927090249.801943776@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.14-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 @@ -4311,11 +4311,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); }