Fixes a bug in generic_writepages() and its cut-n-paste-cousin,
mpage_writepages().
The code was clearing PageDirty and then baling out if it discovered
the page was nder writeback. Which would cause the dirty bit to be
lost.
It's a very small window, but reversing the order so PageDirty is only
cleared when we know for-sure that IO will be started fixes it up.
lock_page(page);
- if (page->mapping && TestClearPageDirty(page) &&
- !PageWriteback(page)) {
+ if (page->mapping && !PageWriteback(page) &&
+ TestClearPageDirty(page)) {
/* FIXME: batch this up */
if (!PageActive(page) && PageLRU(page)) {
spin_lock(&pagemap_lru_lock);
lock_page(page);
/* It may have been removed from swapcache: check ->mapping */
- if (page->mapping && TestClearPageDirty(page) &&
- !PageWriteback(page)) {
+ if (page->mapping && !PageWriteback(page) &&
+ TestClearPageDirty(page)) {
/* FIXME: batch this up */
if (!PageActive(page) && PageLRU(page)) {
spin_lock(&pagemap_lru_lock);