Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3847975pxu; Tue, 20 Oct 2020 01:56:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+Kmo+BzlPNUGcT46h16F3/fYypSg899Ri/pI9B9fBDRITLCQSGWLUs0xcMck3BBOLcG+2 X-Received: by 2002:a17:906:3a8d:: with SMTP id y13mr2128037ejd.460.1603184187891; Tue, 20 Oct 2020 01:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603184187; cv=none; d=google.com; s=arc-20160816; b=ZbsZhuurR8MUZLiHQ3O23yRHU2GULoA++UaMoLw5TeKT1afz3BhurgOlXiguDL7ZHR WwKZNahFs7dcXM6QBZePWIAl8SgID5bswVmDqwPtw6khi3T7HbDrOf+fslpdP1+xXTGz yqo8G0WIR5S+Do4uoee2XRs8NRsKIMVGi46f41du/40Hti/AyPsylgpGKObeUG9FFeX6 DcC1XwPLWnMvD2qaoyj+aBgJrO8UZGEXg3FiWRtKHW7AIwCBlb/nfAXkJ7B0TEWPlKmd VsZir0B+69AsKQB7fat87yyOMTe9KDXLOI6x3eOMfy2urwYZYLhMip/eFPPJuVj+uJEJ apRQ== 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 :message-id:date:subject:to:from; bh=d8R7iTriGoaFA6R3/eVrGQHHJrHC7vt0d7Sxs70nrUg=; b=rBf6NyJQWSYc1sZH+WkJibAII7QaEobPYRmFHdxXOMeL8mOw6FmqK82Cjws7Q3xVE1 b848eRJ6GCEKFmXCGHxBtYQZp8eWuCeAg2GpAGFbtQmdjYn0fNd3BY66TYo5TEKVSrxD yG0cskb0QANLJ17wz9zBR2BCal9mXEtPPd3bQUmgGPwmM3dBc5ZhERz4r1MCTXg7gWLZ Cl1dSUtG9GHYVYFSuT1xdcbqRj6MX5PZ8XifOA+qBcdBlO0LAn0bvKOChxfuHQBU1vuG RYbUhIC67959FgNCEJ+xfwUcBz0z7HZ5gVj0HdbRY0Fk/G/+4qJY7Kcl9REoqPVQV2x/ WuDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si723179edt.35.2020.10.20.01.55.52; Tue, 20 Oct 2020 01:56:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728713AbgJTBcb (ORCPT + 99 others); Mon, 19 Oct 2020 21:32:31 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15235 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728702AbgJTBcb (ORCPT ); Mon, 19 Oct 2020 21:32:31 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C39A9DA67446B305636C; Tue, 20 Oct 2020 09:32:28 +0800 (CST) Received: from code-website.localdomain (10.175.127.227) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Tue, 20 Oct 2020 09:32:20 +0800 From: Luo Meng To: , , , , Subject: [PATCH] ext4: fix invalid inode checksum Date: Tue, 20 Oct 2020 09:36:31 +0800 Message-ID: <20201020013631.3796673-1-luomeng12@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org During the stability test, there are some errors: ext4_lookup:1590: inode #6967: comm fsstress: iget: checksum invalid. If the inode->i_iblocks too big and doesn't set huge file flag, checksum will not be recalculated when update the inode information to it's buffer. If other inode marks the buffer dirty, then the inconsistent inode will be flushed to disk. Fix this problem by checking i_blocks in advance. Signed-off-by: Luo Meng --- fs/ext4/inode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index bf596467c234..fe53774b8b6c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4971,6 +4971,12 @@ static int ext4_do_update_inode(handle_t *handle, if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); + err = ext4_inode_blocks_set(handle, raw_inode, ei); + if (err) { + spin_unlock(&ei->i_raw_lock); + goto out_brelse; + } + raw_inode->i_mode = cpu_to_le16(inode->i_mode); i_uid = i_uid_read(inode); i_gid = i_gid_read(inode); @@ -5004,11 +5010,6 @@ static int ext4_do_update_inode(handle_t *handle, EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode); EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode); - err = ext4_inode_blocks_set(handle, raw_inode, ei); - if (err) { - spin_unlock(&ei->i_raw_lock); - goto out_brelse; - } raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF); if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) -- 2.25.4