From patchwork Sat Jan 17 01:14:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1568 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=1768612535; bh=mH/q3DwCfNw82vwfhbVgKBooJPoa8F37jwusLA7UzEA=; 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=VsiwMIfds4cOr3VdX8RoIKxaAeuAwerLJEmuPvqD4EAqkkej4fIeFXDWb0LamZVHU /IY1BgUGGpsiZ4hZ+RTmLthbNZYFYKwXRhaWlU9xEWNNv2HS6SBCSqvKjKUQYbVPrn bpTkRukwVYh2gM2bMWp/+ExCSXqMpAHcLgx71d+NDJfMuZ9zsghOxm9Ir2rUFu4YvR zFL/XqDOzHvqwUwkI6/Jg53RBhyapKuWbQsz4d/vHXxFe/GAAmVBtOhYyBxH9Ch/GK mnEIHF+ySc2UsHrmSkegZppUGQFBbKjZm6ULfF02nqDXsDZeck29kFWt6pnEw0rpNB h60rlfQRVmosg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D6E376913F for ; Fri, 16 Jan 2026 18:15:35 -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 ElEVoYCBoqoF for ; Fri, 16 Jan 2026 18:15:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612535; bh=mH/q3DwCfNw82vwfhbVgKBooJPoa8F37jwusLA7UzEA=; 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=VsiwMIfds4cOr3VdX8RoIKxaAeuAwerLJEmuPvqD4EAqkkej4fIeFXDWb0LamZVHU /IY1BgUGGpsiZ4hZ+RTmLthbNZYFYKwXRhaWlU9xEWNNv2HS6SBCSqvKjKUQYbVPrn bpTkRukwVYh2gM2bMWp/+ExCSXqMpAHcLgx71d+NDJfMuZ9zsghOxm9Ir2rUFu4YvR zFL/XqDOzHvqwUwkI6/Jg53RBhyapKuWbQsz4d/vHXxFe/GAAmVBtOhYyBxH9Ch/GK mnEIHF+ySc2UsHrmSkegZppUGQFBbKjZm6ULfF02nqDXsDZeck29kFWt6pnEw0rpNB h60rlfQRVmosg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C6A85693FE for ; Fri, 16 Jan 2026 18:15:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612534; bh=Pk4zAW+rC09UQImBFbcv2wRlGDuEdg9wmr5V0Ld31NY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZ5X+tTcNZkbIBweSpbMTgo2SurJhj0xI8X+WrOjbmVt0FDGFP6OX8EwoualWpo7R zOqkpHxfOSx7g7SClQaK2fR084OuhZFWdRd5WFGUT4ZU4o1d+KamBaOKyDdemrYRyA aJ491hC3TfPR4BEdIbvAvxUcua2gQlqY1Xl7PtrSOm1TVlogGrtlZEjzActdIFm+JV 6PQvt/+zVIRLR7ttk1i2ijz+PZmfqagD+mxKwt0TnDIvS0H8n/Acsf7kYIcPNCAz9A yF1r0E8XiBCnLEx6bxGb4Jux2ViQzjd0I+9Oo2ySIzyelWMdRWbUFHVeok9yqH/Qor 5ohd9iHArQOcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E1096913F; Fri, 16 Jan 2026 18:15: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 10026) with ESMTP id 3-m7Qwhtp4C4; Fri, 16 Jan 2026 18:15:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612530; bh=KNtY+iUdFx0vKSElvaa+BBGgT4Oz0Tt5zXHo1yEZSnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mqwuHpsvnrnttc4YDOkzsNPzqG/N2FlZ9GkGP2MJIBKlCHB+zMaaKnz5lCKRfGao+ R6RTZZEAVWZJHUBhImcEvqMtLa9U//DM7p+pmXnsLQ2zlBLcJM3hBYEoWR2zmIgYvt 4i7LZmtWzQEvZRyF8xxzbClh9I1rmw1hwcOYFgIpbor9esr9CzYlMPSNLp3NWntBcL rsX7rCznEJxur06HYXhr8ofXMvP6w6ROc+7/2cyciaJlhqjO/s2J2JzghQWKHH5Vxf aFq/DcbAJ8EmM+D4HpxQ228iOIQK3664ehS510MVElVhOccD6ni8H7YQw/+A4yh/54 h6l8vFd6X4NTA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 173A0693E0; Fri, 16 Jan 2026 18:15:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 18:14:30 -0700 Message-ID: <20260117011448.3007171-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260117011448.3007171-1-sjg@u-boot.org> References: <20260117011448.3007171-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KUXDFS4YWVKEQLOHQHWAWACLAREJXSIV X-Message-ID-Hash: KUXDFS4YWVKEQLOHQHWAWACLAREJXSIV 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/19] linux: Add dcache.h header with dentry stubs 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 Move dentry and directory cache stubs to a dedicated header file that mirrors the Linux kernel organisation. dcache.h provides: - struct qstr and QSTR_INIT() for quick strings - dotdot_name constant for ".." lookups - struct dentry with minimal fields for ext4l - struct name_snapshot for dentry name snapshots - d_inode() accessor - Dentry operation stubs: d_find_any_alias(), dget_parent(), dput(), d_splice_alias(), d_obtain_alias(), d_instantiate_new(), d_instantiate(), d_tmpfile(), d_invalidate(), d_alloc(), d_drop() - Name snapshot operations: take_dentry_name_snapshot(), release_dentry_name_snapshot() - Declarations for generic_set_sb_d_ops() and d_make_root() Also update ext4_fscrypt.h to include dcache.h instead of defining its own struct qstr, avoiding duplication. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_fscrypt.h | 9 +--- fs/ext4l/ext4_uboot.h | 47 ++++----------------- include/linux/dcache.h | 94 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 47 deletions(-) create mode 100644 include/linux/dcache.h diff --git a/fs/ext4l/ext4_fscrypt.h b/fs/ext4l/ext4_fscrypt.h index da91af74343..91f08229e32 100644 --- a/fs/ext4l/ext4_fscrypt.h +++ b/fs/ext4l/ext4_fscrypt.h @@ -13,6 +13,7 @@ #include #include #include +#include /* Forward declarations */ struct inode; @@ -21,16 +22,8 @@ struct page; struct folio; struct bio; struct buffer_head; -struct dentry; struct super_block; -/* qstr - quick string for filenames (needed by fscrypt_name) */ -struct qstr { - u32 hash; - u32 len; - const unsigned char *name; -}; - /* fscrypt_str - encrypted filename string */ struct fscrypt_str { unsigned char *name; diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index a1047607e79..9423c92169e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -86,6 +86,7 @@ #include #include #include +#include /* atomic_dec_if_positive, atomic_add_unless, etc. are now in asm-generic/atomic.h */ @@ -300,8 +301,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* icount - inode reference count */ #define icount_read(inode) (1) -/* d_inode - get inode from dentry */ -#define d_inode(dentry) ((dentry) ? (dentry)->d_inode : NULL) +/* d_inode is now in linux/dcache.h */ /* Random number functions */ #define get_random_u32_below(max) (0) @@ -444,18 +444,7 @@ struct ratelimit_state { /* IS_NOQUOTA - stub */ #define IS_NOQUOTA(inode) (0) -/* dentry - stub */ -struct dentry { - struct qstr d_name; - struct inode *d_inode; - struct super_block *d_sb; - struct dentry *d_parent; -}; - -/* name_snapshot - for dentry name snapshots */ -struct name_snapshot { - struct qstr name; -}; +/* dentry, name_snapshot are now in linux/dcache.h */ /* VM types - use linux/mm_types.h */ #include @@ -758,10 +747,7 @@ static inline void inode_state_assign(struct inode *inode, unsigned long flags) inode->i_state = flags; } -#define QSTR_INIT(n, l) { .name = (const unsigned char *)(n), .len = (l) } - -/* dotdot_name for ".." lookups */ -static const struct qstr dotdot_name = QSTR_INIT("..", 2); +/* QSTR_INIT and dotdot_name are now in linux/dcache.h */ /* * Hash info structure - defined in ext4.h. @@ -999,16 +985,7 @@ typedef unsigned int projid_t; /* hash_64 - simple 64-bit hash */ #define hash_64(val, bits) ((unsigned long)((val) >> (64 - (bits)))) -/* Dentry operations - stubs */ -#define d_find_any_alias(i) ({ (void)(i); (struct dentry *)NULL; }) -#define dget_parent(d) ({ (void)(d); (struct dentry *)NULL; }) -#define dput(d) do { (void)(d); } while (0) -#define d_splice_alias(i, d) ({ (d)->d_inode = (i); (d); }) -#define d_obtain_alias(i) ({ (void)(i); (struct dentry *)NULL; }) -#define d_instantiate_new(d, i) ((void)((d)->d_inode = (i))) -#define d_instantiate(d, i) ((void)((d)->d_inode = (i))) -#define d_tmpfile(f, i) do { (void)(f); (void)(i); } while (0) -#define d_invalidate(d) do { (void)(d); } while (0) +/* Dentry operations are now in linux/dcache.h */ #define finish_open_simple(f, e) (e) #define ihold(i) do { (void)(i); } while (0) @@ -1678,9 +1655,7 @@ struct mb_cache_entry { #define PF_MEMALLOC_NOFS 0x00040000 #endif -/* Dentry operations - declarations for stub.c */ -void generic_set_sb_d_ops(struct super_block *sb); -struct dentry *d_make_root(struct inode *inode); +/* generic_set_sb_d_ops, d_make_root are now in linux/dcache.h */ /* strreplace is in linux/string.h */ @@ -1909,11 +1884,7 @@ struct wait_bit_entry { #define finish_wait(wq, wait) \ do { (void)(wq); (void)(wait); } while (0) -/* Dentry name snapshot operations */ -#define take_dentry_name_snapshot(snap, dentry) \ - do { (snap)->name = (dentry)->d_name; } while (0) -#define release_dentry_name_snapshot(snap) \ - do { (void)(snap); } while (0) +/* Dentry name snapshot operations are now in linux/dcache.h */ /* lockdep_assert_not_held is in linux/lockdep.h */ @@ -1924,9 +1895,7 @@ struct wait_bit_entry { /* wake_up_bit - wake up threads waiting on a bit */ #define wake_up_bit(word, bit) do { (void)(word); (void)(bit); } while (0) -/* Dentry allocation stubs */ -#define d_alloc(parent, name) ({ (void)(parent); (void)(name); (struct dentry *)NULL; }) -#define d_drop(dentry) do { (void)(dentry); } while (0) +/* d_alloc, d_drop are now in linux/dcache.h */ /* get_current_ioprio - I/O priority (not used in U-Boot) */ #define get_current_ioprio() (0) diff --git a/include/linux/dcache.h b/include/linux/dcache.h new file mode 100644 index 00000000000..bf8d1e4755e --- /dev/null +++ b/include/linux/dcache.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Dentry cache stubs for U-Boot + * + * Based on Linux dcache.h - U-Boot doesn't have a real dentry cache, + * so these are stubs for compilation. + */ +#ifndef _LINUX_DCACHE_H +#define _LINUX_DCACHE_H + +#include +#include + +/* Forward declarations */ +struct inode; +struct super_block; + +/** + * struct qstr - quick string for filenames + * @hash: filename hash + * @len: filename length + * @name: filename + * + * Note: Also defined in ext4_fscrypt.h for fscrypt support. + */ +struct qstr { + u32 hash; + u32 len; + const unsigned char *name; +}; + +/** + * QSTR_INIT - initialise a qstr + * @n: name string + * @l: length + */ +#define QSTR_INIT(n, l) { .name = (const unsigned char *)(n), .len = (l) } + +/* dotdot_name for ".." lookups */ +static const struct qstr dotdot_name = QSTR_INIT("..", 2); + +/** + * struct dentry - directory entry + * @d_name: filename + * @d_inode: associated inode + * @d_sb: superblock + * @d_parent: parent directory + * + * U-Boot stub - minimal fields for ext4l. + */ +struct dentry { + struct qstr d_name; + struct inode *d_inode; + struct super_block *d_sb; + struct dentry *d_parent; +}; + +/** + * struct name_snapshot - dentry name snapshot + * @name: snapshot of the name + * + * Used for safe name access during operations. + */ +struct name_snapshot { + struct qstr name; +}; + +/* d_inode - get inode from dentry */ +#define d_inode(dentry) ((dentry) ? (dentry)->d_inode : NULL) + +/* Dentry operations - stubs */ +#define d_find_any_alias(i) ({ (void)(i); (struct dentry *)NULL; }) +#define dget_parent(d) ({ (void)(d); (struct dentry *)NULL; }) +#define dput(d) do { (void)(d); } while (0) +#define d_splice_alias(i, d) ({ (d)->d_inode = (i); (d); }) +#define d_obtain_alias(i) ({ (void)(i); (struct dentry *)NULL; }) +#define d_instantiate_new(d, i) ((void)((d)->d_inode = (i))) +#define d_instantiate(d, i) ((void)((d)->d_inode = (i))) +#define d_tmpfile(f, i) do { (void)(f); (void)(i); } while (0) +#define d_invalidate(d) do { (void)(d); } while (0) +#define d_alloc(parent, name) ({ (void)(parent); (void)(name); (struct dentry *)NULL; }) +#define d_drop(dentry) do { (void)(dentry); } while (0) + +/* Name snapshot operations */ +#define take_dentry_name_snapshot(sn, d) \ + do { (sn)->name = (d)->d_name; } while (0) +#define release_dentry_name_snapshot(sn) \ + do { (void)(sn); } while (0) + +/* Dentry operations - declarations for stub.c */ +void generic_set_sb_d_ops(struct super_block *sb); +struct dentry *d_make_root(struct inode *inode); + +#endif /* _LINUX_DCACHE_H */