From patchwork Sat Jan 27 01:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13533893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DFC8C48285 for ; Sat, 27 Jan 2024 02:02:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DF3E6B0089; Fri, 26 Jan 2024 21:02:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF856B008C; Fri, 26 Jan 2024 21:02:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E03316B008A; Fri, 26 Jan 2024 21:02:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C7A5F6B0083 for ; Fri, 26 Jan 2024 21:02:49 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A496DA1D59 for ; Sat, 27 Jan 2024 02:02:49 +0000 (UTC) X-FDA: 81723442458.02.B89A66C Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf22.hostedemail.com (Postfix) with ESMTP id 2BBFCC0015 for ; Sat, 27 Jan 2024 02:02:46 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706320967; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nDGmM1XnD1u3GRfMKazoP/kuf8eh300xJ6+WETgmkfg=; b=UJL0qldgdiGgrCQgKVv7tMrJ9Duva0sQBhxajQLj0wUhgFAN2Xaaf3cdZUbhg5XguKCHuB F8jH0wATXlPEyf6MczTAXkapP3ylQ3c1DgUQCkRJ7yEzpc51bLawmBg3gX78x6kdxDkSKj CAl+1aoVHpnJuosHEvWPjuXL4iKEcw8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706320968; a=rsa-sha256; cv=none; b=VsEPYlKvrKxtKiKzDKXOAO3YqRxBOS76cEjhtymGLNnQ/fvS5EuP37vbA+vMJjRRj6omcC dXpQ8uV0sNvp1nPzbpJgw+J8HCOqQSKrQzo61u7abeD2zzbdY9uz24oKe9KA2EGYsDrR47 Mm8rDyQxFscWkV/7SBDlSOJ0LvFtVtY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TMHrZ4Qzlz4f3lwQ for ; Sat, 27 Jan 2024 10:02:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9CF2C1A017A for ; Sat, 27 Jan 2024 10:02:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g40ZLRlGJtmCA--.7377S9; Sat, 27 Jan 2024 10:02:42 +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 v3 05/26] ext4: make ext4_map_blocks() distinguish delalloc only extent Date: Sat, 27 Jan 2024 09:58:04 +0800 Message-Id: <20240127015825.1608160-6-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> References: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g40ZLRlGJtmCA--.7377S9 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw47Xw1xGw1DAFy8tr4Dtwb_yoW8KrW8pa 95GFy8GFs8Ww1q93yxGa1UJr1UKa48C3y7Cr4Yqr4F9F9xJr1ftF1q9F1fZFyYgrWxXFyU XF4Utw1UCa9IkrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl 2NtUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspamd-Queue-Id: 2BBFCC0015 X-Rspam-User: X-Stat-Signature: gycob8b4bamer8ik3ua6zyffu1qp7a5d X-Rspamd-Server: rspam03 X-HE-Tag: 1706320966-662317 X-HE-Meta: U2FsdGVkX1+jGRXFmdj72NqKuGCZj0Divtk877zW/FHOeo9Asb/2CpDwMxcTaxLKPbuKGJh0iV4mNLHmeiD1LMwGXRiq5vio/3HUvvmQ4eCa7nSoJvcQWKDJsMsyn8QkO+8QNWnKWUKt3hfgPqTvlskG1BTOF/VW1y/V4Trz+sjirFTDnk0sVTBWFHhqx49LyLIx2ZDOsIa8r9SePROwEhSxbGN1kHkmlOudMoPfFT+WZ0/dfuaNVGTiTo45YE3LwDyslN2domE9xVgBl36Dgz5T0uMotJaKQwWbUbSrLg8d1WaVCgFVr8WKumaVT2k3aXZbxh5GBtM0Aln3FwxMwWaWoTjXZBtzKlqhp1TPS4KF3uSP8owRpKTfw0bdbWxN4aBQUb/pxoH/RTR1/QffFTc91JZxpsccWq3IHmj5JaMu0ztnxLR/9ovKL+j9SbFWeI9p2A67uFRdqz0tPLiB8xdbowSpHCCAbHJ9rjcS/lQYLOki2oVe4u9cZzt3NZrTZkQYBrFIIkJDj2pd4CwXrcuCJy+SzFeZRG+rOJBf3qJYGoEbYUHgjJGnx6WwLq1I9nEbR1DXbjsGh0LQZUmPaN2kqJ8t5HhklzEysoYpKWQuzRmFibY6j3pwuEtSIj4P8jGov6h0VprQp9+xEhB3fjRG8AIlW6OwkN9zi/FiUFwXUfzFdSBTzcAwr/kXoV+CDCIDmI4s15dneBVhWqrksuwO6V6a0PkeWAU5QvhmqtcgCFW1zxNfu5Rk2+NK8kBRvX7eD/NKyFlbd1xMgbwxNj7ixOkMpUHRKYnfXiJ79JVQ1ebDi/XinrWTt5PHWQwW+2l2RXfoP1VA6hoY63ruGvFtdDjLe8gT0LpMjBJc80Onl7fjDubPN/916Y6QDAyfHIZbIytZ2UmtLvUz9fMCF+e8GsJxZwVCV6So8YYMTu4vlnkVapiEYX04MIBCneXrVrR0TuuBcJI8t2sUQdZ TCTS730f xQSY7aLueLg58GCoaJ5dA9/QqQug+0xI2g+c5Zg2TI1jndTJDfZJ2HU79rhwAw0nCQ6pUZUNLYcnUMDMasZ1dN08L9NfKMtVY533eduyvM0DPqmUnkGCQZkfEezwcHo+umMKV+XEfXblBoXCmp5j/RAkafeuMhrtmnhaYd73cm7ZKoCLtXHH8azF4lhznUkHQ5c3jmbytv/vsimnhC2f51XZFqGOrafU8sBXb4r71QfEmUV1vLI77diIzadmag74uRnv02Cn7DzJXeMc0VCX319vj9w8uqtrkoY7rfQa1l7qTKCY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zhang Yi Add a new map flag EXT4_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 Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 4 +++- fs/ext4/extents.c | 7 +++++-- fs/ext4/inode.c | 2 ++ 3 files changed, 10 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 e0b7e48c4c67..6b64319a7df8 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4076,8 +4076,11 @@ static ext4_lblk_t ext4_ext_determine_insert_hole(struct inode *inode, /* * The delalloc extent containing lblk, it must have been * added after ext4_map_blocks() checked the extent status - * tree, adjust the length to the delalloc extent's after - * lblk. + * tree so we are not holding i_rwsem and delalloc info is + * only stabilized by i_data_sem we are going to release + * soon. Don't modify the extent status tree and report + * extent as a hole, just adjust the length to the delalloc + * extent's after lblk. */ len = es.es_lblk + es.es_len - lblk; return len; 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;