From patchwork Sat Jan 27 01:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13533897 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 1F3DEC47422 for ; Sat, 27 Jan 2024 02:03:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41BED6B0095; Fri, 26 Jan 2024 21:02:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F0406B0092; Fri, 26 Jan 2024 21:02:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06EB26B0093; Fri, 26 Jan 2024 21:02:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E6FDF6B008C for ; Fri, 26 Jan 2024 21:02:50 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B0290C0718 for ; Sat, 27 Jan 2024 02:02:50 +0000 (UTC) X-FDA: 81723442500.20.AE2E4F8 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf18.hostedemail.com (Postfix) with ESMTP id 2D87A1C0004 for ; Sat, 27 Jan 2024 02:02:47 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.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=1706320969; 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=A68f8fGvG41lu4S+4QA4P6nfcoO3Ylc64rgculcreRk=; b=NNWGZoHfN73BQKeYbPQIs/6ldMkbUN3fPtIYK0z252tnLaIbzcsKAuaD78R/2kKbHFJzv1 3+5L710rCMShg14R2Ay1jXQxU/gsglvqj7EAtnVb8YEK5PHLZRtsyNtpkx5rI+NT1NkqmV rkhygoz5ABwln2iBCv8h0NBLfb+gkd4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.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=1706320969; a=rsa-sha256; cv=none; b=WHalwPjnMj1zQbSc1lHR7VTiD3P+hY7RUAULzzKQGHQ24Ra5/ubc3Ss4YvJtcuq0FTj7g4 3M0cC0DEeIc7+r+qVrpwDYlJUDpuQNXTVNKDmqvwcCbqlqOBLSpk60YS7SgxKlLexmXa6Y eO0UZxq9kduyBJYrddLauF9CnwU+uak= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TMHrX6jLsz4f3lfJ for ; Sat, 27 Jan 2024 10:02:36 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 4DA121A0172 for ; Sat, 27 Jan 2024 10:02:43 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g40ZLRlGJtmCA--.7377S10; Sat, 27 Jan 2024 10:02: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, 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: [PATCH v3 06/26] ext4: make ext4_set_iomap() recognize IOMAP_DELALLOC map type Date: Sat, 27 Jan 2024 09:58:05 +0800 Message-Id: <20240127015825.1608160-7-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--.7377S10 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw1kKFWkAr4DGw43GrW7Arb_yoW8Kr17pa 9xKFy7GF43Xr1qgr48trW7Zr1Yk3WUK3y7WrWfG3s5Cr10yry8tF48CF1SyF90qrWxZw1I qF4jkr18ua1SyFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl 2NtUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2D87A1C0004 X-Stat-Signature: ffbtjcztdwyqo1pui7ngdxngezidstfx X-HE-Tag: 1706320967-417548 X-HE-Meta: U2FsdGVkX193jlbf2aAd5lNwQXDtWeyBp7bVfVfSu+lk7hbG+/eINiK5iqCX+WMAW4gXFMTvgdYWTswXv1df8Q2EB0uKFM+UBC3NIDsu+iSZOGcrm4mI8qzqi4e2NAMzXT+CINLbOnQwGxLeVvx0cs5RTCWk3daQteLdWzEDSE2IaINBFiqr3wROsH21X4mfHLvWSb+d56Pp31An5Bz/+Rf7WKhhU+d6yjkuj0g3RT81iwalpewO91crPfI1Fm9V3g3najFPFFwFW/kcBF7n/vUxYDr787O1jlDwW/nX/YyaQk9GTQTJplZNTpiMDv8neAfozHkOfjgFbz16e20ejNjvyY2kJQpS1EMyT5OG1/aEEM5elVSWETtWZHP8mHWWPosdPlHvij54vs4sCArVCB+qM/WYL41U5VlJU8Z8qZPASGtaX5LCVQi4ie4Wk259QkkJDRTGpZPdU52XzW3VVzXVxbJvYI4ShBcZLeO208mNYvlddrPrFqDBv7+2egKN4TyYpXkYmDq0x5jEZmCX6YR+1px0MuoxZs0j8fXsg+lWuiN5+Gzlj1UZd29H0+bopBLihBzOKcqTjQqv3/fmmi0/HwVxCtjQBYOb7ia4AVLHmu3Qy2YbaR4GAS53nqubblVNq4jiCuXPfjZXZRlF3UQrLJyS8gtAYGOCqXXKDCMEZhsQ8mZYvZHynSiFManEpchXl4V2jIZcsDdVnZht1/IJF7KbkaGzttZdpbYUSDxa1NMZoAXa2fV8MMGRcBsG4ci6Y4WPiqrtazvyBibdISq6jLlZ/nxJoBJaHcntPNbUShaZAxMsFe0DfyUnuYvQ2jVtMfSeSpwm5EzC1LAPgdkshMGrkx28ckFfPUFlYevVzYv29uSC2vZo10kG1+Z4gepG92BVac+dykwOf5OaJ8ZvDJpgNnGGg36cqU5+kAWpOO3HVnslxye1gWnF6hNi8KNyKHUIeR0s+bbSAdJ HThpP+Xk fyXKE5bj9iQNFpyzAFOaFd+LEYqF591Dxk36qPgXgNz7UMNhbYgn5qikpJq19szp8tM2ek4wSUCYsSy0O+Z6acGiSzBLszZqYAz7hRqQBZZFz9Nv7m73FosA7a06DXcIO1zvFLofjXo7/dvRdBJATE8Lqx7gsLaNF9gANHbxGDw6q5+8x9i+UErLMO1E9AtTqfgszyAEZE0Cib9xZUTcrV6skeqLFPOmHxJifV/yBcSU1KlARFZe5ZfJRhe9qF0VRbktwKbccEKOZ1+UBTEi+h4S2z+2KgA1qkzNlbk51w/PYd1A= 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 Since ext4_map_blocks() can recognize a delayed allocated only extent, make ext4_set_iomap() can also recognize it, and remove the useless separate check in ext4_iomap_begin_report(). Signed-off-by: Zhang Yi Reviewed-by: Jan Kara --- fs/ext4/inode.c | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c141bf6d8db2..0458d7f0c059 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3261,6 +3261,9 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, iomap->addr = (u64) map->m_pblk << blkbits; if (flags & IOMAP_DAX) iomap->addr += EXT4_SB(inode->i_sb)->s_dax_part_off; + } else if (map->m_flags & EXT4_MAP_DELAYED) { + iomap->type = IOMAP_DELALLOC; + iomap->addr = IOMAP_NULL_ADDR; } else { iomap->type = IOMAP_HOLE; iomap->addr = IOMAP_NULL_ADDR; @@ -3423,35 +3426,11 @@ const struct iomap_ops ext4_iomap_overwrite_ops = { .iomap_end = ext4_iomap_end, }; -static bool ext4_iomap_is_delalloc(struct inode *inode, - struct ext4_map_blocks *map) -{ - struct extent_status es; - ext4_lblk_t offset = 0, end = map->m_lblk + map->m_len - 1; - - ext4_es_find_extent_range(inode, &ext4_es_is_delayed, - map->m_lblk, end, &es); - - if (!es.es_len || es.es_lblk > end) - return false; - - if (es.es_lblk > map->m_lblk) { - map->m_len = es.es_lblk - map->m_lblk; - return false; - } - - offset = map->m_lblk - es.es_lblk; - map->m_len = es.es_len - offset; - - return true; -} - static int ext4_iomap_begin_report(struct inode *inode, loff_t offset, loff_t length, unsigned int flags, struct iomap *iomap, struct iomap *srcmap) { int ret; - bool delalloc = false; struct ext4_map_blocks map; u8 blkbits = inode->i_blkbits; @@ -3492,13 +3471,8 @@ static int ext4_iomap_begin_report(struct inode *inode, loff_t offset, ret = ext4_map_blocks(NULL, inode, &map, 0); if (ret < 0) return ret; - if (ret == 0) - delalloc = ext4_iomap_is_delalloc(inode, &map); - set_iomap: ext4_set_iomap(inode, iomap, &map, offset, length, flags); - if (delalloc && iomap->type == IOMAP_HOLE) - iomap->type = IOMAP_DELALLOC; return 0; }