Commit fb5ffb0e160c93c3fe08ab83845eb9a2768af812
Committed by
Jan Kara
1 parent
0197195258
Exists in
master
and in
20 other branches
quota: Change quota error message to print out disk and function name
The current quota error message doesn't always print the disk name, so it is hard to identify the "bad" disk when quota error happens. This patch changes the standardized quota error message to print out disk name and function name. It also uses a combination of cpp macro and inline function to provide better type checking and to lower the text size of the message. [Jan Kara: Export __quota_error] Signed-off-by: Jiaying Zhang <jiayingz@google.com> Signed-off-by: Jan Kara <jack@suse.cz>
Showing 6 changed files with 80 additions and 70 deletions Side-by-side Diff
fs/quota/dquot.c
... | ... | @@ -132,6 +132,22 @@ |
132 | 132 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock); |
133 | 133 | EXPORT_SYMBOL(dq_data_lock); |
134 | 134 | |
135 | +void __quota_error(struct super_block *sb, const char *func, | |
136 | + const char *fmt, ...) | |
137 | +{ | |
138 | + va_list args; | |
139 | + | |
140 | + if (printk_ratelimit()) { | |
141 | + va_start(args, fmt); | |
142 | + printk(KERN_ERR "Quota error (device %s): %s: ", | |
143 | + sb->s_id, func); | |
144 | + vprintk(fmt, args); | |
145 | + printk("\n"); | |
146 | + va_end(args); | |
147 | + } | |
148 | +} | |
149 | +EXPORT_SYMBOL(__quota_error); | |
150 | + | |
135 | 151 | #if defined(CONFIG_QUOTA_DEBUG) || defined(CONFIG_PRINT_QUOTA_WARNING) |
136 | 152 | static char *quotatypes[] = INITQFNAMES; |
137 | 153 | #endif |
... | ... | @@ -705,11 +721,8 @@ |
705 | 721 | return; |
706 | 722 | #ifdef CONFIG_QUOTA_DEBUG |
707 | 723 | if (!atomic_read(&dquot->dq_count)) { |
708 | - printk("VFS: dqput: trying to free free dquot\n"); | |
709 | - printk("VFS: device %s, dquot of %s %d\n", | |
710 | - dquot->dq_sb->s_id, | |
711 | - quotatypes[dquot->dq_type], | |
712 | - dquot->dq_id); | |
724 | + quota_error(dquot->dq_sb, "trying to free free dquot of %s %d", | |
725 | + quotatypes[dquot->dq_type], dquot->dq_id); | |
713 | 726 | BUG(); |
714 | 727 | } |
715 | 728 | #endif |
... | ... | @@ -732,9 +745,9 @@ |
732 | 745 | /* Commit dquot before releasing */ |
733 | 746 | ret = dquot->dq_sb->dq_op->write_dquot(dquot); |
734 | 747 | if (ret < 0) { |
735 | - printk(KERN_ERR "VFS: cannot write quota structure on " | |
736 | - "device %s (error %d). Quota may get out of " | |
737 | - "sync!\n", dquot->dq_sb->s_id, ret); | |
748 | + quota_error(dquot->dq_sb, "Can't write quota structure" | |
749 | + " (error %d). Quota may get out of sync!", | |
750 | + ret); | |
738 | 751 | /* |
739 | 752 | * We clear dirty bit anyway, so that we avoid |
740 | 753 | * infinite loop here |
... | ... | @@ -914,9 +927,9 @@ |
914 | 927 | |
915 | 928 | #ifdef CONFIG_QUOTA_DEBUG |
916 | 929 | if (reserved) { |
917 | - printk(KERN_WARNING "VFS (%s): Writes happened before quota" | |
918 | - " was turned on thus quota information is probably " | |
919 | - "inconsistent. Please run quotacheck(8).\n", sb->s_id); | |
930 | + quota_error(sb, "Writes happened before quota was turned on " | |
931 | + "thus quota information is probably inconsistent. " | |
932 | + "Please run quotacheck(8)"); | |
920 | 933 | } |
921 | 934 | #endif |
922 | 935 | } |
... | ... | @@ -947,7 +960,9 @@ |
947 | 960 | if (dqput_blocks(dquot)) { |
948 | 961 | #ifdef CONFIG_QUOTA_DEBUG |
949 | 962 | if (atomic_read(&dquot->dq_count) != 1) |
950 | - printk(KERN_WARNING "VFS: Adding dquot with dq_count %d to dispose list.\n", atomic_read(&dquot->dq_count)); | |
963 | + quota_error(inode->i_sb, "Adding dquot with " | |
964 | + "dq_count %d to dispose list", | |
965 | + atomic_read(&dquot->dq_count)); | |
951 | 966 | #endif |
952 | 967 | spin_lock(&dq_list_lock); |
953 | 968 | /* As dquot must have currently users it can't be on |
fs/quota/quota_tree.c
... | ... | @@ -65,8 +65,7 @@ |
65 | 65 | ret = sb->s_op->quota_write(sb, info->dqi_type, buf, |
66 | 66 | info->dqi_usable_bs, blk << info->dqi_blocksize_bits); |
67 | 67 | if (ret != info->dqi_usable_bs) { |
68 | - q_warn(KERN_WARNING "VFS: dquota write failed on " | |
69 | - "dev %s\n", sb->s_id); | |
68 | + quota_error(sb, "dquota write failed"); | |
70 | 69 | if (ret >= 0) |
71 | 70 | ret = -EIO; |
72 | 71 | } |
... | ... | @@ -160,9 +159,8 @@ |
160 | 159 | dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0); |
161 | 160 | /* No matter whether write succeeds block is out of list */ |
162 | 161 | if (write_blk(info, blk, buf) < 0) |
163 | - q_warn(KERN_ERR | |
164 | - "VFS: Can't write block (%u) with free entries.\n", | |
165 | - blk); | |
162 | + quota_error(info->dqi_sb, "Can't write block (%u) " | |
163 | + "with free entries", blk); | |
166 | 164 | return 0; |
167 | 165 | out_buf: |
168 | 166 | kfree(tmpbuf); |
... | ... | @@ -252,9 +250,8 @@ |
252 | 250 | if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) { |
253 | 251 | *err = remove_free_dqentry(info, buf, blk); |
254 | 252 | if (*err < 0) { |
255 | - q_warn(KERN_ERR "VFS: find_free_dqentry(): Can't " | |
256 | - "remove block (%u) from entry free list.\n", | |
257 | - blk); | |
253 | + quota_error(dquot->dq_sb, "Can't remove block (%u) " | |
254 | + "from entry free list", blk); | |
258 | 255 | goto out_buf; |
259 | 256 | } |
260 | 257 | } |
261 | 258 | |
... | ... | @@ -268,16 +265,15 @@ |
268 | 265 | } |
269 | 266 | #ifdef __QUOTA_QT_PARANOIA |
270 | 267 | if (i == qtree_dqstr_in_blk(info)) { |
271 | - printk(KERN_ERR "VFS: find_free_dqentry(): Data block full " | |
272 | - "but it shouldn't.\n"); | |
268 | + quota_error(dquot->dq_sb, "Data block full but it shouldn't"); | |
273 | 269 | *err = -EIO; |
274 | 270 | goto out_buf; |
275 | 271 | } |
276 | 272 | #endif |
277 | 273 | *err = write_blk(info, blk, buf); |
278 | 274 | if (*err < 0) { |
279 | - q_warn(KERN_ERR "VFS: find_free_dqentry(): Can't write quota " | |
280 | - "data block %u.\n", blk); | |
275 | + quota_error(dquot->dq_sb, "Can't write quota data block %u", | |
276 | + blk); | |
281 | 277 | goto out_buf; |
282 | 278 | } |
283 | 279 | dquot->dq_off = (blk << info->dqi_blocksize_bits) + |
... | ... | @@ -311,8 +307,8 @@ |
311 | 307 | } else { |
312 | 308 | ret = read_blk(info, *treeblk, buf); |
313 | 309 | if (ret < 0) { |
314 | - q_warn(KERN_ERR "VFS: Can't read tree quota block " | |
315 | - "%u.\n", *treeblk); | |
310 | + quota_error(dquot->dq_sb, "Can't read tree quota " | |
311 | + "block %u", *treeblk); | |
316 | 312 | goto out_buf; |
317 | 313 | } |
318 | 314 | } |
... | ... | @@ -323,9 +319,9 @@ |
323 | 319 | if (depth == info->dqi_qtree_depth - 1) { |
324 | 320 | #ifdef __QUOTA_QT_PARANOIA |
325 | 321 | if (newblk) { |
326 | - printk(KERN_ERR "VFS: Inserting already present quota " | |
327 | - "entry (block %u).\n", | |
328 | - le32_to_cpu(ref[get_index(info, | |
322 | + quota_error(dquot->dq_sb, "Inserting already present " | |
323 | + "quota entry (block %u)", | |
324 | + le32_to_cpu(ref[get_index(info, | |
329 | 325 | dquot->dq_id, depth)])); |
330 | 326 | ret = -EIO; |
331 | 327 | goto out_buf; |
... | ... | @@ -373,8 +369,8 @@ |
373 | 369 | if (!dquot->dq_off) { |
374 | 370 | ret = dq_insert_tree(info, dquot); |
375 | 371 | if (ret < 0) { |
376 | - q_warn(KERN_ERR "VFS: Error %zd occurred while " | |
377 | - "creating quota.\n", ret); | |
372 | + quota_error(sb, "Error %zd occurred while creating " | |
373 | + "quota", ret); | |
378 | 374 | kfree(ddquot); |
379 | 375 | return ret; |
380 | 376 | } |
... | ... | @@ -385,8 +381,7 @@ |
385 | 381 | ret = sb->s_op->quota_write(sb, type, ddquot, info->dqi_entry_size, |
386 | 382 | dquot->dq_off); |
387 | 383 | if (ret != info->dqi_entry_size) { |
388 | - q_warn(KERN_WARNING "VFS: dquota write failed on dev %s\n", | |
389 | - sb->s_id); | |
384 | + quota_error(sb, "dquota write failed"); | |
390 | 385 | if (ret >= 0) |
391 | 386 | ret = -ENOSPC; |
392 | 387 | } else { |
393 | 388 | |
... | ... | @@ -410,14 +405,15 @@ |
410 | 405 | if (!buf) |
411 | 406 | return -ENOMEM; |
412 | 407 | if (dquot->dq_off >> info->dqi_blocksize_bits != blk) { |
413 | - q_warn(KERN_ERR "VFS: Quota structure has offset to other " | |
414 | - "block (%u) than it should (%u).\n", blk, | |
415 | - (uint)(dquot->dq_off >> info->dqi_blocksize_bits)); | |
408 | + quota_error(dquot->dq_sb, "Quota structure has offset to " | |
409 | + "other block (%u) than it should (%u)", blk, | |
410 | + (uint)(dquot->dq_off >> info->dqi_blocksize_bits)); | |
416 | 411 | goto out_buf; |
417 | 412 | } |
418 | 413 | ret = read_blk(info, blk, buf); |
419 | 414 | if (ret < 0) { |
420 | - q_warn(KERN_ERR "VFS: Can't read quota data block %u\n", blk); | |
415 | + quota_error(dquot->dq_sb, "Can't read quota data block %u", | |
416 | + blk); | |
421 | 417 | goto out_buf; |
422 | 418 | } |
423 | 419 | dh = (struct qt_disk_dqdbheader *)buf; |
... | ... | @@ -427,8 +423,8 @@ |
427 | 423 | if (ret >= 0) |
428 | 424 | ret = put_free_dqblk(info, buf, blk); |
429 | 425 | if (ret < 0) { |
430 | - q_warn(KERN_ERR "VFS: Can't move quota data block (%u) " | |
431 | - "to free list.\n", blk); | |
426 | + quota_error(dquot->dq_sb, "Can't move quota data block " | |
427 | + "(%u) to free list", blk); | |
432 | 428 | goto out_buf; |
433 | 429 | } |
434 | 430 | } else { |
435 | 431 | |
... | ... | @@ -440,15 +436,15 @@ |
440 | 436 | /* Insert will write block itself */ |
441 | 437 | ret = insert_free_dqentry(info, buf, blk); |
442 | 438 | if (ret < 0) { |
443 | - q_warn(KERN_ERR "VFS: Can't insert quota data " | |
444 | - "block (%u) to free entry list.\n", blk); | |
439 | + quota_error(dquot->dq_sb, "Can't insert quota " | |
440 | + "data block (%u) to free entry list", blk); | |
445 | 441 | goto out_buf; |
446 | 442 | } |
447 | 443 | } else { |
448 | 444 | ret = write_blk(info, blk, buf); |
449 | 445 | if (ret < 0) { |
450 | - q_warn(KERN_ERR "VFS: Can't write quota data " | |
451 | - "block %u\n", blk); | |
446 | + quota_error(dquot->dq_sb, "Can't write quota " | |
447 | + "data block %u", blk); | |
452 | 448 | goto out_buf; |
453 | 449 | } |
454 | 450 | } |
... | ... | @@ -472,7 +468,8 @@ |
472 | 468 | return -ENOMEM; |
473 | 469 | ret = read_blk(info, *blk, buf); |
474 | 470 | if (ret < 0) { |
475 | - q_warn(KERN_ERR "VFS: Can't read quota data block %u\n", *blk); | |
471 | + quota_error(dquot->dq_sb, "Can't read quota data " | |
472 | + "block %u", blk); | |
476 | 473 | goto out_buf; |
477 | 474 | } |
478 | 475 | newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); |
... | ... | @@ -496,8 +493,8 @@ |
496 | 493 | } else { |
497 | 494 | ret = write_blk(info, *blk, buf); |
498 | 495 | if (ret < 0) |
499 | - q_warn(KERN_ERR "VFS: Can't write quota tree " | |
500 | - "block %u.\n", *blk); | |
496 | + quota_error(dquot->dq_sb, "Can't write quota " | |
497 | + "tree block %u", blk); | |
501 | 498 | } |
502 | 499 | } |
503 | 500 | out_buf: |
... | ... | @@ -529,7 +526,8 @@ |
529 | 526 | return -ENOMEM; |
530 | 527 | ret = read_blk(info, blk, buf); |
531 | 528 | if (ret < 0) { |
532 | - q_warn(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); | |
529 | + quota_error(dquot->dq_sb, "Can't read quota tree " | |
530 | + "block %u", blk); | |
533 | 531 | goto out_buf; |
534 | 532 | } |
535 | 533 | ddquot = buf + sizeof(struct qt_disk_dqdbheader); |
... | ... | @@ -539,8 +537,8 @@ |
539 | 537 | ddquot += info->dqi_entry_size; |
540 | 538 | } |
541 | 539 | if (i == qtree_dqstr_in_blk(info)) { |
542 | - q_warn(KERN_ERR "VFS: Quota for id %u referenced " | |
543 | - "but not present.\n", dquot->dq_id); | |
540 | + quota_error(dquot->dq_sb, "Quota for id %u referenced " | |
541 | + "but not present", dquot->dq_id); | |
544 | 542 | ret = -EIO; |
545 | 543 | goto out_buf; |
546 | 544 | } else { |
... | ... | @@ -564,7 +562,8 @@ |
564 | 562 | return -ENOMEM; |
565 | 563 | ret = read_blk(info, blk, buf); |
566 | 564 | if (ret < 0) { |
567 | - q_warn(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk); | |
565 | + quota_error(dquot->dq_sb, "Can't read quota tree block %u", | |
566 | + blk); | |
568 | 567 | goto out_buf; |
569 | 568 | } |
570 | 569 | ret = 0; |
... | ... | @@ -598,7 +597,7 @@ |
598 | 597 | #ifdef __QUOTA_QT_PARANOIA |
599 | 598 | /* Invalidated quota? */ |
600 | 599 | if (!sb_dqopt(dquot->dq_sb)->files[type]) { |
601 | - printk(KERN_ERR "VFS: Quota invalidated while reading!\n"); | |
600 | + quota_error(sb, "Quota invalidated while reading!"); | |
602 | 601 | return -EIO; |
603 | 602 | } |
604 | 603 | #endif |
... | ... | @@ -607,8 +606,8 @@ |
607 | 606 | offset = find_dqentry(info, dquot); |
608 | 607 | if (offset <= 0) { /* Entry not present? */ |
609 | 608 | if (offset < 0) |
610 | - q_warn(KERN_ERR "VFS: Can't read quota " | |
611 | - "structure for id %u.\n", dquot->dq_id); | |
609 | + quota_error(sb, "Can't read quota structure " | |
610 | + "for id %u", dquot->dq_id); | |
612 | 611 | dquot->dq_off = 0; |
613 | 612 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
614 | 613 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); |
... | ... | @@ -625,8 +624,8 @@ |
625 | 624 | if (ret != info->dqi_entry_size) { |
626 | 625 | if (ret >= 0) |
627 | 626 | ret = -EIO; |
628 | - q_warn(KERN_ERR "VFS: Error while reading quota " | |
629 | - "structure for id %u.\n", dquot->dq_id); | |
627 | + quota_error(sb, "Error while reading quota structure for id %u", | |
628 | + dquot->dq_id); | |
630 | 629 | set_bit(DQ_FAKE_B, &dquot->dq_flags); |
631 | 630 | memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk)); |
632 | 631 | kfree(ddquot); |
fs/quota/quota_tree.h
fs/quota/quota_v1.c
... | ... | @@ -95,8 +95,7 @@ |
95 | 95 | (char *)&dqblk, sizeof(struct v1_disk_dqblk), |
96 | 96 | v1_dqoff(dquot->dq_id)); |
97 | 97 | if (ret != sizeof(struct v1_disk_dqblk)) { |
98 | - printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", | |
99 | - dquot->dq_sb->s_id); | |
98 | + quota_error(dquot->dq_sb, "dquota write failed"); | |
100 | 99 | if (ret >= 0) |
101 | 100 | ret = -EIO; |
102 | 101 | goto out; |
fs/quota/quota_v2.c
... | ... | @@ -63,9 +63,8 @@ |
63 | 63 | size = sb->s_op->quota_read(sb, type, (char *)dqhead, |
64 | 64 | sizeof(struct v2_disk_dqheader), 0); |
65 | 65 | if (size != sizeof(struct v2_disk_dqheader)) { |
66 | - q_warn(KERN_WARNING "quota_v2: Failed header read:" | |
67 | - " expected=%zd got=%zd\n", | |
68 | - sizeof(struct v2_disk_dqheader), size); | |
66 | + quota_error(sb, "Failed header read: expected=%zd got=%zd", | |
67 | + sizeof(struct v2_disk_dqheader), size); | |
69 | 68 | return 0; |
70 | 69 | } |
71 | 70 | return 1; |
... | ... | @@ -106,8 +105,7 @@ |
106 | 105 | size = sb->s_op->quota_read(sb, type, (char *)&dinfo, |
107 | 106 | sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); |
108 | 107 | if (size != sizeof(struct v2_disk_dqinfo)) { |
109 | - q_warn(KERN_WARNING "quota_v2: Can't read info structure on device %s.\n", | |
110 | - sb->s_id); | |
108 | + quota_error(sb, "Can't read info structure"); | |
111 | 109 | return -1; |
112 | 110 | } |
113 | 111 | info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS); |
... | ... | @@ -167,8 +165,7 @@ |
167 | 165 | size = sb->s_op->quota_write(sb, type, (char *)&dinfo, |
168 | 166 | sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); |
169 | 167 | if (size != sizeof(struct v2_disk_dqinfo)) { |
170 | - q_warn(KERN_WARNING "Can't write info structure on device %s.\n", | |
171 | - sb->s_id); | |
168 | + quota_error(sb, "Can't write info structure"); | |
172 | 169 | return -1; |
173 | 170 | } |
174 | 171 | return 0; |
include/linux/quotaops.h
... | ... | @@ -28,6 +28,12 @@ |
28 | 28 | |
29 | 29 | #if defined(CONFIG_QUOTA) |
30 | 30 | |
31 | +#define quota_error(sb, fmt, args...) \ | |
32 | + __quota_error((sb), __func__, fmt , ## args) | |
33 | + | |
34 | +extern void __quota_error(struct super_block *sb, const char *func, | |
35 | + const char *fmt, ...); | |
36 | + | |
31 | 37 | /* |
32 | 38 | * declaration of quota_function calls in kernel. |
33 | 39 | */ |