diff --git a/mm/page_io.c b/mm/page_io.c index ba05b64e5d8..d8a17a5e7b7 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -22,8 +22,15 @@ #include #include #include +#include #include +/* + * We don't need to see swap errors more than once every 1 second to know + * that a problem is occurring. + */ +#define SWAP_ERROR_LOG_RATE_MS 1000 + static struct bio *get_swap_bio(gfp_t gfp_flags, struct page *page, bio_end_io_t end_io) { @@ -47,6 +54,7 @@ void end_swap_bio_write(struct bio *bio, int err) { const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); struct page *page = bio->bi_io_vec[0].bv_page; + static unsigned long swap_error_rs_time; if (!uptodate) { SetPageError(page); @@ -59,7 +67,9 @@ void end_swap_bio_write(struct bio *bio, int err) * Also clear PG_reclaim to avoid rotate_reclaimable_page() */ set_page_dirty(page); - printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n", + if (printk_timed_ratelimit(&swap_error_rs_time, + SWAP_ERROR_LOG_RATE_MS)) + printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n", imajor(bio->bi_bdev->bd_inode), iminor(bio->bi_bdev->bd_inode), (unsigned long long)bio->bi_sector);