1 ext4: add fallocate mode blocking for debugging purposes
3 If a particular fallocate mode is causing test failures, give the
4 tester the ability to block a particular fallocate mode so that the
5 use of a particular fallocate mode will be reported as not supported.
7 For example, if the COLLAPSE_RANGE fallocate mode is causing test
8 failures, this allows us to suppress it so we can more easily test the
9 rest of the file system code.
11 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 fs/ext4/extents.c | 18 ++++++++++++++++++
14 1 file changed, 18 insertions(+)
16 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
17 index 64b4003..f477832 100644
18 --- a/fs/ext4/extents.c
19 +++ b/fs/ext4/extents.c
21 * - smart tree reduction
24 +#include <linux/module.h>
26 #include <linux/time.h>
27 #include <linux/jbd2.h>
28 @@ -4862,6 +4863,14 @@ out_mutex:
32 +#ifdef CONFIG_EXT4_DEBUG
33 +int ext4_fallocate_mode_block __read_mostly;
35 +module_param_named(fallocate_mode_block, ext4_fallocate_mode_block, int, 0644);
36 +MODULE_PARM_DESC(fallocate_mode_block,
37 + "Fallocate modes which are blocked for debugging purposes");
41 * preallocate space for a file. This implements ext4's fallocate file
42 * operation, which gets called from sys_fallocate system call.
43 @@ -4881,6 +4890,15 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
45 unsigned int blkbits = inode->i_blkbits;
47 +#ifdef CONFIG_EXT4_DEBUG
49 + * For debugging purposes, allow certain fallocate operations
52 + if (unlikely(mode & ext4_fallocate_mode_block))
56 /* Return error if mode is not supported */
57 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
58 FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))