mm: swap write failure fixup
Subsystems (2)
PATCH 1/1 mm: swap write failure fixup
From: Peter Zijlstra <[email protected]>
Currently we can silently drop data if the write to swap failed. It usually doesn't result in data-corruption because on page-in the process will receive SIGBUS (assuming write-failure implies read-failure).
This assumption might or might not be valid.
This patch will avoid the page being discarded after a failed write. But will print a warning the sysadmin _should_ take to heart, if a lot of swap space becomes un-writeable, OOM is not far off.
Tested by making the write fail 'randomly' once every 50 writes or so.
--- mm/page_io.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
mm/page_io.c +15 -1
@@ -52,8 +52,22 @@ static int end_swap_bio_write(struct bioif (bio->bi_size)return 1 ; -if (!uptodate) +if (!uptodate) {SetPageError (page); +/* +* We failed to write the page out to swap-space. +* Re-dirty the page in order to avoid it being reclaimed. +* Also print a dire warning that things will go BAD (tm) +* very quickly. +* +* Also clear PG_reclaim to avoid rotate_reclaimable_page() +*/ +set_page_dirty (page); +printk (KERN_ALERT "Write-error on swap-device (%d:%d)\n" , +imajor (bio->bi_bdev->bd_inode), +iminor (bio->bi_bdev->bd_inode)); +ClearPageReclaim (page); + }end_page_writeback (page);bio_put (bio);return 0 ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[PATCH 2/1] mm: swap failure update
From: Peter Zijlstra <[email protected]>
Update the error message on write-failure to also print the bio->bi_sector. And insert an equivalent message on the read-failure path.
--- mm/page_io.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
mm/page_io.c +7 -2
@@ -63,9 +63,10 @@ static int end_swap_bio_write(struct bio* Also clear PG_reclaim to avoid rotate_reclaimable_page() */ set_page_dirty (page); -printk (KERN_ALERT "Write-error on swap-device (%d:%d)\n" , +printk (KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n" ,imajor (bio->bi_bdev->bd_inode), -iminor (bio->bi_bdev->bd_inode)); +iminor (bio->bi_bdev->bd_inode), + bio->bi_sector);ClearPageReclaim (page); }end_page_writeback (page);
@@ -84,6 +85,10 @@ static int end_swap_bio_read(struct bioif (!uptodate) {SetPageError (page);ClearPageUptodate (page); +printk (KERN_ALERT "Read-error on swap-device (%u:%u:%Lu)\n" , +imajor (bio->bi_bdev->bd_inode), +iminor (bio->bi_bdev->bd_inode), + bio->bi_sector); }else {SetPageUptodate (page); }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>