From patchwork Wed Jan 7 23:44:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1340 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829654; bh=sGbzmxXC2UpmEpEhLpHCks9bK+SPirgYqp7rnowWMGQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=O49odasEdyc9B5DFRZ3O3D3uhOcO7mcA7tYi3uMsnzI2LsJAqvRsDfLLfwSvt4WG2 nIlatsqLD6Sql7h/z0jY9Az4K3of/cBAyZDzAiMQHhFXFR66eMp0ZCjZobpZyYh1rs /WIkUxkIWOzubAJq9lKROWbyOSp8byki6YrJxzZndKWpk68C21qlBr9VWKr8EDvC1T jjhoB09yEp5vs3jJPtFQqNg3WWDviaxvIoOsv+VJmU2m+lPFQtRk6DJpCCOAoPXV8p 1Fid4XkHau04BTBmQh2DMaOoVpi6WQ1LTwDVJkV7Dk30mENE4QanFTHnjpiosdE1Zk LMtiUKCmhgVyQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D6A5D69196 for ; Wed, 7 Jan 2026 16:47:34 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KMvcuzCSY7KX for ; Wed, 7 Jan 2026 16:47:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829654; bh=sGbzmxXC2UpmEpEhLpHCks9bK+SPirgYqp7rnowWMGQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=O49odasEdyc9B5DFRZ3O3D3uhOcO7mcA7tYi3uMsnzI2LsJAqvRsDfLLfwSvt4WG2 nIlatsqLD6Sql7h/z0jY9Az4K3of/cBAyZDzAiMQHhFXFR66eMp0ZCjZobpZyYh1rs /WIkUxkIWOzubAJq9lKROWbyOSp8byki6YrJxzZndKWpk68C21qlBr9VWKr8EDvC1T jjhoB09yEp5vs3jJPtFQqNg3WWDviaxvIoOsv+VJmU2m+lPFQtRk6DJpCCOAoPXV8p 1Fid4XkHau04BTBmQh2DMaOoVpi6WQ1LTwDVJkV7Dk30mENE4QanFTHnjpiosdE1Zk LMtiUKCmhgVyQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C5BD369146 for ; Wed, 7 Jan 2026 16:47:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829652; bh=6i6O+sQTvnBQRSaNXBK7+Ok2jMYPcMAk2pBrMHHw5l0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1P2XPOft6sHkboaY7bed7Qb6vTJgdBi+DQR8BqP1BQc17NjvL4OdSaAotasDNBWj g5x+R6ELtCd9UmJnVJqpkpiFFw0D5ZLea7UPzDZpXkWt22AB+A+xA/GPkRkyPLJLX/ 5xZRulpVpXVUDGsrM5e+3gWTy3hTi0A2Qeom6c47TQvBsavRtkNImgSgZr+Hj6hzSb uY0yaviXAwHxss0VG/PGRrPv+8nf4kMbEPj4w/l68XeWF0mHYe/aF0QmzsPBNq9u0p TlaCJB3LdWwd8syKfN/5rPOXojw7nsTMoHggykkCyhlvVmoy4dXEq2+aJrC6WXY4ut oJOLQJDUYvbxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A07969196; Wed, 7 Jan 2026 16:47:32 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id DUKn9JgZeDXC; Wed, 7 Jan 2026 16:47:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829647; bh=jqP6zt5mwQ3T5onWZmv2Th3RKu3j5X5gkWaAgAl2AFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUWLm3Oad90nHFXWNfGZkk2MWEc7PWTz/FRrdUWEUc0p6giHOSXimtqpOYvjiEDav yBAt/D/jJs0ARnh//JEYHaIgkR6OPchPA8+QGvXv771dfVDzfTqPZwfqRGssBMfJaR l/DhLto/0RwCDZ0WwunyGjZeinv5/TLyPBuafPkMwy4rSr0ageApcplda1B3djT1xn M1BQ5mKeO9sMOsCkPEH0aHa19bwBNnRebNLgEJWGPGAj9JpehsGW5vTGWGp2LMwUFU GN+SNwV+k+51hccL1Ed5f8uCvXr+ZRY53keVAYTxZmD1wSPeCwgptJWcszkC7UKWzO XYFSvhaeuHA/A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CD87769187; Wed, 7 Jan 2026 16:47:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:18 -0700 Message-ID: <20260107234426.3508161-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260107234426.3508161-1-sjg@u-boot.org> References: <20260107234426.3508161-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UWKHTARI6PFFZ7QXLZSJAXLNEBMKVFMV X-Message-ID-Hash: UWKHTARI6PFFZ7QXLZSJAXLNEBMKVFMV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 8/9] fs: ext4l: Rename EXT4_GET_BLOCKS_PRE_IO flag List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Align with the Linux kernel's rename of this flag. The flag is used to indicate that newly allocated extents cannot be merged, and if an unwritten extent is found, it needs to be split. Rename to EXT4_GET_BLOCKS_SPLIT_NOMERGE to match Linux v6.12 Also update extents.c to: - Use EXT4_LBLK_TO_B() macro for block-to-byte conversion - Remove unnecessary initialisation of the 'len' variable in ext4_ext_find_hole() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 18 +++++++++++++----- fs/ext4l/extents.c | 18 +++++++++--------- fs/ext4l/inode.c | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index 1cbeebaf0a6..34dbc4f12b8 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -678,12 +678,20 @@ enum { /* Caller is from the delayed allocation writeout path * finally doing the actual allocation of delayed blocks */ #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004 - /* caller is from the direct IO path, request to creation of an - unwritten extents if not allocated, split the unwritten - extent if blocks has been preallocated already*/ -#define EXT4_GET_BLOCKS_PRE_IO 0x0008 + /* + * This means that we cannot merge newly allocated extents, and if we + * found an unwritten extent, we need to split it. + */ +#define EXT4_GET_BLOCKS_SPLIT_NOMERGE 0x0008 #define EXT4_GET_BLOCKS_CONVERT 0x0010 -#define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_PRE_IO|\ + /* + * Caller is from the dio or dioread_nolock buffered IO, request to + * create an unwritten extent if it does not exist or split the + * found unwritten extent. Also do not merge the newly created + * unwritten extent, io end will convert unwritten to written, + * and try to merge the written extent. + */ +#define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_SPLIT_NOMERGE|\ EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT) /* Eventual metadata allocation (due to growing extent tree) * should not fail, so try to use reserved blocks for that.*/ diff --git a/fs/ext4l/extents.c b/fs/ext4l/extents.c index d2103fbac83..028d77272b5 100644 --- a/fs/ext4l/extents.c +++ b/fs/ext4l/extents.c @@ -320,7 +320,7 @@ ext4_force_split_extent_at(handle_t *handle, struct inode *inode, int nofail) { int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); - int flags = EXT4_EX_NOCACHE | EXT4_GET_BLOCKS_PRE_IO; + int flags = EXT4_EX_NOCACHE | EXT4_GET_BLOCKS_SPLIT_NOMERGE; if (nofail) flags |= EXT4_GET_BLOCKS_METADATA_NOFAIL | EXT4_EX_NOFAIL; @@ -1989,7 +1989,7 @@ ext4_ext_insert_extent(handle_t *handle, struct inode *inode, } /* try to insert block into found extent and return */ - if (ex && !(gb_flags & EXT4_GET_BLOCKS_PRE_IO)) { + if (ex && !(gb_flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE)) { /* * Try to see whether we should rather test the extent on @@ -2168,7 +2168,7 @@ has_space: merge: /* try to merge extents */ - if (!(gb_flags & EXT4_GET_BLOCKS_PRE_IO)) + if (!(gb_flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE)) ext4_ext_try_to_merge(handle, inode, path, nearex); /* time to correct all indexes above */ @@ -3211,7 +3211,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle, else ext4_ext_mark_initialized(ex); - if (!(flags & EXT4_GET_BLOCKS_PRE_IO)) + if (!(flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE)) ext4_ext_try_to_merge(handle, inode, path, ex); err = ext4_ext_dirty(handle, inode, path + path->p_depth); @@ -3355,7 +3355,7 @@ static struct ext4_ext_path *ext4_split_extent(handle_t *handle, if (map->m_lblk + map->m_len < ee_block + ee_len) { split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT; - flags1 = flags | EXT4_GET_BLOCKS_PRE_IO; + flags1 = flags | EXT4_GET_BLOCKS_SPLIT_NOMERGE; if (unwritten) split_flag1 |= EXT4_EXT_MARK_UNWRIT1 | EXT4_EXT_MARK_UNWRIT2; @@ -3726,7 +3726,7 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle, EXT4_EXT_MAY_ZEROOUT : 0; split_flag |= (EXT4_EXT_MARK_UNWRIT2 | EXT4_EXT_DATA_VALID2); } - flags |= EXT4_GET_BLOCKS_PRE_IO; + flags |= EXT4_GET_BLOCKS_SPLIT_NOMERGE; return ext4_split_extent(handle, inode, path, map, split_flag, flags, allocated); } @@ -3898,7 +3898,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, *allocated, newblock); /* get_block() before submitting IO, split the extent */ - if (flags & EXT4_GET_BLOCKS_PRE_IO) { + if (flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE) { path = ext4_split_convert_extents(handle, inode, map, path, flags | EXT4_GET_BLOCKS_CONVERT, allocated); if (IS_ERR(path)) @@ -4549,7 +4549,7 @@ retry: * allow a full retry cycle for any remaining allocations */ retries = 0; - epos = (loff_t)(map.m_lblk + ret) << blkbits; + epos = EXT4_LBLK_TO_B(inode, map.m_lblk + ret); inode_set_ctime_current(inode); if (new_size) { if (epos > new_size) @@ -5605,7 +5605,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len) path = ext4_split_extent_at(handle, inode, path, start_lblk, split_flag, EXT4_EX_NOCACHE | - EXT4_GET_BLOCKS_PRE_IO | + EXT4_GET_BLOCKS_SPLIT_NOMERGE | EXT4_GET_BLOCKS_METADATA_NOFAIL); } diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index d0262fa53f2..12f1333660f 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -626,7 +626,7 @@ static int ext4_map_create_blocks(handle_t *handle, struct inode *inode, * If the extent has been zeroed out, we don't need to update * extent status tree. */ - if (flags & EXT4_GET_BLOCKS_PRE_IO && + if (flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE && ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, &map->m_seq)) { if (ext4_es_is_written(&es)) return retval;