Re: [PATCH v10 02/14] fs: export variant of generic_write_checks without iov_iter

Nikolay Borisov
2021-08-20T07:59:37Z

On 18.08.21 г. 0:06, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> Encoded I/O in Btrfs needs to check a write with a given logical size
> without an iov_iter that matches that size (because the iov_iter we have
> is for the compressed data). So, factor out the parts of
> generic_write_check() that expect an iov_iter into a new
> __generic_write_checks() function and export that.
>
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
> fs/read_write.c | 40 ++++++++++++++++++++++------------------
> include/linux/fs.h | 1 +
> 2 files changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 0029ff2b0ca8..3bddd5ee7f64 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1633,6 +1633,26 @@ int generic_write_check_limits(struct file *file, loff_t pos, loff_t *count)
> return 0;
> }
>
> +/* Like generic_write_checks(), but takes size of write instead of iter. */
> +int __generic_write_checks(struct kiocb *iocb, loff_t *count)
> +{
> + struct file *file = iocb->ki_filp;
> + struct inode *inode = file->f_mapping->host;
> +
> + if (IS_SWAPFILE(inode))
> + return -ETXTBSY;

Missing 'if(!count) return 0' from original code ?

<snip>