mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: Zhang Yi <yi.zhang@huaweicloud.com>, <linux-ext4@vger.kernel.org>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
	<ojaswin@linux.ibm.com>, <ritesh.list@gmail.com>,
	<yi.zhang@huawei.com>, <yizhang089@gmail.com>,
	<yangerkun@huawei.com>, <yukuai@fnnas.com>
Subject: Re: [PATCH -next v2 4/7] ext4: remove useless ext4_iomap_overwrite_ops
Date: Wed, 31 Dec 2025 15:40:11 +0800	[thread overview]
Message-ID: <f290e8d7-a382-4164-a87f-731682076100@huawei.com> (raw)
In-Reply-To: <20251223011802.31238-5-yi.zhang@huaweicloud.com>

On 2025-12-23 09:17, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> 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>

Nice cleanup! Feel free to add:

Reviewed-by: Baokun Li <libaokun1@huawei.com>

> ---
>  fs/ext4/ext4.h  |  1 -
>  fs/ext4/file.c  |  5 +----
>  fs/ext4/inode.c | 24 ------------------------
>  3 files changed, 1 insertion(+), 29 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 56112f201cac..9a71357f192d 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3909,7 +3909,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)
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 9f571acc7782..6b4b68f830d5 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -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;
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index ff3ad1a2df45..b84a2a10dfb8 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3833,10 +3833,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);
>  	}
>  
> @@ -3865,30 +3861,10 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
>  	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)



  reply	other threads:[~2025-12-31  7:40 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23  1:17 [PATCH -next v2 0/7] ext4: defer unwritten splitting until I/O completion Zhang Yi
2025-12-23  1:17 ` [PATCH -next v2 1/7] ext4: use reserved metadata blocks when splitting extent on endio Zhang Yi
2025-12-31  7:34   ` Baokun Li
2026-01-03 13:42   ` Ojaswin Mujoo
2026-01-05  1:17     ` Zhang Yi
2025-12-23  1:17 ` [PATCH -next v2 2/7] ext4: don't split extent before submitting I/O Zhang Yi
2025-12-31  7:35   ` Baokun Li
2026-01-03 13:47   ` Ojaswin Mujoo
2025-12-23  1:17 ` [PATCH -next v2 3/7] ext4: avoid starting handle when dio writing an unwritten extent Zhang Yi
2025-12-31  7:36   ` Baokun Li
2026-01-03 14:06   ` Ojaswin Mujoo
2025-12-23  1:17 ` [PATCH -next v2 4/7] ext4: remove useless ext4_iomap_overwrite_ops Zhang Yi
2025-12-31  7:40   ` Baokun Li [this message]
2026-01-03 14:14   ` Ojaswin Mujoo
2025-12-23  1:18 ` [PATCH -next v2 5/7] ext4: remove unused unwritten parameter in ext4_dio_write_iter() Zhang Yi
2025-12-31  7:42   ` Baokun Li
2026-01-03 14:16   ` Ojaswin Mujoo
2025-12-23  1:18 ` [PATCH -next v2 6/7] ext4: simply the mapping query logic in ext4_iomap_begin() Zhang Yi
2025-12-31  7:46   ` Baokun Li
2026-01-03 14:17   ` Ojaswin Mujoo
2026-01-04 13:00   ` Markus Elfring
2026-01-05  1:18     ` Zhang Yi
2025-12-23  1:18 ` [PATCH -next v2 7/7] ext4: remove EXT4_GET_BLOCKS_IO_CREATE_EXT Zhang Yi
2025-12-31  7:55   ` Baokun Li
2026-01-03 14:20   ` Ojaswin Mujoo

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=f290e8d7-a382-4164-a87f-731682076100@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yi.zhang@huaweicloud.com \
    --cc=yizhang089@gmail.com \
    --cc=yukuai@fnnas.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

all inboxes | Powered by JetHome®