Commit 823e0df8 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] batched movement of lru pages in writeback

Makes mpage_writepages() move pages around on the LRU sixteen-at-a-time
rather than one-at-a-time.
parent 3aa1dc77
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/mpage.h> #include <linux/mpage.h>
#include <linux/pagevec.h>
/* /*
* The largest-sized BIO which this code will assemble, in bytes. Set this * The largest-sized BIO which this code will assemble, in bytes. Set this
...@@ -522,12 +523,14 @@ mpage_writepages(struct address_space *mapping, ...@@ -522,12 +523,14 @@ mpage_writepages(struct address_space *mapping,
sector_t last_block_in_bio = 0; sector_t last_block_in_bio = 0;
int ret = 0; int ret = 0;
int done = 0; int done = 0;
struct pagevec pvec;
int (*writepage)(struct page *); int (*writepage)(struct page *);
writepage = NULL; writepage = NULL;
if (get_block == NULL) if (get_block == NULL)
writepage = mapping->a_ops->writepage; writepage = mapping->a_ops->writepage;
pagevec_init(&pvec);
write_lock(&mapping->page_lock); write_lock(&mapping->page_lock);
list_splice_init(&mapping->dirty_pages, &mapping->io_pages); list_splice_init(&mapping->dirty_pages, &mapping->io_pages);
...@@ -557,28 +560,24 @@ mpage_writepages(struct address_space *mapping, ...@@ -557,28 +560,24 @@ mpage_writepages(struct address_space *mapping,
if (page->mapping && !PageWriteback(page) && if (page->mapping && !PageWriteback(page) &&
TestClearPageDirty(page)) { TestClearPageDirty(page)) {
/* FIXME: batch this up */
if (!PageActive(page) && PageLRU(page)) {
spin_lock(&pagemap_lru_lock);
if (!PageActive(page) && PageLRU(page)) {
list_del(&page->lru);
list_add(&page->lru, &inactive_list);
}
spin_unlock(&pagemap_lru_lock);
}
if (writepage) { if (writepage) {
ret = (*writepage)(page); ret = (*writepage)(page);
} else { } else {
bio = mpage_writepage(bio, page, get_block, bio = mpage_writepage(bio, page, get_block,
&last_block_in_bio, &ret); &last_block_in_bio, &ret);
} }
if (!PageActive(page) && PageLRU(page)) {
if (!pagevec_add(&pvec, page))
pagevec_deactivate_inactive(&pvec);
page = NULL;
}
if (ret || (nr_to_write && --(*nr_to_write) <= 0)) if (ret || (nr_to_write && --(*nr_to_write) <= 0))
done = 1; done = 1;
} else { } else {
unlock_page(page); unlock_page(page);
} }
if (page)
page_cache_release(page); page_cache_release(page);
write_lock(&mapping->page_lock); write_lock(&mapping->page_lock);
} }
...@@ -587,6 +586,7 @@ mpage_writepages(struct address_space *mapping, ...@@ -587,6 +586,7 @@ mpage_writepages(struct address_space *mapping,
*/ */
list_splice_init(&mapping->io_pages, mapping->dirty_pages.prev); list_splice_init(&mapping->io_pages, mapping->dirty_pages.prev);
write_unlock(&mapping->page_lock); write_unlock(&mapping->page_lock);
pagevec_deactivate_inactive(&pvec);
if (bio) if (bio)
mpage_bio_submit(WRITE, bio); mpage_bio_submit(WRITE, bio);
return ret; return ret;
......
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