Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp184358lqj; Wed, 10 Apr 2024 07:41:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXfh8yONLmqC4lUdPZcEHbEkEqqq1dqmIHddmIZu2O8AbhmrWnCbU7+fVhPwuSTaO+yv8PhwbNJWoBYs6JND1dbjNMs7TVo/8ErmeAoQ== X-Google-Smtp-Source: AGHT+IFg0C72zKP0ygRHs6olQYSRIe43Hb4IQ8tNWVXjdH2YBGGRmDBeEbpxRS+L9shrxZPYx6tY X-Received: by 2002:a05:620a:1a04:b0:78d:5d86:ee3a with SMTP id bk4-20020a05620a1a0400b0078d5d86ee3amr5152639qkb.27.1712760071036; Wed, 10 Apr 2024 07:41:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712760071; cv=pass; d=google.com; s=arc-20160816; b=D77FItKTyFC4M4CaiEZ5FFBa+57LBMv5qEsXcdIryq+ov/oh1M5OIuIoXOJ/nRRKNQ q/ZcENSMg73iG02upwmHzpFF/cyUvsrMCORheqVTtpnmLlBW+nmMFG9o6LZoA0t8/aHf UaL3q6QJV1K95Hw60Z51hhvMWkNzxyshicV0N0UHE/+/l3z/D9+5UNQVTgjHOBAVnSbi /cq5VfkP5kOSc1RiXRszV1sYcxczcb8+/CWOqoBbBkIsquoq384Lh1HVqn3sx/haYqgq pkOgbdsHd/C1yY47SyYiG7m2dFQCWg3n10dFZdUaTtsxpQuCjTwNscUBKsFS5w5sEKLH Alyg== 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=vlSVZYHGBCwe5po1YBBPtd9L9lS3Ca8QXEZWdubIRGM=; fh=VCdyVZCUh9R8dltaA9/RWs/hxQzWhc63WX0fta2PQtE=; b=k5wqlsZP1lykMucCDcNiuTGakQy1hnbSiLrvN8nZ3vL+Zw6t2hGjMEtvuHBxLEVe0S txrXOzxMG2/om4p6g5QckvR3X0N/Nv/wnmOdkZPTnYrB9E3bXH6nxB+XdEEEr/2/RQW0 kE5ki5T/5fng3H421+PrmlcGJQeCBrmQAA4HrUwalhX7ExzP7dLwughcjYaAYpadsN/7 kr1X8b2JVFXLEOwxEAzQJNnSFH9wLKin38CK4bIJZdwlzWrh5cn+0GlQzJ+yCCvqIs53 hG4UYcZyvM6xfLP3GZRDcba6cKW95R6yt/Llb5p1N30RBJ2V/rygK0kiGr0GT/VXvBIi dmyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1974-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ye20-20020a05620a3b9400b0078a4cc85415si10185018qkn.42.2024.04.10.07.41.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:41:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1974-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 B3B731C20AED for ; Wed, 10 Apr 2024 14:41:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE5B9171679; Wed, 10 Apr 2024 14:38:33 +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 645F716DEB0; Wed, 10 Apr 2024 14:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759913; cv=none; b=GpHON8btLNp8Tf1xJAFgyDgk2d30w9DkhmgAbQugk0QjWGbJkCOvFGTs8CBixvtGsnmm1hnXt0ZcUX5LqBurU0iyVAGS08xaaFa/PBYroKI4fgnll7gBZHZaZwKmXfjDfUPWrfU/0XwO/6cbCgdclqWaypoBvDD0Px+2X0YSSso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759913; c=relaxed/simple; bh=2HBjfnmXGyvn6SftJTPT4OD804rNnbXj6VZFRswgzHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=se9X+e/QDn/q3/EOTNy/evLoWJBd8v4Uw5z1MdoAMKRbTPo2jrVR2NK/SPW+dNTHGhy5jXZs+mCyb3tFgY2EbA+ij40SvAGxXP/vn6NpQ6BLOZnX2lPW52W4j26OWlVgcKefBgaYoCVn2nGlLZQQqTQbX5xoz9t2P2Rn4kLXA/g= 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.51 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF56K5hZFz4f3lWJ; Wed, 10 Apr 2024 22:38:17 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 701951A016E; Wed, 10 Apr 2024 22:38:26 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6RFSpBZmcwR8Jg--.63000S5; Wed, 10 Apr 2024 22:38:26 +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, david@fromorbit.com, 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 v4 01/34] ext4: factor out a common helper to query extent map Date: Wed, 10 Apr 2024 22:29:15 +0800 Message-Id: <20240410142948.2817554-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> References: <20240410142948.2817554-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:cCh0CgAX6RFSpBZmcwR8Jg--.63000S5 X-Coremail-Antispam: 1UD129KBjvJXoWxXr4rtF1xtFWfXw15Zry3CFg_yoW5XFWUpr ZxCryrCr1UWwsagayftr1UZFySk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2NuUUUUU X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Factor out a new common helper ext4_map_query_blocks() from the ext4_da_map_blocks(), it query and return the extent map status on the inode's extent path, no logic changes. Signed-off-by: Zhang Yi --- fs/ext4/inode.c | 57 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 537803250ca9..6a41172c06e1 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -453,6 +453,35 @@ static void ext4_map_blocks_es_recheck(handle_t *handle, } #endif /* ES_AGGRESSIVE_TEST */ +static int ext4_map_query_blocks(handle_t *handle, struct inode *inode, + struct ext4_map_blocks *map) +{ + unsigned int status; + int retval; + + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) + retval = ext4_ext_map_blocks(handle, inode, map, 0); + else + retval = ext4_ind_map_blocks(handle, inode, map, 0); + + if (retval <= 0) + return retval; + + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertion failed for inode " + "%lu: retval %d != map->m_len %d", + inode->i_ino, retval, map->m_len); + WARN_ON(1); + } + + status = map->m_flags & EXT4_MAP_UNWRITTEN ? + EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; + ext4_es_insert_extent(inode, map->m_lblk, map->m_len, + map->m_pblk, status); + return retval; +} + /* * The ext4_map_blocks() function tries to look up the requested blocks, * and returns if the blocks are already mapped. @@ -1744,33 +1773,11 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, down_read(&EXT4_I(inode)->i_data_sem); if (ext4_has_inline_data(inode)) retval = 0; - else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) - retval = ext4_ext_map_blocks(NULL, inode, map, 0); else - retval = ext4_ind_map_blocks(NULL, inode, map, 0); - if (retval < 0) { - up_read(&EXT4_I(inode)->i_data_sem); - return retval; - } - if (retval > 0) { - unsigned int status; - - if (unlikely(retval != map->m_len)) { - ext4_warning(inode->i_sb, - "ES len assertion failed for inode " - "%lu: retval %d != map->m_len %d", - inode->i_ino, retval, map->m_len); - WARN_ON(1); - } - - status = map->m_flags & EXT4_MAP_UNWRITTEN ? - EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; - ext4_es_insert_extent(inode, map->m_lblk, map->m_len, - map->m_pblk, status); - up_read(&EXT4_I(inode)->i_data_sem); - return retval; - } + retval = ext4_map_query_blocks(NULL, inode, map); up_read(&EXT4_I(inode)->i_data_sem); + if (retval) + return retval; add_delayed: down_write(&EXT4_I(inode)->i_data_sem); -- 2.39.2