Skip to content

Commit e7c96e8

Browse files
JoePerchestytso
authored andcommitted
ext4: reduce object size when !CONFIG_PRINTK
Reduce the object size ~10% could be useful for embedded systems. Add #ifdef CONFIG_PRINTK #else #endif blocks to hold formats and arguments, passing " " to functions when !CONFIG_PRINTK and still verifying format and arguments with no_printk. $ size fs/ext4/built-in.o* text data bss dec hex filename 239375 610 888 240873 3ace9 fs/ext4/built-in.o.new 264167 738 888 265793 40e41 fs/ext4/built-in.o.old $ grep -E "CONFIG_EXT4|CONFIG_PRINTK" .config # CONFIG_PRINTK is not set CONFIG_EXT4_FS=y CONFIG_EXT4_USE_FOR_EXT23=y CONFIG_EXT4_FS_POSIX_ACL=y # CONFIG_EXT4_FS_SECURITY is not set # CONFIG_EXT4_DEBUG is not set Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent d3922a7 commit e7c96e8

2 files changed

Lines changed: 75 additions & 20 deletions

File tree

‎fs/ext4/ext4.h‎

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,42 +2169,96 @@ extern int ext4_alloc_flex_bg_array(struct super_block *sb,
21692169
ext4_group_t ngroup);
21702170
extern const char *ext4_decode_error(struct super_block *sb, int errno,
21712171
char nbuf[16]);
2172+
21722173
extern __printf(4, 5)
21732174
void __ext4_error(struct super_block *, const char *, unsigned int,
21742175
const char *, ...);
2175-
#define ext4_error(sb, message...) __ext4_error(sb, __func__, \
2176-
__LINE__, ## message)
21772176
extern __printf(5, 6)
2178-
void ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t,
2177+
void __ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t,
21792178
const char *, ...);
21802179
extern __printf(5, 6)
2181-
void ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t,
2180+
void __ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t,
21822181
const char *, ...);
21832182
extern void __ext4_std_error(struct super_block *, const char *,
21842183
unsigned int, int);
21852184
extern __printf(4, 5)
21862185
void __ext4_abort(struct super_block *, const char *, unsigned int,
21872186
const char *, ...);
2188-
#define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \
2189-
__LINE__, ## message)
21902187
extern __printf(4, 5)
21912188
void __ext4_warning(struct super_block *, const char *, unsigned int,
21922189
const char *, ...);
2193-
#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \
2194-
__LINE__, ## message)
21952190
extern __printf(3, 4)
2196-
void ext4_msg(struct super_block *, const char *, const char *, ...);
2191+
void __ext4_msg(struct super_block *, const char *, const char *, ...);
21972192
extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp,
21982193
const char *, unsigned int, const char *);
2199-
#define dump_mmp_msg(sb, mmp, msg) __dump_mmp_msg(sb, mmp, __func__, \
2200-
__LINE__, msg)
22012194
extern __printf(7, 8)
22022195
void __ext4_grp_locked_error(const char *, unsigned int,
22032196
struct super_block *, ext4_group_t,
22042197
unsigned long, ext4_fsblk_t,
22052198
const char *, ...);
2206-
#define ext4_grp_locked_error(sb, grp, message...) \
2207-
__ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message)
2199+
2200+
#ifdef CONFIG_PRINTK
2201+
2202+
#define ext4_error_inode(inode, func, line, block, fmt, ...) \
2203+
__ext4_error_inode(inode, func, line, block, fmt, ##__VA_ARGS__)
2204+
#define ext4_error_file(file, func, line, block, fmt, ...) \
2205+
__ext4_error_file(file, func, line, block, fmt, ##__VA_ARGS__)
2206+
#define ext4_error(sb, fmt, ...) \
2207+
__ext4_error(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
2208+
#define ext4_abort(sb, fmt, ...) \
2209+
__ext4_abort(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
2210+
#define ext4_warning(sb, fmt, ...) \
2211+
__ext4_warning(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
2212+
#define ext4_msg(sb, level, fmt, ...) \
2213+
__ext4_msg(sb, level, fmt, ##__VA_ARGS__)
2214+
#define dump_mmp_msg(sb, mmp, msg) \
2215+
__dump_mmp_msg(sb, mmp, __func__, __LINE__, msg)
2216+
#define ext4_grp_locked_error(sb, grp, ino, block, fmt, ...) \
2217+
__ext4_grp_locked_error(__func__, __LINE__, sb, grp, ino, block, \
2218+
fmt, ##__VA_ARGS__)
2219+
2220+
#else
2221+
2222+
#define ext4_error_inode(inode, func, line, block, fmt, ...) \
2223+
do { \
2224+
no_printk(fmt, ##__VA_ARGS__); \
2225+
__ext4_error_inode(inode, "", 0, block, " "); \
2226+
} while (0)
2227+
#define ext4_error_file(file, func, line, block, fmt, ...) \
2228+
do { \
2229+
no_printk(fmt, ##__VA_ARGS__); \
2230+
__ext4_error_file(file, "", 0, block, " "); \
2231+
} while (0)
2232+
#define ext4_error(sb, fmt, ...) \
2233+
do { \
2234+
no_printk(fmt, ##__VA_ARGS__); \
2235+
__ext4_error(sb, "", 0, " "); \
2236+
} while (0)
2237+
#define ext4_abort(sb, fmt, ...) \
2238+
do { \
2239+
no_printk(fmt, ##__VA_ARGS__); \
2240+
__ext4_abort(sb, "", 0, " "); \
2241+
} while (0)
2242+
#define ext4_warning(sb, fmt, ...) \
2243+
do { \
2244+
no_printk(fmt, ##__VA_ARGS__); \
2245+
__ext4_warning(sb, "", 0, " "); \
2246+
} while (0)
2247+
#define ext4_msg(sb, level, fmt, ...) \
2248+
do { \
2249+
no_printk(fmt, ##__VA_ARGS__); \
2250+
__ext4_msg(sb, "", " "); \
2251+
} while (0)
2252+
#define dump_mmp_msg(sb, mmp, msg) \
2253+
__dump_mmp_msg(sb, mmp, "", 0, "")
2254+
#define ext4_grp_locked_error(sb, grp, ino, block, fmt, ...) \
2255+
do { \
2256+
no_printk(fmt, ##__VA_ARGS__); \
2257+
__ext4_grp_locked_error("", 0, sb, grp, ino, block, " "); \
2258+
} while (0)
2259+
2260+
#endif
2261+
22082262
extern void ext4_update_dynamic_rev(struct super_block *sb);
22092263
extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
22102264
__u32 compat);

‎fs/ext4/super.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ void __ext4_error(struct super_block *sb, const char *function,
428428
ext4_handle_error(sb);
429429
}
430430

431-
void ext4_error_inode(struct inode *inode, const char *function,
432-
unsigned int line, ext4_fsblk_t block,
433-
const char *fmt, ...)
431+
void __ext4_error_inode(struct inode *inode, const char *function,
432+
unsigned int line, ext4_fsblk_t block,
433+
const char *fmt, ...)
434434
{
435435
va_list args;
436436
struct va_format vaf;
@@ -457,9 +457,9 @@ void ext4_error_inode(struct inode *inode, const char *function,
457457
ext4_handle_error(inode->i_sb);
458458
}
459459

460-
void ext4_error_file(struct file *file, const char *function,
461-
unsigned int line, ext4_fsblk_t block,
462-
const char *fmt, ...)
460+
void __ext4_error_file(struct file *file, const char *function,
461+
unsigned int line, ext4_fsblk_t block,
462+
const char *fmt, ...)
463463
{
464464
va_list args;
465465
struct va_format vaf;
@@ -591,7 +591,8 @@ void __ext4_abort(struct super_block *sb, const char *function,
591591
panic("EXT4-fs panic from previous error\n");
592592
}
593593

594-
void ext4_msg(struct super_block *sb, const char *prefix, const char *fmt, ...)
594+
void __ext4_msg(struct super_block *sb,
595+
const char *prefix, const char *fmt, ...)
595596
{
596597
struct va_format vaf;
597598
va_list args;

0 commit comments

Comments
 (0)