Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1338036rdb; Sat, 23 Dec 2023 03:05:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUzJ//VZyhpZ6oIy224cVXZmGhRFrjPsdJbrASLnOXZ+ajwTGfoTmTBxT+O0im07rCskOM X-Received: by 2002:a05:600c:2201:b0:40d:3bd2:a1b3 with SMTP id z1-20020a05600c220100b0040d3bd2a1b3mr1588782wml.120.1703329503605; Sat, 23 Dec 2023 03:05:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703329503; cv=none; d=google.com; s=arc-20160816; b=cNzuVc5/rZsCzEEBoRxsO+yiVcfNXTZTSRV1x8iM3JLQclz77GZMp3rJwh1QZqd2kJ Grz0QHTAQ62ErlaKK1a9BkpKWTugM84e1oAqrQBzxMhSoiPu9L0PEpvkQB5l+LZayssf WatVR0QzW6ooYgqO9+fD711g9m7JTpw8gn+x6AxYxN01fEuqSRjLueeZ+l7gTRWEV6pE Ingy2nwkwsB7haSirnBzMdiDw9zSE2HC5YmDzNOX8NYNMFRl0gEMyQ3UUwFQUVXNn7AM U17/4j1e+JGXIOsPMEwpxoQE01lJieXM9BpeIewrbleIdOmgaOavvYOfd8HqwzR6tFaJ ePzw== 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=DKgcxMhuCFWX3NfsFQtfiljZhpmDtfk2MXzzX5VQ0XA=; fh=Uq/HK0tePPZ4uFSrjmAoQ+8fm8HBRKIYZPcFTEYnhm4=; b=DcnmFqHA1sHsUTDk4nxbfpA6hFxSlB7OaBTM/3rawvkwloBswRnvevNnWqDi62vGTr C9jH9bva2jZ8bkvnkQ9F5v17vd23Vj4QkevjKynLq2WF0DOzOuIbAvT2LgbRA7oAb/Rc ckTuKW+8/pN1q11div0p9x5xIDrKNFAr02jSR1bFzC20jUKZGTOIEnG8XDVkqCTTI9Ey pWLw5JLweYdino6g1nkJzqASyTKuy0yk73VfIXKGJhiTh2eXMtl7fHl7EoY1l6rBuT4B Dq2nuZdkW8CayX+6BkH8+Lkaz39UU6H22op35PNyqxwOcJzd80ucrUrDoXVttZ27NcOU D3Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-555-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c17-20020a170906695100b00a2692c33716si2725802ejs.794.2023.12.23.03.05.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 03:05:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-555-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 5DEF51F2267D for ; Sat, 23 Dec 2023 11:05:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AAFDD2E9; Sat, 23 Dec 2023 11:04:49 +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 A907DD263 for ; Sat, 23 Dec 2023 11:04:47 +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 4Sy1X51T82z4f3jqs for ; Sat, 23 Dec 2023 19:04:37 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A0BBA1A0538 for ; Sat, 23 Dec 2023 19:04:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgDX5UW6voZlWeceEg--.27538S9; Sat, 23 Dec 2023 19:04:38 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH v2 5/6] ext4: make ext4_map_blocks() distinguish delalloc only extent Date: Sat, 23 Dec 2023 19:02:22 +0800 Message-Id: <20231223110223.3650717-6-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231223110223.3650717-1-yi.zhang@huaweicloud.com> References: <20231223110223.3650717-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:gCh0CgDX5UW6voZlWeceEg--.27538S9 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw47Xw1xGw1DAry7Wry5CFg_yoW8tr4fpa 95GF1UGFs8uw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T4_MAP_DELAYED to indicate the mapping range is a delayed allocated only (not unwritten) one, and making ext4_map_blocks() can distinguish it, no longer mixing it with holes. Signed-off-by: Zhang Yi --- fs/ext4/ext4.h | 4 +++- fs/ext4/extents.c | 5 +++-- fs/ext4/inode.c | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index a5d784872303..55195909d32f 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -252,8 +252,10 @@ struct ext4_allocation_request { #define EXT4_MAP_MAPPED BIT(BH_Mapped) #define EXT4_MAP_UNWRITTEN BIT(BH_Unwritten) #define EXT4_MAP_BOUNDARY BIT(BH_Boundary) +#define EXT4_MAP_DELAYED BIT(BH_Delay) #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ - EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY) + EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\ + EXT4_MAP_DELAYED) struct ext4_map_blocks { ext4_fsblk_t m_pblk; diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 0892d0568013..fc69f13cf510 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4073,9 +4073,10 @@ static void ext4_ext_determine_hole(struct inode *inode, } else if (in_range(map->m_lblk, es.es_lblk, es.es_len)) { /* * Straddle the beginning of the queried range, it's no - * longer a hole, adjust the length to the delayed extent's - * after map->m_lblk. + * longer a hole, mark it is a delalloc and adjust the + * length to the delayed extent's after map->m_lblk. */ + map->m_flags |= EXT4_MAP_DELAYED; len = es.es_lblk + es.es_len - map->m_lblk; goto out; } else { diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 1b5e6409f958..c141bf6d8db2 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -515,6 +515,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, map->m_len = retval; } else if (ext4_es_is_delayed(&es) || ext4_es_is_hole(&es)) { map->m_pblk = 0; + map->m_flags |= ext4_es_is_delayed(&es) ? + EXT4_MAP_DELAYED : 0; retval = es.es_len - (map->m_lblk - es.es_lblk); if (retval > map->m_len) retval = map->m_len; -- 2.39.2