public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Yang Erkun <yangerkun@huawei.com>
To: linux-ext4@vger.kernel.org, tytso@mit.edu,
	adilger.kernel@dilger.ca, jack@suse.cz
Cc: yi.zhang@huawei.com, libaokun1@huawei.com, yangerkun@huawei.com,
	yangerkun@huaweicloud.com
Subject: [PATCH v2 4/4] ext4: order mode should not take effect for DIO
Date: Tue,  4 Nov 2025 21:17:50 +0800	[thread overview]
Message-ID: <20251104131750.1581541-4-yangerkun@huawei.com> (raw)
In-Reply-To: <20251104131750.1581541-1-yangerkun@huawei.com>

Since the size will be updated after the DIO completes, the data
will not be shown to userspace before that.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Signed-off-by: Yang Erkun <yangerkun@huawei.com>
---
 fs/ext4/ext4.h              | 2 ++
 fs/ext4/inode.c             | 5 +++--
 include/trace/events/ext4.h | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 96d7d649ccb0..d0331697467d 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -715,6 +715,8 @@ enum {
 #define EXT4_GET_BLOCKS_METADATA_NOFAIL		0x0020
 	/* Don't normalize allocation size (used for fallocate) */
 #define EXT4_GET_BLOCKS_NO_NORMALIZE		0x0040
+	/* Get blocks from DIO */
+#define EXT4_GET_BLOCKS_DIO			0x0080
 	/* Convert written extents to unwritten */
 #define EXT4_GET_BLOCKS_CONVERT_UNWRITTEN	0x0100
 	/* Write zeros to newly created written extents */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3d8ada26d5cd..168dbcc9e921 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -818,6 +818,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 		if (map->m_flags & EXT4_MAP_NEW &&
 		    !(map->m_flags & EXT4_MAP_UNWRITTEN) &&
 		    !(flags & EXT4_GET_BLOCKS_ZERO) &&
+		    !(flags & EXT4_GET_BLOCKS_DIO) &&
 		    !ext4_is_quota_file(inode) &&
 		    ext4_should_order_data(inode)) {
 			loff_t start_byte =
@@ -3729,9 +3730,9 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
 	 * happening and thus expose allocated blocks to direct I/O reads.
 	 */
 	else if (((loff_t)map->m_lblk << blkbits) >= i_size_read(inode))
-		m_flags = EXT4_GET_BLOCKS_CREATE;
+		m_flags = EXT4_GET_BLOCKS_CREATE | EXT4_GET_BLOCKS_DIO;
 	else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-		m_flags = EXT4_GET_BLOCKS_IO_CREATE_EXT;
+		m_flags = EXT4_GET_BLOCKS_IO_CREATE_EXT | EXT4_GET_BLOCKS_DIO;
 
 	if (flags & IOMAP_ATOMIC)
 		ret = ext4_map_blocks_atomic_write(handle, inode, map, m_flags,
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index ada2b9223df5..de6d848f2e37 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -43,6 +43,7 @@ struct partial_cluster;
 	{ EXT4_GET_BLOCKS_CONVERT,		"CONVERT" },		\
 	{ EXT4_GET_BLOCKS_METADATA_NOFAIL,	"METADATA_NOFAIL" },	\
 	{ EXT4_GET_BLOCKS_NO_NORMALIZE,		"NO_NORMALIZE" },	\
+	{ EXT4_GET_BLOCKS_DIO,			"DIO" },		\
 	{ EXT4_GET_BLOCKS_CONVERT_UNWRITTEN,	"CONVERT_UNWRITTEN" },  \
 	{ EXT4_GET_BLOCKS_ZERO,			"ZERO" },		\
 	{ EXT4_GET_BLOCKS_IO_SUBMIT,		"IO_SUBMIT" },		\
-- 
2.39.2


  parent reply	other threads:[~2025-11-04 13:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04 13:17 [PATCH v2 1/4] ext4: remove useless code in ext4_map_create_blocks Yang Erkun
2025-11-04 13:17 ` [PATCH v2 2/4] ext4: rename EXT4_GET_BLOCKS_PRE_IO Yang Erkun
2025-11-04 14:06   ` Zhang Yi
2025-11-04 14:32   ` Jan Kara
2025-11-04 13:17 ` [PATCH v2 3/4] ext4: cleanup for ext4_map_blocks Yang Erkun
2025-11-04 14:36   ` Jan Kara
2025-11-04 13:17 ` Yang Erkun [this message]
2025-11-04 15:07   ` [PATCH v2 4/4] ext4: order mode should not take effect for DIO Jan Kara
2025-11-07 11:54     ` yangerkun
2025-11-04 14:28 ` [PATCH v2 1/4] ext4: remove useless code in ext4_map_create_blocks Jan Kara
2025-11-05  1:39   ` yangerkun
2025-11-05 10:20     ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251104131750.1581541-4-yangerkun@huawei.com \
    --to=yangerkun@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=libaokun1@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huaweicloud.com \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox