Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubifs: Add logging functions for ubifs_msg, ubifs_err and ubifs_warn

The existing logging macros are fairly large and converting the
macros to functions make the object code smaller.

Use %pV and __builtin_return_address(0) as appropriate.

$ size fs/ubifs/built-in.o*
text data bss dec hex filename
575831 309688 161312 1046831 ff92f fs/ubifs/built-in.o.allyesconfig.new
622457 312872 161120 1096449 10bb01 fs/ubifs/built-in.o.allyesconfig.old
223785 640 644 225069 36f2d fs/ubifs/built-in.o.defconfig.new
251873 640 644 253157 3dce5 fs/ubifs/built-in.o.defconfig.old

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Joe Perches and committed by
Richard Weinberger
3e7f2c51 1e75a9f3

+75 -24
+1
fs/ubifs/Makefile
··· 4 4 ubifs-y += tnc.o master.o scan.o replay.o log.o commit.o gc.o orphan.o 5 5 ubifs-y += budget.o find.o tnc_commit.o compress.o lpt.o lprops.o 6 6 ubifs-y += recovery.o ioctl.o lpt_commit.o tnc_misc.o xattr.o debug.o 7 + ubifs-y += misc.o
+57
fs/ubifs/misc.c
··· 1 + #include <linux/kernel.h> 2 + #include "ubifs.h" 3 + 4 + /* Normal UBIFS messages */ 5 + void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...) 6 + { 7 + struct va_format vaf; 8 + va_list args; 9 + 10 + va_start(args, fmt); 11 + 12 + vaf.fmt = fmt; 13 + vaf.va = &args; 14 + 15 + pr_notice("UBIFS (ubi%d:%d): %pV\n", 16 + c->vi.ubi_num, c->vi.vol_id, &vaf); 17 + 18 + va_end(args); 19 + } \ 20 + 21 + /* UBIFS error messages */ 22 + void ubifs_err(const struct ubifs_info *c, const char *fmt, ...) 23 + { 24 + struct va_format vaf; 25 + va_list args; 26 + 27 + va_start(args, fmt); 28 + 29 + vaf.fmt = fmt; 30 + vaf.va = &args; 31 + 32 + pr_err("UBIFS error (ubi%d:%d pid %d): %ps: %pV\n", 33 + c->vi.ubi_num, c->vi.vol_id, current->pid, 34 + __builtin_return_address(0), 35 + &vaf); 36 + 37 + va_end(args); 38 + } \ 39 + 40 + /* UBIFS warning messages */ 41 + void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...) 42 + { 43 + struct va_format vaf; 44 + va_list args; 45 + 46 + va_start(args, fmt); 47 + 48 + vaf.fmt = fmt; 49 + vaf.va = &args; 50 + 51 + pr_warn("UBIFS warning (ubi%d:%d pid %d): %ps: %pV\n", 52 + c->vi.ubi_num, c->vi.vol_id, current->pid, 53 + __builtin_return_address(0), 54 + &vaf); 55 + 56 + va_end(args); 57 + }
+17 -24
fs/ubifs/ubifs.h
··· 42 42 /* Version of this UBIFS implementation */ 43 43 #define UBIFS_VERSION 1 44 44 45 - /* Normal UBIFS messages */ 46 - #define ubifs_msg(c, fmt, ...) \ 47 - pr_notice("UBIFS (ubi%d:%d): " fmt "\n", \ 48 - (c)->vi.ubi_num, (c)->vi.vol_id, ##__VA_ARGS__) 49 - /* UBIFS error messages */ 50 - #define ubifs_err(c, fmt, ...) \ 51 - pr_err("UBIFS error (ubi%d:%d pid %d): %s: " fmt "\n", \ 52 - (c)->vi.ubi_num, (c)->vi.vol_id, current->pid, \ 53 - __func__, ##__VA_ARGS__) 54 - /* UBIFS warning messages */ 55 - #define ubifs_warn(c, fmt, ...) \ 56 - pr_warn("UBIFS warning (ubi%d:%d pid %d): %s: " fmt "\n", \ 57 - (c)->vi.ubi_num, (c)->vi.vol_id, current->pid, \ 58 - __func__, ##__VA_ARGS__) 59 - /* 60 - * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description 61 - * object as an argument. 62 - */ 63 - #define ubifs_errc(c, fmt, ...) \ 64 - do { \ 65 - if (!(c)->probing) \ 66 - ubifs_err(c, fmt, ##__VA_ARGS__); \ 67 - } while (0) 68 - 69 45 /* UBIFS file system VFS magic number */ 70 46 #define UBIFS_SUPER_MAGIC 0x24051905 71 47 ··· 1777 1801 #include "debug.h" 1778 1802 #include "misc.h" 1779 1803 #include "key.h" 1804 + 1805 + /* Normal UBIFS messages */ 1806 + __printf(2, 3) 1807 + void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...); 1808 + __printf(2, 3) 1809 + void ubifs_err(const struct ubifs_info *c, const char *fmt, ...); 1810 + __printf(2, 3) 1811 + void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...); 1812 + /* 1813 + * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description 1814 + * object as an argument. 1815 + */ 1816 + #define ubifs_errc(c, fmt, ...) \ 1817 + do { \ 1818 + if (!(c)->probing) \ 1819 + ubifs_err(c, fmt, ##__VA_ARGS__); \ 1820 + } while (0) 1780 1821 1781 1822 #endif /* !__UBIFS_H__ */