Commit 40c8348e authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] tag writeback pages as such in their radix tree

Arrange for under-writeback pages to be marked thus in their pagecache radix
tree.
parent 8ece6262
...@@ -1829,7 +1829,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1829,7 +1829,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
} while ((bh = bh->b_this_page) != head); } while ((bh = bh->b_this_page) != head);
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); /* Keeps try_to_free_buffers() away */ set_page_writeback(page); /* Keeps try_to_free_buffers() away */
unlock_page(page); unlock_page(page);
/* /*
...@@ -1892,7 +1892,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1892,7 +1892,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
} while ((bh = bh->b_this_page) != head); } while ((bh = bh->b_this_page) != head);
SetPageError(page); SetPageError(page);
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
do { do {
struct buffer_head *next = bh->b_this_page; struct buffer_head *next = bh->b_this_page;
......
...@@ -546,7 +546,7 @@ mpage_writepage(struct bio *bio, struct page *page, get_block_t get_block, ...@@ -546,7 +546,7 @@ mpage_writepage(struct bio *bio, struct page *page, get_block_t get_block,
} }
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
if (boundary || (first_unmapped != blocks_per_page)) { if (boundary || (first_unmapped != blocks_per_page)) {
bio = mpage_bio_submit(WRITE, bio); bio = mpage_bio_submit(WRITE, bio);
......
...@@ -768,7 +768,7 @@ nfs_write_rpcsetup(struct list_head *head, struct nfs_write_data *data, int how) ...@@ -768,7 +768,7 @@ nfs_write_rpcsetup(struct list_head *head, struct nfs_write_data *data, int how)
req = nfs_list_entry(head->next); req = nfs_list_entry(head->next);
nfs_list_remove_request(req); nfs_list_remove_request(req);
nfs_list_add_request(req, &data->pages); nfs_list_add_request(req, &data->pages);
SetPageWriteback(req->wb_page); set_page_writeback(req->wb_page);
*pages++ = req->wb_page; *pages++ = req->wb_page;
count += req->wb_bytes; count += req->wb_bytes;
} }
......
...@@ -743,7 +743,7 @@ static int ntfs_write_block(struct page *page) ...@@ -743,7 +743,7 @@ static int ntfs_write_block(struct page *page)
} }
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); /* Keeps try_to_free_buffers() away. */ set_page_writeback(page); /* Keeps try_to_free_buffers() away. */
unlock_page(page); unlock_page(page);
/* /*
...@@ -885,7 +885,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc) ...@@ -885,7 +885,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
// FIXME: Make sure it is ok to SetPageError() on unlocked page under // FIXME: Make sure it is ok to SetPageError() on unlocked page under
// writeback before doing the change! // writeback before doing the change!
#if 0 #if 0
SetPageWriteback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
#endif #endif
......
...@@ -2134,7 +2134,7 @@ static int reiserfs_write_full_page(struct page *page, struct writeback_control ...@@ -2134,7 +2134,7 @@ static int reiserfs_write_full_page(struct page *page, struct writeback_control
} while(bh != head) ; } while(bh != head) ;
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
/* /*
...@@ -2198,7 +2198,7 @@ static int reiserfs_write_full_page(struct page *page, struct writeback_control ...@@ -2198,7 +2198,7 @@ static int reiserfs_write_full_page(struct page *page, struct writeback_control
} while(bh != head); } while(bh != head);
SetPageError(page); SetPageError(page);
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
do { do {
struct buffer_head *next = bh->b_this_page; struct buffer_head *next = bh->b_this_page;
......
...@@ -566,7 +566,7 @@ xfs_submit_page( ...@@ -566,7 +566,7 @@ xfs_submit_page(
int i; int i;
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
SetPageWriteback(page); set_page_writeback(page);
clear_page_dirty(page); clear_page_dirty(page);
unlock_page(page); unlock_page(page);
......
...@@ -312,12 +312,18 @@ extern struct address_space swapper_space; ...@@ -312,12 +312,18 @@ extern struct address_space swapper_space;
struct page; /* forward declaration */ struct page; /* forward declaration */
int test_clear_page_dirty(struct page *page); int test_clear_page_dirty(struct page *page);
int __clear_page_dirty(struct page *page);
int test_clear_page_writeback(struct page *page);
int test_set_page_writeback(struct page *page);
static inline void clear_page_dirty(struct page *page) static inline void clear_page_dirty(struct page *page)
{ {
test_clear_page_dirty(page); test_clear_page_dirty(page);
} }
int __clear_page_dirty(struct page *page); static inline void set_page_writeback(struct page *page)
{
test_set_page_writeback(page);
}
#endif /* PAGE_FLAGS_H */ #endif /* PAGE_FLAGS_H */
...@@ -363,8 +363,7 @@ void end_page_writeback(struct page *page) ...@@ -363,8 +363,7 @@ void end_page_writeback(struct page *page)
wait_queue_head_t *waitqueue = page_waitqueue(page); wait_queue_head_t *waitqueue = page_waitqueue(page);
if (!TestClearPageReclaim(page) || rotate_reclaimable_page(page)) { if (!TestClearPageReclaim(page) || rotate_reclaimable_page(page)) {
smp_mb__before_clear_bit(); if (!test_clear_page_writeback(page))
if (!TestClearPageWriteback(page))
BUG(); BUG();
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
} }
......
...@@ -604,3 +604,45 @@ int __clear_page_dirty(struct page *page) ...@@ -604,3 +604,45 @@ int __clear_page_dirty(struct page *page)
} }
return TestClearPageDirty(page); return TestClearPageDirty(page);
} }
int test_clear_page_writeback(struct page *page)
{
struct address_space *mapping = page->mapping;
int ret;
if (mapping) {
unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags);
ret = TestClearPageWriteback(page);
if (ret)
radix_tree_tag_clear(&mapping->page_tree, page->index,
PAGECACHE_TAG_WRITEBACK);
spin_unlock_irqrestore(&mapping->tree_lock, flags);
} else {
ret = TestClearPageWriteback(page);
}
return ret;
}
int test_set_page_writeback(struct page *page)
{
struct address_space *mapping = page->mapping;
int ret;
if (mapping) {
unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags);
ret = TestSetPageWriteback(page);
if (!ret)
radix_tree_tag_set(&mapping->page_tree, page->index,
PAGECACHE_TAG_WRITEBACK);
spin_unlock_irqrestore(&mapping->tree_lock, flags);
} else {
ret = TestSetPageWriteback(page);
}
return ret;
}
EXPORT_SYMBOL(test_set_page_writeback);
...@@ -104,7 +104,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) ...@@ -104,7 +104,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
goto out; goto out;
} }
inc_page_state(pswpout); inc_page_state(pswpout);
SetPageWriteback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
submit_bio(WRITE, bio); submit_bio(WRITE, bio);
out: out:
......
...@@ -70,7 +70,7 @@ int rotate_reclaimable_page(struct page *page) ...@@ -70,7 +70,7 @@ int rotate_reclaimable_page(struct page *page)
list_add_tail(&page->lru, &zone->inactive_list); list_add_tail(&page->lru, &zone->inactive_list);
inc_page_state(pgrotated); inc_page_state(pgrotated);
} }
if (!TestClearPageWriteback(page)) if (!test_clear_page_writeback(page))
BUG(); BUG();
spin_unlock_irqrestore(&zone->lru_lock, flags); spin_unlock_irqrestore(&zone->lru_lock, flags);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment