Skip to content

Commit 8d5459c

Browse files
jankaratytso
authored andcommitted
ext4: improve write performance with disabled delalloc
When delayed allocation is disabled (either through mount option or because we are running low on free space), ext4_write_begin() allocates blocks with EXT4_GET_BLOCKS_IO_CREATE_EXT flag. With this flag extent merging is disabled and since ext4_write_begin() is called for each page separately, we end up with a *lot* of 1 block extents in the extent tree and following writeback is writing 1 block at a time which results in very poor write throughput (4 MB/s instead of 200 MB/s). These days when ext4_get_block_unwritten() is used only by ext4_write_begin(), ext4_page_mkwrite() and inline data conversion, we can safely allow extent merging to happen from these paths since following writeback will happen on different boundaries anyway. So use EXT4_GET_BLOCKS_CREATE_UNRIT_EXT instead which restores the performance. Signed-off-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 15baa7d commit 8d5459c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ int ext4_get_block_unwritten(struct inode *inode, sector_t iblock,
829829
ext4_debug("ext4_get_block_unwritten: inode %lu, create flag %d\n",
830830
inode->i_ino, create);
831831
return _ext4_get_block(inode, iblock, bh_result,
832-
EXT4_GET_BLOCKS_IO_CREATE_EXT);
832+
EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT);
833833
}
834834

835835
/* Maximum number of blocks we map for direct IO at once. */

0 commit comments

Comments
 (0)