Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: clarify rate limit suppressed buffer I/O errors

When quiet_error applies rate limiting to buffer_io_error calls, what the
they apply to is unclear because the name is so generic, particularly
if the messages are interleaved with others:

[ 1936.063572] quiet_error: 664293 callbacks suppressed
[ 1936.065297] Buffer I/O error on dev sdr, logical block 257429952, lost async page write
[ 1936.067814] Buffer I/O error on dev sdr, logical block 257429953, lost async page write

Also, the function uses printk_ratelimit(), although printk.h includes a
comment advising "Please don't use... Instead use printk_ratelimited()."

Change buffer_io_error to check the BH_Quiet bit itself, drop the
printk_ratelimit call, and print using printk_ratelimited.

This makes the messages look like:

[ 387.208839] buffer_io_error: 676394 callbacks suppressed
[ 387.210693] Buffer I/O error on dev sdr, logical block 211291776, lost async page write
[ 387.213432] Buffer I/O error on dev sdr, logical block 211291777, lost async page write

Signed-off-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Robert Elliott and committed by
Jens Axboe
432f16e6 b744c2ac

+7 -16
+7 -16
fs/buffer.c
··· 128 128 page_cache_release(page); 129 129 } 130 130 131 - 132 - static int quiet_error(struct buffer_head *bh) 133 - { 134 - if (!test_bit(BH_Quiet, &bh->b_state) && printk_ratelimit()) 135 - return 0; 136 - return 1; 137 - } 138 - 139 - 140 131 static void buffer_io_error(struct buffer_head *bh, char *msg) 141 132 { 142 133 char b[BDEVNAME_SIZE]; 143 - printk(KERN_ERR "Buffer I/O error on dev %s, logical block %llu%s\n", 134 + 135 + if (!test_bit(BH_Quiet, &bh->b_state)) 136 + printk_ratelimited(KERN_ERR 137 + "Buffer I/O error on dev %s, logical block %llu%s\n", 144 138 bdevname(bh->b_bdev, b), 145 139 (unsigned long long)bh->b_blocknr, msg); 146 140 } ··· 174 180 if (uptodate) { 175 181 set_buffer_uptodate(bh); 176 182 } else { 177 - if (!quiet_error(bh)) 178 - buffer_io_error(bh, ", lost sync page write"); 183 + buffer_io_error(bh, ", lost sync page write"); 179 184 set_buffer_write_io_error(bh); 180 185 clear_buffer_uptodate(bh); 181 186 } ··· 291 298 set_buffer_uptodate(bh); 292 299 } else { 293 300 clear_buffer_uptodate(bh); 294 - if (!quiet_error(bh)) 295 - buffer_io_error(bh, ", async page read"); 301 + buffer_io_error(bh, ", async page read"); 296 302 SetPageError(page); 297 303 } 298 304 ··· 350 358 if (uptodate) { 351 359 set_buffer_uptodate(bh); 352 360 } else { 353 - if (!quiet_error(bh)) 354 - buffer_io_error(bh, ", lost async page write"); 361 + buffer_io_error(bh, ", lost async page write"); 355 362 set_bit(AS_EIO, &page->mapping->flags); 356 363 set_buffer_write_io_error(bh); 357 364 clear_buffer_uptodate(bh);