From 26f9c9ac0a118a6d30486df71daaddc297622b6c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 21 Apr 2014 14:38:22 -0400 Subject: [PATCH] ext4: add fallocate mode blocking for debugging purposes If a particular fallocate mode is causing test failures, give the tester the ability to block a particular fallocate mode so that the use of a particular fallocate mode will be reported as not supported. For example, if the COLLAPSE_RANGE fallocate mode is causing test failures, this allows us to suppress it so we can more easily test the rest of the file system code. Signed-off-by: "Theodore Ts'o" --- fs/ext4/extents.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e305a31641f2..086baa9b5983 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -29,6 +29,7 @@ * - smart tree reduction */ +#include #include #include #include @@ -4861,6 +4862,14 @@ out_mutex: return ret; } +#ifdef CONFIG_EXT4_DEBUG +int ext4_fallocate_mode_block __read_mostly; + +module_param_named(fallocate_mode_block, ext4_fallocate_mode_block, int, 0644); +MODULE_PARM_DESC(fallocate_mode_block, + "Fallocate modes which are blocked for debugging purposes"); +#endif + /* * preallocate space for a file. This implements ext4's fallocate file * operation, which gets called from sys_fallocate system call. @@ -4880,6 +4889,15 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) struct timespec tv; unsigned int blkbits = inode->i_blkbits; +#ifdef CONFIG_EXT4_DEBUG + /* + * For debugging purposes, allow certain fallocate operations + * to be disabled + */ + if (unlikely(mode & ext4_fallocate_mode_block)) + return -EOPNOTSUPP; +#endif + /* 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)) -- 2.39.5