[Devel] [PATCH rh7 1/3] vfs: fix fallocate(FALLOC_FL_CONVERT_AND_EXTEND)

Dmitry Monakhov dmonakhov at openvz.org
Thu Mar 10 05:47:07 PST 2016


Maxim Patlasov <mpatlasov at virtuozzo.com> writes:

> Modern vfs_fallocate() checks flags for sanity. To avoid EOPNOTSUPP error,
> we have to list FALLOC_FL_CONVERT_AND_EXTEND among other valid flags. Also,
> to keep checks uniform, the patch also enforces exclusiveness of the flag.
Ack-by: dmonakhov at openvz.org
>
> https://jira.sw.ru/browse/PSBM-22381
>
> Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
> ---
>  fs/open.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index 75b9d8e..22b9699 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -232,7 +232,8 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>  
>  	/* Return error if mode is not supported */
>  	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
> -		     FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))
> +		     FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
> +		     FALLOC_FL_CONVERT_AND_EXTEND))
>  		return -EOPNOTSUPP;
>  
>  	/* Punch hole and zero range are mutually exclusive */
> @@ -250,6 +251,11 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>  	    (mode & ~FALLOC_FL_COLLAPSE_RANGE))
>  		return -EINVAL;
>  
> +	/* Convert-and-extend should only be used exclusively. */
> +	if ((mode & FALLOC_FL_CONVERT_AND_EXTEND) &&
> +	    (mode & ~FALLOC_FL_CONVERT_AND_EXTEND))
> +		return -EINVAL;
> +
>  	if (!(file->f_mode & FMODE_WRITE))
>  		return -EBADF;
>  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20160310/1ab5ed5d/attachment.sig>


More information about the Devel mailing list