Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp43735rdb; Fri, 26 Jan 2024 18:06:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLcpXOvNRLXOjsETsHhmresV5KJJu/nTHOl/jP7+y1w+7Zl/2zRsDbzIgOKSSUpmjeD2yG X-Received: by 2002:a05:622a:e:b0:42a:7fb1:daee with SMTP id x14-20020a05622a000e00b0042a7fb1daeemr859390qtw.24.1706321180385; Fri, 26 Jan 2024 18:06:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706321180; cv=pass; d=google.com; s=arc-20160816; b=cOzoxQ93mlxm+yk1wxyCLSwk+yyPJhD+lXzH8O4ylTqJJYb57fnCG9UJcmexNKJaCv 5WT4PvbDyGrqhRd3wb4L5r4K+K2HXPaVe2RiXcwErFoKUFFKqH/Z+65o0qtwM6cXM6n8 LPN3foMjS3Slh5y2PgAsdwpB3toPH3fryNa6/W/9lkEnFZzUEfQ5M1ok1UsZOTdtMYvv Gwa7H/HQHP/bzh3OPhqMG2nQjHek8lmEY95/ANhTJKrHovh6sqKpev3Y7/HceE17Dew1 ArnwRwaV4r0HVTsXnstte2l2/gigdH0hQ2XqgUHQXTyQBgNDa0R7kziVX7NoFlU6uPfJ +NHg== 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=A68f8fGvG41lu4S+4QA4P6nfcoO3Ylc64rgculcreRk=; fh=UhGiR19HeAIu8tzXykjZgtAKLLMPZj8YX6gPScUOsdE=; b=sXDhsRyKuFlj2cNFU1YmfueV2HHsQZBiTXTAl9gnLah96p8vmYjAzwN5B0vJ72v4zZ bbdqyEcA23B1FaWmaD7ji5UIXdruzBzk6MFSej98p5IWn9lU+ailjyxyvrX9aa7dzW5F rDP/dmuVqepq76rsQMy/HDHCbC5ijEST0lzJOp/g2bELi8Ea+8QURTu0oRme6EN1mqoI uxYM5JwKJNx3876OEXOEJzdgN3HoSNeHVmm95MkBjYhuWLoCPbRvS7dGNdqMzTSPpvYd eGQBt+A9L3SPXg5cBwx070Kk6xvcItxWjDFx7JZlZw+zXP+a6tjl5TO9GWvHWpnnjJUq 9kew== 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-40986-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40986-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 d2-20020ac85ac2000000b0042a2112b22csi2568792qtd.732.2024.01.26.18.06.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 18:06:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40986-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; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-40986-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40986-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 1D1461C242D5 for ; Sat, 27 Jan 2024 02:05:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BD4B1F19D; Sat, 27 Jan 2024 02:02:49 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 416A4BE7F; Sat, 27 Jan 2024 02:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706320968; cv=none; b=NIb+jEqGR7jcy/bJDWZBJkgI/1iUjYIFbWvSKcJN39V7GqER1A9sy8vMNTuPXpP/VddI+VQfj0DbjRNDoidRVh5H/CQT2//k/cbjI0KZNM7UuINQQS/GFMIrG2sNUuPtgDK5SdpJvnFulCdEkzCNhL0lcF6EtWTyf15YkgHDmiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706320968; c=relaxed/simple; bh=RMdfiISJk+4rEAYVn9te2DbUmcmL8lNdE+cN6ajlTwo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JXwMtH8HVicjU6o7yenCxtzas+RZ9h/wn/3JlIUu+JG996KeFec972ISsnoCPikVMYxf3XBCz3RhewDR71Xur99XtLROmUC5kHZZqJQceltL1xoC9h3SkMg/t/5m5eU8QBEnn3pfA9hOB4cLO0PQT/X8mpj50qydRa2Ec7hlD/A= 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.56 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.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TMHrb2bylz4f3lwX; Sat, 27 Jan 2024 10:02:39 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 5CAB71A038B; 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> 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: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/ 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; } -- 2.39.2