Skip to content

Commit

Permalink
ext3: Try to avoid starting a transaction in writepage for data=write…
Browse files Browse the repository at this point in the history
…page

This does the same as commit 9e80d40
(avoid starting a transaction when no block allocation is needed)
but for data=writeback mode of ext3. We also cleanup the data=ordered
case a bit to stick to coding style...

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Jan Kara authored and Theodore Ts'o committed Apr 8, 2009
1 parent 6e34eed commit 430db32
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,12 +1521,16 @@ static int ext3_ordered_writepage(struct page *page,
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);
} else {
page_bufs = page_buffers(page);
if (!walk_page_buffers(NULL, page_bufs, 0, PAGE_CACHE_SIZE,
NULL, buffer_unmapped)) {
/* Provide NULL get_block() to 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));

if (IS_ERR(handle)) {
Expand Down Expand Up @@ -1581,6 +1585,15 @@ static int ext3_writeback_writepage(struct page *page,
if (ext3_journal_current_handle())
goto out_fail;

if (page_has_buffers(page)) {
if (!walk_page_buffers(NULL, page_buffers(page), 0,
PAGE_CACHE_SIZE, NULL, buffer_unmapped)) {
/* Provide NULL get_block() to catch bugs if buffers
* weren't really mapped */
return block_write_full_page(page, NULL, wbc);
}
}

handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode));
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
Expand Down

0 comments on commit 430db32

Please sign in to comment.