提交 aaedb55b 编写于 作者: J Josef Bacik 提交者: Chris Mason

Btrfs: add tests for btrfs_get_extent

I'm going to be removing hole extents in the near future so I wanted to make a
sanity test for btrfs_get_extent to make sure I don't break anything in the
meantime.  This patch just puts btrfs_get_extent through its paces by giving it
a completely unreasonable mapping to look at and make sure it is giving us back
maps that make sense.  Thanks,
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
Signed-off-by: NChris Mason <chris.mason@fusionio.com>
上级 294e30fe
...@@ -15,4 +15,5 @@ btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o ...@@ -15,4 +15,5 @@ btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
btrfs-$(CONFIG_BTRFS_FS_RUN_SANITY_TESTS) += tests/free-space-tests.o \ btrfs-$(CONFIG_BTRFS_FS_RUN_SANITY_TESTS) += tests/free-space-tests.o \
tests/extent-buffer-tests.o tests/btrfs-tests.o tests/extent-io-tests.o tests/extent-buffer-tests.o tests/btrfs-tests.o \
tests/extent-io-tests.o tests/inode-tests.o
...@@ -4034,5 +4034,9 @@ static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info) ...@@ -4034,5 +4034,9 @@ static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info)
return signal_pending(current); return signal_pending(current);
} }
/* Sanity test specific functions */
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
void btrfs_test_destroy_inode(struct inode *inode);
#endif
#endif #endif
...@@ -7795,6 +7795,14 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) ...@@ -7795,6 +7795,14 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
return inode; return inode;
} }
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
void btrfs_test_destroy_inode(struct inode *inode)
{
btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
}
#endif
static void btrfs_i_callback(struct rcu_head *head) static void btrfs_i_callback(struct rcu_head *head)
{ {
struct inode *inode = container_of(head, struct inode, i_rcu); struct inode *inode = container_of(head, struct inode, i_rcu);
......
...@@ -1802,6 +1802,9 @@ static int btrfs_run_sanity_tests(void) ...@@ -1802,6 +1802,9 @@ static int btrfs_run_sanity_tests(void)
if (ret) if (ret)
goto out; goto out;
ret = btrfs_test_extent_io(); ret = btrfs_test_extent_io();
if (ret)
goto out;
ret = btrfs_test_inodes();
out: out:
btrfs_destroy_test_fs(); btrfs_destroy_test_fs();
return ret; return ret;
......
...@@ -24,11 +24,17 @@ ...@@ -24,11 +24,17 @@
static struct vfsmount *test_mnt = NULL; static struct vfsmount *test_mnt = NULL;
static const struct super_operations btrfs_test_super_ops = {
.alloc_inode = btrfs_alloc_inode,
.destroy_inode = btrfs_test_destroy_inode,
};
static struct dentry *btrfs_test_mount(struct file_system_type *fs_type, static struct dentry *btrfs_test_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, int flags, const char *dev_name,
void *data) void *data)
{ {
return mount_pseudo(fs_type, "btrfs_test:", NULL, NULL, BTRFS_TEST_MAGIC); return mount_pseudo(fs_type, "btrfs_test:", &btrfs_test_super_ops,
NULL, BTRFS_TEST_MAGIC);
} }
static struct file_system_type test_type = { static struct file_system_type test_type = {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
int btrfs_test_free_space_cache(void); int btrfs_test_free_space_cache(void);
int btrfs_test_extent_buffer_operations(void); int btrfs_test_extent_buffer_operations(void);
int btrfs_test_extent_io(void); int btrfs_test_extent_io(void);
int btrfs_test_inodes(void);
int btrfs_init_test_fs(void); int btrfs_init_test_fs(void);
void btrfs_destroy_test_fs(void); void btrfs_destroy_test_fs(void);
struct inode *btrfs_new_test_inode(void); struct inode *btrfs_new_test_inode(void);
...@@ -49,6 +50,10 @@ static inline int btrfs_test_extent_io(void) ...@@ -49,6 +50,10 @@ static inline int btrfs_test_extent_io(void)
{ {
return 0; return 0;
} }
static inline int btrfs_test_inodes(void)
{
return 0;
}
#endif #endif
#endif #endif
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册