aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-01-13 05:33:53 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-01-13 05:50:42 -0500
commit515315a123af641a9533e4ff0f178c470dc08fc7 (patch)
tree1a215c3df46286d7ff878cd86517818404758900 /fs/ubifs
parentbeba006074e7170d3bc91470c8a6c914730d4c63 (diff)
UBIFS: fix key printing
Before commit 56e46742e846e4de167dde0e1e1071ace1c882a5 we have had locking around all printing macros and we could use static buffers for creating key strings and printing them. However, now we do not have that locking and we cannot use static buffers. This commit removes the old DBGKEY() macros and introduces few new helper macros for printing debugging messages plus a key at the end. Thankfully, all the messages are already structures in a way that the key is printed in the end. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/debug.c60
-rw-r--r--fs/ubifs/debug.h39
-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
6 files changed, 91 insertions, 88 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 6ae9fdcd2020..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 snprintf_key(const struct ubifs_info *c, const union ubifs_key *key, 103const char *dbg_snprintf_key(const struct ubifs_info *c,
107 char *buffer, int len) 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);
@@ -139,20 +136,7 @@ static void snprintf_key(const struct ubifs_info *c, const union ubifs_key *key,
139 } else 136 } else
140 len -= snprintf(p, len, "bad key format %d", c->key_fmt); 137 len -= snprintf(p, len, "bad key format %d", c->key_fmt);
141 ubifs_assert(len > 0); 138 ubifs_assert(len > 0);
142} 139 return p;
143
144const char *dbg_key_str0(const struct ubifs_info *c, const union ubifs_key *key)
145{
146 /* dbg_lock must be held */
147 snprintf_key(c, key, dbg_key_buf0, sizeof(dbg_key_buf0) - 1);
148 return dbg_key_buf0;
149}
150
151const char *dbg_key_str1(const struct ubifs_info *c, const union ubifs_key *key)
152{
153 /* dbg_lock must be held */
154 snprintf_key(c, key, dbg_key_buf1, sizeof(dbg_key_buf1) - 1);
155 return dbg_key_buf1;
156} 140}
157 141
158const char *dbg_ntype(int type) 142const char *dbg_ntype(int type)
@@ -321,6 +305,7 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
321 int i, n; 305 int i, n;
322 union ubifs_key key; 306 union ubifs_key key;
323 const struct ubifs_ch *ch = node; 307 const struct ubifs_ch *ch = node;
308 char key_buf[DBG_KEY_BUF_LEN];
324 309
325 if (dbg_is_tst_rcvry(c)) 310 if (dbg_is_tst_rcvry(c))
326 return; 311 return;
@@ -476,7 +461,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
476 const struct ubifs_ino_node *ino = node; 461 const struct ubifs_ino_node *ino = node;
477 462
478 key_read(c, &ino->key, &key); 463 key_read(c, &ino->key, &key);
479 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));
480 printk(KERN_DEBUG "\tcreat_sqnum %llu\n", 466 printk(KERN_DEBUG "\tcreat_sqnum %llu\n",
481 (unsigned long long)le64_to_cpu(ino->creat_sqnum)); 467 (unsigned long long)le64_to_cpu(ino->creat_sqnum));
482 printk(KERN_DEBUG "\tsize %llu\n", 468 printk(KERN_DEBUG "\tsize %llu\n",
@@ -519,7 +505,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
519 int nlen = le16_to_cpu(dent->nlen); 505 int nlen = le16_to_cpu(dent->nlen);
520 506
521 key_read(c, &dent->key, &key); 507 key_read(c, &dent->key, &key);
522 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));
523 printk(KERN_DEBUG "\tinum %llu\n", 510 printk(KERN_DEBUG "\tinum %llu\n",
524 (unsigned long long)le64_to_cpu(dent->inum)); 511 (unsigned long long)le64_to_cpu(dent->inum));
525 printk(KERN_DEBUG "\ttype %d\n", (int)dent->type); 512 printk(KERN_DEBUG "\ttype %d\n", (int)dent->type);
@@ -543,7 +530,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
543 int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ; 530 int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ;
544 531
545 key_read(c, &dn->key, &key); 532 key_read(c, &dn->key, &key);
546 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));
547 printk(KERN_DEBUG "\tsize %u\n", 535 printk(KERN_DEBUG "\tsize %u\n",
548 le32_to_cpu(dn->size)); 536 le32_to_cpu(dn->size));
549 printk(KERN_DEBUG "\tcompr_typ %d\n", 537 printk(KERN_DEBUG "\tcompr_typ %d\n",
@@ -584,7 +572,9 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
584 key_read(c, &br->key, &key); 572 key_read(c, &br->key, &key);
585 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",
586 i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs), 574 i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs),
587 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));
588 } 578 }
589 break; 579 break;
590 } 580 }
@@ -936,6 +926,7 @@ void dbg_dump_znode(const struct ubifs_info *c,
936{ 926{
937 int n; 927 int n;
938 const struct ubifs_zbranch *zbr; 928 const struct ubifs_zbranch *zbr;
929 char key_buf[DBG_KEY_BUF_LEN];
939 930
940 spin_lock(&dbg_lock); 931 spin_lock(&dbg_lock);
941 if (znode->parent) 932 if (znode->parent)
@@ -960,12 +951,16 @@ void dbg_dump_znode(const struct ubifs_info *c,
960 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 "
961 "%s\n", n, zbr->znode, zbr->lnum, 952 "%s\n", n, zbr->znode, zbr->lnum,
962 zbr->offs, zbr->len, 953 zbr->offs, zbr->len,
963 DBGKEY(&zbr->key)); 954 dbg_snprintf_key(c, &zbr->key,
955 key_buf,
956 DBG_KEY_BUF_LEN));
964 else 957 else
965 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 "
966 "%s\n", n, zbr->znode, zbr->lnum, 959 "%s\n", n, zbr->znode, zbr->lnum,
967 zbr->offs, zbr->len, 960 zbr->offs, zbr->len,
968 DBGKEY(&zbr->key)); 961 dbg_snprintf_key(c, &zbr->key,
962 key_buf,
963 DBG_KEY_BUF_LEN));
969 } 964 }
970 spin_unlock(&dbg_lock); 965 spin_unlock(&dbg_lock);
971} 966}
@@ -1262,6 +1257,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1262 int err, nlen1, nlen2, cmp; 1257 int err, nlen1, nlen2, cmp;
1263 struct ubifs_dent_node *dent1, *dent2; 1258 struct ubifs_dent_node *dent1, *dent2;
1264 union ubifs_key key; 1259 union ubifs_key key;
1260 char key_buf[DBG_KEY_BUF_LEN];
1265 1261
1266 ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key)); 1262 ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key));
1267 dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS); 1263 dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS);
@@ -1292,9 +1288,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1292 key_read(c, &dent1->key, &key); 1288 key_read(c, &dent1->key, &key);
1293 if (keys_cmp(c, &zbr1->key, &key)) { 1289 if (keys_cmp(c, &zbr1->key, &key)) {
1294 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,
1295 zbr1->offs, DBGKEY(&key)); 1291 zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
1292 DBG_KEY_BUF_LEN));
1296 dbg_err("but it should have key %s according to tnc", 1293 dbg_err("but it should have key %s according to tnc",
1297 DBGKEY(&zbr1->key)); 1294 dbg_snprintf_key(c, &zbr1->key, key_buf,
1295 DBG_KEY_BUF_LEN));
1298 dbg_dump_node(c, dent1); 1296 dbg_dump_node(c, dent1);
1299 goto out_free; 1297 goto out_free;
1300 } 1298 }
@@ -1302,9 +1300,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1302 key_read(c, &dent2->key, &key); 1300 key_read(c, &dent2->key, &key);
1303 if (keys_cmp(c, &zbr2->key, &key)) { 1301 if (keys_cmp(c, &zbr2->key, &key)) {
1304 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,
1305 zbr1->offs, DBGKEY(&key)); 1303 zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
1304 DBG_KEY_BUF_LEN));
1306 dbg_err("but it should have key %s according to tnc", 1305 dbg_err("but it should have key %s according to tnc",
1307 DBGKEY(&zbr2->key)); 1306 dbg_snprintf_key(c, &zbr2->key, key_buf,
1307 DBG_KEY_BUF_LEN));
1308 dbg_dump_node(c, dent2); 1308 dbg_dump_node(c, dent2);
1309 goto out_free; 1309 goto out_free;
1310 } 1310 }
@@ -1321,7 +1321,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1321 dbg_err("2 xent/dent nodes with the same name"); 1321 dbg_err("2 xent/dent nodes with the same name");
1322 else 1322 else
1323 dbg_err("bad order of colliding key %s", 1323 dbg_err("bad order of colliding key %s",
1324 DBGKEY(&key)); 1324 dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
1325 1325
1326 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);
1327 dbg_dump_node(c, dent1); 1327 dbg_dump_node(c, dent1);
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index c9d294111a53..307ab1d23f75 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -169,41 +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,
173 const union ubifs_key *key);
174const char *dbg_key_str1(const struct ubifs_info *c,
175 const union ubifs_key *key);
176
177/*
178 * TODO: these macros are now broken because there is no locking around them
179 * and we use a global buffer for the key string. This means that in case of
180 * concurrent execution we will end up with incorrect and messy key strings.
181 */
182#define DBGKEY(key) dbg_key_str0(c, (key))
183#define DBGKEY1(key) dbg_key_str1(c, (key))
184
185extern spinlock_t dbg_lock;
186
187#define ubifs_dbg_msg(type, fmt, ...) \ 172#define ubifs_dbg_msg(type, fmt, ...) \
188 pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__) 173 pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__)
189 174
175#define DBG_KEY_BUF_LEN 32
176#define ubifs_dbg_msg_key(type, key, fmt, ...) do { \
177 char __tmp_key_buf[DBG_KEY_BUF_LEN]; \
178 pr_debug("UBIFS DBG " type ": " fmt "%s\n", ##__VA_ARGS__, \
179 dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN)); \
180} while (0)
181
190/* Just a debugging messages not related to any specific UBIFS subsystem */ 182/* Just a debugging messages not related to any specific UBIFS subsystem */
191#define dbg_msg(fmt, ...) \ 183#define dbg_msg(fmt, ...) \
192 printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \ 184 printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \
193 __func__, ##__VA_ARGS__) 185 __func__, ##__VA_ARGS__)
194 186
195/* General messages */ 187/* General messages */
196#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__) 188#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
197/* Additional journal messages */ 189/* Additional journal messages */
198#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__)
199/* Additional TNC messages */ 193/* Additional TNC messages */
200#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__)
201/* Additional lprops messages */ 197/* Additional lprops messages */
202#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__) 198#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
203/* Additional LEB find messages */ 199/* Additional LEB find messages */
204#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__) 200#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
205/* Additional mount messages */ 201/* Additional mount messages */
206#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__)
207/* Additional I/O messages */ 205/* Additional I/O messages */
208#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__) 206#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
209/* Additional commit messages */ 207/* Additional commit messages */
@@ -219,6 +217,7 @@ extern spinlock_t dbg_lock;
219/* Additional recovery messages */ 217/* Additional recovery messages */
220#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) 218#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
221 219
220extern spinlock_t dbg_lock;
222extern struct ubifs_global_debug_info ubifs_dbg; 221extern struct ubifs_global_debug_info ubifs_dbg;
223 222
224static inline int dbg_is_chk_gen(const struct ubifs_info *c) 223static inline int dbg_is_chk_gen(const struct ubifs_info *c)
@@ -259,6 +258,8 @@ const char *dbg_cstate(int cmt_state);
259const char *dbg_jhead(int jhead); 258const char *dbg_jhead(int jhead);
260const char *dbg_get_key_dump(const struct ubifs_info *c, 259const char *dbg_get_key_dump(const struct ubifs_info *c,
261 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);
262void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode); 263void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode);
263void dbg_dump_node(const struct ubifs_info *c, const void *node); 264void dbg_dump_node(const struct ubifs_info *c, const void *node);
264void 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,
@@ -369,6 +370,10 @@ static inline const char *dbg_jhead(int jhead) { return ""; }
369static inline const char * 370static inline const char *
370dbg_get_key_dump(const struct ubifs_info *c, 371dbg_get_key_dump(const struct ubifs_info *c,
371 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 ""; }
372static inline void dbg_dump_inode(struct ubifs_info *c, 377static inline void dbg_dump_inode(struct ubifs_info *c,
373 const struct inode *inode) { return; } 378 const struct inode *inode) { return; }
374static 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 066738647685..cbd6dd310987 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -506,7 +506,7 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
506{ 506{
507 int ret; 507 int ret;
508 508
509 dbg_tnc("LEB %d:%d, key %s", zbr->lnum, zbr->offs, DBGKEY(key)); 509 dbg_tnck(key, "LEB %d:%d, key ", zbr->lnum, zbr->offs);
510 510
511 ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum, 511 ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum,
512 zbr->offs); 512 zbr->offs);
@@ -520,8 +520,8 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
520 ret = 0; 520 ret = 0;
521 } 521 }
522 if (ret == 0 && c->replaying) 522 if (ret == 0 && c->replaying)
523 dbg_mnt("dangling branch LEB %d:%d len %d, key %s", 523 dbg_mntk(key, "dangling branch LEB %d:%d len %d, key ",
524 zbr->lnum, zbr->offs, zbr->len, DBGKEY(key)); 524 zbr->lnum, zbr->offs, zbr->len);
525 return ret; 525 return ret;
526} 526}
527 527
@@ -996,9 +996,9 @@ static int fallible_resolve_collision(struct ubifs_info *c,
996 if (adding || !o_znode) 996 if (adding || !o_znode)
997 return 0; 997 return 0;
998 998
999 dbg_mnt("dangling match LEB %d:%d len %d %s", 999 dbg_mntk(key, "dangling match LEB %d:%d len %d key ",
1000 o_znode->zbranch[o_n].lnum, o_znode->zbranch[o_n].offs, 1000 o_znode->zbranch[o_n].lnum, o_znode->zbranch[o_n].offs,
1001 o_znode->zbranch[o_n].len, DBGKEY(key)); 1001 o_znode->zbranch[o_n].len);
1002 *zn = o_znode; 1002 *zn = o_znode;
1003 *n = o_n; 1003 *n = o_n;
1004 return 1; 1004 return 1;
@@ -1180,7 +1180,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key,
1180 struct ubifs_znode *znode; 1180 struct ubifs_znode *znode;
1181 unsigned long time = get_seconds(); 1181 unsigned long time = get_seconds();
1182 1182
1183 dbg_tnc("search key %s", DBGKEY(key)); 1183 dbg_tnck(key, "search key ");
1184 ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); 1184 ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY);
1185 1185
1186 znode = c->zroot.znode; 1186 znode = c->zroot.znode;
@@ -1316,7 +1316,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key,
1316 struct ubifs_znode *znode; 1316 struct ubifs_znode *znode;
1317 unsigned long time = get_seconds(); 1317 unsigned long time = get_seconds();
1318 1318
1319 dbg_tnc("search and dirty key %s", DBGKEY(key)); 1319 dbg_tnck(key, "search and dirty key ");
1320 1320
1321 znode = c->zroot.znode; 1321 znode = c->zroot.znode;
1322 if (unlikely(!znode)) { 1322 if (unlikely(!znode)) {
@@ -1723,8 +1723,8 @@ static int validate_data_node(struct ubifs_info *c, void *buf,
1723 if (!keys_eq(c, &zbr->key, &key1)) { 1723 if (!keys_eq(c, &zbr->key, &key1)) {
1724 ubifs_err("bad key in node at LEB %d:%d", 1724 ubifs_err("bad key in node at LEB %d:%d",
1725 zbr->lnum, zbr->offs); 1725 zbr->lnum, zbr->offs);
1726 dbg_tnc("looked for key %s found node's key %s", 1726 dbg_tnck(&zbr->key, "looked for key ");
1727 DBGKEY(&zbr->key), DBGKEY1(&key1)); 1727 dbg_tnck(&key1, "found node's key ");
1728 goto out_err; 1728 goto out_err;
1729 } 1729 }
1730 1730
@@ -1777,7 +1777,7 @@ int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu)
1777 ubifs_err("failed to read from LEB %d:%d, error %d", 1777 ubifs_err("failed to read from LEB %d:%d, error %d",
1778 lnum, offs, err); 1778 lnum, offs, err);
1779 dbg_dump_stack(); 1779 dbg_dump_stack();
1780 dbg_tnc("key %s", DBGKEY(&bu->key)); 1780 dbg_tnck(&bu->key, "key ");
1781 return err; 1781 return err;
1782 } 1782 }
1783 1783
@@ -1812,7 +1812,7 @@ static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key,
1812 int found, n, err; 1812 int found, n, err;
1813 struct ubifs_znode *znode; 1813 struct ubifs_znode *znode;
1814 1814
1815 dbg_tnc("name '%.*s' key %s", nm->len, nm->name, DBGKEY(key)); 1815 dbg_tnck(key, "name '%.*s' key ", nm->len, nm->name);
1816 mutex_lock(&c->tnc_mutex); 1816 mutex_lock(&c->tnc_mutex);
1817 found = ubifs_lookup_level0(c, key, &znode, &n); 1817 found = ubifs_lookup_level0(c, key, &znode, &n);
1818 if (!found) { 1818 if (!found) {
@@ -1986,8 +1986,7 @@ again:
1986 zp = znode->parent; 1986 zp = znode->parent;
1987 if (znode->child_cnt < c->fanout) { 1987 if (znode->child_cnt < c->fanout) {
1988 ubifs_assert(n != c->fanout); 1988 ubifs_assert(n != c->fanout);
1989 dbg_tnc("inserted at %d level %d, key %s", n, znode->level, 1989 dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level);
1990 DBGKEY(key));
1991 1990
1992 insert_zbranch(znode, zbr, n); 1991 insert_zbranch(znode, zbr, n);
1993 1992
@@ -2002,7 +2001,7 @@ again:
2002 * Unfortunately, @znode does not have more empty slots and we have to 2001 * Unfortunately, @znode does not have more empty slots and we have to
2003 * split it. 2002 * split it.
2004 */ 2003 */
2005 dbg_tnc("splitting level %d, key %s", znode->level, DBGKEY(key)); 2004 dbg_tnck(key, "splitting level %d, key ", znode->level);
2006 2005
2007 if (znode->alt) 2006 if (znode->alt)
2008 /* 2007 /*
@@ -2096,7 +2095,7 @@ do_split:
2096 } 2095 }
2097 2096
2098 /* Insert new key and branch */ 2097 /* Insert new key and branch */
2099 dbg_tnc("inserting at %d level %d, key %s", n, zn->level, DBGKEY(key)); 2098 dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level);
2100 2099
2101 insert_zbranch(zi, zbr, n); 2100 insert_zbranch(zi, zbr, n);
2102 2101
@@ -2172,7 +2171,7 @@ int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum,
2172 struct ubifs_znode *znode; 2171 struct ubifs_znode *znode;
2173 2172
2174 mutex_lock(&c->tnc_mutex); 2173 mutex_lock(&c->tnc_mutex);
2175 dbg_tnc("%d:%d, len %d, key %s", lnum, offs, len, DBGKEY(key)); 2174 dbg_tnck(key, "%d:%d, len %d, key ", lnum, offs, len);
2176 found = lookup_level0_dirty(c, key, &znode, &n); 2175 found = lookup_level0_dirty(c, key, &znode, &n);
2177 if (!found) { 2176 if (!found) {
2178 struct ubifs_zbranch zbr; 2177 struct ubifs_zbranch zbr;
@@ -2221,8 +2220,8 @@ int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key,
2221 struct ubifs_znode *znode; 2220 struct ubifs_znode *znode;
2222 2221
2223 mutex_lock(&c->tnc_mutex); 2222 mutex_lock(&c->tnc_mutex);
2224 dbg_tnc("old LEB %d:%d, new LEB %d:%d, len %d, key %s", old_lnum, 2223 dbg_tnck(key, "old LEB %d:%d, new LEB %d:%d, len %d, key ", old_lnum,
2225 old_offs, lnum, offs, len, DBGKEY(key)); 2224 old_offs, lnum, offs, len);
2226 found = lookup_level0_dirty(c, key, &znode, &n); 2225 found = lookup_level0_dirty(c, key, &znode, &n);
2227 if (found < 0) { 2226 if (found < 0) {
2228 err = found; 2227 err = found;
@@ -2304,8 +2303,8 @@ int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key,
2304 struct ubifs_znode *znode; 2303 struct ubifs_znode *znode;
2305 2304
2306 mutex_lock(&c->tnc_mutex); 2305 mutex_lock(&c->tnc_mutex);
2307 dbg_tnc("LEB %d:%d, name '%.*s', key %s", lnum, offs, nm->len, nm->name, 2306 dbg_tnck(key, "LEB %d:%d, name '%.*s', key ",
2308 DBGKEY(key)); 2307 lnum, offs, nm->len, nm->name);
2309 found = lookup_level0_dirty(c, key, &znode, &n); 2308 found = lookup_level0_dirty(c, key, &znode, &n);
2310 if (found < 0) { 2309 if (found < 0) {
2311 err = found; 2310 err = found;
@@ -2398,7 +2397,7 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
2398 /* Delete without merge for now */ 2397 /* Delete without merge for now */
2399 ubifs_assert(znode->level == 0); 2398 ubifs_assert(znode->level == 0);
2400 ubifs_assert(n >= 0 && n < c->fanout); 2399 ubifs_assert(n >= 0 && n < c->fanout);
2401 dbg_tnc("deleting %s", DBGKEY(&znode->zbranch[n].key)); 2400 dbg_tnck(&znode->zbranch[n].key, "deleting key ");
2402 2401
2403 zbr = &znode->zbranch[n]; 2402 zbr = &znode->zbranch[n];
2404 lnc_free(zbr); 2403 lnc_free(zbr);
@@ -2508,7 +2507,7 @@ int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key)
2508 struct ubifs_znode *znode; 2507 struct ubifs_znode *znode;
2509 2508
2510 mutex_lock(&c->tnc_mutex); 2509 mutex_lock(&c->tnc_mutex);
2511 dbg_tnc("key %s", DBGKEY(key)); 2510 dbg_tnck(key, "key ");
2512 found = lookup_level0_dirty(c, key, &znode, &n); 2511 found = lookup_level0_dirty(c, key, &znode, &n);
2513 if (found < 0) { 2512 if (found < 0) {
2514 err = found; 2513 err = found;
@@ -2539,7 +2538,7 @@ int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key,
2539 struct ubifs_znode *znode; 2538 struct ubifs_znode *znode;
2540 2539
2541 mutex_lock(&c->tnc_mutex); 2540 mutex_lock(&c->tnc_mutex);
2542 dbg_tnc("%.*s, key %s", nm->len, nm->name, DBGKEY(key)); 2541 dbg_tnck(key, "%.*s, key ", nm->len, nm->name);
2543 err = lookup_level0_dirty(c, key, &znode, &n); 2542 err = lookup_level0_dirty(c, key, &znode, &n);
2544 if (err < 0) 2543 if (err < 0)
2545 goto out_unlock; 2544 goto out_unlock;
@@ -2654,7 +2653,7 @@ int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key,
2654 dbg_dump_znode(c, znode); 2653 dbg_dump_znode(c, znode);
2655 goto out_unlock; 2654 goto out_unlock;
2656 } 2655 }
2657 dbg_tnc("removing %s", DBGKEY(key)); 2656 dbg_tnck(key, "removing key ");
2658 } 2657 }
2659 if (k) { 2658 if (k) {
2660 for (i = n + 1 + k; i < znode->child_cnt; i++) 2659 for (i = n + 1 + k; i < znode->child_cnt; i++)
@@ -2774,7 +2773,7 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
2774 struct ubifs_zbranch *zbr; 2773 struct ubifs_zbranch *zbr;
2775 union ubifs_key *dkey; 2774 union ubifs_key *dkey;
2776 2775
2777 dbg_tnc("%s %s", nm->name ? (char *)nm->name : "(lowest)", DBGKEY(key)); 2776 dbg_tnck(key, "%s ", nm->name ? (char *)nm->name : "(lowest)");
2778 ubifs_assert(is_hash_key(c, key)); 2777 ubifs_assert(is_hash_key(c, key));
2779 2778
2780 mutex_lock(&c->tnc_mutex); 2779 mutex_lock(&c->tnc_mutex);
@@ -3333,9 +3332,9 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
3333 3332
3334out_dump: 3333out_dump:
3335 block = key_block(c, key); 3334 block = key_block(c, key);
3336 ubifs_err("inode %lu has size %lld, but there are data at offset %lld " 3335 ubifs_err("inode %lu has size %lld, but there are data at offset %lld",
3337 "(data key %s)", (unsigned long)inode->i_ino, size, 3336 (unsigned long)inode->i_ino, size,
3338 ((loff_t)block) << UBIFS_BLOCK_SHIFT, DBGKEY(key)); 3337 ((loff_t)block) << UBIFS_BLOCK_SHIFT);
3339 mutex_unlock(&c->tnc_mutex); 3338 mutex_unlock(&c->tnc_mutex);
3340 dbg_dump_inode(c, inode); 3339 dbg_dump_inode(c, inode);
3341 dbg_dump_stack(); 3340 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 }