]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix dirty page management
authorAndrew Morton <akpm@zip.com.au>
Sun, 19 May 2002 09:21:10 +0000 (02:21 -0700)
committerArnaldo Carvalho de Melo <acme@conectiva.com.br>
Sun, 19 May 2002 09:21:10 +0000 (02:21 -0700)
This fixes a bug in ext3 - when ext3 decides that it wants to fail its
writepage(), it is running SetPageDirty().  But ->writepage has just put
the page on ->clean_pages().  The page ends up dirty, on ->clean_pages
and the normal writeback paths don't know about it any more.

So run set_page_dirty() instead, to place the page back on the dirty
list.

And in move_from_swap_cache(), shuffle the page across to ->dirty_pages
so that it's eligible for writeout.  ___add_to_page_cache() forgets to
look at the page state when deciding which list to attach it to.

All SetPageDirty() callers otherwise look OK.

fs/ext3/inode.c
mm/filemap.c
mm/swap_state.c
mm/swapfile.c

index 6b52c880aa86ea47a22f86e61aa94cf3402db84a..6f764bf1eec9db983a18603f771c8afa3cbd5b82 100644 (file)
@@ -1325,7 +1325,7 @@ static int ext3_writepage(struct page *page)
 out_fail:
        
        unlock_kernel();
-       SetPageDirty(page);
+       set_page_dirty(page);
        unlock_page(page);
        return ret;
 }
index af964d8602c83feebfbdb1cac461633054637cdf..752547b2d3cbdcc361dd1a37c0e52966a42641a4 100644 (file)
@@ -425,6 +425,9 @@ void invalidate_inode_pages2(struct address_space * mapping)
  *  - activate the page so that the page stealer
  *    doesn't try to write it out over and over
  *    again.
+ *
+ * NOTE!  The livelock in fdatasync went away, due to io_pages.
+ * So this function can now call set_page_dirty().
  */
 int fail_writepage(struct page *page)
 {
index 8ada8b5ada7936cc63e05e43e20802447ce41adf..acdabaeccb4a60a4ee341e8236965586d96738d8 100644 (file)
@@ -220,8 +220,16 @@ int move_from_swap_cache(struct page *page, unsigned long index,
                page->flags &= ~(1 << PG_uptodate | 1 << PG_error |
                                 1 << PG_referenced | 1 << PG_arch_1 |
                                 1 << PG_checked);
+               /*
+                * ___add_to_page_cache puts the page on ->clean_pages,
+                * but it's dirty.  If it's on ->clean_pages, it will basically
+                * never get written out.
+                */
                SetPageDirty(page);
                ___add_to_page_cache(page, mapping, index);
+               /* fix that up */
+               list_del(&page->list);
+               list_add(&page->list, &mapping->dirty_pages);
        }
 
        write_unlock(&mapping->page_lock);
index 0c49a1481ddbd7bbdf52cf2fcccb4ddb60ffd39a..504c34fbbaf0b9d106f038e52c810f27d8240d1f 100644 (file)
@@ -311,6 +311,11 @@ int remove_exclusive_swap_page(struct page *page)
                write_lock(&swapper_space.page_lock);
                if (page_count(page) - !!PagePrivate(page) == 2) {
                        __delete_from_swap_cache(page);
+                       /*
+                        * NOTE: if/when swap gets buffer/page coherency
+                        * like other mappings, we'll need to mark the buffers
+                        * dirty here too.  set_page_dirty().
+                        */
                        SetPageDirty(page);
                        retval = 1;
                }