When something let __find_get_block_slow() hit all_mapped path, it calls printk() for 100+ times per a second. But there is no need to print same message with such high frequency; it is just asking for stall warning, or at least bloating log files. [ 399.866302][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8 [ 399.873324][T15342] b_state=0x00000029, b_size=512 [ 399.878403][T15342] device loop0 blocksize: 4096 [ 399.883296][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8 [ 399.890400][T15342] b_state=0x00000029, b_size=512 [ 399.895595][T15342] device loop0 blocksize: 4096 [ 399.900556][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8 [ 399.907471][T15342] b_state=0x00000029, b_size=512 [ 399.912506][T15342] device loop0 blocksize: 4096 This patch reduces frequency to up to once per a second, in addition to concatenating three lines into one. [ 399.866302][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8, b_state=0x00000029, b_size=512, device loop0 blocksize: 4096
Unified · Split
| @@ -200,6 +200,7 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) · 199 unmodified lines | ||
| 200 | 200 | struct buffer_head *head; |
| 201 | 201 | struct page *page; |
| 202 | 202 | int all_mapped = 1; |
| 203 | + static DEFINE_RATELIMIT_STATE(last_warned, HZ, 1); | |
| 203 | 204 | |
| 204 | 205 | index = block >> (PAGE_SHIFT - bd_inode->i_blkbits); |
| 205 | 206 | page = find_get_page_flags(bd_mapping, index, FGP_ACCESSED); |
| @@ -227,15 +228,15 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) · 21 unmodified lines | ||
| 227 | 228 | * file io on the block device and getblk. It gets dealt with |
| 228 | 229 | * elsewhere, don't buffer_error if we had some unmapped buffers |
| 229 | 230 | */ |
| 230 | − if (all_mapped) { | |
| 231 | − printk("__find_get_block_slow() failed. " | |
| 232 | − "block=%llu, b_blocknr=%llu\n", | |
| 233 | − (unsigned long long)block, | |
| 234 | − (unsigned long long)bh->b_blocknr); | |
| 235 | − printk("b_state=0x%08lx, b_size=%zu\n", | |
| 236 | − bh->b_state, bh->b_size); | |
| 237 | − printk("device %pg blocksize: %d\n", bdev, | |
| 238 | − 1 << bd_inode->i_blkbits); | |
| 231 | + ratelimit_set_flags(&last_warned, RATELIMIT_MSG_ON_RELEASE); | |
| 232 | + if (all_mapped && __ratelimit(&last_warned)) { | |
| 233 | + printk("__find_get_block_slow() failed. block=%llu, " | |
| 234 | + "b_blocknr=%llu, b_state=0x%08lx, b_size=%zu, " | |
| 235 | + "device %pg blocksize: %d\n", | |
| 236 | + (unsigned long long)block, | |
| 237 | + (unsigned long long)bh->b_blocknr, | |
| 238 | + bh->b_state, bh->b_size, bdev, | |
| 239 | + 1 << bd_inode->i_blkbits); | |
| 239 | 240 | } |
| 240 | 241 | out_unlock: |
| 241 | 242 | spin_unlock(&bd_mapping->private_lock); |