Fix handling of write failures to swap devices.
Calling SetPageError(page) marks the data in memory as bad and processes using
the page in question will die unexpectedly. This isn't necessary as the data in the memory page is still valid, just the copy on disk isn't. This patch therefore removes this call.
Setting set_page_dirty(page) is good as the memory page will be retained and processes don't die. It will try to write out the page again soon but a second attempt at a write is probably no more likely to succeed than the first resulting in IO loops. We can do better.
This patch attempts to unuse the page in a similar manner to swapoff. If successful, mark the swap page as bad and remove it from use. If we fail to
remove all references, we fall back on set_page_dirty above which will retry the write.
If we can mark the swap page as bad, adjust the VM accounting to reflect this.
Signed-off-by: Richard Purdie <rpurdie@xxxxxxxxxxxxxx>
---
Comments and testing from people who know this area of code better than
me would be appreciated!