Re: [PATCH] btrfs: Return EINVAL when length to trim is less than FSB

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

 



On Tue, 16 Oct 2012, Lukas Czerner wrote:

> Date: Tue, 16 Oct 2012 11:34:36 +0200
> From: Lukas Czerner <lczerner@xxxxxxxxxx>
> To: linux-btrfs@xxxxxxxxxxxxxxx
> Cc: jbacik@xxxxxxxxxxxx, Lukas Czerner <lczerner@xxxxxxxxxx>
> Subject: [PATCH] btrfs: Return EINVAL when length to trim is less than FSB
> 
> Currently if len argument in btrfs_ioctl_fitrim() is smaller than
> one FSB we will continue and finally return 0 bytes discarded.
> However if the length to discard is smaller then file system block
> we should really return EINVAL.

ping

> 
> Signed-off-by: Lukas Czerner <lczerner@xxxxxxxxxx>
> ---
>  fs/btrfs/ioctl.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 6116880..3b8b509 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -343,7 +343,8 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
>  		return -EOPNOTSUPP;
>  	if (copy_from_user(&range, arg, sizeof(range)))
>  		return -EFAULT;
> -	if (range.start > total_bytes)
> +	if (range.start > total_bytes ||
> +	    range.len < fs_info->sb->s_blocksize)
>  		return -EINVAL;
>  
>  	range.len = min(range.len, total_bytes - range.start);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux