Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3593628pxb; Mon, 24 Jan 2022 13:04:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjsAvhFfgPm+sYjCHtB59rE3BVy7WyoOO/dpjvC2Wuypit97KZHUJiyYaJI6HncSOON7B/ X-Received: by 2002:a17:903:2342:b0:14b:449:d517 with SMTP id c2-20020a170903234200b0014b0449d517mr16053623plh.104.1643058258498; Mon, 24 Jan 2022 13:04:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058258; cv=none; d=google.com; s=arc-20160816; b=LeY+sJdyS5oGpmmcRM8S0TgbU2IiMZrufM2r5Be5OB5CakNx7OwA8288oKd1YUlDzB VdUuhoFB8kgv8rHrvTyB4MAhADbdLJKzpJ3O80wEMG9R1Cae24J17HQdlM58ddFQ7TWA eiox70XMZjDY6bwaXbnmJOrkj0jIpqYZ6QTtiZkTT1qIBiXBWYetyceHdkuXCV6Ndhes 2NtqU9k4B6W0PpWB7oHcLf1FTUPsDNX7UvG+GU4vuCkgFYwtYfuwG0u6Nfd4Ui0YA7OM guMEbwGuamlvplyVcyTTpyFnd9kCGiShZ279EKBWv6CsOayHoSpt+NvVBcJFbJW5sEcK WBhw== 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=jsB46dr5CUNIynH22aq4YtgMmDYOSvYFv7WmfDPEOcw=; b=IQoqH5ajReez74LEmqaiRhxVzWTuDV2eB02CgyrxS84uvySyPb/4pCpJYfl9SkXuiM ECgewxdcPxRPaChVpsQYn5qkGwzxzF1hMIl054w1VppaYOtcBvqOiUVVrM0xDPSzw9on QWit0HM/z2oe8BrDl4RjMpUvRC9a/JpkPohzzr9CpEm+qBcmNujz+sDmu+iLB86hATT8 n9NFT+/rV20UDXmc9pWf43IXo718CcKfJMMGM0GwTq9Ic54r7JaXr2irYbJwNzZN/Tzo VgtLPz5wvDyXPCr78IqSO7NZmRt+p4vOdA4OAdRHySGNYzvwpfLTYGf9P2pfK8cvg3Z7 86qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kfMYlhF7; 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 16si15138800pfm.145.2022.01.24.13.04.03; Mon, 24 Jan 2022 13:04:18 -0800 (PST) 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=kfMYlhF7; 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 S1383734AbiAXU1l (ORCPT + 99 others); Mon, 24 Jan 2022 15:27:41 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:59572 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377186AbiAXUFG (ORCPT ); Mon, 24 Jan 2022 15:05:06 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C24E36090B; Mon, 24 Jan 2022 20:05:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E643C340E5; Mon, 24 Jan 2022 20:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643054705; bh=PBfU0sjDKHjPEXXIWzNxqIfWzz3fkDv5Yi5PMouzK2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfMYlhF7DPqdB1Zzb88S6aeafGMFemxSQOOnz/Ktmcwsgh/U2minb8r8swJfLaqKL 6J2DP8GQoYiXkCyZbkAGs6ab9vM3XWoIR9uM1pMVOupRw7w//pcOOo7JZzOEyfAE6e VRv5E+yk7225BqQnTRGCIHgKy7mXOMAkei1AaMkI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeroen van Wolffelaar , =?UTF-8?q?Lu=C3=ADs=20Henriques?= , Theodore Tso , stable@kernel.org Subject: [PATCH 5.10 477/563] ext4: set csum seed in tmp inode while migrating to extents Date: Mon, 24 Jan 2022 19:44:02 +0100 Message-Id: <20220124184040.962722424@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@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: Luís Henriques commit e81c9302a6c3c008f5c30beb73b38adb0170ff2d upstream. When migrating to extents, the temporary inode will have it's own checksum seed. This means that, when swapping the inodes data, the inode checksums will be incorrect. This can be fixed by recalculating the extents checksums again. Or simply by copying the seed into the temporary inode. Link: https://bugzilla.kernel.org/show_bug.cgi?id=213357 Reported-by: Jeroen van Wolffelaar Signed-off-by: Luís Henriques Link: https://lore.kernel.org/r/20211214175058.19511-1-lhenriques@suse.de Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/migrate.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c @@ -459,6 +459,17 @@ int ext4_ext_migrate(struct inode *inode ext4_journal_stop(handle); goto out_unlock; } + /* + * Use the correct seed for checksum (i.e. the seed from 'inode'). This + * is so that the metadata blocks will have the correct checksum after + * the migration. + * + * Note however that, if a crash occurs during the migration process, + * the recovery process is broken because the tmp_inode checksums will + * be wrong and the orphans cleanup will fail. + */ + ei = EXT4_I(inode); + EXT4_I(tmp_inode)->i_csum_seed = ei->i_csum_seed; i_size_write(tmp_inode, i_size_read(inode)); /* * Set the i_nlink to zero so it will be deleted later @@ -502,7 +513,6 @@ int ext4_ext_migrate(struct inode *inode goto out_tmp_inode; } - ei = EXT4_I(inode); i_data = ei->i_data; memset(&lb, 0, sizeof(lb));