Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3682734pxb; Mon, 24 Jan 2022 15:14:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbuOD10ATFzLnG5ISBWltBUrNrnJ6nyllrHyoJiRwWLvy8fg+U1FixUwhl220j3N3DGCil X-Received: by 2002:a17:90a:5d8d:: with SMTP id t13mr601987pji.47.1643066095921; Mon, 24 Jan 2022 15:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066095; cv=none; d=google.com; s=arc-20160816; b=tS8tRjDoUlghjfzm0ouKsAzMvEr+XfaJ/CXhSJMgdYRlBkT5/AJ2spyI4GtyfzhujH +w64ZZ0ZN5Mt6C3ZwUudCmSRxf5TF680x8twhCbgRzvJawIg/60aSfnLXFeFLPC73DQc NI7FJF+KZqPu0sW/ogiZse3uhtcRnOdb2yaCUezG0mJjZPZIm5CmOt6xzsCaWKHHBkh7 4eW3r4exFWzHqjASFv5/UQe+E+JWUZdokZJo8xJzbHE88q7D5a6jlxVRUCcYhL8tAB2h VC+7igkfKovgoUBcDSf2gSS4RxEBrkc9dHhPUvKSvnBb/6OA8Tdc7r/2v3lSWYnS6mHv MSSA== 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=QmkD7r1+f2L+xOwkpip0eo7WmtmJbelX/jROf9Fph6lo3qms4Id0FQ9tvApkROtdw+ sLMYYu+d0Y2zJgqjsPiCa8mepzFfJK9kNsqJrpmR2ykeahMIDg996fdTdhL6kqS9QiyN SzSQkCoQGhd6Vmh2icmyqDGSHAtJaSBy1v9H2YME+bP390oQU8I+XaMQuLDAKgqEjAIw ihAnfHiwQ0L2LymxdgAfM2ckVta81wF6n9Whl0oPe6cMikkBXVW0dabDfdkr/EBpQdK7 hIFXwP7VwIvaEUCPEVT573av5JqMpJjklS6Ts2c5wwYsMaInkudRhYDQ3u1mHsKUJdT3 dSlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LWyf/GLb"; 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 q26si15405129pgl.158.2022.01.24.15.14.43; Mon, 24 Jan 2022 15:14:55 -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="LWyf/GLb"; 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 S1384915AbiAXXHx (ORCPT + 99 others); Mon, 24 Jan 2022 18:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1583209AbiAXWR1 (ORCPT ); Mon, 24 Jan 2022 17:17:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9EEFC04A2EB; Mon, 24 Jan 2022 12:46:46 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 75FBDB81243; Mon, 24 Jan 2022 20:46:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E627C340E5; Mon, 24 Jan 2022 20:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057204; bh=PBfU0sjDKHjPEXXIWzNxqIfWzz3fkDv5Yi5PMouzK2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LWyf/GLbvpoUjYfAk5QeL4GpEbbjhVyWPmbFoNADagG0AlXDArSofiLwuCLhbmIYC 6B+aP3g59SunyOHwP2kHs86PLigs00S/L77WJoyCNSszJgnIERvnP86ngQa0bhxF/6 LOtNZ8m+l8FTfnt0MctDpYiAnB+8rPeIxiSeZQ74= 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.15 718/846] ext4: set csum seed in tmp inode while migrating to extents Date: Mon, 24 Jan 2022 19:43:55 +0100 Message-Id: <20220124184125.785634387@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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));