* [PATCH] btrfs: Return EINVAL when length to trim is less than FSB
@ 2012-10-16 9:34 Lukas Czerner
2012-10-24 8:15 ` Lukáš Czerner
0 siblings, 1 reply; 3+ messages in thread
From: Lukas Czerner @ 2012-10-16 9:34 UTC (permalink / raw)
To: linux-btrfs; +Cc: jbacik, Lukas Czerner
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.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
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);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: Return EINVAL when length to trim is less than FSB
2012-10-16 9:34 [PATCH] btrfs: Return EINVAL when length to trim is less than FSB Lukas Czerner
@ 2012-10-24 8:15 ` Lukáš Czerner
2012-10-24 8:20 ` Li Zefan
0 siblings, 1 reply; 3+ messages in thread
From: Lukáš Czerner @ 2012-10-24 8:15 UTC (permalink / raw)
To: Lukas Czerner; +Cc: linux-btrfs, jbacik
On Tue, 16 Oct 2012, Lukas Czerner wrote:
> Date: Tue, 16 Oct 2012 11:34:36 +0200
> From: Lukas Czerner <lczerner@redhat.com>
> To: linux-btrfs@vger.kernel.org
> Cc: jbacik@fusionio.com, Lukas Czerner <lczerner@redhat.com>
> 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@redhat.com>
> ---
> 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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-24 8:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 9:34 [PATCH] btrfs: Return EINVAL when length to trim is less than FSB Lukas Czerner
2012-10-24 8:15 ` Lukáš Czerner
2012-10-24 8:20 ` Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).