add patch create-function-to-read-journal-inode
[ext4-patch-queue.git] / add-fallocate-mode-blocking-for-debugging
blobc9bdba4e2dacc9955c32874634ea37053733d342
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>
12 ---
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
20 @@ -29,6 +29,7 @@
21   *   - smart tree reduction
22   */
24 +#include <linux/module.h>
25  #include <linux/fs.h>
26  #include <linux/time.h>
27  #include <linux/jbd2.h>
28 @@ -4862,6 +4863,14 @@ out_mutex:
29         return ret;
30  }
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");
38 +#endif
40  /*
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)
44         struct timespec tv;
45         unsigned int blkbits = inode->i_blkbits;
47 +#ifdef CONFIG_EXT4_DEBUG
48 +       /*
49 +        * For debugging purposes, allow certain fallocate operations
50 +        * to be disabled
51 +        */
52 +       if (unlikely(mode & ext4_fallocate_mode_block))
53 +               return -EOPNOTSUPP;
54 +#endif
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))