Re: [PATCH v6 01/34] vfs: Unconditionally set IOCB_WRITE in call_write_iter()

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

 



On Mon, Jan 16, 2023 at 11:08:09PM +0000, David Howells wrote:
> IOCB_WRITE is set by aio, io_uring and cachefiles before submitting a write
> operation to the VFS, but it isn't set by, say, the write() system call.
> 
> Fix this by setting IOCB_WRITE unconditionally in call_write_iter().
> 
> This will allow drivers to use IOCB_WRITE instead of the iterator data
> source to determine the I/O direction.
> 
> Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
> cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
> cc: Christoph Hellwig <hch@xxxxxx>
> cc: Jens Axboe <axboe@xxxxxxxxx>
> cc: linux-block@xxxxxxxxxxxxxxx
> cc: linux-fsdevel@xxxxxxxxxxxxxxx
> ---
> 
>  include/linux/fs.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 066555ad1bf8..649ff061440e 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2183,6 +2183,7 @@ static inline ssize_t call_read_iter(struct file *file, struct kiocb *kio,
>  static inline ssize_t call_write_iter(struct file *file, struct kiocb *kio,
>  				      struct iov_iter *iter)
>  {
> +	kio->ki_flags |= IOCB_WRITE;
>  	return file->f_op->write_iter(kio, iter);
>  }

This doesn't remove the existing setting of IOCB_WRITE, and also
feelds like the wrong place.

I suspect the best is to:

 - rename init_sync_kiocb to init_kiocb
 - pass a new argument for the destination to it.  I'm not entirely
   sure if flags is a good thing, or an explicit READ/WRITE might be
   better because it's harder to get wrong, even if a the compiler
   might generate worth code for it.
 - also use it in the async callers (io_uring, aio, overlayfs, loop,
   nvmet, target, cachefs, file backed swap)



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux