From: Lukas Czerner <lczerner@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: Lukas Czerner <lczerner@redhat.com>, linux-ext4@vger.kernel.org
Subject: [PATCH 2/7] ext4: Implement fallocate query support mode
Date: Mon, 18 Sep 2017 17:52:22 +0200 [thread overview]
Message-ID: <1505749947-26360-3-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1505749947-26360-1-git-send-email-lczerner@redhat.com>
Return all fallocate modes supported by ext4 file system. Ext4 does have
a lot of exceptions for inodes with various features enabled so take
that into account as well.
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
fs/ext4/ext4.h | 11 +++++++++++
fs/ext4/extents.c | 42 ++++++++++++++++++------------------------
2 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index e2abe01..6546c2c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -558,6 +558,17 @@ enum {
};
/*
+ * Supported fallocate modes
+ */
+#define EXT4_FALLOC_SUPPORTED (FALLOC_FL_KEEP_SIZE | \
+ FALLOC_FL_PUNCH_HOLE | \
+ FALLOC_FL_COLLAPSE_RANGE | \
+ FALLOC_FL_ZERO_RANGE | \
+ FALLOC_FL_INSERT_RANGE | \
+ FALLOC_FL_QUERY_SUPPORT | \
+ FALLOC_FL_PREALLOC_RANGE)
+
+/*
* Flags used by ext4_map_blocks()
*/
/* Allocate any needed blocks and/or convert an unwritten
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 97f0fd0..91071b3 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4905,7 +4905,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
loff_t new_size = 0;
unsigned int max_blocks;
int ret = 0;
- int flags;
+ int flags = 0;
ext4_lblk_t lblk;
unsigned int blkbits = inode->i_blkbits;
@@ -4919,17 +4919,27 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
* leave it disabled for encrypted inodes for now. This is a
* bug we should fix....
*/
- if (ext4_encrypted_inode(inode) &&
- (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE |
- FALLOC_FL_ZERO_RANGE)))
- return -EOPNOTSUPP;
+ if (ext4_encrypted_inode(inode)) {
+ /* Modes not supported on encrypted indoes */
+ flags |= (FALLOC_FL_COLLAPSE_RANGE |
+ FALLOC_FL_INSERT_RANGE |
+ FALLOC_FL_ZERO_RANGE);
+ }
+ if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
+ /* Modes not supported on non-extent inodes */
+ flags |= (FALLOC_FL_COLLAPSE_RANGE |
+ FALLOC_FL_INSERT_RANGE |
+ FALLOC_FL_ZERO_RANGE |
+ FALLOC_FL_PREALLOC_RANGE);
+ }
/* Return error if mode is not supported */
- if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
- FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
- FALLOC_FL_INSERT_RANGE))
+ if (mode & ~(EXT4_FALLOC_SUPPORTED & ~flags))
return -EOPNOTSUPP;
+ if (mode & FALLOC_FL_QUERY_SUPPORT)
+ return EXT4_FALLOC_SUPPORTED & ~flags;
+
if (mode & FALLOC_FL_PUNCH_HOLE)
return ext4_punch_hole(inode, offset, len);
@@ -5449,14 +5459,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
loff_t new_size, ioffset;
int ret;
- /*
- * We need to test this early because xfstests assumes that a
- * collapse range of (0, 1) will return EOPNOTSUPP if the file
- * system does not support collapse range.
- */
- if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
- return -EOPNOTSUPP;
-
/* Collapse range works only on fs block size aligned offsets. */
if (offset & (EXT4_CLUSTER_SIZE(sb) - 1) ||
len & (EXT4_CLUSTER_SIZE(sb) - 1))
@@ -5596,14 +5598,6 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
int ret = 0, depth, split_flag = 0;
loff_t ioffset;
- /*
- * We need to test this early because xfstests assumes that an
- * insert range of (0, 1) will return EOPNOTSUPP if the file
- * system does not support insert range.
- */
- if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
- return -EOPNOTSUPP;
-
/* Insert range works only on fs block size aligned offsets. */
if (offset & (EXT4_CLUSTER_SIZE(sb) - 1) ||
len & (EXT4_CLUSTER_SIZE(sb) - 1))
--
2.7.5
next prev parent reply other threads:[~2017-09-18 15:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 15:52 [PATCH 0/7][RFC] Introduce fallocate query support mode Lukas Czerner
2017-09-18 15:52 ` [PATCH 1/7] vfs: " Lukas Czerner
2017-09-18 15:52 ` Lukas Czerner [this message]
2017-09-18 15:52 ` [PATCH 3/7] ext4: Remove unnecessary S_ISREG checks in fallocate operations Lukas Czerner
2017-09-18 15:52 ` [PATCH 4/7] xfs: Implement fallocate query support mode Lukas Czerner
2017-09-18 17:56 ` Christoph Hellwig
2017-09-19 3:28 ` OGAWA Hirofumi
2017-09-19 8:15 ` Lukas Czerner
2017-09-19 14:13 ` Christoph Hellwig
2017-09-18 20:48 ` Darrick J. Wong
2017-09-18 21:55 ` Andreas Dilger
2017-09-19 14:55 ` Theodore Ts'o
2017-09-19 15:33 ` Lukas Czerner
2017-09-19 15:55 ` Christoph Hellwig
2017-09-19 19:17 ` Florian Weimer
2017-09-19 20:37 ` Christoph Hellwig
2017-09-19 23:17 ` Theodore Ts'o
2017-09-21 13:17 ` pathconf syscall for linux Lukas Czerner
2017-09-21 13:49 ` Florian Weimer
2017-09-22 8:38 ` Lukas Czerner
2017-09-21 13:54 ` [PATCH 4/7] xfs: Implement fallocate query support mode Florian Weimer
2017-09-22 8:40 ` Lukas Czerner
2017-09-19 8:20 ` Lukas Czerner
2017-09-18 15:52 ` [PATCH 5/7] fat: " Lukas Czerner
2017-09-18 15:52 ` [PATCH 6/7] gfs2: " Lukas Czerner
2017-09-18 15:52 ` [PATCH 7/7] loop: Check for puch hole and zero range support specifically Lukas 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=1505749947-26360-3-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).