aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index fbe11e676624..65576c02c6f5 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4419,6 +4419,31 @@ int ext4_can_truncate(struct inode *inode)
4419} 4419}
4420 4420
4421/* 4421/*
4422 * ext4_punch_hole: punches a hole in a file by releaseing the blocks
4423 * associated with the given offset and length
4424 *
4425 * @inode: File inode
4426 * @offset: The offset where the hole will begin
4427 * @len: The length of the hole
4428 *
4429 * Returns: 0 on sucess or negative on failure
4430 */
4431
4432int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
4433{
4434 struct inode *inode = file->f_path.dentry->d_inode;
4435 if (!S_ISREG(inode->i_mode))
4436 return -ENOTSUPP;
4437
4438 if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
4439 /* TODO: Add support for non extent hole punching */
4440 return -ENOTSUPP;
4441 }
4442
4443 return ext4_ext_punch_hole(file, offset, length);
4444}
4445
4446/*
4422 * ext4_truncate() 4447 * ext4_truncate()
4423 * 4448 *
4424 * We block out ext4_get_block() block instantiations across the entire 4449 * We block out ext4_get_block() block instantiations across the entire