Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6515995rdb; Tue, 2 Jan 2024 04:51:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1N5f1jYiW3EXYfstMJYOedhqBxZBobbApUWtOd5UazAHGY/WIZcypW8bLOfeEWJFH7nbI X-Received: by 2002:a17:906:55cc:b0:a23:4b6c:7dfd with SMTP id z12-20020a17090655cc00b00a234b6c7dfdmr7574509ejp.9.1704199905116; Tue, 02 Jan 2024 04:51:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704199905; cv=none; d=google.com; s=arc-20160816; b=uddDzMiqPkCbimejNl+BLYgtzu/egRo6Ar6J/PeZlwJfYLYuT9schOcNnYFrnXAZab QjzVP7g0NUEWePwrghj4WQ3viOVVYsgSprP3ofm+dCzNfuXYl131MwQmTkOywo2fxjJq HYmYEiwUeQSC6ez8PgYnWRTQZbd6o/c28VuYRaFBz1ANuVbxkxxNtr7PE+ySYlbOhIpd lIhhcLCHlYsB4jVHj6D5Y5y1BvJWYzH3GlCqPdL5QwxrnauXTYXngel9dVNp0RiyWEm3 3TeTtwQQ+TVZluvuaWvOUMap2HYOjsp0By93rU3ACS6s7vkGcjVMyTy127t+1gxg3neZ MMRA== ARC-Message-Signature: i=1; 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=NDoB8aNXDr1tYXk4jVmpF8JIZfU/QLBNBZZkzqqLejo=; fh=yWWoL3IRufgA/+2kSpO6uyfw9eN3ZOO7zvul0qbDPkA=; b=jSFkUdTtHWqPSz2KgLJAeJHErEubNFobIpYqAM+QG7XSCKZ8xTyAl134LaRakXWroZ VenJHitkFoKHL/wR3s18ulw4wQ8bN5rqbkbA8IweKGhTSNAXc3WiKp7PJk3ux8TVwOYi C2Q6LGz3Ljo9vPUxdvLXwgqXjHUubmajL+tdPQAjoafOO7kCAhCwiOEPbZ4CbenMhWV6 qzPGw+zoyFePhIeJGOm1ZYIJJnXyKNNI/5S018bfuTG7DEAGRoqptLE1+34B5Ci+DE2f j9N5+kyspLQ26xy2+OBtOYSiVoJ2vpWFG3fU9xkzviiJ5dvrUCdRrNe4GPF+uScTqFAR ke3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-614-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y26-20020a170906471a00b00a26ef8a537fsi6905090ejq.927.2024.01.02.04.51.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:51:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-614-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-614-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 6D69F1F247BB for ; Tue, 2 Jan 2024 12:44:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A561156D9; Tue, 2 Jan 2024 12:42:21 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [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 78896154A1; Tue, 2 Jan 2024 12:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4T4CD314xRz4f3nK3; Tue, 2 Jan 2024 20:42:11 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id C1CC71A0380; Tue, 2 Jan 2024 20:42:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBnwUGUBJRl+EvDFQ--.31823S25; Tue, 02 Jan 2024 20:42:16 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, willy@infradead.org, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v2 21/25] ext4: writeback partial blocks before zero range Date: Tue, 2 Jan 2024 20:39:14 +0800 Message-Id: <20240102123918.799062-22-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240102123918.799062-1-yi.zhang@huaweicloud.com> References: <20240102123918.799062-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:gCh0CgBnwUGUBJRl+EvDFQ--.31823S25 X-Coremail-Antispam: 1UD129KBjvdXoW7JrW5Aw4UCw1kWw45Jr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UUU== X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi If we zero partial blocks, iomap_zero_iter() will skip zeroing out if the srcmap is IOMAP_UNWRITTEN, it works fine in xfs because this type means the block is pure unwritten, doesn't contain any delayed data, but in ext4, IOMAP_UNWRITTEN may contain delayed data. For now we cannot simply change the meaning of this flag in ext4, so just writeback partial blocks from the beginning, make sure it becomes IOMAP_MAPPED 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 67ff75108cd1..d98c50472a42 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4606,6 +4606,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