Re: [PATCH 5/7] add llseek_nowait support for xfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 26, 2023 at 06:26:01PM +0800, Hao Xu wrote:
> From: Hao Xu <howeyxu@xxxxxxxxxxx>
> 
> Add llseek_nowait() operation for xfs, it acts just like llseek(). The
> thing different is it delivers nowait parameter to iomap layer.
> 
> Signed-off-by: Hao Xu <howeyxu@xxxxxxxxxxx>
> ---
>  fs/xfs/xfs_file.c | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 73adc0aee2ff..cba82264221d 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1257,10 +1257,11 @@ xfs_file_readdir(
>  }
>  
>  STATIC loff_t
> -xfs_file_llseek(
> +__xfs_file_llseek(
>  	struct file	*file,
>  	loff_t		offset,
> -	int		whence)
> +	int		whence,
> +	bool		nowait)
>  {
>  	struct inode		*inode = file->f_mapping->host;
>  
> @@ -1282,6 +1283,28 @@ xfs_file_llseek(
>  	return vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
>  }
>  
> +STATIC loff_t
> +xfs_file_llseek(
> +	struct file	*file,
> +	loff_t		offset,
> +	int		whence)
> +{
> +	return __xfs_file_llseek(file, offset, whence, false);
> +}
> +
> +STATIC loff_t
> +xfs_file_llseek_nowait(
> +	struct file	*file,
> +	loff_t		offset,
> +	int		whence,
> +	bool		nowait)
> +{
> +	if (file->f_op == &xfs_file_operations)
> +		return __xfs_file_llseek(file, offset, whence, nowait);
> +	else
> +		return generic_file_llseek(file, offset, whence);
> +}
> +
>  #ifdef CONFIG_FS_DAX
>  static inline vm_fault_t
>  xfs_dax_fault(
> @@ -1442,6 +1465,7 @@ xfs_file_mmap(
>  
>  const struct file_operations xfs_file_operations = {
>  	.llseek		= xfs_file_llseek,
> +	.llseek_nowait	= xfs_file_llseek_nowait,
>  	.read_iter	= xfs_file_read_iter,
>  	.write_iter	= xfs_file_write_iter,
>  	.splice_read	= xfs_file_splice_read,
> @@ -1467,6 +1491,7 @@ const struct file_operations xfs_dir_file_operations = {
>  	.read		= generic_read_dir,
>  	.iterate_shared	= xfs_file_readdir,
>  	.llseek		= generic_file_llseek,
> +	.llseek_nowait	= xfs_file_llseek_nowait,
>  	.unlocked_ioctl	= xfs_file_ioctl,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl	= xfs_file_compat_ioctl,

This is pretty nasty. It would be far better just to change the
.llseek method than to inflict this on every filesystem for the
forseeable future.

Not that I'm a fan of passing "nowait" booleans all through the file
operations methods - that way lies madness. We use a control
structure for the IO path operations (kiocb) to hold per-call
context information, perhaps we need something similar for these
other methods that people are wanting to hook up to io_uring (e.g.
readdir) so taht we don't have to play whack-a-mole with every new
io_uring method that people want and then end up with a different
nowait solution for every method.

-Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux