From patchwork Thu Jan 8 18:51:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1361 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=1767898403; bh=i9JNcpUdHZKzJ8eftj44mWKHyO3md3I/pA24eKeKmTg=; 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=HzR5dRuzcVgCt/HE1M4t0O1Wdd9MR5dxzKRatzS/lgVOjuiewtFEkYFuqM8k8JW63 Z5pvLy0HTa4RfiMIVxqYQjasICX9QIF9bhJ6dOTaOLY6E17RcZscQ1mdlXeb3iNxsQ zYHoLZWb3BnvFkdysiHmTV1Lvn3a2VdNKZ8n7+vadrmb89L/fjOdDeUoOu0IoDvN+Q PhWc2O0nwUz3/Fs5xNECgN0OZ7UrXOaQKxz/JBqMbUT+ibqVihO87DQF0G+nm5J02S 7dRgZPhQ//f2s4NrAEpscED/lpSj7Dponb9+q9B/K145Q2HubI5Jt3EZHyIw8MfVL5 nrB6oBEZTVOLw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B32CD691DB for ; Thu, 8 Jan 2026 11:53:23 -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 UMdiaHrxz8xM for ; Thu, 8 Jan 2026 11:53:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898401; bh=i9JNcpUdHZKzJ8eftj44mWKHyO3md3I/pA24eKeKmTg=; 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=YqW8BfX+HXhBlQ4cFLPW0/nFaAGbX4OSr9dPxN5E4dOtBXUt6D1hF3im3SgbBb2xk Di4PjowVYTebKXw3GVN4X7A8tNeDlyM0uk9K6AN6lEt7+MIm9F5OerWWBAjn/Ao/oV JIDrwGGGRHfxFusEAW9S1GqaLolUzqi8un45AoQuTPTY+CJlF5cfPoRUiI4OmyN57L 4C+6GcyAbjFBqB1m+V1WoxdcNn7xOvLJsZJ5BsEqhtGDwkn0+XKYe1SGmYWiSyIK6s MyQnyk0RNgvRkSWlsVLwIoLkmmICLNH+9ALNU8v5HGUbKizbyPCZvzu6RZp4F8vmko /l9ObMZsEFOIg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A817069101 for ; Thu, 8 Jan 2026 11:53:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898399; bh=5rIKtxf4h0LlZdtq9uT6gh82XSLJX4XLpq71PA5AMow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WGb/7aLSdCK4+JlIbm6RqEUsdF/9Pooq7KQIecuyU9x4Vf/dqrxP+Bd3XVrQ3YWYR IClT17DW3/oAPD6Lna+ZeymSFKTIGwmweRcNMLlcMIDo/yfpshDQwSgZgDgMoTGkki fHjuwCn0tjV+6DGfQJ4uBSnD5iB1OY+RqLU+6bZz/Uuztg01A6t6sI8Z2btuNyL17L kn6Z8nqDHAA7iSBDPYv7Ssmc8PnoQjvDxDpuXaVLKjeoRYQGSnrkGf9PDgjVfmZ9+/ hIrEsblZtCtbylc5uxXHeQ08CO8DjiJkFkIN5HzUURqhJ+/wg0/Vd65RMn2BYIq7Id TLDWOtM4i9xTg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E2E169101; Thu, 8 Jan 2026 11:53:19 -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 e_TTbqCKos0c; Thu, 8 Jan 2026 11:53:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898399; bh=7ydZyQq0nBS/0SwdL/rw4N1wmk+rWDFz73elAWA46HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v7xQ21naX/lHT9fcWCy/H1hPFc6ohAZqX4RfokJS407ItVmktclsqfXZsQTja0lwf EJpcL6Iijc3lsYilbAgbD9z/6TiS6N5bBXtszVt0tZUS7Y/Ss5qL0dEFgubTzaL3Ao Z84GaQ4Krg7MJrehkue7FL1jItRsDgNbA7bq5NoS8afvYdsO3lDAahwqWly1R01iYQ yHAORJZRIn6bCMhxsLI24qDUNm+kOnUfEuBFGJocwDLqMxgWOJAfDxV9pWQtSl3rl2 h0naFaxpG5Gz8wbNu1AuCwobvDsh+l02ugP3zk2l6Qjj9PL+wzKWq2ggsQzrUmtSja 9G+rxXBlwVRFA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B251169057; Thu, 8 Jan 2026 11:53:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 11:51:35 -0700 Message-ID: <20260108185149.1995917-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108185149.1995917-1-sjg@u-boot.org> References: <20260108185149.1995917-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HT4IX6AP6W64UQFCMMKRISREISHSIXEW X-Message-ID-Hash: HT4IX6AP6W64UQFCMMKRISREISHSIXEW 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 20/21] ext4l: Add a CONFIG_EXT4_MOUNT_OPTS option 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 The ext4 mount-option-parsing infrastructure includes specification tables (ext4_param_specs, ext4_mount_opts) and related functions that add about 23K of rodata. For U-Boot's typical use case of mounting with default options, this parsing is unnecessary. Even if the options are needed in the future, it might be good enough to use the flags direcrly. Add a CONFIG_EXT4_MOUNT_OPTS option that, when disabled: - Stubs out ext4_parse_param() to accept any options silently - Removes the parameter-specification tables - Stubs ext4_show_options() and related functions This reduces code size by about 3.5K Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/Kconfig | 14 ++++++++++ fs/ext4l/super.c | 69 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 22 deletions(-) diff --git a/fs/ext4l/Kconfig b/fs/ext4l/Kconfig index fcd5953b6dd..4d0f6d95926 100644 --- a/fs/ext4l/Kconfig +++ b/fs/ext4l/Kconfig @@ -49,6 +49,20 @@ config EXT4L_PRINT Messages are always recorded and can be retrieved programmatically; this option controls whether they are also printed. +config EXT4_MOUNT_OPTS + bool "Enable mount option parsing" + depends on FS_EXT4L + help + Enable parsing of ext4 mount options (e.g., "data=ordered", + "barrier=1"). This requires the mount option specification + tables which add about 2KB of rodata. + + When disabled, ext4 uses fixed default options suitable for + read-only operation. This saves space but prevents customising + mount behaviour. + + If unsure, say N. + config EXT4_RESIZE bool "Enable ext4 online resize support" depends on FS_EXT4L diff --git a/fs/ext4l/super.c b/fs/ext4l/super.c index 98785935f19..9d8fee07907 100644 --- a/fs/ext4l/super.c +++ b/fs/ext4l/super.c @@ -61,7 +61,12 @@ static int ext4_reconfigure(struct fs_context *fc); static void ext4_fc_free(struct fs_context *fc); static int ext4_init_fs_context(struct fs_context *fc); static void ext4_kill_sb(struct super_block *sb); +#ifdef CONFIG_EXT4_MOUNT_OPTS static const struct fs_parameter_spec ext4_param_specs[]; +#define EXT4_PARAM_SPECS ext4_param_specs +#else +#define EXT4_PARAM_SPECS NULL +#endif /* * Lock ordering @@ -102,7 +107,7 @@ static struct file_system_type ext2_fs_type = { .owner = THIS_MODULE, .name = "ext2", .init_fs_context = ext4_init_fs_context, - .parameters = ext4_param_specs, + .parameters = EXT4_PARAM_SPECS, .kill_sb = ext4_kill_sb, .fs_flags = FS_REQUIRES_DEV, }; @@ -118,7 +123,7 @@ static struct file_system_type ext3_fs_type = { .owner = THIS_MODULE, .name = "ext3", .init_fs_context = ext4_init_fs_context, - .parameters = ext4_param_specs, + .parameters = EXT4_PARAM_SPECS, .kill_sb = ext4_kill_sb, .fs_flags = FS_REQUIRES_DEV, }; @@ -1663,6 +1668,24 @@ enum { #endif }; +#define MOPT_SET 0x0001 +#define MOPT_CLEAR 0x0002 +#define MOPT_NOSUPPORT 0x0004 +#define MOPT_EXPLICIT 0x0008 +#ifdef CONFIG_QUOTA +#define MOPT_Q 0 +#define MOPT_QFMT 0x0010 +#else +#define MOPT_Q MOPT_NOSUPPORT +#define MOPT_QFMT MOPT_NOSUPPORT +#endif +#define MOPT_NO_EXT2 0x0020 +#define MOPT_NO_EXT3 0x0040 +#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3) +#define MOPT_SKIP 0x0080 +#define MOPT_2 0x0100 + +#ifdef CONFIG_EXT4_MOUNT_OPTS static const struct constant_table ext4_param_errors[] = { {"continue", EXT4_MOUNT_ERRORS_CONT}, {"panic", EXT4_MOUNT_ERRORS_PANIC}, @@ -1803,24 +1826,6 @@ static const struct fs_parameter_spec ext4_param_specs[] = { {} }; - -#define MOPT_SET 0x0001 -#define MOPT_CLEAR 0x0002 -#define MOPT_NOSUPPORT 0x0004 -#define MOPT_EXPLICIT 0x0008 -#ifdef CONFIG_QUOTA -#define MOPT_Q 0 -#define MOPT_QFMT 0x0010 -#else -#define MOPT_Q MOPT_NOSUPPORT -#define MOPT_QFMT MOPT_NOSUPPORT -#endif -#define MOPT_NO_EXT2 0x0020 -#define MOPT_NO_EXT3 0x0040 -#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3) -#define MOPT_SKIP 0x0080 -#define MOPT_2 0x0100 - static const struct mount_opts { int token; int mount_opt; @@ -1895,6 +1900,7 @@ static const struct mount_opts { {Opt_abort, EXT4_MOUNT2_ABORT, MOPT_SET | MOPT_2}, {Opt_err, 0, 0} }; +#endif /* CONFIG_EXT4_MOUNT_OPTS */ #if IS_ENABLED(CONFIG_UNICODE) static const struct ext4_sb_encodings { @@ -2084,6 +2090,7 @@ EXT4_SET_CTX(mount_opt2); EXT4_CLEAR_CTX(mount_opt2); EXT4_TEST_CTX(mount_opt2); +#ifdef CONFIG_EXT4_MOUNT_OPTS static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) { struct ext4_fs_context *ctx = fc->fs_private; @@ -2377,6 +2384,13 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) return 0; } +#else +/* Stub when mount option parsing is disabled - use defaults */ +static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) +{ + return 0; +} +#endif /* CONFIG_EXT4_MOUNT_OPTS */ static int parse_options(struct fs_context *fc, char *options) { @@ -2862,6 +2876,7 @@ static inline void ext4_show_quota_options(struct seq_file *seq, #endif } +#ifdef CONFIG_EXT4_MOUNT_OPTS static const char *token2str(int token) { const struct fs_parameter_spec *spec; @@ -2871,7 +2886,6 @@ static const char *token2str(int token) break; return spec->name; } - /* * Show an option if * - it's set to a non-default value OR @@ -3018,6 +3032,17 @@ int ext4_seq_options_show(struct seq_file *seq, void *offset) seq_putc(seq, '\n'); return rc; } +#else +static int ext4_show_options(struct seq_file *seq, struct dentry *root) +{ + return 0; +} + +int ext4_seq_options_show(struct seq_file *seq, void *offset) +{ + return 0; +} +#endif /* CONFIG_EXT4_MOUNT_OPTS */ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, int read_only) @@ -7397,7 +7422,7 @@ static struct file_system_type ext4_fs_type = { .owner = THIS_MODULE, .name = "ext4", .init_fs_context = ext4_init_fs_context, - .parameters = ext4_param_specs, + .parameters = EXT4_PARAM_SPECS, .kill_sb = ext4_kill_sb, .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MGTIME, };