* [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate()
@ 2014-04-19 5:11 Namjae Jeon
2014-04-23 6:08 ` Zheng Liu
0 siblings, 1 reply; 5+ messages in thread
From: Namjae Jeon @ 2014-04-19 5:11 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: linux-ext4, Lukáš Czerner
From: Namjae Jeon <namjae.jeon@samsung.com>
Punch hole return EOPNOTSUPP about a non-REGULAR file also. So change EINVAL
to be consistent with xfs. And move this check to the start of
ext4_fallocate().
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
---
fs/ext4/extents.c | 9 +++------
fs/ext4/inode.c | 3 ---
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 3276865..b38f487 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4741,9 +4741,6 @@ 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 -EINVAL;
-
/*
* Write out all dirty pages to avoid race conditions
* Then release them.
@@ -4888,6 +4885,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))
return -EOPNOTSUPP;
+
+ if (!S_ISREG(inode->i_mode))
+ return -EINVAL;
if (mode & FALLOC_FL_PUNCH_HOLE)
return ext4_punch_hole(inode, offset, len);
@@ -5403,9 +5403,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
len & (EXT4_BLOCK_SIZE(sb) - 1))
return -EINVAL;
- if (!S_ISREG(inode->i_mode))
- return -EINVAL;
-
if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1)
return -EOPNOTSUPP;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d7b7462..d6cbbe3 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3524,9 +3524,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
unsigned int credits;
int ret = 0;
- if (!S_ISREG(inode->i_mode))
- return -EOPNOTSUPP;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate()
2014-04-19 5:11 [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate() Namjae Jeon
@ 2014-04-23 6:08 ` Zheng Liu
2014-04-23 6:36 ` Namjae Jeon
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zheng Liu @ 2014-04-23 6:08 UTC (permalink / raw)
To: Namjae Jeon; +Cc: Theodore Ts'o, linux-ext4, Lukáš Czerner
On Sat, Apr 19, 2014 at 02:11:07PM +0900, Namjae Jeon wrote:
> From: Namjae Jeon <namjae.jeon@samsung.com>
>
> Punch hole return EOPNOTSUPP about a non-REGULAR file also. So change EINVAL
> to be consistent with xfs. And move this check to the start of
> ext4_fallocate().
IMHO, EOPNOTSUPP makes sense to me. From the man page of fallocate(2):
EOPNOTSUPP
The filesystem containing the file referred to by fd does not
support this operation; or the mode is not supported by the
filesystem containing the file referred to by fd.
Regards,
- Zheng
>
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
> ---
> fs/ext4/extents.c | 9 +++------
> fs/ext4/inode.c | 3 ---
> 2 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 3276865..b38f487 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4741,9 +4741,6 @@ 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 -EINVAL;
> -
> /*
> * Write out all dirty pages to avoid race conditions
> * Then release them.
> @@ -4888,6 +4885,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
> FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))
> return -EOPNOTSUPP;
> +
> + if (!S_ISREG(inode->i_mode))
> + return -EINVAL;
>
> if (mode & FALLOC_FL_PUNCH_HOLE)
> return ext4_punch_hole(inode, offset, len);
> @@ -5403,9 +5403,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
> len & (EXT4_BLOCK_SIZE(sb) - 1))
> return -EINVAL;
>
> - if (!S_ISREG(inode->i_mode))
> - return -EINVAL;
> -
> if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1)
> return -EOPNOTSUPP;
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d7b7462..d6cbbe3 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3524,9 +3524,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
> unsigned int credits;
> int ret = 0;
>
> - if (!S_ISREG(inode->i_mode))
> - return -EOPNOTSUPP;
> -
> trace_ext4_punch_hole(inode, offset, length, 0);
>
> /*
> --
> 1.7.11-rc0
>
> --
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate()
2014-04-23 6:08 ` Zheng Liu
@ 2014-04-23 6:36 ` Namjae Jeon
2014-04-23 8:35 ` Namjae Jeon
2014-04-23 13:23 ` Lukáš Czerner
2 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2014-04-23 6:36 UTC (permalink / raw)
To: 'Zheng Liu'
Cc: 'Theodore Ts'o', 'linux-ext4',
'Lukáš Czerner'
> On Sat, Apr 19, 2014 at 02:11:07PM +0900, Namjae Jeon wrote:
> > From: Namjae Jeon <namjae.jeon@samsung.com>
> >
> > Punch hole return EOPNOTSUPP about a non-REGULAR file also. So change EINVAL
> > to be consistent with xfs. And move this check to the start of
> > ext4_fallocate().
>
> IMHO, EOPNOTSUPP makes sense to me. From the man page of fallocate(2):
Hi Zheng.
IMHO, EOPNOTSUPP should be used where the operation is not yet implemented but
there is some chance that it could be implemented in future.
for example, it is ok for FS which has not yet implemented punch hole to
return EOPNOTSUPP as they could implement it in future. but for the cases where
it does not make sense to implement the operation, for example punching hole
for non regular files does not make any sense, it is better to use EINVAL.
On these lines, I agree that returning EOPNOTSUPP for collapse range in case of
non-extent based file is ok, as it is plausible to implemet collapse range for
non extent files in future.
Thanks for your opinion!
>
> EOPNOTSUPP
> The filesystem containing the file referred to by fd does not
> support this operation; or the mode is not supported by the
> filesystem containing the file referred to by fd.
>
> Regards,
> - Zheng
>
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate()
2014-04-23 6:08 ` Zheng Liu
2014-04-23 6:36 ` Namjae Jeon
@ 2014-04-23 8:35 ` Namjae Jeon
2014-04-23 13:23 ` Lukáš Czerner
2 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2014-04-23 8:35 UTC (permalink / raw)
To: 'Zheng Liu'
Cc: 'Theodore Ts'o', 'linux-ext4',
'Lukáš Czerner'
> On Sat, Apr 19, 2014 at 02:11:07PM +0900, Namjae Jeon wrote:
> > From: Namjae Jeon <namjae.jeon@samsung.com>
> >
> > Punch hole return EOPNOTSUPP about a non-REGULAR file also. So change EINVAL
> > to be consistent with xfs. And move this check to the start of
> > ext4_fallocate().
>
> IMHO, EOPNOTSUPP makes sense to me. From the man page of fallocate(2):
Hi Zheng.
IMHO, EOPNOTSUPP should be used where the operation is not yet implemented but
there is some chance that it could be implemented in future.
for example, it is ok for FS which has not yet implemented punch hole to
return EOPNOTSUPP as they could implement it in future. but for the cases where
it does not make sense to implement the operation, for example punching hole
for non regular files does not make any sense, it is better to use EINVAL.
On these lines, I agree that returning EOPNOTSUPP for collapse range in case of
non-extent based file is ok, as it is plausible to implemet collapse range for
non extent files in future.
Thanks for your opinion!
>
> EOPNOTSUPP
> The filesystem containing the file referred to by fd does not
> support this operation; or the mode is not supported by the
> filesystem containing the file referred to by fd.
>
> Regards,
> - Zheng
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate()
2014-04-23 6:08 ` Zheng Liu
2014-04-23 6:36 ` Namjae Jeon
2014-04-23 8:35 ` Namjae Jeon
@ 2014-04-23 13:23 ` Lukáš Czerner
2 siblings, 0 replies; 5+ messages in thread
From: Lukáš Czerner @ 2014-04-23 13:23 UTC (permalink / raw)
To: Zheng Liu; +Cc: Namjae Jeon, Theodore Ts'o, linux-ext4
[-- Attachment #1: Type: TEXT/PLAIN, Size: 3440 bytes --]
On Wed, 23 Apr 2014, Zheng Liu wrote:
> Date: Wed, 23 Apr 2014 14:08:23 +0800
> From: Zheng Liu <gnehzuil.liu@gmail.com>
> To: Namjae Jeon <namjae.jeon@samsung.com>
> Cc: Theodore Ts'o <tytso@mit.edu>, linux-ext4 <linux-ext4@vger.kernel.org>,
> Lukáš Czerner <lczerner@redhat.com>
> Subject: Re: [PATCH] ext4: use EINVAL if not a regular file in
> ext4_fallocate()
>
> On Sat, Apr 19, 2014 at 02:11:07PM +0900, Namjae Jeon wrote:
> > From: Namjae Jeon <namjae.jeon@samsung.com>
> >
> > Punch hole return EOPNOTSUPP about a non-REGULAR file also. So change EINVAL
> > to be consistent with xfs. And move this check to the start of
> > ext4_fallocate().
>
> IMHO, EOPNOTSUPP makes sense to me. From the man page of fallocate(2):
>
> EOPNOTSUPP
> The filesystem containing the file referred to by fd does not
> support this operation; or the mode is not supported by the
> filesystem containing the file referred to by fd.
>
> Regards,
> - Zheng
I actually have the same opinion. There has been a discussion on
fsdevel-list and it seems that the decision was made to use EINVAL
for this case.
However there was only one person actually arguing for using EINVA
and that was Dave Chinner. Maybe we can discuss it a little bit more
?
-Lukas
>
> >
> > Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> > Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
> > ---
> > fs/ext4/extents.c | 9 +++------
> > fs/ext4/inode.c | 3 ---
> > 2 files changed, 3 insertions(+), 9 deletions(-)
> >
> > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> > index 3276865..b38f487 100644
> > --- a/fs/ext4/extents.c
> > +++ b/fs/ext4/extents.c
> > @@ -4741,9 +4741,6 @@ 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 -EINVAL;
> > -
> > /*
> > * Write out all dirty pages to avoid race conditions
> > * Then release them.
> > @@ -4888,6 +4885,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> > if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
> > FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))
> > return -EOPNOTSUPP;
> > +
> > + if (!S_ISREG(inode->i_mode))
> > + return -EINVAL;
> >
> > if (mode & FALLOC_FL_PUNCH_HOLE)
> > return ext4_punch_hole(inode, offset, len);
> > @@ -5403,9 +5403,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
> > len & (EXT4_BLOCK_SIZE(sb) - 1))
> > return -EINVAL;
> >
> > - if (!S_ISREG(inode->i_mode))
> > - return -EINVAL;
> > -
> > if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1)
> > return -EOPNOTSUPP;
> >
> > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> > index d7b7462..d6cbbe3 100644
> > --- a/fs/ext4/inode.c
> > +++ b/fs/ext4/inode.c
> > @@ -3524,9 +3524,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
> > unsigned int credits;
> > int ret = 0;
> >
> > - if (!S_ISREG(inode->i_mode))
> > - return -EOPNOTSUPP;
> > -
> > trace_ext4_punch_hole(inode, offset, length, 0);
> >
> > /*
> > --
> > 1.7.11-rc0
> >
> > --
> > 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-23 13:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-19 5:11 [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate() Namjae Jeon
2014-04-23 6:08 ` Zheng Liu
2014-04-23 6:36 ` Namjae Jeon
2014-04-23 8:35 ` Namjae Jeon
2014-04-23 13:23 ` Lukáš Czerner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox