2929#include <linux/crc32c.h>
3030#include <linux/slab.h>
3131#include <linux/migrate.h>
32+ #include <linux/ratelimit.h>
3233#include <asm/unaligned.h>
3334#include "compat.h"
3435#include "ctree.h"
@@ -254,14 +255,12 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
254255 memcpy (& found , result , csum_size );
255256
256257 read_extent_buffer (buf , & val , 0 , csum_size );
257- if (printk_ratelimit ()) {
258- printk (KERN_INFO "btrfs: %s checksum verify "
258+ printk_ratelimited (KERN_INFO "btrfs: %s checksum verify "
259259 "failed on %llu wanted %X found %X "
260260 "level %d\n" ,
261261 root -> fs_info -> sb -> s_id ,
262262 (unsigned long long )buf -> start , val , found ,
263263 btrfs_header_level (buf ));
264- }
265264 if (result != (char * )& inline_result )
266265 kfree (result );
267266 return 1 ;
@@ -296,13 +295,11 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
296295 ret = 0 ;
297296 goto out ;
298297 }
299- if (printk_ratelimit ()) {
300- printk ("parent transid verify failed on %llu wanted %llu "
298+ printk_ratelimited ("parent transid verify failed on %llu wanted %llu "
301299 "found %llu\n" ,
302300 (unsigned long long )eb -> start ,
303301 (unsigned long long )parent_transid ,
304302 (unsigned long long )btrfs_header_generation (eb ));
305- }
306303 ret = 1 ;
307304 clear_extent_buffer_uptodate (io_tree , eb , & cached_state );
308305out :
@@ -533,12 +530,10 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
533530
534531 found_start = btrfs_header_bytenr (eb );
535532 if (found_start != start ) {
536- if (printk_ratelimit ()) {
537- printk (KERN_INFO "btrfs bad tree block start "
533+ printk_ratelimited (KERN_INFO "btrfs bad tree block start "
538534 "%llu %llu\n" ,
539535 (unsigned long long )found_start ,
540536 (unsigned long long )eb -> start );
541- }
542537 ret = - EIO ;
543538 goto err ;
544539 }
@@ -550,10 +545,8 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
550545 goto err ;
551546 }
552547 if (check_tree_block_fsid (root , eb )) {
553- if (printk_ratelimit ()) {
554- printk (KERN_INFO "btrfs bad fsid on block %llu\n" ,
548+ printk_ratelimited (KERN_INFO "btrfs bad fsid on block %llu\n" ,
555549 (unsigned long long )eb -> start );
556- }
557550 ret = - EIO ;
558551 goto err ;
559552 }
@@ -2108,11 +2101,9 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
21082101 if (uptodate ) {
21092102 set_buffer_uptodate (bh );
21102103 } else {
2111- if (printk_ratelimit ()) {
2112- printk (KERN_WARNING "lost page write due to "
2104+ printk_ratelimited (KERN_WARNING "lost page write due to "
21132105 "I/O error on %s\n" ,
21142106 bdevname (bh -> b_bdev , b ));
2115- }
21162107 /* note, we dont' set_buffer_write_io_error because we have
21172108 * our own ways of dealing with the IO errors
21182109 */
0 commit comments