Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3548246pxb; Mon, 24 Jan 2022 11:58:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTX7tTPRN7dVTdn0JAAHXgtnQ7/QsqdCVNcxVFHuD1tDbyehxHWwUUhl2oTghhr9eSWaZS X-Received: by 2002:a62:cdc2:0:b0:4c7:f9a5:ebc6 with SMTP id o185-20020a62cdc2000000b004c7f9a5ebc6mr9327913pfg.34.1643054304903; Mon, 24 Jan 2022 11:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054304; cv=none; d=google.com; s=arc-20160816; b=Jq7wnvx2KSW9kweUtZJnwKHdMSa5+JkV2Z8U5iWsVC6H/lqKRW5Y5NZYNTu3hPzsSU RpgdCiDC6TbR6P+3qbuiuH6qhyr8v1exSZjG03N1RJjzmAXEcMkAr+wWRsrKLJerUcqp wMGF2cua0fkyFbPTKxUm4CAFJ1bVffn1K6WpuylTNckhWtLms15HOyrRkm0R9qQwgNxR C5d6VqAB9aa6p3k8zJ1giwYAaMI5le5Inapndd4GJ/qDe9nns5qEZrKqVkxEfqMkjUll Wq0EJlo++Q4yHPzX097Vd27WwHnQYFYp7epnTH0c00KRP+HENFliULezgkaRb24eeqjz sjHw== 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=AgaEUDhx9iPX1p1IcNbv95UCkiCpvZr7cwtqgJPyiY4=; b=Kh9Vyc2n0dNd5p3zdKFfqn7bpF56jejWDjtxHnZFw13B4PIku40zebi1xlHQBuEzLs MjG/2EnzzF36NEgLCPnLVgIYEHzrZQAH8iETekv+wuVWn69fRDVwYi3zKBZJARIfqsyV UvwIzBo3PBdkOawZ57cn9g47CO0GCGcJHdVgujjl6woD5KUzKZwssxTwVt99IJm5tYHY l7p8EacciI2rR8NcfAAeBykustCTIK7Ep2iNzny85zqxhALeTUUBaJZuEmYfmPRPTaNf WhlbXOm444Dm9D7ts3lYjNKLbfdcyzB2omqAMRX/mKcNvfnkiSt8KGsiTVE+jusTP4eW yvlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UUzn2C5c; 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 r3si13502995pff.365.2022.01.24.11.58.11; Mon, 24 Jan 2022 11:58:24 -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=UUzn2C5c; 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 S245493AbiAXSzV (ORCPT + 99 others); Mon, 24 Jan 2022 13:55:21 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:52078 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343982AbiAXSwy (ORCPT ); Mon, 24 Jan 2022 13:52:54 -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 EB390614BE; Mon, 24 Jan 2022 18:52:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2613C340E5; Mon, 24 Jan 2022 18:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050373; bh=W46B476feYqGoB0BzzWIPhXASw9qeqBJiY3JXo5Z8qE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UUzn2C5cBpCuTGlw2zb2KlsqeQ/2uu2HPOaZzIbLKmmHdt1Oc15c7TVQGZo63n2n2 0vdfp4hth7/9f30os2CV6OgNuCjySd36hC2C/lqD0ERP1sAdQ6zziq+YCuMx+vSVTe nWM6qo1hFPb7y/LobVPXuRTMrT0ulm3MRv2T4RGE= 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 4.4 098/114] ext4: set csum seed in tmp inode while migrating to extents Date: Mon, 24 Jan 2022 19:43:13 +0100 Message-Id: <20220124183930.140510144@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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 @@ -481,6 +481,17 @@ int ext4_ext_migrate(struct inode *inode ext4_journal_stop(handle); return retval; } + /* + * 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 @@ -524,7 +535,6 @@ int ext4_ext_migrate(struct inode *inode goto out; } - ei = EXT4_I(inode); i_data = ei->i_data; memset(&lb, 0, sizeof(lb));