All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read
@ 2020-01-15 13:46 Christoph Hellwig
  2020-01-15 14:33 ` Carlos Maiolino
  2020-01-15 17:12 ` Darrick J. Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-01-15 13:46 UTC (permalink / raw)
  To: linux-xfs

Direct I/O reads can also be used with RWF_NOWAIT & co.  Fix the inode
locking in xfs_file_dio_aio_read to take IOCB_NOWAIT into account.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---

Resending standalone to get a little more attention.

 fs/xfs/xfs_file.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index c93250108952..b8a4a3f29b36 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -187,7 +187,12 @@ xfs_file_dio_aio_read(
 
 	file_accessed(iocb->ki_filp);
 
-	xfs_ilock(ip, XFS_IOLOCK_SHARED);
+	if (iocb->ki_flags & IOCB_NOWAIT) {
+		if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
+			return -EAGAIN;
+	} else {
+		xfs_ilock(ip, XFS_IOLOCK_SHARED);
+	}
 	ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL,
 			is_sync_kiocb(iocb));
 	xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-- 
2.24.1


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

* Re: [PATCH] xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read
  2020-01-15 13:46 [PATCH] xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read Christoph Hellwig
@ 2020-01-15 14:33 ` Carlos Maiolino
  2020-01-15 17:12 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos Maiolino @ 2020-01-15 14:33 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Wed, Jan 15, 2020 at 02:46:53PM +0100, Christoph Hellwig wrote:
> Direct I/O reads can also be used with RWF_NOWAIT & co.  Fix the inode
> locking in xfs_file_dio_aio_read to take IOCB_NOWAIT into account.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> Resending standalone to get a little more attention.
> 
>  fs/xfs/xfs_file.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index c93250108952..b8a4a3f29b36 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -187,7 +187,12 @@ xfs_file_dio_aio_read(
>  
>  	file_accessed(iocb->ki_filp);
>  
> -	xfs_ilock(ip, XFS_IOLOCK_SHARED);
> +	if (iocb->ki_flags & IOCB_NOWAIT) {
> +		if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
> +			return -EAGAIN;
> +	} else {
> +		xfs_ilock(ip, XFS_IOLOCK_SHARED);
> +	}
>  	ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL,
>  			is_sync_kiocb(iocb));
>  	xfs_iunlock(ip, XFS_IOLOCK_SHARED);
> 

Looks good to me.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

-- 
Carlos


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

* Re: [PATCH] xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read
  2020-01-15 13:46 [PATCH] xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read Christoph Hellwig
  2020-01-15 14:33 ` Carlos Maiolino
@ 2020-01-15 17:12 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-01-15 17:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Wed, Jan 15, 2020 at 02:46:53PM +0100, Christoph Hellwig wrote:
> Direct I/O reads can also be used with RWF_NOWAIT & co.  Fix the inode
> locking in xfs_file_dio_aio_read to take IOCB_NOWAIT into account.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> Resending standalone to get a little more attention.
> 
>  fs/xfs/xfs_file.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index c93250108952..b8a4a3f29b36 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -187,7 +187,12 @@ xfs_file_dio_aio_read(
>  
>  	file_accessed(iocb->ki_filp);
>  
> -	xfs_ilock(ip, XFS_IOLOCK_SHARED);
> +	if (iocb->ki_flags & IOCB_NOWAIT) {
> +		if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
> +			return -EAGAIN;
> +	} else {
> +		xfs_ilock(ip, XFS_IOLOCK_SHARED);
> +	}

/me really wishes we had a better way to do this than to open-code this
idiom over and over and over again in every fs.  Unfortunately I know of
no way to accomplish that without macros(!) so this will have to do:

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  	ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL,
>  			is_sync_kiocb(iocb));
>  	xfs_iunlock(ip, XFS_IOLOCK_SHARED);
> -- 
> 2.24.1
> 

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

end of thread, other threads:[~2020-01-15 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 13:46 [PATCH] xfs: fix IOCB_NOWAIT handling in xfs_file_dio_aio_read Christoph Hellwig
2020-01-15 14:33 ` Carlos Maiolino
2020-01-15 17:12 ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.