Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp310815rdh; Thu, 23 Nov 2023 04:53:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVlMkF/NzeYYL/b/gb2LmamrE/faE6wSgzDMrGubG6VTZboX2fRLP1oDVCyvw+8MRTw8fd X-Received: by 2002:ac8:5945:0:b0:417:934e:ade with SMTP id 5-20020ac85945000000b00417934e0ademr6807892qtz.15.1700743979884; Thu, 23 Nov 2023 04:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700743979; cv=none; d=google.com; s=arc-20160816; b=Dd2t1jnm7eWk61aGq40h7IMj6kUxAD+1GQnGq0uatp0j4T58GMstXijbbsMg7fKvMh K/8xx/+ucEhxyz8nqbJaDjpFh2HaE00ZCGWlgov7zls0Tb6ZsMNZK6Dkm0GAGjUQl5K8 Tp1AvAjZ2xdDVVU2phSIk5zD5DKD4LCW0LxygJRHV2jtxD60WEyq+GMSW6VpL2PYuUes zVhIzfcE3oDJZLbo/JBK1GZxAGYQ7V9FLGHpmXm9ug/iQR3JSJkepVAMML9EQRRMDTcx xKBwBHODVmYz4OiBAVWF8AVLgakrP0vWaiKXBcQTRq9q3mgIvv4gA7TmUAxbbkblJjNi pCkA== 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=10ZAePn9k+fruGoBGaHuSxwUXoVOEgFD3MndFw2xlHo=; fh=oXgJbFeK1mY0T4jBbK/Fs3Mi9F4SdMRqpoziDljuAF4=; b=rc6Gi7i6L0cpUN3Qs2Dk2tFvLPdre0uZBEfmSmOoPxxvRQcMJ9LotB5FL3ivs+1/aG wSp2jMKh2whkaj4LoJljDH7KTz8cRrq5D9JZ9zBrDqPvO7Oq+K+PM5seOvGvFI4OiDTT FXjm36O8qDd65VdIyi6faBrOwcqQ2rRIgEE/CLoXpbF4NlBUjP08fwrfF20BAwQlXz0J YBXyhSpjJXv8N5snGAjA3ijNXnYeEaAz4HpnfBUcD6qohMK1vli4MS4YfhM25HYktEtz jLPE/6sNIp+0Mnwpz9X0MGvyiVrEMEoxa4idjZve7GioTA6sNDFb2Zh8w1o9JL3ZckMM PyTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-116-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v11-20020a05622a188b00b004238508147csi1141920qtc.122.2023.11.23.04.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 04:52:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-116-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9FC3D1C20E2F for ; Thu, 23 Nov 2023 12:52:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B69B25778; Thu, 23 Nov 2023 12:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BDEBD56; Thu, 23 Nov 2023 04:52:08 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SbdKv1qm3z4f3kkN; Thu, 23 Nov 2023 20:52:03 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id F2B2F1A056E; Thu, 23 Nov 2023 20:52:05 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDn6xHdSl9lSfnfBg--.20473S19; Thu, 23 Nov 2023 20:52:05 +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, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH 15/18] ext4: writeback partial blocks before zero range Date: Thu, 23 Nov 2023 20:51:17 +0800 Message-Id: <20231123125121.4064694-16-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123125121.4064694-1-yi.zhang@huaweicloud.com> References: <20231123125121.4064694-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:cCh0CgDn6xHdSl9lSfnfBg--.20473S19 X-Coremail-Antispam: 1UD129KBjvdXoW7JrW5Aw4UCw1kAw4rKw4DJwb_yoWkCFg_Za 4rJrn5JrWftr97uas7CFy3ZrWIyw4vkr1xuFyFq3s8ZFW2gws29wn5Ar18ZrZ8WF429ry3 Cr4qqF4xGFy7ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqxFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr 1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AK xVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUbmZ X7UUUUU== 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, it may hard to change the definition of this flag in ext4, so just writeback partial blocks firstly, make sure it becomes IOMAP_MAPPED. 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 52bad225e3c8..b502edcf014b 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4576,6 +4576,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