[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a19bf499c10fc3d668ffee22519f3a8f62e8e307.1571647180.git.mbobrowski@mbobrowski.org>
Date: Mon, 21 Oct 2019 20:20:29 +1100
From: Matthew Bobrowski <mbobrowski@...browski.org>
To: tytso@....edu, jack@...e.cz, adilger.kernel@...ger.ca
Cc: linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
hch@...radead.org, david@...morbit.com, darrick.wong@...cle.com
Subject: [PATCH v5 11/12] ext4: reorder map->m_flags checks in
ext4_set_iomap()
For the direct I/O iomap write changes that follow in this patch
series, we need to accommodate for the case where the block mapping
flags passed to ext4_map_blocks() result in map->m_flags having both
EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits set. In order for
allocated unwritten extents to be converted correctly in the
->end_io() handler, the iomap->type must be set to IOMAP_UNWRITTEN for
cases where map->m_flags has EXT4_MAP_UNWRITTEN set. Hence the reason
why we reshuffle the conditional statement in this patch.
This change is a no-op for DAX as the block mapping flags passed to
ext4_map_blocks() when the inode IS_DAX never results in both
EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN being set at once.
Signed-off-by: Matthew Bobrowski <mbobrowski@...browski.org>
Reviewed-by: Jan Kara <jack@...e.cz>
Reviewed-by: Ritesh Harjani <riteshh@...ux.ibm.com>
---
fs/ext4/inode.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index a37112efe3fb..70ddcb9c2c1c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3428,10 +3428,19 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
iomap->length = (u64) map->m_len << blkbits;
if (map->m_flags & (EXT4_MAP_MAPPED | EXT4_MAP_UNWRITTEN)) {
- if (map->m_flags & EXT4_MAP_MAPPED)
- iomap->type = IOMAP_MAPPED;
- else if (map->m_flags & EXT4_MAP_UNWRITTEN)
+ /*
+ * Flags passed into ext4_map_blocks() for direct I/O writes
+ * can result in map->m_flags having both EXT4_MAP_MAPPED and
+ * EXT4_MAP_UNWRITTEN bits set. In order for any allocated
+ * extents to be converted to written extents correctly in the
+ * ->end_io() handler, we need to ensure that the iomap->type
+ * is set appropriately. Hence the reason why we need to check
+ * whether EXT4_MAP_UNWRITTEN is set first.
+ */
+ if (map->m_flags & EXT4_MAP_UNWRITTEN)
iomap->type = IOMAP_UNWRITTEN;
+ else if (map->m_flags & EXT4_MAP_MAPPED)
+ iomap->type = IOMAP_MAPPED;
iomap->addr = (u64) map->m_pblk << blkbits;
} else {
iomap->type = IOMAP_HOLE;
--
2.20.1
--<M>--
Powered by blists - more mailing lists