Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp195282lqj; Wed, 10 Apr 2024 07:59:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXtxAIDDQWXGw8T5xLM4x6aKCFAsJrL70f2xJCDnFk5TF1S7DupX4ut2imCOrZ1nhH2juwxdt/NjDVMV1zB4TzN0mGpVHAndsfP5u5Rg== X-Google-Smtp-Source: AGHT+IG0O1Z9ZQtyNAjTuHbLPdawKC485jkc2LeUaBf2mbX/xEpL90sdE2nQ/MIzpFNeAP58Wwl7 X-Received: by 2002:a50:96c4:0:b0:56d:f035:7db2 with SMTP id z4-20020a5096c4000000b0056df0357db2mr1546287eda.24.1712761188777; Wed, 10 Apr 2024 07:59:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712761188; cv=pass; d=google.com; s=arc-20160816; b=D+hjbZNiPee64ZFkHr67uKyBOM0jBRrVLAPYBoaeXHGDNQqeYnv+cA0dkjKoqNqs5O SBB7F5G3aiHUmbe1fa0COPCCSb7lh4yYfVT3COGJwYw9czrIeIomCNZvOf+Hr1DnIE9w jpQ23UOdpN1rf3PwOHc+UoXz9TQJ1ouYFl6GiqNGbTuSYm7ocRW3MYNm/a/dt6oZnQP5 qB/UXDLzVshdRx5TEBiaVnUPOm78Q1tsuQtV7Oe584rYSVGoRLehAbukhshlOpTZZL/q QdgCbrz1ODBbm29vWsNrSUH6t+oGBDw2I1PF7Y8iabin49LfRF3DBWCTqwYqQvDYRkKF XNeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=1rfO3bDUWjwaLs+wdCUIuN/1ZGWNGlnDZNmsSH0BvMA=; fh=VCdyVZCUh9R8dltaA9/RWs/hxQzWhc63WX0fta2PQtE=; b=0g2ybaVabDGM/MTRDgLlO363WsqwiKiFeJ5rxreLluxZ9ufOJ2eDM7+jDAF7bnqIDR vJW4LeuqZVBEuienwOBXyMbBwKpGdwX3a7o6vZLVX/g0thyPPNSv69/0Xg5UZ0qLgppm 6AZDemJahL9OoA242/JGqSpZ65Q13m2lvErnxlJg8sfVcxwmMuOoGkYbI8+n3XA8fj71 lE4ZYNMHXI3UDYiMWGnXRWZaxU7musy3ou0EhMoOsW0HyvVK26xexwfetQS1us6KSJpW lD/iNIr7nqlF7YEV/Cbf0unFxnsW2Sj65s2vdF1VXXmuAWjaGzg5KyvBhU8Qt4uqPBWM D6Hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-138797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138797-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m14-20020a056402430e00b0056fde9c51easi147952edc.459.2024.04.10.07.59.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:59:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-138797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138797-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 45AF91F2C802 for ; Wed, 10 Apr 2024 14:50:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0D0C184110; Wed, 10 Apr 2024 14:38:49 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2CB018132B; Wed, 10 Apr 2024 14:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759929; cv=none; b=aoOylt+fX9Si1rBb13qhF1Q23xMUs8pDspNbKa8TzpjVgVAZFRQ0O0a+IA6VUtqUQ+qaftp4hTamQqyhfRxjVbldKJDAkBQBsW1O5un7uFQ/Xv+9APL3Wn5XS4FuxytOWwb5RnwjRIVTHCfNJMN7QwZYmKnCGM0uH/3N2UT9bu0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759929; c=relaxed/simple; bh=rE9Rcx+buyMmwsXHYp7x2evEfE+Nh2dJdCHXPJa71C8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RSi6UznCoPtZzUnkl0Vrp6O9wxxZ81eGYv/BCVD4S9+MrAO2aQZ5M/yjr8qAd7JiCk6DhUh37//F9zuvXEJIn10h3/hK36sVCj+Cw5ABsAlvujiJTzyMrrcmx6RUp+hyXKJHpxyrK/lLlBOp3X42yzisuZEVulUsyKpYsqmY7RA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF56l3V9Xz4f3kK0; Wed, 10 Apr 2024 22:38:39 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DE50F1A0175; Wed, 10 Apr 2024 22:38:43 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6RFSpBZmcwR8Jg--.63000S32; Wed, 10 Apr 2024 22:38:43 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, david@fromorbit.com, willy@infradead.org, zokeefe@google.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v4 28/34] ext4: writeback partial blocks before zeroing out range Date: Wed, 10 Apr 2024 22:29:42 +0800 Message-Id: <20240410142948.2817554-29-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> References: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAX6RFSpBZmcwR8Jg--.63000S32 X-Coremail-Antispam: 1UD129KBjvdXoW7JrW5Aw4UXw1DtFy5XF47Jwb_yoWkZrc_Xa 4rJr1kWrWftr92g3s7Cry3ArWIyw409r1fuF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TRtOzsDUUUU X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi If we zero partial blocks, iomap_zero_iter() will skip zeroing out the IOMAP_UNWRITTEN srcmap, it works fine in xfs because this type means the block is pure unwritten and doesn't contain any delayed data. But it doesn't work in ext4, because IOMAP_UNWRITTEN may contain delayed data in ext4. For now it's hard to unify the meaning of this flag, so just fix it by writeback partial blocks before zeroing out. Signed-off-by: Zhang Yi --- fs/ext4/extents.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 9849947cec56..c4c38a323ff7 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4580,6 +4580,15 @@ static long ext4_zero_range(struct file *file, loff_t offset, if (ret) goto out_mutex; + ret = filemap_write_and_wait_range(mapping, + round_down(offset, 1 << blkbits), offset); + if (ret) + goto out_mutex; + + ret = filemap_write_and_wait_range(mapping, offset + len, + round_up((offset + len), 1 << blkbits)); + if (ret) + goto out_mutex; } /* Zero range excluding the unaligned edges */ -- 2.39.2