Commit 05937baa authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] __block_write_full_page speedup

Remove all those get_bh()'s and put_bh()'s by extending lock_page() to cover
the troublesome regions.

(get_bh() and put_bh() happen every time whereas contention on a page's lock
in there happens basically never).

Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ad576e63
...@@ -1826,7 +1826,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1826,7 +1826,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
} }
if (test_clear_buffer_dirty(bh)) { if (test_clear_buffer_dirty(bh)) {
mark_buffer_async_write(bh); mark_buffer_async_write(bh);
get_bh(bh);
last_bh = bh; last_bh = bh;
} else { } else {
unlock_buffer(bh); unlock_buffer(bh);
...@@ -1839,20 +1838,19 @@ static int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1839,20 +1838,19 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
*/ */
BUG_ON(PageWriteback(page)); BUG_ON(PageWriteback(page));
set_page_writeback(page); set_page_writeback(page);
unlock_page(page);
do { do {
struct buffer_head *next = bh->b_this_page; struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) { if (buffer_async_write(bh)) {
submit_bh(WRITE, bh); submit_bh(WRITE, bh);
nr_underway++; nr_underway++;
put_bh(bh);
if (bh == last_bh) if (bh == last_bh)
break; break;
} }
bh = next; bh = next;
} while (bh != head); } while (bh != head);
bh = head; bh = head;
unlock_page(page);
err = 0; err = 0;
done: done:
...@@ -1894,7 +1892,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1894,7 +1892,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
if (buffer_mapped(bh) && buffer_dirty(bh)) { if (buffer_mapped(bh) && buffer_dirty(bh)) {
lock_buffer(bh); lock_buffer(bh);
mark_buffer_async_write(bh); mark_buffer_async_write(bh);
get_bh(bh);
last_bh = bh; last_bh = bh;
} else { } else {
/* /*
...@@ -1914,7 +1911,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1914,7 +1911,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
clear_buffer_dirty(bh); clear_buffer_dirty(bh);
submit_bh(WRITE, bh); submit_bh(WRITE, bh);
nr_underway++; nr_underway++;
put_bh(bh);
if (bh == last_bh) if (bh == last_bh)
break; break;
} }
......
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