* [PATCH] mm: swap write failure fixup
@ 2006-07-27 13:01 Peter Zijlstra
2006-07-31 7:56 ` [PATCH 2/1] mm: swap failure update Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: Peter Zijlstra @ 2006-07-27 13:01 UTC (permalink / raw)
To: linux-mm; +Cc: Andrew Morton
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
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.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
mm/page_io.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
Index: linux-2.6/mm/page_io.c
===================================================================
--- linux-2.6.orig/mm/page_io.c
+++ linux-2.6/mm/page_io.c
@@ -52,8 +52,22 @@ static int end_swap_bio_write(struct bio
if (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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 2/1] mm: swap failure update
2006-07-27 13:01 [PATCH] mm: swap write failure fixup Peter Zijlstra
@ 2006-07-31 7:56 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2006-07-31 7:56 UTC (permalink / raw)
To: linux-mm; +Cc: Andrew Morton
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Update the error message on write-failure to also print the bio->bi_sector.
And insert an equivalent message on the read-failure path.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
mm/page_io.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
Index: linux-2.6/mm/page_io.c
===================================================================
--- linux-2.6.orig/mm/page_io.c
+++ linux-2.6/mm/page_io.c
@@ -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 bio
if (!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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-07-31 7:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-27 13:01 [PATCH] mm: swap write failure fixup Peter Zijlstra
2006-07-31 7:56 ` [PATCH 2/1] mm: swap failure update Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox