public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: Do not fallback to buffered-io for DIO atomic write
@ 2024-10-25 18:18 Ritesh Harjani (IBM)
  2024-10-25 18:31 ` Darrick J. Wong
  2024-10-28 18:39 ` Ritesh Harjani
  0 siblings, 2 replies; 3+ messages in thread
From: Ritesh Harjani (IBM) @ 2024-10-25 18:18 UTC (permalink / raw)
  To: linux-xfs
  Cc: Darrick J . Wong, Christoph Hellwig, John Garry, Ojaswin Mujoo,
	Dave Chinner, Carlos Maiolino, linux-kernel, linux-fsdevel,
	Ritesh Harjani (IBM)

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.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---

This should be on top of John's atomic write series [1].
[1]: https://lore.kernel.org/linux-xfs/20241019125113.369994-1-john.g.garry@oracle.com/

 fs/xfs/xfs_file.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index ca47cae5a40a..b819a9273511 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -876,6 +876,14 @@ xfs_file_write_iter(
 		ret = xfs_file_dio_write(iocb, from);
 		if (ret != -ENOTBLK)
 			return ret;
+		/*
+		 * 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)
+			return -EIO;
 	}

 	return xfs_file_buffered_write(iocb, from);
--
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: Do not fallback to buffered-io for DIO atomic write
  2024-10-25 18:18 [PATCH] xfs: Do not fallback to buffered-io for DIO atomic write Ritesh Harjani (IBM)
@ 2024-10-25 18:31 ` Darrick J. Wong
  2024-10-28 18:39 ` Ritesh Harjani
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2024-10-25 18:31 UTC (permalink / raw)
  To: Ritesh Harjani (IBM)
  Cc: linux-xfs, Christoph Hellwig, John Garry, Ojaswin Mujoo,
	Dave Chinner, Carlos Maiolino, linux-kernel, linux-fsdevel

On Fri, Oct 25, 2024 at 11:48:05PM +0530, 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.
> 
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
> 
> This should be on top of John's atomic write series [1].
> [1]: https://lore.kernel.org/linux-xfs/20241019125113.369994-1-john.g.garry@oracle.com/
> 
>  fs/xfs/xfs_file.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index ca47cae5a40a..b819a9273511 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -876,6 +876,14 @@ xfs_file_write_iter(
>  		ret = xfs_file_dio_write(iocb, from);
>  		if (ret != -ENOTBLK)
>  			return ret;
> +		/*
> +		 * 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)
> +			return -EIO;
>  	}
> 
>  	return xfs_file_buffered_write(iocb, from);
> --
> 2.39.5
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: Do not fallback to buffered-io for DIO atomic write
  2024-10-25 18:18 [PATCH] xfs: Do not fallback to buffered-io for DIO atomic write Ritesh Harjani (IBM)
  2024-10-25 18:31 ` Darrick J. Wong
@ 2024-10-28 18:39 ` Ritesh Harjani
  1 sibling, 0 replies; 3+ messages in thread
From: Ritesh Harjani @ 2024-10-28 18:39 UTC (permalink / raw)
  To: linux-xfs
  Cc: Darrick J . Wong, Christoph Hellwig, John Garry, Ojaswin Mujoo,
	Dave Chinner, Carlos Maiolino, linux-kernel, linux-fsdevel


We need not pick this patch up. As after the careful review of the code,
it seems XFS can never fallback to buffered-io for DIO atomic writes. 

Hence we don't need this patch. More details in [1]. 

[1]: https://lore.kernel.org/linux-xfs/cover.1729825985.git.ritesh.list@gmail.com/T/#m9dbecc11bed713ed0d7a486432c56b105b555f04

(Sorry for the noise).

"Ritesh Harjani (IBM)" <ritesh.list@gmail.com> writes:

> 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.
>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---
>
> This should be on top of John's atomic write series [1].
> [1]: https://lore.kernel.org/linux-xfs/20241019125113.369994-1-john.g.garry@oracle.com/
>
>  fs/xfs/xfs_file.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index ca47cae5a40a..b819a9273511 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -876,6 +876,14 @@ xfs_file_write_iter(
>  		ret = xfs_file_dio_write(iocb, from);
>  		if (ret != -ENOTBLK)
>  			return ret;
> +		/*
> +		 * 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)
> +			return -EIO;
>  	}
>
>  	return xfs_file_buffered_write(iocb, from);
> --
> 2.39.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-28 18:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-25 18:18 [PATCH] xfs: Do not fallback to buffered-io for DIO atomic write Ritesh Harjani (IBM)
2024-10-25 18:31 ` Darrick J. Wong
2024-10-28 18:39 ` Ritesh Harjani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox