diff mbox

[Vivid] UBUNTU: SAUCE: ext4: disable ext4_punch_hole for indirect filesystems

Message ID 1422987649-29687-1-git-send-email-chris.j.arges@canonical.com
State New
Headers show

Commit Message

Chris J Arges Feb. 3, 2015, 6:20 p.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1292234

Users of non-extent ext4 filesystems (ext4 ^extents, or ext3 w/
CONFIG_EXT4_USE_FOR_EXT23=y) can encounter data corruption when using fallocate
with FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE flags.

This patch returns EOPNOTSUPP when ext4_punch_hole is called from a non-extents
filesystem.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
---
 fs/ext4/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stefan Bader Feb. 4, 2015, 8:33 a.m. UTC | #1
There was, to my knowledge, extensive testing with this. And also user-space
should be prepared to handle that return code since it is documented in
fallocate(2) that not all filesystems will support it.

Chris, if I remember correctly this might be currently misbehaving in previous
releases, too. For which we probably should avoid corruption as well as long as
it takes to get a proper upstream fix.

-Stefan
Chris J Arges Feb. 4, 2015, 7:18 p.m. UTC | #2
On 02/04/2015 02:33 AM, Stefan Bader wrote:
> There was, to my knowledge, extensive testing with this. And also user-space
> should be prepared to handle that return code since it is documented in
> fallocate(2) that not all filesystems will support it.
> 
> Chris, if I remember correctly this might be currently misbehaving in previous
> releases, too. For which we probably should avoid corruption as well as long as
> it takes to get a proper upstream fix.
> 
> -Stefan
> 

I agree, once this is applied to Vivid, I'll work on getting this SRUed.
Thanks!
--chris
Andy Whitcroft Feb. 5, 2015, 7:08 a.m. UTC | #3
Applied to Vivid master-next and unstable.

-apw
diff mbox

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3356ab5..d06d518 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3390,6 +3390,10 @@  int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
 	unsigned int credits;
 	int ret = 0;
 
+	/* WORKAROUND: EXTENTS required (LP: #1292234) */
+	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
+		return -EOPNOTSUPP;
+
 	if (!S_ISREG(inode->i_mode))
 		return -EOPNOTSUPP;