aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2016-02-23 07:13:49 -0500
committerRichard Weinberger <richard@nod.at>2016-03-20 16:36:05 -0400
commit3e7f2c5104a01f5385f64d45372aadaab898a656 (patch)
treea1c125e5bc3b0bcac3e9fb230450eebda2ee5282 /fs/ubifs
parent1e75a9f34a5ed5902707fb74b468356c55142b71 (diff)
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>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/Makefile1
-rw-r--r--fs/ubifs/misc.c57
-rw-r--r--fs/ubifs/ubifs.h41
3 files changed, 75 insertions, 24 deletions
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 2c6f0cb816b4..c54a24360f85 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -4,3 +4,4 @@ ubifs-y += shrinker.o journal.o file.o dir.o super.o sb.o io.o
4ubifs-y += tnc.o master.o scan.o replay.o log.o commit.o gc.o orphan.o 4ubifs-y += tnc.o master.o scan.o replay.o log.o commit.o gc.o orphan.o
5ubifs-y += budget.o find.o tnc_commit.o compress.o lpt.o lprops.o 5ubifs-y += budget.o find.o tnc_commit.o compress.o lpt.o lprops.o
6ubifs-y += recovery.o ioctl.o lpt_commit.o tnc_misc.o xattr.o debug.o 6ubifs-y += recovery.o ioctl.o lpt_commit.o tnc_misc.o xattr.o debug.o
7ubifs-y += misc.o
diff --git a/fs/ubifs/misc.c b/fs/ubifs/misc.c
new file mode 100644
index 000000000000..486a2844949f
--- /dev/null
+++ b/fs/ubifs/misc.c
@@ -0,0 +1,57 @@
1#include <linux/kernel.h>
2#include "ubifs.h"
3
4/* Normal UBIFS messages */
5void 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 */
22void 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 */
41void 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}
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index a5697de763f5..c2a57e193a81 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -42,30 +42,6 @@
42/* Version of this UBIFS implementation */ 42/* Version of this UBIFS implementation */
43#define UBIFS_VERSION 1 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/* UBIFS file system VFS magic number */ 45/* UBIFS file system VFS magic number */
70#define UBIFS_SUPER_MAGIC 0x24051905 46#define UBIFS_SUPER_MAGIC 0x24051905
71 47
@@ -1802,4 +1778,21 @@ int ubifs_decompress(const struct ubifs_info *c, const void *buf, int len,
1802#include "misc.h" 1778#include "misc.h"
1803#include "key.h" 1779#include "key.h"
1804 1780
1781/* Normal UBIFS messages */
1782__printf(2, 3)
1783void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...);
1784__printf(2, 3)
1785void ubifs_err(const struct ubifs_info *c, const char *fmt, ...);
1786__printf(2, 3)
1787void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...);
1788/*
1789 * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description
1790 * object as an argument.
1791 */
1792#define ubifs_errc(c, fmt, ...) \
1793do { \
1794 if (!(c)->probing) \
1795 ubifs_err(c, fmt, ##__VA_ARGS__); \
1796} while (0)
1797
1805#endif /* !__UBIFS_H__ */ 1798#endif /* !__UBIFS_H__ */