Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp883818pxb; Fri, 22 Apr 2022 13:23:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX5DBtUsTcQwpiRes+SS/u1CiAvBeiXLP/8aOgkXx69KnsmOataUkaSQE5ZqsQBUG9VYSI X-Received: by 2002:a17:903:240c:b0:153:c8df:7207 with SMTP id e12-20020a170903240c00b00153c8df7207mr6185247plo.44.1650658996757; Fri, 22 Apr 2022 13:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650658996; cv=none; d=google.com; s=arc-20160816; b=k9hOuNTQ7cNvqTSkZ/T6LzlIJkf/QEvtohoLkJiLaD+pSN0y3akTwucoV6OLWdxMQu MG8FjtgZyanSurrbDG9+qziRFJ5eo4Bxd+0/rQhAtxUbYZT688pDegfIUPmjF42gfKpH 6w9kcAc0rVKFNtFDM/7OYl3zfFgu8oLbJuwLvyvsSFBZErhkS5BQ/mm/FK89DJTThv1q WGkRXtfVATOlZ62RSFdPxXNR1bKmachz0y0eCUUcadIvQbwvqzT0Q4O0LZVdle6hfvq2 VJJaU/ubGqdHvEGqTF1BJSXlW3ypDkirOxno63FfBLJ0tId8eiPPG7or5kSWiDXLjjSu G/dg== 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:cc:to:from:dkim-signature; bh=VLO6n5Kyx5Jt1lDOIMAhd6sizYhI+Qn7Hd+uBN8pjgE=; b=nsi9M4wUXbR0VWKer1FbqadDZ0Bb+jqBWm13mMgS00HId/DHw2jXw7ex0Y//z+Lsx3 LbdLDGVHQWE3dYYLETvWyYD8t+N7PuxvkcAFQAVTNRVgO5HKypOWhJIXpM82qpfy/OCx QyeSCw4IOfjFR7nEkFfLLmGqSP2rY30N3s2BApgrNvp/dMj2PK/4dd7MIiNEWAOW8VkS 5lShMSRzVM/F6PWr+1Rg5wRSWS1YdF4+MB5Xv8lbtwqlh/JkzyYeGNKFQwkeldsyj/TV TeelDGQ2yJ+SSVYvuuIQh/OyPly8VP48/ay5QgXOEATE3rCbHT3TiB1ug0jfUXi4totC VeBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iiLN8BDg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i2-20020a17090332c200b0015ce553dc09si110017plr.522.2022.04.22.13.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:23:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iiLN8BDg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDDDF14AAF2; Fri, 22 Apr 2022 12:09:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353112AbiDVB7U (ORCPT + 99 others); Thu, 21 Apr 2022 21:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233228AbiDVB7T (ORCPT ); Thu, 21 Apr 2022 21:59:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E57A3C4B3; Thu, 21 Apr 2022 18:56:28 -0700 (PDT) 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 4CE88B821CA; Fri, 22 Apr 2022 01:56:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7F9EC385A5; Fri, 22 Apr 2022 01:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650592585; bh=CzcOPGlCV2xBPZx/jKlTI8M8Y1NunJ0Bj92iUue9INk=; h=From:To:Cc:Subject:Date:From; b=iiLN8BDg66zTXKmHVej8yVayRizhGuBO6B+N2pie/4oFdO7UER4X0grM5jKZfUd5X +l0pfAj72kDnySTte91S4LoxcsVEjE68ufCnw7zdwmBU5yMniRL/NKJEdiQAUPPLXZ k8sdEWmmwA00Jc9SQa/QIWcGgucBqOF5oDVB5KKU2nM1GS0nSvIw/vegRomfXUuHfy bqgaR4JGg1AavxejnRftYJp/6+mxq+KuomAQi1Az1kNY7WLhHn61GrJm3jApHLyvB8 cvR4UtgHXunncIwzmHJdcnjh7xB8q+tXreEONhBmKJplF6tUtCHvWNEFKG9xD75BdB R42WeyOzze27A== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , stable@vger.kernel.org Subject: [PATCH] f2fs: should not truncate blocks during roll-forward recovery Date: Thu, 21 Apr 2022 18:56:24 -0700 Message-Id: <20220422015624.3521607-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the file preallocated blocks and fsync'ed, we should not truncate them during roll-forward recovery which will recover i_size correctly back. Fixes: d4dd19ec1ea0 ("f2fs: do not expose unwritten blocks to user by DIO") Cc: # 5.17+ Signed-off-by: Jaegeuk Kim --- fs/f2fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 71f232dcf3c2..83639238a1fe 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -550,7 +550,8 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino) } f2fs_set_inode_flags(inode); - if (file_should_truncate(inode)) { + if (file_should_truncate(inode) && + !is_sbi_flag_set(sbi, SBI_POR_DOING)) { ret = f2fs_truncate(inode); if (ret) goto bad_inode; -- 2.36.0.rc2.479.g8af0fa9b8e-goog