aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/debug.h
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/debug.h
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/debug.h')
-rw-r--r--fs/ubifs/debug.h39
1 files changed, 22 insertions, 17 deletions
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,