Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp304015lqo; Tue, 7 May 2024 23:25:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWk+db42WE+RVOFN76uSkTsg/LDlPDrzb1vzGZdP0W7bxEjAuEfV3NpbJWYCN4+zzyT5pqin96VTkAZIihaA3recHxwCDyz/Ylj7WvZAA== X-Google-Smtp-Source: AGHT+IFQpKn9AOw4ggJHcH4/VvNJ848VqB45aRv0FRhZialv7Dm5EnrkEFxkJTkjbsvp4KfF1J5a X-Received: by 2002:a05:622a:12:b0:43a:9071:7f5b with SMTP id d75a77b69052e-43d8f32bbcbmr74853781cf.14.1715149511964; Tue, 07 May 2024 23:25:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715149511; cv=pass; d=google.com; s=arc-20160816; b=mcCoKUftaXTnqywfkQ25XL7J5pl2d3FW2gHy3WhchiuWlL2ltNIG4wp9+RH6zQ7sj0 rByXK5fpOaNknaFc+Tsq6uvhUTg0hiNcVd4bdQ8PKEjjbb/hrnGDylBO/CB3GDMqn92b RB4DYGhr00jRMAJk34lOQQ11Qm5GOVK21m75uZSYBhmvnp6znhJ48sgX0PYYb19EFtGT G2ATywCJpALI0jiTCjDJIoou4reWFRhRwoVOUq6LGXa/8/mQNdt8bP5iaWtIOR77tpZh idnuWXHMpwYXsNQShVEAPES5i+j+BbGCZG4SSZc3urYX7aJzShxI6ddzgOeyDp/ZE71x EThw== 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=e1+nFtY4mmVC44PtPZOvwOt7bF4haZKYTA+q9sAPzHEDGJqu7H//Fm1p+fivGNZea6 25q5AEY2XKZ4RF2Fiy/AR8B2P2g5AuZwoDgRv1ynA3/slucpJFfGoQo5s/H6HEORp/FX vB7tcO+pYXYHH0LBAth+myIEp8fu4d9yDn0SfdF5wlKvlp40oXZKcENxTMPpx2SKmn8I NAf10R8ENBc92SUwZ+BRKVYW8QbxiaRDxUXdDS9mTCpRQwKXHsGP696l0OfGettkD890 pwAmNWc8VFgSpoKH7L5Xh42BKwzxm0Qa9g9ZTQmJRkBPJ5E1BShswcpg7XLLeCEg12ok 8oLw==; 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-2363-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2363-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 n9-20020a05622a040900b0043b06b5897esi12765767qtx.644.2024.05.07.23.25.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 23:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2363-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-2363-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2363-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 3C22A1C21633 for ; Wed, 8 May 2024 06:25:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D451E51C4B; Wed, 8 May 2024 06:22:49 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org 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 7F9A7364A5; Wed, 8 May 2024 06:22:47 +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=1715149369; cv=none; b=da4ZRZ/j0KVo8ITsRRoESoHzT29EQ5gbHB1HNMmpXaFSEOvECSArvR3DJ3D4uXXyY/VUr2s1WA3/hfAAC+HCyOqTPYeRARqexxAir5DoWQeJy63nIICdvTvQKvTlbGb15oY7I3NzdXVrbRj40P2rgq94c9KwmgkqZgj2fmPzs9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715149369; c=relaxed/simple; bh=r3kGCj6p4ccBjVSfW52HjxMspg48PzdX9qXYKJ4T0w8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FILO8gbFMoO/XZJxDzaQzeexr7+I3vm03dTaNrf6O6erAOmzKdhzjdMqhbiuaoVlDuHv+trcRX7gU/7zsMVbAhnHUHbR/mYKfkNvDuAO4urI6nWO+XwoH7oPLzPhDrewgZLyCFcM4HHAnAZABuYSZDhWxbUKX0wzfsIIoj1W37Y= 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 4VZ4nL2GGrz4f3l78; Wed, 8 May 2024 14:22:30 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 970821A0DBA; Wed, 8 May 2024 14:22:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6REbGjtm9_1NMA--.61952S5; Wed, 08 May 2024 14:22:38 +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 v3 01/10] ext4: factor out a common helper to query extent map Date: Wed, 8 May 2024 14:12:11 +0800 Message-Id: <20240508061220.967970-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240508061220.967970-1-yi.zhang@huaweicloud.com> References: <20240508061220.967970-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:cCh0CgAX6REbGjtm9_1NMA--.61952S5 X-Coremail-Antispam: 1UD129KBjvJXoWxXr47GrW8uF4UWr1xtF1DWrg_yoW5WF43pr W3CryrCr1UWws2gayftr1UZFyfK3W5trZFq397Wr15A3W5CrnayF15tFySqFyDKrZ7Xw4Y qFWSkryrCw4rGrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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