]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4: remove useless ext4_iomap_overwrite_ops
authorZhang Yi <yi.zhang@huawei.com>
Mon, 5 Jan 2026 01:45:19 +0000 (09:45 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2026 03:28:30 +0000 (22:28 -0500)
ext4_iomap_overwrite_ops was introduced in commit 8cd115bdda17 ("ext4:
Optimize ext4 DIO overwrites"), which can optimize pure overwrite
performance by dropping the IOMAP_WRITE flag to only query the mapped
mapping information. This avoids starting a new journal handle, thereby
improving speed. Later, commit 9faac62d4013 ("ext4: optimize file
overwrites") also optimized similar scenarios, but it performs the check
later, examining the mappings status only when the actual block mapping
is needed. Thus, it can handle the previous commit scenario. That means
in the case of an overwrite scenario, the condition
"offset + length <= i_size_read(inode)" in the write path must always be
true.

Therefore, it is acceptable to remove the ext4_iomap_overwrite_ops,
which will also clarify the write and read paths of ext4_iomap_begin.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://patch.msgid.link/20260105014522.1937690-5-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/file.c
fs/ext4/inode.c

index 046706c1f01fe0a02fbf685ab24f8d61088e175a..146d694beb02d2d1001c379fbf40c1dae23f1ec0 100644 (file)
@@ -3911,7 +3911,6 @@ static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end)
 }
 
 extern const struct iomap_ops ext4_iomap_ops;
-extern const struct iomap_ops ext4_iomap_overwrite_ops;
 extern const struct iomap_ops ext4_iomap_report_ops;
 
 static inline int ext4_buffer_uptodate(struct buffer_head *bh)
index 4fadc476d64568b85380248cefb3dbeea67e8a1d..43a24c776bf05c0db79bb5f0e3c5f12173b6f519 100644 (file)
@@ -506,7 +506,6 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
        struct inode *inode = file_inode(iocb->ki_filp);
        loff_t offset = iocb->ki_pos;
        size_t count = iov_iter_count(from);
-       const struct iomap_ops *iomap_ops = &ext4_iomap_ops;
        bool extend = false, unwritten = false;
        bool ilock_shared = true;
        int dio_flags = 0;
@@ -573,9 +572,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
                        goto out;
        }
 
-       if (ilock_shared && !unwritten)
-               iomap_ops = &ext4_iomap_overwrite_ops;
-       ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops,
+       ret = iomap_dio_rw(iocb, from, &ext4_iomap_ops, &ext4_dio_write_ops,
                           dio_flags, NULL, 0);
        if (ret == -ENOTBLK)
                ret = 0;
index 1cb7775c5e41ea11090451f63d956b9f4da8f222..f346302709b9b01df9e53cc3d2b36b6d2faa7a12 100644 (file)
@@ -3829,10 +3829,6 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
                }
                ret = ext4_iomap_alloc(inode, &map, flags);
        } else {
-               /*
-                * This can be called for overwrites path from
-                * ext4_iomap_overwrite_begin().
-                */
                ret = ext4_map_blocks(NULL, inode, &map, 0);
        }
 
@@ -3861,30 +3857,10 @@ out:
        return 0;
 }
 
-static int ext4_iomap_overwrite_begin(struct inode *inode, loff_t offset,
-               loff_t length, unsigned flags, struct iomap *iomap,
-               struct iomap *srcmap)
-{
-       int ret;
-
-       /*
-        * Even for writes we don't need to allocate blocks, so just pretend
-        * we are reading to save overhead of starting a transaction.
-        */
-       flags &= ~IOMAP_WRITE;
-       ret = ext4_iomap_begin(inode, offset, length, flags, iomap, srcmap);
-       WARN_ON_ONCE(!ret && iomap->type != IOMAP_MAPPED);
-       return ret;
-}
-
 const struct iomap_ops ext4_iomap_ops = {
        .iomap_begin            = ext4_iomap_begin,
 };
 
-const struct iomap_ops ext4_iomap_overwrite_ops = {
-       .iomap_begin            = ext4_iomap_overwrite_begin,
-};
-
 static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,
                                   loff_t length, unsigned int flags,
                                   struct iomap *iomap, struct iomap *srcmap)