[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZMGaqsDTe4oDCdAZ@dread.disaster.area>
Date: Thu, 27 Jul 2023 08:14:02 +1000
From: Dave Chinner <david@...morbit.com>
To: Hao Xu <hao.xu@...ux.dev>
Cc: io-uring@...r.kernel.org, Jens Axboe <axboe@...nel.dk>,
Dominique Martinet <asmadeus@...ewreck.org>,
Pavel Begunkov <asml.silence@...il.com>,
Christian Brauner <brauner@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Stefan Roesch <shr@...com>, Clay Harris <bugs@...ycon.org>,
"Darrick J . Wong" <djwong@...nel.org>,
linux-fsdevel@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-ext4@...r.kernel.org, Wanpeng Li <wanpengli@...cent.com>
Subject: Re: [PATCH 5/7] add llseek_nowait support for xfs
On Wed, Jul 26, 2023 at 06:26:01PM +0800, Hao Xu wrote:
> From: Hao Xu <howeyxu@...cent.com>
>
> 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@...cent.com>
> ---
> 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@...morbit.com
Powered by blists - more mailing lists