提交 9e80d407 编写于 作者: J Jan Kara 提交者: Linus Torvalds

ext3: Avoid starting a transaction in writepage when not necessary

We don't have to start a transaction in writepage() when all the blocks
are a properly allocated. Even in ordered mode either the data has been
written via write() and they are thus already added to transaction's list
or the data was written via mmap and then it's random in which transaction
they get written anyway.

This should help VM to pageout dirty memory without blocking on transaction
commits.
Signed-off-by: NJan Kara <jack@suse.cz>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0384e295
...@@ -1435,6 +1435,10 @@ static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh) ...@@ -1435,6 +1435,10 @@ static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
return 0; return 0;
} }
static int buffer_unmapped(handle_t *handle, struct buffer_head *bh)
{
return !buffer_mapped(bh);
}
/* /*
* Note that we always start a transaction even if we're not journalling * Note that we always start a transaction even if we're not journalling
* data. This is to preserve ordering: any hole instantiation within * data. This is to preserve ordering: any hole instantiation within
...@@ -1505,6 +1509,15 @@ static int ext3_ordered_writepage(struct page *page, ...@@ -1505,6 +1509,15 @@ static int ext3_ordered_writepage(struct page *page,
if (ext3_journal_current_handle()) if (ext3_journal_current_handle())
goto out_fail; goto out_fail;
if (!page_has_buffers(page)) {
create_empty_buffers(page, inode->i_sb->s_blocksize,
(1 << BH_Dirty)|(1 << BH_Uptodate));
} else if (!walk_page_buffers(NULL, page_buffers(page), 0, PAGE_CACHE_SIZE, NULL, buffer_unmapped)) {
/* Provide NULL instead of get_block so that we catch bugs if buffers weren't really mapped */
return block_write_full_page(page, NULL, wbc);
}
page_bufs = page_buffers(page);
handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode)); handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode));
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
...@@ -1512,11 +1525,6 @@ static int ext3_ordered_writepage(struct page *page, ...@@ -1512,11 +1525,6 @@ static int ext3_ordered_writepage(struct page *page,
goto out_fail; goto out_fail;
} }
if (!page_has_buffers(page)) {
create_empty_buffers(page, inode->i_sb->s_blocksize,
(1 << BH_Dirty)|(1 << BH_Uptodate));
}
page_bufs = page_buffers(page);
walk_page_buffers(handle, page_bufs, 0, walk_page_buffers(handle, page_bufs, 0,
PAGE_CACHE_SIZE, NULL, bget_one); PAGE_CACHE_SIZE, NULL, bget_one);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册