public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Namjae Jeon <namjae.jeon@samsung.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>,
	"Lukáš Czerner" <lczerner@redhat.com>
Subject: [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate()
Date: Sat, 19 Apr 2014 14:11:07 +0900	[thread overview]
Message-ID: <000e01cf5b8d$c57e9f80$507bde80$@samsung.com> (raw)

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;

             reply	other threads:[~2014-04-19  5:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-19  5:11 Namjae Jeon [this message]
2014-04-23  6:08 ` [PATCH] ext4: use EINVAL if not a regular file in ext4_fallocate() Zheng Liu
2014-04-23  6:36   ` Namjae Jeon
2014-04-23  8:35   ` Namjae Jeon
2014-04-23 13:23   ` Lukáš Czerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000e01cf5b8d$c57e9f80$507bde80$@samsung.com' \
    --to=namjae.jeon@samsung.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox