Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp918382lqo; Fri, 17 May 2024 05:51:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVB4jpOP65S01OeN1+xx2pDhpSsee7w/K5LKeoKIia4sW6Gshw4DSly64oohlU487L3IFbxUBcMy644qpNaRUFPT21ruzivc3VcUhFy2Q== X-Google-Smtp-Source: AGHT+IE3Sg7ubfNwxXKaoeR6bXovkJ46SWmoeF0zwyL1h9SRWvitOZBmt8AMBSnuC0gZudmoINpt X-Received: by 2002:a05:6a21:1aa:b0:1af:cd45:598b with SMTP id adf61e73a8af0-1afde10f2c3mr24438457637.34.1715950271958; Fri, 17 May 2024 05:51:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715950271; cv=pass; d=google.com; s=arc-20160816; b=d41RL2NWdHhCv0Tbpus9hWxnmpNZ5uzBtR9ZM8rjp9N03UZHDBvXOkHQm5PETYRxrJ 5hn/uqynpuMTZVIggXuDhvisbvEuZVBmA/YHWa02t93SzqYk4hfjbvlTocozidmbD3/b 1Gf5p5Lg8C69+WSJa/8TMg6f8i0O8AsnBHNpnnaCT8QpRqnRYGjRSMabkEpd7hHFL4l6 hNOL7Rtwtz/Ocou/QESU81axzWGCCgfss912j1HKy7FKlZRiW+EAHC6r59b+pR/DNwBz StKYsdt2X5V4X0IoF8qhrQUl8/cOQXU1vSGbWWZI51wS7v6KhG/QQD/8E+lvUBTtFiUT qhFQ== 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=w1cXyqYlh2LXNDzFcenB7wmhePxQ2Ock9nqFsBNVwb0=; fh=/gW0yUFnRcFNkSCPxz8UjBHCGPgiCEguRpLIibqIEzc=; b=lKczCkQQgJA6CpGj2E1ZT59LgWH8HtGjqw74HqQFpbKiX48ExZDDZtqNDhzoa2bMIy 4Y12+sX90csodhSdq1kB3fGgcFZ2JAA8YkjjDYHUHqOS0HH0MbZjH7zB1mGI0wDNX05E PD87xkYj2PWV3mdPIhMDmQkyn4CMqig0Nw9KCDjESqoAEGdJeqZVcH4nKFSKySbzLvE7 l1UffqvMRUiupRMlL3tqXBrqdm6V/7MgG+66KUFt91LLfKh+gjmlTiClWViMb/qDhO6i u610nfTRUILC2NpiuNIIUGlgdVpMgo3adD0/d8JbSyIWFfXtxH7yz+L5cukKotnCRwjP cJeA==; 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-2551-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2551-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b156d5si18601837b3a.224.2024.05.17.05.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 05:51:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2551-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2551-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2551-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 15BC1283890 for ; Fri, 17 May 2024 12:51:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A3EA4F61D; Fri, 17 May 2024 12:51:01 +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 CA535481C7; Fri, 17 May 2024 12:50:58 +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=1715950261; cv=none; b=aheghoBXgWjvOK3KdJyL8L95JxVaPX3ejOMLNsr8SUpQbfyFd43XNfFOvoRkd+woQWpZ0fBnUm2F26swItD658OPBVXwsFVqq+FXNQAY+ys/KHlIIs3oHAoM2k7A6HXHz/8ZtQ/jSmu5NFWG9ps3I/jvl2HydCBdFmU0fPKvSQQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715950261; c=relaxed/simple; bh=r3kGCj6p4ccBjVSfW52HjxMspg48PzdX9qXYKJ4T0w8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jZIT/C2gEBIRvcYUInA+aHkzIXQASzzilvWLIWHcuiJc38jJKePKhHNHBr8SpxgIb4jj4K8D7c9yWQA9crAzrSbftSld5TdDaR2erP1pp8EqxAMa72QliZphwrfCLzxH+zHhBMilwb3TDdmCgC/WC78OEbbe9AG1JhkCDnfyvlA= 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.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VgmzF4TxCz4f3k6f; Fri, 17 May 2024 20:50:49 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 3FF5A1A01A7; Fri, 17 May 2024 20:50:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBGdUkdmdAmqMw--.14380S5; Fri, 17 May 2024 20:50:55 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH v5 01/10] ext4: factor out a common helper to query extent map Date: Fri, 17 May 2024 20:39:56 +0800 Message-Id: <20240517124005.347221-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240517124005.347221-1-yi.zhang@huaweicloud.com> References: <20240517124005.347221-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:cCh0CgBXKBGdUkdmdAmqMw--.14380S5 X-Coremail-Antispam: 1UD129KBjvJXoWxXr47GrW8uF4UWr1xtF1DWrg_yoW5WF43pr W3CryrCr1UWws2gayftr1UZFyfK3W5trZFq397Wr15A3W5CrnayF15tFySqFyDKrZ7Xw4Y qFWSkryrCw4rGrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUTHqxUUUUU = 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 Reviewed-by: Jan Kara Reviewed-by: Ritesh Harjani (IBM) --- 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