aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-13 13:31:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-13 13:31:33 -0500
commit94b1984ab9ab61cc6047c07e074d766485299a9c (patch)
tree4b6cba21caf3d99129bea6a5eba0544b2fe8402a
parent1a52bb0b686844021597d190e562ab55d1210104 (diff)
parent515315a123af641a9533e4ff0f178c470dc08fc7 (diff)
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
* 'linux-next' of git://git.infradead.org/ubifs-2.6: UBIFS: fix key printing UBIFS: use snprintf instead of sprintf when printing keys UBIFS: fix debugging messages UBIFS: make debugging messages light again UBI: fix debugging messages UBI: make vid_hdr non-static
-rw-r--r--drivers/mtd/ubi/debug.h5
-rw-r--r--drivers/mtd/ubi/vtbl.c2
-rw-r--r--fs/ubifs/debug.c90
-rw-r--r--fs/ubifs/debug.h44
-rw-r--r--fs/ubifs/journal.c7
-rw-r--r--fs/ubifs/replay.c8
-rw-r--r--fs/ubifs/tnc.c55
-rw-r--r--fs/ubifs/tnc_misc.c10
8 files changed, 115 insertions, 106 deletions
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 64fbb0021825..ead2cd16ba75 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -43,7 +43,10 @@
43 pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__) 43 pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__)
44 44
45/* Just a debugging messages not related to any specific UBI subsystem */ 45/* Just a debugging messages not related to any specific UBI subsystem */
46#define dbg_msg(fmt, ...) ubi_dbg_msg("msg", fmt, ##__VA_ARGS__) 46#define dbg_msg(fmt, ...) \
47 printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
48 current->pid, __func__, ##__VA_ARGS__)
49
47/* General debugging messages */ 50/* General debugging messages */
48#define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__) 51#define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
49/* Messages from the eraseblock association sub-system */ 52/* Messages from the eraseblock association sub-system */
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 9ad18da1891d..890754c9f327 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -306,7 +306,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si,
306 int copy, void *vtbl) 306 int copy, void *vtbl)
307{ 307{
308 int err, tries = 0; 308 int err, tries = 0;
309 static struct ubi_vid_hdr *vid_hdr; 309 struct ubi_vid_hdr *vid_hdr;
310 struct ubi_scan_leb *new_seb; 310 struct ubi_scan_leb *new_seb;
311 311
312 ubi_msg("create volume table (copy #%d)", copy + 1); 312 ubi_msg("create volume table (copy #%d)", copy + 1);
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index b09ba2dd8b62..f922cbacdb96 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -38,9 +38,6 @@
38 38
39DEFINE_SPINLOCK(dbg_lock); 39DEFINE_SPINLOCK(dbg_lock);
40 40
41static char dbg_key_buf0[128];
42static char dbg_key_buf1[128];
43
44static const char *get_key_fmt(int fmt) 41static const char *get_key_fmt(int fmt)
45{ 42{
46 switch (fmt) { 43 switch (fmt) {
@@ -103,8 +100,8 @@ static const char *get_dent_type(int type)
103 } 100 }
104} 101}
105 102
106static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key, 103const char *dbg_snprintf_key(const struct ubifs_info *c,
107 char *buffer) 104 const union ubifs_key *key, char *buffer, int len)
108{ 105{
109 char *p = buffer; 106 char *p = buffer;
110 int type = key_type(c, key); 107 int type = key_type(c, key);
@@ -112,45 +109,34 @@ static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key,
112 if (c->key_fmt == UBIFS_SIMPLE_KEY_FMT) { 109 if (c->key_fmt == UBIFS_SIMPLE_KEY_FMT) {
113 switch (type) { 110 switch (type) {
114 case UBIFS_INO_KEY: 111 case UBIFS_INO_KEY:
115 sprintf(p, "(%lu, %s)", (unsigned long)key_inum(c, key), 112 len -= snprintf(p, len, "(%lu, %s)",
116 get_key_type(type)); 113 (unsigned long)key_inum(c, key),
114 get_key_type(type));
117 break; 115 break;
118 case UBIFS_DENT_KEY: 116 case UBIFS_DENT_KEY:
119 case UBIFS_XENT_KEY: 117 case UBIFS_XENT_KEY:
120 sprintf(p, "(%lu, %s, %#08x)", 118 len -= snprintf(p, len, "(%lu, %s, %#08x)",
121 (unsigned long)key_inum(c, key), 119 (unsigned long)key_inum(c, key),
122 get_key_type(type), key_hash(c, key)); 120 get_key_type(type), key_hash(c, key));
123 break; 121 break;
124 case UBIFS_DATA_KEY: 122 case UBIFS_DATA_KEY:
125 sprintf(p, "(%lu, %s, %u)", 123 len -= snprintf(p, len, "(%lu, %s, %u)",
126 (unsigned long)key_inum(c, key), 124 (unsigned long)key_inum(c, key),
127 get_key_type(type), key_block(c, key)); 125 get_key_type(type), key_block(c, key));
128 break; 126 break;
129 case UBIFS_TRUN_KEY: 127 case UBIFS_TRUN_KEY:
130 sprintf(p, "(%lu, %s)", 128 len -= snprintf(p, len, "(%lu, %s)",
131 (unsigned long)key_inum(c, key), 129 (unsigned long)key_inum(c, key),
132 get_key_type(type)); 130 get_key_type(type));
133 break; 131 break;
134 default: 132 default:
135 sprintf(p, "(bad key type: %#08x, %#08x)", 133 len -= snprintf(p, len, "(bad key type: %#08x, %#08x)",
136 key->u32[0], key->u32[1]); 134 key->u32[0], key->u32[1]);
137 } 135 }
138 } else 136 } else
139 sprintf(p, "bad key format %d", c->key_fmt); 137 len -= snprintf(p, len, "bad key format %d", c->key_fmt);
140} 138 ubifs_assert(len > 0);
141 139 return p;
142const char *dbg_key_str0(const struct ubifs_info *c, const union ubifs_key *key)
143{
144 /* dbg_lock must be held */
145 sprintf_key(c, key, dbg_key_buf0);
146 return dbg_key_buf0;
147}
148
149const char *dbg_key_str1(const struct ubifs_info *c, const union ubifs_key *key)
150{
151 /* dbg_lock must be held */
152 sprintf_key(c, key, dbg_key_buf1);
153 return dbg_key_buf1;
154} 140}
155 141
156const char *dbg_ntype(int type) 142const char *dbg_ntype(int type)
@@ -319,6 +305,7 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
319 int i, n; 305 int i, n;
320 union ubifs_key key; 306 union ubifs_key key;
321 const struct ubifs_ch *ch = node; 307 const struct ubifs_ch *ch = node;
308 char key_buf[DBG_KEY_BUF_LEN];
322 309
323 if (dbg_is_tst_rcvry(c)) 310 if (dbg_is_tst_rcvry(c))
324 return; 311 return;
@@ -474,7 +461,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
474 const struct ubifs_ino_node *ino = node; 461 const struct ubifs_ino_node *ino = node;
475 462
476 key_read(c, &ino->key, &key); 463 key_read(c, &ino->key, &key);
477 printk(KERN_DEBUG "\tkey %s\n", DBGKEY(&key)); 464 printk(KERN_DEBUG "\tkey %s\n",
465 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
478 printk(KERN_DEBUG "\tcreat_sqnum %llu\n", 466 printk(KERN_DEBUG "\tcreat_sqnum %llu\n",
479 (unsigned long long)le64_to_cpu(ino->creat_sqnum)); 467 (unsigned long long)le64_to_cpu(ino->creat_sqnum));
480 printk(KERN_DEBUG "\tsize %llu\n", 468 printk(KERN_DEBUG "\tsize %llu\n",
@@ -517,7 +505,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
517 int nlen = le16_to_cpu(dent->nlen); 505 int nlen = le16_to_cpu(dent->nlen);
518 506
519 key_read(c, &dent->key, &key); 507 key_read(c, &dent->key, &key);
520 printk(KERN_DEBUG "\tkey %s\n", DBGKEY(&key)); 508 printk(KERN_DEBUG "\tkey %s\n",
509 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
521 printk(KERN_DEBUG "\tinum %llu\n", 510 printk(KERN_DEBUG "\tinum %llu\n",
522 (unsigned long long)le64_to_cpu(dent->inum)); 511 (unsigned long long)le64_to_cpu(dent->inum));
523 printk(KERN_DEBUG "\ttype %d\n", (int)dent->type); 512 printk(KERN_DEBUG "\ttype %d\n", (int)dent->type);
@@ -541,7 +530,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
541 int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ; 530 int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ;
542 531
543 key_read(c, &dn->key, &key); 532 key_read(c, &dn->key, &key);
544 printk(KERN_DEBUG "\tkey %s\n", DBGKEY(&key)); 533 printk(KERN_DEBUG "\tkey %s\n",
534 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
545 printk(KERN_DEBUG "\tsize %u\n", 535 printk(KERN_DEBUG "\tsize %u\n",
546 le32_to_cpu(dn->size)); 536 le32_to_cpu(dn->size));
547 printk(KERN_DEBUG "\tcompr_typ %d\n", 537 printk(KERN_DEBUG "\tcompr_typ %d\n",
@@ -582,7 +572,9 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
582 key_read(c, &br->key, &key); 572 key_read(c, &br->key, &key);
583 printk(KERN_DEBUG "\t%d: LEB %d:%d len %d key %s\n", 573 printk(KERN_DEBUG "\t%d: LEB %d:%d len %d key %s\n",
584 i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs), 574 i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs),
585 le32_to_cpu(br->len), DBGKEY(&key)); 575 le32_to_cpu(br->len),
576 dbg_snprintf_key(c, &key, key_buf,
577 DBG_KEY_BUF_LEN));
586 } 578 }
587 break; 579 break;
588 } 580 }
@@ -934,6 +926,7 @@ void dbg_dump_znode(const struct ubifs_info *c,
934{ 926{
935 int n; 927 int n;
936 const struct ubifs_zbranch *zbr; 928 const struct ubifs_zbranch *zbr;
929 char key_buf[DBG_KEY_BUF_LEN];
937 930
938 spin_lock(&dbg_lock); 931 spin_lock(&dbg_lock);
939 if (znode->parent) 932 if (znode->parent)
@@ -958,12 +951,16 @@ void dbg_dump_znode(const struct ubifs_info *c,
958 printk(KERN_DEBUG "\t%d: znode %p LEB %d:%d len %d key " 951 printk(KERN_DEBUG "\t%d: znode %p LEB %d:%d len %d key "
959 "%s\n", n, zbr->znode, zbr->lnum, 952 "%s\n", n, zbr->znode, zbr->lnum,
960 zbr->offs, zbr->len, 953 zbr->offs, zbr->len,
961 DBGKEY(&zbr->key)); 954 dbg_snprintf_key(c, &zbr->key,
955 key_buf,
956 DBG_KEY_BUF_LEN));
962 else 957 else
963 printk(KERN_DEBUG "\t%d: LNC %p LEB %d:%d len %d key " 958 printk(KERN_DEBUG "\t%d: LNC %p LEB %d:%d len %d key "
964 "%s\n", n, zbr->znode, zbr->lnum, 959 "%s\n", n, zbr->znode, zbr->lnum,
965 zbr->offs, zbr->len, 960 zbr->offs, zbr->len,
966 DBGKEY(&zbr->key)); 961 dbg_snprintf_key(c, &zbr->key,
962 key_buf,
963 DBG_KEY_BUF_LEN));
967 } 964 }
968 spin_unlock(&dbg_lock); 965 spin_unlock(&dbg_lock);
969} 966}
@@ -1260,6 +1257,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1260 int err, nlen1, nlen2, cmp; 1257 int err, nlen1, nlen2, cmp;
1261 struct ubifs_dent_node *dent1, *dent2; 1258 struct ubifs_dent_node *dent1, *dent2;
1262 union ubifs_key key; 1259 union ubifs_key key;
1260 char key_buf[DBG_KEY_BUF_LEN];
1263 1261
1264 ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key)); 1262 ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key));
1265 dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS); 1263 dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS);
@@ -1290,9 +1288,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1290 key_read(c, &dent1->key, &key); 1288 key_read(c, &dent1->key, &key);
1291 if (keys_cmp(c, &zbr1->key, &key)) { 1289 if (keys_cmp(c, &zbr1->key, &key)) {
1292 dbg_err("1st entry at %d:%d has key %s", zbr1->lnum, 1290 dbg_err("1st entry at %d:%d has key %s", zbr1->lnum,
1293 zbr1->offs, DBGKEY(&key)); 1291 zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
1292 DBG_KEY_BUF_LEN));
1294 dbg_err("but it should have key %s according to tnc", 1293 dbg_err("but it should have key %s according to tnc",
1295 DBGKEY(&zbr1->key)); 1294 dbg_snprintf_key(c, &zbr1->key, key_buf,
1295 DBG_KEY_BUF_LEN));
1296 dbg_dump_node(c, dent1); 1296 dbg_dump_node(c, dent1);
1297 goto out_free; 1297 goto out_free;
1298 } 1298 }
@@ -1300,9 +1300,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1300 key_read(c, &dent2->key, &key); 1300 key_read(c, &dent2->key, &key);
1301 if (keys_cmp(c, &zbr2->key, &key)) { 1301 if (keys_cmp(c, &zbr2->key, &key)) {
1302 dbg_err("2nd entry at %d:%d has key %s", zbr1->lnum, 1302 dbg_err("2nd entry at %d:%d has key %s", zbr1->lnum,
1303 zbr1->offs, DBGKEY(&key)); 1303 zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
1304 DBG_KEY_BUF_LEN));
1304 dbg_err("but it should have key %s according to tnc", 1305 dbg_err("but it should have key %s according to tnc",
1305 DBGKEY(&zbr2->key)); 1306 dbg_snprintf_key(c, &zbr2->key, key_buf,
1307 DBG_KEY_BUF_LEN));
1306 dbg_dump_node(c, dent2); 1308 dbg_dump_node(c, dent2);
1307 goto out_free; 1309 goto out_free;
1308 } 1310 }
@@ -1319,7 +1321,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1319 dbg_err("2 xent/dent nodes with the same name"); 1321 dbg_err("2 xent/dent nodes with the same name");
1320 else 1322 else
1321 dbg_err("bad order of colliding key %s", 1323 dbg_err("bad order of colliding key %s",
1322 DBGKEY(&key)); 1324 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
1323 1325
1324 ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs); 1326 ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs);
1325 dbg_dump_node(c, dent1); 1327 dbg_dump_node(c, dent1);
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index 8d9c46810189..307ab1d23f75 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -169,40 +169,39 @@ struct ubifs_global_debug_info {
169 spin_unlock(&dbg_lock); \ 169 spin_unlock(&dbg_lock); \
170} while (0) 170} while (0)
171 171
172const char *dbg_key_str0(const struct ubifs_info *c, 172#define ubifs_dbg_msg(type, fmt, ...) \
173 const union ubifs_key *key); 173 pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__)
174const char *dbg_key_str1(const struct ubifs_info *c, 174
175 const union ubifs_key *key); 175#define DBG_KEY_BUF_LEN 32
176 176#define ubifs_dbg_msg_key(type, key, fmt, ...) do { \
177/* 177 char __tmp_key_buf[DBG_KEY_BUF_LEN]; \
178 * DBGKEY macros require @dbg_lock to be held, which it is in the dbg message 178 pr_debug("UBIFS DBG " type ": " fmt "%s\n", ##__VA_ARGS__, \
179 * macros. 179 dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN)); \
180 */
181#define DBGKEY(key) dbg_key_str0(c, (key))
182#define DBGKEY1(key) dbg_key_str1(c, (key))
183
184extern spinlock_t dbg_lock;
185
186#define ubifs_dbg_msg(type, fmt, ...) do { \
187 spin_lock(&dbg_lock); \
188 pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__); \
189 spin_unlock(&dbg_lock); \
190} while (0) 180} while (0)
191 181
192/* Just a debugging messages not related to any specific UBIFS subsystem */ 182/* Just a debugging messages not related to any specific UBIFS subsystem */
193#define dbg_msg(fmt, ...) ubifs_dbg_msg("msg", fmt, ##__VA_ARGS__) 183#define dbg_msg(fmt, ...) \
184 printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \
185 __func__, ##__VA_ARGS__)
186
194/* General messages */ 187/* General messages */
195#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__) 188#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
196/* Additional journal messages */ 189/* Additional journal messages */
197#define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__) 190#define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)
191#define dbg_jnlk(key, fmt, ...) \
192 ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__)
198/* Additional TNC messages */ 193/* Additional TNC messages */
199#define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__) 194#define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)
195#define dbg_tnck(key, fmt, ...) \
196 ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__)
200/* Additional lprops messages */ 197/* Additional lprops messages */
201#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__) 198#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
202/* Additional LEB find messages */ 199/* Additional LEB find messages */
203#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__) 200#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
204/* Additional mount messages */ 201/* Additional mount messages */
205#define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__) 202#define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)
203#define dbg_mntk(key, fmt, ...) \
204 ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__)
206/* Additional I/O messages */ 205/* Additional I/O messages */
207#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__) 206#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
208/* Additional commit messages */ 207/* Additional commit messages */
@@ -218,6 +217,7 @@ extern spinlock_t dbg_lock;
218/* Additional recovery messages */ 217/* Additional recovery messages */
219#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) 218#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
220 219
220extern spinlock_t dbg_lock;
221extern struct ubifs_global_debug_info ubifs_dbg; 221extern struct ubifs_global_debug_info ubifs_dbg;
222 222
223static inline int dbg_is_chk_gen(const struct ubifs_info *c) 223static inline int dbg_is_chk_gen(const struct ubifs_info *c)
@@ -258,6 +258,8 @@ const char *dbg_cstate(int cmt_state);
258const char *dbg_jhead(int jhead); 258const char *dbg_jhead(int jhead);
259const char *dbg_get_key_dump(const struct ubifs_info *c, 259const char *dbg_get_key_dump(const struct ubifs_info *c,
260 const union ubifs_key *key); 260 const union ubifs_key *key);
261const char *dbg_snprintf_key(const struct ubifs_info *c,
262 const union ubifs_key *key, char *buffer, int len);
261void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode); 263void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode);
262void dbg_dump_node(const struct ubifs_info *c, const void *node); 264void dbg_dump_node(const struct ubifs_info *c, const void *node);
263void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum, 265void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum,
@@ -368,6 +370,10 @@ static inline const char *dbg_jhead(int jhead) { return ""; }
368static inline const char * 370static inline const char *
369dbg_get_key_dump(const struct ubifs_info *c, 371dbg_get_key_dump(const struct ubifs_info *c,
370 const union ubifs_key *key) { return ""; } 372 const union ubifs_key *key) { return ""; }
373static inline const char *
374dbg_snprintf_key(const struct ubifs_info *c,
375 const union ubifs_key *key, char *buffer,
376 int len) { return ""; }
371static inline void dbg_dump_inode(struct ubifs_info *c, 377static inline void dbg_dump_inode(struct ubifs_info *c,
372 const struct inode *inode) { return; } 378 const struct inode *inode) { return; }
373static inline void dbg_dump_node(const struct ubifs_info *c, 379static inline void dbg_dump_node(const struct ubifs_info *c,
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index cef0460f4c54..2f438ab2e7a2 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -697,9 +697,8 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
697 int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1; 697 int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1;
698 struct ubifs_inode *ui = ubifs_inode(inode); 698 struct ubifs_inode *ui = ubifs_inode(inode);
699 699
700 dbg_jnl("ino %lu, blk %u, len %d, key %s", 700 dbg_jnlk(key, "ino %lu, blk %u, len %d, key ",
701 (unsigned long)key_inum(c, key), key_block(c, key), len, 701 (unsigned long)key_inum(c, key), key_block(c, key), len);
702 DBGKEY(key));
703 ubifs_assert(len <= UBIFS_BLOCK_SIZE); 702 ubifs_assert(len <= UBIFS_BLOCK_SIZE);
704 703
705 data = kmalloc(dlen, GFP_NOFS | __GFP_NOWARN); 704 data = kmalloc(dlen, GFP_NOFS | __GFP_NOWARN);
@@ -1177,7 +1176,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
1177 dn = (void *)trun + UBIFS_TRUN_NODE_SZ; 1176 dn = (void *)trun + UBIFS_TRUN_NODE_SZ;
1178 blk = new_size >> UBIFS_BLOCK_SHIFT; 1177 blk = new_size >> UBIFS_BLOCK_SHIFT;
1179 data_key_init(c, &key, inum, blk); 1178 data_key_init(c, &key, inum, blk);
1180 dbg_jnl("last block key %s", DBGKEY(&key)); 1179 dbg_jnlk(&key, "last block key ");
1181 err = ubifs_tnc_lookup(c, &key, dn); 1180 err = ubifs_tnc_lookup(c, &key, dn);
1182 if (err == -ENOENT) 1181 if (err == -ENOENT)
1183 dlen = 0; /* Not found (so it is a hole) */ 1182 dlen = 0; /* Not found (so it is a hole) */
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index ccabaf1164b3..b007637f0406 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -221,8 +221,8 @@ static int apply_replay_entry(struct ubifs_info *c, struct replay_entry *r)
221{ 221{
222 int err; 222 int err;
223 223
224 dbg_mnt("LEB %d:%d len %d deletion %d sqnum %llu %s", r->lnum, 224 dbg_mntk(&r->key, "LEB %d:%d len %d deletion %d sqnum %llu key ",
225 r->offs, r->len, r->deletion, r->sqnum, DBGKEY(&r->key)); 225 r->lnum, r->offs, r->len, r->deletion, r->sqnum);
226 226
227 /* Set c->replay_sqnum to help deal with dangling branches. */ 227 /* Set c->replay_sqnum to help deal with dangling branches. */
228 c->replay_sqnum = r->sqnum; 228 c->replay_sqnum = r->sqnum;
@@ -361,7 +361,7 @@ static int insert_node(struct ubifs_info *c, int lnum, int offs, int len,
361{ 361{
362 struct replay_entry *r; 362 struct replay_entry *r;
363 363
364 dbg_mnt("add LEB %d:%d, key %s", lnum, offs, DBGKEY(key)); 364 dbg_mntk(key, "add LEB %d:%d, key ", lnum, offs);
365 365
366 if (key_inum(c, key) >= c->highest_inum) 366 if (key_inum(c, key) >= c->highest_inum)
367 c->highest_inum = key_inum(c, key); 367 c->highest_inum = key_inum(c, key);
@@ -409,7 +409,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
409 struct replay_entry *r; 409 struct replay_entry *r;
410 char *nbuf; 410 char *nbuf;
411 411
412 dbg_mnt("add LEB %d:%d, key %s", lnum, offs, DBGKEY(key)); 412 dbg_mntk(key, "add LEB %d:%d, key ", lnum, offs);
413 if (key_inum(c, key) >= c->highest_inum) 413 if (key_inum(c, key) >= c->highest_inum)
414 c->highest_inum = key_inum(c, key); 414 c->highest_inum = key_inum(c, key);
415 415
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index e14ee53159db..16ad84d8402f 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -505,7 +505,7 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
505{ 505{
506 int ret; 506 int ret;
507 507
508 dbg_tnc("LEB %d:%d, key %s", zbr->lnum, zbr->offs, DBGKEY(key)); 508 dbg_tnck(key, "LEB %d:%d, key ", zbr->lnum, zbr->offs);
509 509
510 ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum, 510 ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum,
511 zbr->offs); 511 zbr->offs);
@@ -519,8 +519,8 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
519 ret = 0; 519 ret = 0;
520 } 520 }
521 if (ret == 0 && c->replaying) 521 if (ret == 0 && c->replaying)
522 dbg_mnt("dangling branch LEB %d:%d len %d, key %s", 522 dbg_mntk(key, "dangling branch LEB %d:%d len %d, key ",
523 zbr->lnum, zbr->offs, zbr->len, DBGKEY(key)); 523 zbr->lnum, zbr->offs, zbr->len);
524 return ret; 524 return ret;
525} 525}
526 526
@@ -995,9 +995,9 @@ static int fallible_resolve_collision(struct ubifs_info *c,
995 if (adding || !o_znode) 995 if (adding || !o_znode)
996 return 0; 996 return 0;
997 997
998 dbg_mnt("dangling match LEB %d:%d len %d %s", 998 dbg_mntk(key, "dangling match LEB %d:%d len %d key ",
999 o_znode->zbranch[o_n].lnum, o_znode->zbranch[o_n].offs, 999 o_znode->zbranch[o_n].lnum, o_znode->zbranch[o_n].offs,
1000 o_znode->zbranch[o_n].len, DBGKEY(key)); 1000 o_znode->zbranch[o_n].len);
1001 *zn = o_znode; 1001 *zn = o_znode;
1002 *n = o_n; 1002 *n = o_n;
1003 return 1; 1003 return 1;
@@ -1179,7 +1179,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key,
1179 struct ubifs_znode *znode; 1179 struct ubifs_znode *znode;
1180 unsigned long time = get_seconds(); 1180 unsigned long time = get_seconds();
1181 1181
1182 dbg_tnc("search key %s", DBGKEY(key)); 1182 dbg_tnck(key, "search key ");
1183 ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); 1183 ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY);
1184 1184
1185 znode = c->zroot.znode; 1185 znode = c->zroot.znode;
@@ -1315,7 +1315,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key,
1315 struct ubifs_znode *znode; 1315 struct ubifs_znode *znode;
1316 unsigned long time = get_seconds(); 1316 unsigned long time = get_seconds();
1317 1317
1318 dbg_tnc("search and dirty key %s", DBGKEY(key)); 1318 dbg_tnck(key, "search and dirty key ");
1319 1319
1320 znode = c->zroot.znode; 1320 znode = c->zroot.znode;
1321 if (unlikely(!znode)) { 1321 if (unlikely(!znode)) {
@@ -1722,8 +1722,8 @@ static int validate_data_node(struct ubifs_info *c, void *buf,
1722 if (!keys_eq(c, &zbr->key, &key1)) { 1722 if (!keys_eq(c, &zbr->key, &key1)) {
1723 ubifs_err("bad key in node at LEB %d:%d", 1723 ubifs_err("bad key in node at LEB %d:%d",
1724 zbr->lnum, zbr->offs); 1724 zbr->lnum, zbr->offs);
1725 dbg_tnc("looked for key %s found node's key %s", 1725 dbg_tnck(&zbr->key, "looked for key ");
1726 DBGKEY(&zbr->key), DBGKEY1(&key1)); 1726 dbg_tnck(&key1, "found node's key ");
1727 goto out_err; 1727 goto out_err;
1728 } 1728 }
1729 1729
@@ -1776,7 +1776,7 @@ int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu)
1776 ubifs_err("failed to read from LEB %d:%d, error %d", 1776 ubifs_err("failed to read from LEB %d:%d, error %d",
1777 lnum, offs, err); 1777 lnum, offs, err);
1778 dbg_dump_stack(); 1778 dbg_dump_stack();
1779 dbg_tnc("key %s", DBGKEY(&bu->key)); 1779 dbg_tnck(&bu->key, "key ");
1780 return err; 1780 return err;
1781 } 1781 }
1782 1782
@@ -1811,7 +1811,7 @@ static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key,
1811 int found, n, err; 1811 int found, n, err;
1812 struct ubifs_znode *znode; 1812 struct ubifs_znode *znode;
1813 1813
1814 dbg_tnc("name '%.*s' key %s", nm->len, nm->name, DBGKEY(key)); 1814 dbg_tnck(key, "name '%.*s' key ", nm->len, nm->name);
1815 mutex_lock(&c->tnc_mutex); 1815 mutex_lock(&c->tnc_mutex);
1816 found = ubifs_lookup_level0(c, key, &znode, &n); 1816 found = ubifs_lookup_level0(c, key, &znode, &n);
1817 if (!found) { 1817 if (!found) {
@@ -1985,8 +1985,7 @@ again:
1985 zp = znode->parent; 1985 zp = znode->parent;
1986 if (znode->child_cnt < c->fanout) { 1986 if (znode->child_cnt < c->fanout) {
1987 ubifs_assert(n != c->fanout); 1987 ubifs_assert(n != c->fanout);
1988 dbg_tnc("inserted at %d level %d, key %s", n, znode->level, 1988 dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level);
1989 DBGKEY(key));
1990 1989
1991 insert_zbranch(znode, zbr, n); 1990 insert_zbranch(znode, zbr, n);
1992 1991
@@ -2001,7 +2000,7 @@ again:
2001 * Unfortunately, @znode does not have more empty slots and we have to 2000 * Unfortunately, @znode does not have more empty slots and we have to
2002 * split it. 2001 * split it.
2003 */ 2002 */
2004 dbg_tnc("splitting level %d, key %s", znode->level, DBGKEY(key)); 2003 dbg_tnck(key, "splitting level %d, key ", znode->level);
2005 2004
2006 if (znode->alt) 2005 if (znode->alt)
2007 /* 2006 /*
@@ -2095,7 +2094,7 @@ do_split:
2095 } 2094 }
2096 2095
2097 /* Insert new key and branch */ 2096 /* Insert new key and branch */
2098 dbg_tnc("inserting at %d level %d, key %s", n, zn->level, DBGKEY(key)); 2097 dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level);
2099 2098
2100 insert_zbranch(zi, zbr, n); 2099 insert_zbranch(zi, zbr, n);
2101 2100
@@ -2171,7 +2170,7 @@ int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum,
2171 struct ubifs_znode *znode; 2170 struct ubifs_znode *znode;
2172 2171
2173 mutex_lock(&c->tnc_mutex); 2172 mutex_lock(&c->tnc_mutex);
2174 dbg_tnc("%d:%d, len %d, key %s", lnum, offs, len, DBGKEY(key)); 2173 dbg_tnck(key, "%d:%d, len %d, key ", lnum, offs, len);
2175 found = lookup_level0_dirty(c, key, &znode, &n); 2174 found = lookup_level0_dirty(c, key, &znode, &n);
2176 if (!found) { 2175 if (!found) {
2177 struct ubifs_zbranch zbr; 2176 struct ubifs_zbranch zbr;
@@ -2220,8 +2219,8 @@ int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key,
2220 struct ubifs_znode *znode; 2219 struct ubifs_znode *znode;
2221 2220
2222 mutex_lock(&c->tnc_mutex); 2221 mutex_lock(&c->tnc_mutex);
2223 dbg_tnc("old LEB %d:%d, new LEB %d:%d, len %d, key %s", old_lnum, 2222 dbg_tnck(key, "old LEB %d:%d, new LEB %d:%d, len %d, key ", old_lnum,
2224 old_offs, lnum, offs, len, DBGKEY(key)); 2223 old_offs, lnum, offs, len);
2225 found = lookup_level0_dirty(c, key, &znode, &n); 2224 found = lookup_level0_dirty(c, key, &znode, &n);
2226 if (found < 0) { 2225 if (found < 0) {
2227 err = found; 2226 err = found;
@@ -2303,8 +2302,8 @@ int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key,
2303 struct ubifs_znode *znode; 2302 struct ubifs_znode *znode;
2304 2303
2305 mutex_lock(&c->tnc_mutex); 2304 mutex_lock(&c->tnc_mutex);
2306 dbg_tnc("LEB %d:%d, name '%.*s', key %s", lnum, offs, nm->len, nm->name, 2305 dbg_tnck(key, "LEB %d:%d, name '%.*s', key ",
2307 DBGKEY(key)); 2306 lnum, offs, nm->len, nm->name);
2308 found = lookup_level0_dirty(c, key, &znode, &n); 2307 found = lookup_level0_dirty(c, key, &znode, &n);
2309 if (found < 0) { 2308 if (found < 0) {
2310 err = found; 2309 err = found;
@@ -2397,7 +2396,7 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
2397 /* Delete without merge for now */ 2396 /* Delete without merge for now */
2398 ubifs_assert(znode->level == 0); 2397 ubifs_assert(znode->level == 0);
2399 ubifs_assert(n >= 0 && n < c->fanout); 2398 ubifs_assert(n >= 0 && n < c->fanout);
2400 dbg_tnc("deleting %s", DBGKEY(&znode->zbranch[n].key)); 2399 dbg_tnck(&znode->zbranch[n].key, "deleting key ");
2401 2400
2402 zbr = &znode->zbranch[n]; 2401 zbr = &znode->zbranch[n];
2403 lnc_free(zbr); 2402 lnc_free(zbr);
@@ -2507,7 +2506,7 @@ int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key)
2507 struct ubifs_znode *znode; 2506 struct ubifs_znode *znode;
2508 2507
2509 mutex_lock(&c->tnc_mutex); 2508 mutex_lock(&c->tnc_mutex);
2510 dbg_tnc("key %s", DBGKEY(key)); 2509 dbg_tnck(key, "key ");
2511 found = lookup_level0_dirty(c, key, &znode, &n); 2510 found = lookup_level0_dirty(c, key, &znode, &n);
2512 if (found < 0) { 2511 if (found < 0) {
2513 err = found; 2512 err = found;
@@ -2538,7 +2537,7 @@ int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key,
2538 struct ubifs_znode *znode; 2537 struct ubifs_znode *znode;
2539 2538
2540 mutex_lock(&c->tnc_mutex); 2539 mutex_lock(&c->tnc_mutex);
2541 dbg_tnc("%.*s, key %s", nm->len, nm->name, DBGKEY(key)); 2540 dbg_tnck(key, "%.*s, key ", nm->len, nm->name);
2542 err = lookup_level0_dirty(c, key, &znode, &n); 2541 err = lookup_level0_dirty(c, key, &znode, &n);
2543 if (err < 0) 2542 if (err < 0)
2544 goto out_unlock; 2543 goto out_unlock;
@@ -2653,7 +2652,7 @@ int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key,
2653 dbg_dump_znode(c, znode); 2652 dbg_dump_znode(c, znode);
2654 goto out_unlock; 2653 goto out_unlock;
2655 } 2654 }
2656 dbg_tnc("removing %s", DBGKEY(key)); 2655 dbg_tnck(key, "removing key ");
2657 } 2656 }
2658 if (k) { 2657 if (k) {
2659 for (i = n + 1 + k; i < znode->child_cnt; i++) 2658 for (i = n + 1 + k; i < znode->child_cnt; i++)
@@ -2773,7 +2772,7 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
2773 struct ubifs_zbranch *zbr; 2772 struct ubifs_zbranch *zbr;
2774 union ubifs_key *dkey; 2773 union ubifs_key *dkey;
2775 2774
2776 dbg_tnc("%s %s", nm->name ? (char *)nm->name : "(lowest)", DBGKEY(key)); 2775 dbg_tnck(key, "%s ", nm->name ? (char *)nm->name : "(lowest)");
2777 ubifs_assert(is_hash_key(c, key)); 2776 ubifs_assert(is_hash_key(c, key));
2778 2777
2779 mutex_lock(&c->tnc_mutex); 2778 mutex_lock(&c->tnc_mutex);
@@ -3332,9 +3331,9 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
3332 3331
3333out_dump: 3332out_dump:
3334 block = key_block(c, key); 3333 block = key_block(c, key);
3335 ubifs_err("inode %lu has size %lld, but there are data at offset %lld " 3334 ubifs_err("inode %lu has size %lld, but there are data at offset %lld",
3336 "(data key %s)", (unsigned long)inode->i_ino, size, 3335 (unsigned long)inode->i_ino, size,
3337 ((loff_t)block) << UBIFS_BLOCK_SHIFT, DBGKEY(key)); 3336 ((loff_t)block) << UBIFS_BLOCK_SHIFT);
3338 mutex_unlock(&c->tnc_mutex); 3337 mutex_unlock(&c->tnc_mutex);
3339 dbg_dump_inode(c, inode); 3338 dbg_dump_inode(c, inode);
3340 dbg_dump_stack(); 3339 dbg_dump_stack();
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
index b48db999903e..dc28fe6ec07a 100644
--- a/fs/ubifs/tnc_misc.c
+++ b/fs/ubifs/tnc_misc.c
@@ -328,8 +328,8 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
328 case UBIFS_XENT_KEY: 328 case UBIFS_XENT_KEY:
329 break; 329 break;
330 default: 330 default:
331 dbg_msg("bad key type at slot %d: %s", i, 331 dbg_msg("bad key type at slot %d: %d",
332 DBGKEY(&zbr->key)); 332 i, key_type(c, &zbr->key));
333 err = 3; 333 err = 3;
334 goto out_dump; 334 goto out_dump;
335 } 335 }
@@ -475,7 +475,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
475 zbr->offs); 475 zbr->offs);
476 476
477 if (err) { 477 if (err) {
478 dbg_tnc("key %s", DBGKEY(key)); 478 dbg_tnck(key, "key ");
479 return err; 479 return err;
480 } 480 }
481 481
@@ -484,8 +484,8 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
484 if (!keys_eq(c, key, &key1)) { 484 if (!keys_eq(c, key, &key1)) {
485 ubifs_err("bad key in node at LEB %d:%d", 485 ubifs_err("bad key in node at LEB %d:%d",
486 zbr->lnum, zbr->offs); 486 zbr->lnum, zbr->offs);
487 dbg_tnc("looked for key %s found node's key %s", 487 dbg_tnck(key, "looked for key ");
488 DBGKEY(key), DBGKEY1(&key1)); 488 dbg_tnck(&key1, "but found node's key ");
489 dbg_dump_node(c, node); 489 dbg_dump_node(c, node);
490 return -EINVAL; 490 return -EINVAL;
491 } 491 }