From patchwork Sat Jan 27 01:58:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13533914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 046BEC47DA9 for ; Sat, 27 Jan 2024 02:03:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68B096B00A3; Fri, 26 Jan 2024 21:03:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63B256B00A5; Fri, 26 Jan 2024 21:03:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B55F6B00A6; Fri, 26 Jan 2024 21:03:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 36CA26B00A3 for ; Fri, 26 Jan 2024 21:03:00 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1718F80821 for ; Sat, 27 Jan 2024 02:03:00 +0000 (UTC) X-FDA: 81723442920.25.2FD7555 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf09.hostedemail.com (Postfix) with ESMTP id A1BD314001F for ; Sat, 27 Jan 2024 02:02:57 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706320978; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QboxDcRjbBuLzciXveZIXmgBvzYHPY4OBOFRdlHKrSw=; b=UNFvo4f70X7qZo2qRZee1XDCGE52+370NdWv1jaRJER0IH++IxtQ/BzbnjtJAxkGzveesU BB7lEY5O0/2nfI8dZGyvevotwv+4AOGiX733mxqxgvUR09mLtC8ymuhYkI8hLEOwRaNW6P mEEHVIl/akX1xJAKdSeJdp1RanGyqSM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706320978; a=rsa-sha256; cv=none; b=dS5fZm19+29UPh03Jqs2a79imTobaPvKRF7kffunpIm5G1zhvIBxL3yFR+T1L3tf1QZxXi DQ2sfYs3BGsZsn5Fbb80X9EIPwRSRLyslpgdtPnQOCXjnQivniwCmn6eO25vII52SwfFJr fW5wvN8ErkIkHR/1+z+MoLVLwV9w3Nk= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TMHrl3q9Kz4f3lgK for ; Sat, 27 Jan 2024 10:02:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DF3C01A0232 for ; Sat, 27 Jan 2024 10:02:53 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g40ZLRlGJtmCA--.7377S26; Sat, 27 Jan 2024 10:02:53 +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, 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 v3 22/26] ext4: writeback partial blocks before zero range Date: Sat, 27 Jan 2024 09:58:21 +0800 Message-Id: <20240127015825.1608160-23-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> References: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g40ZLRlGJtmCA--.7377S26 X-Coremail-Antispam: 1UD129KBjvdXoW7JrW5Aw4UCw1kWw45Jr1fZwb_yoWktFX_Za 4rJrn5JrWftrn7Was7AFy3ZrZ2yw4vkr1xWFy0vr98ZFy2gws2kwnYyr1xurZ8WF429ry3 Cr4qqF4xWFy7ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbq8FF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJr0_Gc Wl84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW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3DVQSM/GuHNkEAY9LL6p2Rl/t1mwGXCG8h2xLkWmF9dJ2LCxLanm6HreFZDW2kEIPCnW95oQOjtKGCCgrZaHZWBV/v2J+WnPT0JEEEfF5bE+nubT+faMd2ocGpaQXWeW11KEO9+/YBuMlQHAI6ntVNNAf3OmJZFMU5tR6iflp5FNyWQ480e2R2ejJpidyJqAhIOo0sGew36jupfTxtf+DR3A+G8r6S6yuhSrH8IOC9NnmNQSI9dBWg8lgut9ZbDN0vCO6U6YMLTVD2kemUTwUv1GaeORTipViSEKAlSCazaKBqKPYBO+0Mzn1IUjLToJjmuUdRuOvzN0fk6WmHrg91osPdh6p0n7m3FgL/bgEAnAzarAveAUlvOzCCdRFGSM5Xq0GsH8AEfoabFDsQSyyrwoyxOzfPzRl+WoJgbsOMmgl9+LIPea8UIbN0nmAPUnEEPstEHHfNi8AZthFCdNyNaWN7A1qfV9S1O21ushxuprNvsGXGme BIIyeysI MYDjKqGoWPOs7jaHqVMDu67Nl7/3yS9C0PudJDSigswpkERO2v4SFMEocg0OwGMlI/LLSvoch7VBx09/N3HSTkbsT3aNXecPGIW9l223fe07cOFHALh89KBIMMQSBF1rUHMRgfn7/rT5uBAe9JtKw0xgJwosIZxPKdQvxtZ4fyx9vvNvFPiKO84tBXv74rkf1a/DaD5XC/iLW2ZEuCSLUki/LTO+oumSDaz6MKXRffrijgtvwCitsHtXI8nB3NToLKVCt X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 46805b8e7bdc..cb80c57ccc3d 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4616,6 +4616,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 */