2014-04-17 04:22:05

by jon ernst

[permalink] [raw]
Subject: [PATCH] ext4: fallocate_zero_range, check if is regular file

fallocate_zero_range, check if inode is regular file.

Signed-off-by: Jon Ernst <[email protected]>
---
fs/ext4/extents.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 1bb3e4b..756a3b9 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4742,6 +4742,8 @@ static long ext4_zero_range(struct file *file,
loff_t offset,

trace_ext4_zero_range(inode, offset, len, mode);

+ if (!S_ISREG(inode->i_mode))
+ return -EOPNOTSUPP;
/*
* Write out all dirty pages to avoid race conditions
* Then release them.
--
1.8.1.2


2014-04-17 11:08:53

by Lukas Czerner

[permalink] [raw]
Subject: Re: [PATCH] ext4: fallocate_zero_range, check if is regular file

On Thu, 17 Apr 2014, jon ernst wrote:

> Date: Thu, 17 Apr 2014 00:22:04 -0400
> From: jon ernst <[email protected]>
> To: "[email protected] List" <[email protected]>
> Subject: [PATCH] ext4: fallocate_zero_range, check if is regular file
>
> fallocate_zero_range, check if inode is regular file.
>
> Signed-off-by: Jon Ernst <[email protected]>

Thanks, you can add.

Reviewed-by: Lukas Czerner <[email protected]>

> ---
> fs/ext4/extents.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 1bb3e4b..756a3b9 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4742,6 +4742,8 @@ static long ext4_zero_range(struct file *file,
> loff_t offset,
>
> trace_ext4_zero_range(inode, offset, len, mode);
>
> + if (!S_ISREG(inode->i_mode))
> + return -EOPNOTSUPP;
> /*
> * Write out all dirty pages to avoid race conditions
> * Then release them.

2014-04-18 07:50:14

by Ashish Sangwan

[permalink] [raw]
Subject: Re: [PATCH] ext4: fallocate_zero_range, check if is regular file

On Thu, Apr 17, 2014 at 9:52 AM, jon ernst <[email protected]> wrote:
> fallocate_zero_range, check if inode is regular file.
>
> Signed-off-by: Jon Ernst <[email protected]>
> ---
> fs/ext4/extents.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 1bb3e4b..756a3b9 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4742,6 +4742,8 @@ static long ext4_zero_range(struct file *file,
> loff_t offset,
>
> trace_ext4_zero_range(inode, offset, len, mode);
>
> + if (!S_ISREG(inode->i_mode))
> + return -EOPNOTSUPP;
IMO returning -EINVAL is better suited in this situation.
And the same error value has to be updated for collapse_range too. (as
mentioned by Michael in other mail thread regarding manpage patch of
collapse range)
> /*
> * Write out all dirty pages to avoid race conditions
> * Then release them.
> --
> 1.8.1.2
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-04-18 15:52:52

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] ext4: fallocate_zero_range, check if is regular file

Thanks, applied with the error code changed to -EINVAL.

- Ted