diff mbox series

[v2,4/4] ext4: Do not fallback to buffered-io for DIO atomic write

Message ID 80da397c359adaf54b87999eff6a63b331cfbcfc.1729944406.git.ritesh.list@gmail.com (mailing list archive)
State Deferred, archived
Headers show
Series ext4: Add atomic writes support for DIO | expand

Commit Message

Ritesh Harjani (IBM) Oct. 27, 2024, 6:17 p.m. UTC
iomap can return -ENOTBLK if pagecache invalidation fails.
Let's make sure if -ENOTBLK is ever returned for atomic
writes than we fail the write request (-EIO) instead of
fallback to buffered-io.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 fs/ext4/file.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--
2.46.0

Comments

John Garry Oct. 29, 2024, 8:57 a.m. UTC | #1
On 27/10/2024 18:17, Ritesh Harjani (IBM) wrote:
> iomap can return -ENOTBLK if pagecache invalidation fails.
> Let's make sure if -ENOTBLK is ever returned for atomic
> writes than we fail the write request (-EIO) instead of
> fallback to buffered-io.
> 
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

I am not sure if you plan on dropping this patch...

> ---
>   fs/ext4/file.c | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 8116bd78910b..22d31b4fdff3 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -576,8 +576,18 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
>   		iomap_ops = &ext4_iomap_overwrite_ops;
>   	ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops,
>   			   dio_flags, NULL, 0);
> -	if (ret == -ENOTBLK)
> +	if (ret == -ENOTBLK) {
>   		ret = 0;
> +		/*
> +		 * iomap can return -ENOTBLK if pagecache invalidation fails.
> +		 * Let's make sure if -ENOTBLK is ever returned for atomic
> +		 * writes than we fail the write request instead of fallback
> +		 * to buffered-io.
> +		 */
> +		if (iocb->ki_flags & IOCB_ATOMIC)
> +			ret = -EIO;
> +	}
> +
>   	if (extend) {
>   		/*
>   		 * We always perform extending DIO write synchronously so by
> --
> 2.46.0
>
Ritesh Harjani (IBM) Oct. 29, 2024, 9:22 a.m. UTC | #2
John Garry <john.g.garry@oracle.com> writes:

> On 27/10/2024 18:17, Ritesh Harjani (IBM) wrote:
>> iomap can return -ENOTBLK if pagecache invalidation fails.
>> Let's make sure if -ENOTBLK is ever returned for atomic
>> writes than we fail the write request (-EIO) instead of
>> fallback to buffered-io.
>> 
>> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>
> I am not sure if you plan on dropping this patch...
>

As discussed in the other thread, EXT4 has got a fallback to buffered-io
logic at certain places including during short DIO writes unlike XFS
which never fallsback to buffered-io in case of short DIO writes.
Let me send another patch for this one.

Thanks for the review. 

-ritesh
diff mbox series

Patch

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 8116bd78910b..22d31b4fdff3 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -576,8 +576,18 @@  static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
 		iomap_ops = &ext4_iomap_overwrite_ops;
 	ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops,
 			   dio_flags, NULL, 0);
-	if (ret == -ENOTBLK)
+	if (ret == -ENOTBLK) {
 		ret = 0;
+		/*
+		 * iomap can return -ENOTBLK if pagecache invalidation fails.
+		 * Let's make sure if -ENOTBLK is ever returned for atomic
+		 * writes than we fail the write request instead of fallback
+		 * to buffered-io.
+		 */
+		if (iocb->ki_flags & IOCB_ATOMIC)
+			ret = -EIO;
+	}
+
 	if (extend) {
 		/*
 		 * We always perform extending DIO write synchronously so by