Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp143301lqj; Wed, 10 Apr 2024 06:39:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBsgqkfMGwspRB7pBDNlw2HbxOLiZhtA9KHqzEOPD/65DSFtJAQFUSjCgyZPvfmneNEpFIriR1Sw++E2Dt+GShoJGvmh0zz/H/DTNv7g== X-Google-Smtp-Source: AGHT+IEiBiISMemAMi9taIFOH7+B5Nu4vz9jhlP8Bday1gHbvj3SoOKidE2MtzFcxJiIpNUvkscA X-Received: by 2002:a81:8a07:0:b0:615:2a14:d405 with SMTP id a7-20020a818a07000000b006152a14d405mr2698421ywg.4.1712756350381; Wed, 10 Apr 2024 06:39:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712756350; cv=pass; d=google.com; s=arc-20160816; b=pZZvNMbU7AH6AKnIIEMIAvVUm8rc6diHBr2MucClNde4QWTddgTcG2/mOYn4HaduFn ynEok3kTWFe8FYMMM5jMoBW1DmLFw8N4PuHr3ehUkNXHNXaG+n+3nDX4YjS6vDYPC9/n r4gWguLB+dXOWFiTkj2g3RlS3aINAYbF7jp4CvAOi47zcDiCCJ3R8ZlilbOkiU8Yenbm moM4IgViSYl3kMxKvmy5vLHjKrg0SV5TgnHjnQH8hD3FejQIjEuySzsHXHvKfJWFGsyI UrDX7M554O+8iWg1++IuwV0fm9GId11JlCH0bizZjn20LHCOOBBcEBEAyIKY1ZjPyVEb GVsQ== 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=UhGiR19HeAIu8tzXykjZgtAKLLMPZj8YX6gPScUOsdE=; b=FeI/EjD9Df4lW4VunBiESFIi2qXkpJH/Lm0639euqzxAoK1OWNfzUSMJW7M9yDWyyS LgrdaFHZy8rNojVkj3yc6UvREPlh+cAwzsZDmOyhA6FOgFGx9249xHSQaQFcDvJmMPbz 0plAL5ycdEzR7BAdUYZVxeuWi7KwmuaDdUggJ3/E2bQAlFCqK3nNU11cMLm53T7XmS1U wXs+UALUQkBWX2pFLs+nsEU0exZO37NI8gE1np4oGkRS01AkloYxl9QzOyQjNpbkJEjQ Fx3xqLJPC5eUdP3S1IWyJuokA8G7Ubz0G3OXoUPOsAOjGW47C36hwBcOAv9Poqu35fxJ VWhQ==; 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-1945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1945-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 dj21-20020a05622a4e9500b0043181621de6si1775338qtb.253.2024.04.10.06.39.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1945-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-ext4+bounces-1945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1945-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 639C51C2684E for ; Wed, 10 Apr 2024 13:38:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 645DE161319; Wed, 10 Apr 2024 13:37:00 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [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 C15C315F326; Wed, 10 Apr 2024 13:36:57 +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=1712756220; cv=none; b=LwjnuvCNf0CA/7hsMEQP6k7X0dk9AITygQwBcQGFwYWGIeYj9r1QuqyxMR9xOUSoRbFzEXsnL6mS8Dj/iauU4Ad46aYmO++U5xJJrpWdUlFKKbqN6ud1uuUxWVDHl3JTjlnFE2GT8DF015AUwg0I+v1RA2nuaiy8CErdoQiN+qs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712756220; c=relaxed/simple; bh=2HBjfnmXGyvn6SftJTPT4OD804rNnbXj6VZFRswgzHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XyMB1GJcgkfx4Rm7NoiGnlLmAAv+iq+vpeI/Q396HBx6/MBc1H0gz2zuCYv7OcQS0OF0H0ssr/jlK8dcdt3EdSEgLtZvafbm0mzPHTho7oKQIllu/yOT7GZzqDxXILw8ZOQjlbNVQ2uG+7zx2v7+YCDjou0myd7BM0KButFDHo8= 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 4VF3lF5mpSz4f3jsd; Wed, 10 Apr 2024 21:36:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id A06DE1A0D5E; Wed, 10 Apr 2024 21:36:48 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn+RHolRZmeCl4Jg--.8806S5; Wed, 10 Apr 2024 21:36:48 +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 v4 01/34] ext4: factor out a common helper to query extent map Date: Wed, 10 Apr 2024 21:27:45 +0800 Message-Id: <20240410132818.2812377-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> References: <20240410132818.2812377-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:cCh0CgAn+RHolRZmeCl4Jg--.8806S5 X-Coremail-Antispam: 1UD129KBjvJXoWxXr4rtF1xtFWfXw15Zry3CFg_yoW5XFWUpr ZxCryrCr1UWwsagayftr1UZFySk3W5trWqq397Wr1rA3W5CrnayF15tFySqF9rKrWxXw4Y qFWfKryrCw4fGrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIx AIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUSYLPUUUUU = 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