Commit 2b388c67906ee8cd3bf1a600a7023cd0807d414f

Authored by Joel Becker
Committed by Mark Fasheh
1 parent e7515d065d

ocfs2: Compile-time disabling of ocfs2 debugging output.

Give gcc the chance to compile out the debug logging code in ocfs2.
This saves some size at the expense of being able to debug the code.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

Showing 4 changed files with 35 additions and 7 deletions Side-by-side Diff

... ... @@ -356,6 +356,16 @@
356 356 - POSIX ACLs
357 357 - readpages / writepages (not user visible)
358 358  
  359 +config OCFS2_DEBUG_MASKLOG
  360 + bool "OCFS2 logging support"
  361 + depends on OCFS2_FS
  362 + default y
  363 + help
  364 + The ocfs2 filesystem has an extensive logging system. The system
  365 + allows selection of events to log via files in /sys/o2cb/logmask/.
  366 + This option will enlarge your kernel, but it allows debugging of
  367 + ocfs2 filesystem issues.
  368 +
359 369 config MINIX_FS
360 370 tristate "Minix fs support"
361 371 help
fs/ocfs2/cluster/masklog.h
... ... @@ -123,6 +123,17 @@
123 123 #define MLOG_MASK_PREFIX 0
124 124 #endif
125 125  
  126 +/*
  127 + * When logging is disabled, force the bit test to 0 for anything other
  128 + * than errors and notices, allowing gcc to remove the code completely.
  129 + * When enabled, allow all masks.
  130 + */
  131 +#if defined(CONFIG_OCFS2_DEBUG_MASKLOG)
  132 +#define ML_ALLOWED_BITS ~0
  133 +#else
  134 +#define ML_ALLOWED_BITS (ML_ERROR|ML_NOTICE)
  135 +#endif
  136 +
126 137 #define MLOG_MAX_BITS 64
127 138  
128 139 struct mlog_bits {
... ... @@ -187,7 +198,8 @@
187 198  
188 199 #define mlog(mask, fmt, args...) do { \
189 200 u64 __m = MLOG_MASK_PREFIX | (mask); \
190   - if (__mlog_test_u64(__m, mlog_and_bits) && \
  201 + if ((__m & ML_ALLOWED_BITS) && \
  202 + __mlog_test_u64(__m, mlog_and_bits) && \
191 203 !__mlog_test_u64(__m, mlog_not_bits)) { \
192 204 if (__m & ML_ERROR) \
193 205 __mlog_printk(KERN_ERR, "ERROR: "fmt , ##args); \
... ... @@ -204,6 +216,7 @@
204 216 mlog(ML_ERROR, "status = %lld\n", (long long)_st); \
205 217 } while (0)
206 218  
  219 +#if defined(CONFIG_OCFS2_DEBUG_MASKLOG)
207 220 #define mlog_entry(fmt, args...) do { \
208 221 mlog(ML_ENTRY, "ENTRY:" fmt , ##args); \
209 222 } while (0)
... ... @@ -247,6 +260,13 @@
247 260 #define mlog_exit_void() do { \
248 261 mlog(ML_EXIT, "EXIT\n"); \
249 262 } while (0)
  263 +#else
  264 +#define mlog_entry(...) do { } while (0)
  265 +#define mlog_entry_void(...) do { } while (0)
  266 +#define mlog_exit(...) do { } while (0)
  267 +#define mlog_exit_ptr(...) do { } while (0)
  268 +#define mlog_exit_void(...) do { } while (0)
  269 +#endif /* defined(CONFIG_OCFS2_DEBUG_MASKLOG) */
250 270  
251 271 #define mlog_bug_on_msg(cond, fmt, args...) do { \
252 272 if (cond) { \
... ... @@ -213,11 +213,9 @@
213 213 struct ocfs2_dir_entry **dirent)
214 214 {
215 215 int status = -ENOENT;
216   - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
217 216  
218   - mlog_entry("(osb=%p, parent=%llu, name='%.*s', blkno=%p, inode=%p)\n",
219   - osb, (unsigned long long)OCFS2_I(inode)->ip_blkno,
220   - namelen, name, blkno, inode);
  217 + mlog_entry("(name=%.*s, blkno=%p, inode=%p, dirent_bh=%p, dirent=%p)\n",
  218 + namelen, name, blkno, inode, dirent_bh, dirent);
221 219  
222 220 *dirent_bh = ocfs2_find_entry(name, namelen, inode, dirent);
223 221 if (!*dirent_bh || !*dirent) {
... ... @@ -46,12 +46,12 @@
46 46 unsigned long address,
47 47 int *type)
48 48 {
49   - struct inode *inode = area->vm_file->f_dentry->d_inode;
50 49 struct page *page = NOPAGE_SIGBUS;
51 50 sigset_t blocked, oldset;
52 51 int ret;
53 52  
54   - mlog_entry("(inode %lu, address %lu)\n", inode->i_ino, address);
  53 + mlog_entry("(area=%p, address=%lu, type=%p)\n", area, address,
  54 + type);
55 55  
56 56 /* The best way to deal with signals in this path is
57 57 * to block them upfront, rather than allowing the