From patchwork Mon Dec 22 11:56:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1048 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=1766404663; bh=SyPPAQSdnvkGFeYuld9xZ2WRHRbVwn2Op4EJeBrIbGU=; 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=ZI9tJWZv07hFNIoPkaZQlFSYLVeuu7tPnZunW1M3mGv3ZAldmIKS52u/jAasFoXnR WYZHbBTQetDmZ4KY+mZ/4Q1pezFhtvEiJfiigMURvgZYfxQFiC+w2sXl+LA1CyBDsf NjSh/6xKkSY+fxLjDkbs3XB3kVPmHhZBKo/9X5f5zl0o2xfp5eHT5g4RVRz5ztNSgP 8wk5kf+b6Xm5gvokuNEh4WyelVzFMKXf2h3O3FHigt1IIToMIXsHMhdEe9r/Qbe/xl sBy42BWEb8KbhWE7NZ+227lxJuyJ3dTgSzH/sgUViQfstykoJk2kOZHtWNWJDE19AJ Z/Gm6Ig1TgkiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8030764C31 for ; Mon, 22 Dec 2025 04:57:43 -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 ZL5x5tTxbt5C for ; Mon, 22 Dec 2025 04:57:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404663; bh=SyPPAQSdnvkGFeYuld9xZ2WRHRbVwn2Op4EJeBrIbGU=; 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=ZI9tJWZv07hFNIoPkaZQlFSYLVeuu7tPnZunW1M3mGv3ZAldmIKS52u/jAasFoXnR WYZHbBTQetDmZ4KY+mZ/4Q1pezFhtvEiJfiigMURvgZYfxQFiC+w2sXl+LA1CyBDsf NjSh/6xKkSY+fxLjDkbs3XB3kVPmHhZBKo/9X5f5zl0o2xfp5eHT5g4RVRz5ztNSgP 8wk5kf+b6Xm5gvokuNEh4WyelVzFMKXf2h3O3FHigt1IIToMIXsHMhdEe9r/Qbe/xl sBy42BWEb8KbhWE7NZ+227lxJuyJ3dTgSzH/sgUViQfstykoJk2kOZHtWNWJDE19AJ Z/Gm6Ig1TgkiA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E12664CCE for ; Mon, 22 Dec 2025 04:57:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404661; bh=1CS+jhTbGi9wTtWQKlbEXh8Ts8GUuXqRCcB/VtlbNEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aGgWKHvBdGO9oSFgdNniisgocm0CpyDgV4WNPyccITgx6DPQdVtfz8dQ+HRL7Ejaa z3uKzbkLjhkTionqXYTQMDJG4E3Qcp4u5JKYvsicPgaZw7XGiUn5pjs5vjS/EbklJ6 s4/kBpikplKmJ+wSTbvQZiH9Q+mJ/k040GOtbXD6P7p41VKnAc6laClhUwklSr558Z GNcHgOFTQwqo4FP959Xjyrcup8J9XNRZEW8YvQbTWMZBNZvw4GPsRjxktEoU2nFyXf q6P8Ff19zXGnStgxS4nUpoo0xV+2NEkQROiyG+uSUaaAFN0Z7iwXZorfUhVgrjDoGS uW+Gs9aFNrkcg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 69AA664D38; Mon, 22 Dec 2025 04:57:41 -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 JlXKQG_aAWsy; Mon, 22 Dec 2025 04:57:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404656; bh=oDQbnKuh1burUlDasfVm67OfM6Yu7p1sC+4sj4YA510=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9RBuNx1rmrCGbBKShpC5RC/Auzta7rMxLAsu5ltmrOrJ3DK5H28aRadDl4hyFSaj u6fksK2kprWd6tRDmUeHVU/L4+z3aXvoIGkcs5NTqp4NTJ732IENFufe3frmPJmkjb YqnEDjuU4+BaxROvRIoSz/x0TL4df7849djMF7meZ8YvO0q8EPFZRPm8UBTyNDTvcy cYi0HYndfLnIZ4BeGhunNZvip4fpSjoK45ntQBDiHXNqNz0gP8BFBD6f4oFEyhkSbM 8eH5DCreUGhN9NS2ZrUWNckc3rq74i0ozDyKJIfetm1VeLiRk1RAORN9NAF2uxYw4E /NxCeb2GmowYg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5698F64C31; Mon, 22 Dec 2025 04:57:36 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 04:56:22 -0700 Message-ID: <20251222115639.700578-19-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: HQHAX47FKTPKJIJD6VSYMTVHN4PHWGL6 X-Message-ID-Hash: HQHAX47FKTPKJIJD6VSYMTVHN4PHWGL6 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 18/26] fs: ext4l: Initialise super_block and call ext4_fill_super() 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 Set up essential super_block fields after allocation: - Link bd_super back to super_block - Set initial blocksize to 1024 (will be updated by ext4_fill_super) - Clear flags for read-write mount - Clear s_fs_info (will be set by ext4_fill_super) Add the call to ext4_fill_super() which performs the actual filesystem mount. This requires making ext4_fill_super() non-static in super.c. Also fix an uninitialised variable warning in ext4_journalled_submit_inode_data_buffers(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 9 ++++++--- fs/ext4l/extents_status.c | 5 ++++- fs/ext4l/interface.c | 22 ++++++++++++++++------ fs/ext4l/super.c | 4 ++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 1f823ba6ea3..7c65aa8567e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -457,8 +457,8 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* Memory allocation - use linux/slab.h which is already available */ #include -/* KMEM_CACHE macro - not in U-Boot's slab.h */ -#define KMEM_CACHE(s, flags) ((struct kmem_cache *)1) +/* 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) \ @@ -650,7 +650,7 @@ struct super_block { struct rw_semaphore s_umount; struct sb_writers s_writers; struct block_device *s_bdev; - const char *s_id; + char s_id[32]; struct dentry *s_root; uuid_t s_uuid; struct file_system_type *s_type; @@ -2026,6 +2026,9 @@ struct fs_context { bool silent; }; +/* ext4 superblock initialisation */ +int ext4_fill_super(struct super_block *sb, struct fs_context *fc); + /* fs_parameter stubs */ struct fs_parameter { const char *key; diff --git a/fs/ext4l/extents_status.c b/fs/ext4l/extents_status.c index 485f3a2f5cc..a3ab26624e7 100644 --- a/fs/ext4l/extents_status.c +++ b/fs/ext4l/extents_status.c @@ -197,7 +197,10 @@ int __init ext4_init_es(void) void ext4_exit_es(void) { - kmem_cache_destroy(ext4_es_cachep); + if (ext4_es_cachep) { + kmem_cache_destroy(ext4_es_cachep); + ext4_es_cachep = NULL; + } } void ext4_es_init_tree(struct ext4_es_tree *tree) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 20fdf3c908c..4652f8c835f 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -76,6 +76,15 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, goto err_free_bdev; } + /* Initialise super_block fields */ + sb->s_bdev->bd_super = sb; + sb->s_blocksize = 1024; + sb->s_blocksize_bits = 10; + snprintf(sb->s_id, sizeof(sb->s_id), "ext4l_mmc%d", + fs_dev_desc->devnum); + sb->s_flags = 0; + sb->s_fs_info = NULL; + /* Allocate fs_context */ fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL); if (!fc) { @@ -93,6 +102,7 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, /* Initialise fs_context fields */ fc->fs_private = ctx; fc->sb_flags |= SB_I_VERSION; + fc->root = (struct dentry *)sb; /* Hack: store sb for ext4_fill_super */ buf = malloc(BLOCK_SIZE + 512); if (!buf) { @@ -119,17 +129,17 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, goto err_free_buf; } + free(buf); + /* Save device info for later operations */ ext4l_dev_desc = fs_dev_desc; if (fs_partition) memcpy(&ext4l_part, fs_partition, sizeof(ext4l_part)); - free(buf); - kfree(ctx); - kfree(fc); - kfree(sb->s_bdev->bd_mapping); - kfree(sb->s_bdev); - kfree(sb); + /* Mount the filesystem */ + ret = ext4_fill_super(sb, fc); + if (ret) + goto err_free_ctx; return 0; diff --git a/fs/ext4l/super.c b/fs/ext4l/super.c index af5b9b1986d..f986ca6e0b6 100644 --- a/fs/ext4l/super.c +++ b/fs/ext4l/super.c @@ -526,7 +526,7 @@ static int ext4_journalled_submit_inode_data_buffers(struct jbd2_inode *jinode) .range_end = jinode->i_dirty_end, }; struct folio *folio = NULL; - int error; + int error = 0; /* * writeback_iter() already checks for dirty pages and calls @@ -5654,7 +5654,7 @@ out_fail: return err; } -static int ext4_fill_super(struct super_block *sb, struct fs_context *fc) +int ext4_fill_super(struct super_block *sb, struct fs_context *fc) { struct ext4_fs_context *ctx = fc->fs_private; struct ext4_sb_info *sbi;