Commit 7f5cd470 authored by Zhang Yi's avatar Zhang Yi
Browse files

ext4: don't mark IOMAP_F_DIRTY for buffer write

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9DN5Z


CVE: NA

--------------------------------

The data sync dirty check in ext4_inode_datasync_dirty() is expansive
since jbd2_transaction_committed() holds journal->j_state lock when
journal is enabled, it costs a lot in high-concurrency iomap buffered
read/write paths, but we never check IOMAP_F_DIRTY in these cases, so
let's check it only in swap file, dax and direct IO cases. Tested by
Unixbench on 100GB ramdisk:

./Run -c 128 -i 10 fstime fsbuffer fsdisk

  == without this patch ==
  128 CPUs in system; running 128 parallel copies of tests

  File Copy 1024 bufsize 2000 maxblocks       6332521.0 KBps
  File Copy 256 bufsize 500 maxblocks         1639726.0 KBps
  File Copy 4096 bufsize 8000 maxblocks      24018572.0 KBps

  == with this patch ==
  128 CPUs in system; running 128 parallel copies of tests

  File Copy 1024 bufsize 2000 maxblocks      49229257.0 KBps
  File Copy 256 bufsize 500 maxblocks        24057510.0 KBps
  File Copy 4096 bufsize 8000 maxblocks      75704437.0 KBps

Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
parent 7f4075f0
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -3312,9 +3312,13 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
	 * there is no other metadata changes being made or are pending.
	 */
	iomap->flags = 0;
	if (ext4_inode_datasync_dirty(inode) ||
	    offset + length > i_size_read(inode))
	if ((flags & (IOMAP_DAX | IOMAP_REPORT)) ||
	    ((flags & (IOMAP_WRITE | IOMAP_DIRECT)) ==
	     (IOMAP_WRITE | IOMAP_DIRECT))) {
		if (offset + length > i_size_read(inode) ||
		    ext4_inode_datasync_dirty(inode))
			iomap->flags |= IOMAP_F_DIRTY;
	}

	if (map->m_flags & EXT4_MAP_NEW)
		iomap->flags |= IOMAP_F_NEW;