diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-10-09 12:00:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-11-11 21:56:51 -0500 |
commit | 294e30fee35d3151d100cfe59e839c2dbc16a374 (patch) | |
tree | 3906ec3d135ec29dc7700f8e35e494909b210848 /fs/btrfs/tests/btrfs-tests.c | |
parent | 857cc2fc29cfaf4ee98fe9967bbf6a3942191136 (diff) |
Btrfs: add tests for find_lock_delalloc_range
So both Liu and I made huge messes of find_lock_delalloc_range trying to fix
stuff, me first by fixing extent size, then him by fixing something I broke and
then me again telling him to fix it a different way. So this is obviously a
candidate for some testing. This patch adds a pseudo fs so we can allocate fake
inodes for tests that need an inode or pages. Then it addes a bunch of tests to
make sure find_lock_delalloc_range is acting the way it is supposed to. With
this patch and all of our previous patches to find_lock_delalloc_range I am sure
it is working as expected now. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/tests/btrfs-tests.c')
-rw-r--r-- | fs/btrfs/tests/btrfs-tests.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c new file mode 100644 index 000000000000..697d527377c1 --- /dev/null +++ b/fs/btrfs/tests/btrfs-tests.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Fusion IO. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public | ||
6 | * License v2 as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | * General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public | ||
14 | * License along with this program; if not, write to the | ||
15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
16 | * Boston, MA 021110-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/fs.h> | ||
20 | #include <linux/mount.h> | ||
21 | #include <linux/magic.h> | ||
22 | #include "btrfs-tests.h" | ||
23 | #include "../ctree.h" | ||
24 | |||
25 | static struct vfsmount *test_mnt = NULL; | ||
26 | |||
27 | static struct dentry *btrfs_test_mount(struct file_system_type *fs_type, | ||
28 | int flags, const char *dev_name, | ||
29 | void *data) | ||
30 | { | ||
31 | return mount_pseudo(fs_type, "btrfs_test:", NULL, NULL, BTRFS_TEST_MAGIC); | ||
32 | } | ||
33 | |||
34 | static struct file_system_type test_type = { | ||
35 | .name = "btrfs_test_fs", | ||
36 | .mount = btrfs_test_mount, | ||
37 | .kill_sb = kill_anon_super, | ||
38 | }; | ||
39 | |||
40 | struct inode *btrfs_new_test_inode(void) | ||
41 | { | ||
42 | return new_inode(test_mnt->mnt_sb); | ||
43 | } | ||
44 | |||
45 | int btrfs_init_test_fs(void) | ||
46 | { | ||
47 | int ret; | ||
48 | |||
49 | ret = register_filesystem(&test_type); | ||
50 | if (ret) { | ||
51 | printk(KERN_ERR "btrfs: cannot register test file system\n"); | ||
52 | return ret; | ||
53 | } | ||
54 | |||
55 | test_mnt = kern_mount(&test_type); | ||
56 | if (IS_ERR(test_mnt)) { | ||
57 | printk(KERN_ERR "btrfs: cannot mount test file system\n"); | ||
58 | unregister_filesystem(&test_type); | ||
59 | return ret; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | void btrfs_destroy_test_fs(void) | ||
65 | { | ||
66 | kern_unmount(test_mnt); | ||
67 | unregister_filesystem(&test_type); | ||
68 | } | ||