diff mbox

ext4: fallocate_zero_range, check if is regular file

Message ID CAGW2f1GoMPwcO3o4Q=As-DkiT2WPN7BiEkq1=RYfX6rnpExipA@mail.gmail.com
State Accepted, archived
Headers show

Commit Message

jon ernst April 17, 2014, 4:22 a.m. UTC
fallocate_zero_range, check if inode is regular file.

Signed-off-by: Jon Ernst <jonernst07@gmail.com>
---
 fs/ext4/extents.c | 2 ++
 1 file changed, 2 insertions(+)

     * Then release them.

Comments

Lukas Czerner April 17, 2014, 11:08 a.m. UTC | #1
On Thu, 17 Apr 2014, jon ernst wrote:

> Date: Thu, 17 Apr 2014 00:22:04 -0400
> From: jon ernst <jonernst07@gmail.com>
> To: "linux-ext4@vger.kernel.org List" <linux-ext4@vger.kernel.org>
> 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 <jonernst07@gmail.com>

Thanks, you can add.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

> ---
>  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.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ashish Sangwan April 18, 2014, 7:50 a.m. UTC | #2
On Thu, Apr 17, 2014 at 9:52 AM, jon ernst <jonernst07@gmail.com> wrote:
> fallocate_zero_range, check if inode is regular file.
>
> Signed-off-by: Jon Ernst <jonernst07@gmail.com>
> ---
>  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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o April 18, 2014, 3:52 p.m. UTC | #3
Thanks, applied with the error code changed to -EINVAL.

		     	       	    - Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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