From patchwork Mon Dec 22 11:56:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1051 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=1766404670; bh=gOnfGbwvuP0oek6I0Pr0mDpPLm1r+MAAkMPSY884oQQ=; 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=bm/fGhBfcKwmRLBpGIEd0szwKNmWIvlO5U8lSYNyR/kmu7DWThTigWuonjov5Z50t wAnP1JzjV6wOus85Bq9rBilN5jAvmLP9B3oq/fS6SRXYZm/qs8Zl5Hdc77bbpRmZyW 5fbz/jPaSUFSI7PKrvkLXHe10JKgiTcB7GMhuKsQQbzMPqm0faEjoX0RoEjR0s3lC6 tvs1pnsV66D5RulPiTh/rm/kV6l2Aj3BHU+/EtVopb3Q4gyYc1CcMqdLNBpaYI4QRu NTaU40hgfWNO0Wy5ZEgCmhOhGjCwC8PWS+oEDxpuXknuyr5kZrvRU7vBCuGywS5pQ6 5tNSq8IAcF0gw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 20BD364D70 for ; Mon, 22 Dec 2025 04:57:50 -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 zQ35Z2sfNFPP for ; Mon, 22 Dec 2025 04:57:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404670; bh=gOnfGbwvuP0oek6I0Pr0mDpPLm1r+MAAkMPSY884oQQ=; 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=bm/fGhBfcKwmRLBpGIEd0szwKNmWIvlO5U8lSYNyR/kmu7DWThTigWuonjov5Z50t wAnP1JzjV6wOus85Bq9rBilN5jAvmLP9B3oq/fS6SRXYZm/qs8Zl5Hdc77bbpRmZyW 5fbz/jPaSUFSI7PKrvkLXHe10JKgiTcB7GMhuKsQQbzMPqm0faEjoX0RoEjR0s3lC6 tvs1pnsV66D5RulPiTh/rm/kV6l2Aj3BHU+/EtVopb3Q4gyYc1CcMqdLNBpaYI4QRu NTaU40hgfWNO0Wy5ZEgCmhOhGjCwC8PWS+oEDxpuXknuyr5kZrvRU7vBCuGywS5pQ6 5tNSq8IAcF0gw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0FDE95FB5A for ; Mon, 22 Dec 2025 04:57:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404668; bh=S/7O+q2ovoOLIuQYbCNqfo145rKXaNro/IjwV466WqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TecgSx7/aLKDg1vZbXFHKxhWGZ84LZScLkwSlfZWYWcQ4lSRVjOauqXsFzYeLsulh 4apuwVQ81GMET4vhWq3RZa8MCyhW7iWgBlpMxx0G57APyZna7SikpUWrFhymLg75YV BpJGdzJlegLhW1ZTQgaNCc1pzKJXJqhtjt3DdU9qZRv14LTA9kbHblxyAecoi35mTP SssXeeGHzaVpcTxQOPWB0AQzdREfnv1lNQ1FuKVaPBXQkz9xQP9u6snkiQ9NQkA3SB Y0eZG7+qNC30KfA5amKGhjGT2ZpsOEGLiloycZXde4FdL1DfO4hdHBIqvFPHMf+ZJt YplcItyq832Yw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 813A164D6D; Mon, 22 Dec 2025 04:57:48 -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 BDQwdOYRoJO6; Mon, 22 Dec 2025 04:57:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404663; bh=pZG+H/8HdEtoIL1PEvNE5HjqcQ/+ZIf+h3u3S7T0pow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHpzfqMg4/nkKsPl/LulXoYg1OG0Y7t6DIZ6bejo0VONzvla/uce5vzYA0kFgjYv0 uLL03EFf7KES5a3oHJjJwXMecSlwpfHbF/TbSBhC7UeLdLh/t48FtWvPJ7h3iRgkOA j9bBrjtkbj/YmGXTfzv+8GMeeSj3honQoWwSZhWxAwwes692/zXTHPTNMTtF5QUjtl 5cYe6u+Cta5gdGW7NHeei+5xnaSEbJ4pmNBNFHNU06eA8JJp4NvJBB5bOU7nvnRhOC p6+N5mNcj5wBYZqRw5+RLcIRD1uW7bQ0pUeKPkd4W3mn2xxE6LekAOcCfRP0q2jBgz MdIz7pRZdEeRg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E7C4D5FB5A; Mon, 22 Dec 2025 04:57:42 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 04:56:25 -0700 Message-ID: <20251222115639.700578-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251222115639.700578-1-sjg@u-boot.org> References: <20251222115639.700578-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VPRLMRDJCDIDVWZNYU3HO5AREMY5N7NE X-Message-ID-Hash: VPRLMRDJCDIDVWZNYU3HO5AREMY5N7NE 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 21/26] fs: ext4l: Use real rbtree implementation 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 Replace broken rbtree stubs with the real implementation from lib/rbtree.c. The previous stubs had critical bugs: - rb_link_node() only did *(rb_link) = node without initializing rb_left and rb_right to NULL, causing crashes when traversing the extent status tree - rb_next/rb_prev were wrong (just returned right/left child) - rb_insert_color was a no-op, breaking tree balancing Include and remove the conflicting struct definitions and broken operation macros. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index dfa362389a8..96b1c06a05b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -34,6 +34,7 @@ #include #include #include +#include /* Real rbtree implementation */ /* * Override no_printk to avoid format warnings in disabled debug prints. @@ -87,18 +88,7 @@ typedef struct { atomic_t refs; } refcount_t; /* rwlock_t and read_lock/read_unlock are now in linux/spinlock.h */ #include -/* RB tree types - stubs */ -struct rb_node { - unsigned long __rb_parent_color; - struct rb_node *rb_right; - struct rb_node *rb_left; -}; - -struct rb_root { - struct rb_node *rb_node; -}; - -#define RB_ROOT (struct rb_root) { NULL, } +/* RB tree types - from included above */ /* percpu_counter - use Linux header */ #include @@ -460,18 +450,13 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* KMEM_CACHE macro - use kmem_cache_create */ #define KMEM_CACHE(s, flags) kmem_cache_create(#s, sizeof(struct s), 0, flags, NULL) -/* RB tree operations - stubs */ -#define rb_entry(ptr, type, member) \ - container_of(ptr, type, member) -#define rb_first(root) ((root)->rb_node) -#define rb_next(node) ((node)->rb_right) -#define rb_prev(node) ((node)->rb_left) -#define rb_insert_color(node, root) do { } while (0) -#define rb_erase(node, root) do { } while (0) -#define rb_link_node(node, parent, rb_link) do { *(rb_link) = (node); } while (0) -#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) -#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \ - for (pos = NULL, (void)(n); pos != NULL; ) +/* + * RB tree operations - use real rbtree implementation from lib/rbtree.c + * and include/linux/rbtree.h. rb_entry, rb_first, rb_next, rb_prev, + * rb_insert_color, rb_erase, rb_link_node, RB_EMPTY_ROOT, and + * rbtree_postorder_for_each_entry_safe are all provided by the real + * implementation - do not stub them! + */ /* RCU barrier - stub */ #define rcu_barrier() do { } while (0)