aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2015-10-03 10:49:23 -0400
committerTheodore Ts'o <tytso@mit.edu>2015-10-03 10:49:23 -0400
commitcccd147a57e47527ce9c27fcd5f0a1c5669d6870 (patch)
tree1cb956df150d20b0d1cf3f34fbf970b6a84561c5 /fs/ext4/inode.c
parent937d7b84dca58f2565715f2c8e52f14c3d65fb22 (diff)
ext4: optimize ext4_writepage() for attempted 4k delalloc writes
In cases where the file system block size is the same as the page size, and ext4_writepage() is asked to write out a page which is either has the unwritten bit set in the extent tree, or which does not yet have a block assigned due to delayed allocation, we can bail out early and, unlocking the page earlier and avoiding a round trip through ext4_bio_write_page() with the attendant calls to set_page_writeback() and redirty_page_for_writeback(). Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 612fbcf76b5c..c95d40658979 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1815,11 +1815,22 @@ static int ext4_writepage(struct page *page,
1815 * the page. But we may reach here when we do a journal commit via 1815 * the page. But we may reach here when we do a journal commit via
1816 * journal_submit_inode_data_buffers() and in that case we must write 1816 * journal_submit_inode_data_buffers() and in that case we must write
1817 * allocated buffers to achieve data=ordered mode guarantees. 1817 * allocated buffers to achieve data=ordered mode guarantees.
1818 *
1819 * Also, if there is only one buffer per page (the fs block
1820 * size == the page size), if one buffer needs block
1821 * allocation or needs to modify the extent tree to clear the
1822 * unwritten flag, we know that the page can't be written at
1823 * all, so we might as well refuse the write immediately.
1824 * Unfortunately if the block size != page size, we can't as
1825 * easily detect this case using ext4_walk_page_buffers(), but
1826 * for the extremely common case, this is an optimization that
1827 * skips a useless round trip through ext4_bio_write_page().
1818 */ 1828 */
1819 if (ext4_walk_page_buffers(NULL, page_bufs, 0, len, NULL, 1829 if (ext4_walk_page_buffers(NULL, page_bufs, 0, len, NULL,
1820 ext4_bh_delay_or_unwritten)) { 1830 ext4_bh_delay_or_unwritten)) {
1821 redirty_page_for_writepage(wbc, page); 1831 redirty_page_for_writepage(wbc, page);
1822 if (current->flags & PF_MEMALLOC) { 1832 if ((current->flags & PF_MEMALLOC) ||
1833 (inode->i_sb->s_blocksize == PAGE_CACHE_SIZE)) {
1823 /* 1834 /*
1824 * For memory cleaning there's no point in writing only 1835 * For memory cleaning there's no point in writing only
1825 * some buffers. So just bail out. Warn if we came here 1836 * some buffers. So just bail out. Warn if we came here