lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f290e8d7-a382-4164-a87f-731682076100@huawei.com>
Date: Wed, 31 Dec 2025 15:40:11 +0800
From: Baokun Li <libaokun1@...wei.com>
To: Zhang Yi <yi.zhang@...weicloud.com>, <linux-ext4@...r.kernel.org>
CC: <linux-fsdevel@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<tytso@....edu>, <adilger.kernel@...ger.ca>, <jack@...e.cz>,
	<ojaswin@...ux.ibm.com>, <ritesh.list@...il.com>, <yi.zhang@...wei.com>,
	<yizhang089@...il.com>, <yangerkun@...wei.com>, <yukuai@...as.com>
Subject: Re: [PATCH -next v2 4/7] ext4: remove useless
 ext4_iomap_overwrite_ops

On 2025-12-23 09:17, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@...wei.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@...wei.com>
> Reviewed-by: Jan Kara <jack@...e.cz>

Nice cleanup! Feel free to add:

Reviewed-by: Baokun Li <libaokun1@...wei.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)



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ