Btrfs: add sanity test for outstanding_extents accounting
PATCH 1/1 Btrfs: add sanity test for outstanding_extents accounting
I introduced a regression wrt outstanding_extents accounting. These are tricky areas that aren't easily covered by xfstests as we could change MAX_EXTENT_SIZE at any time. So add sanity tests to cover the various conditions that are tricky in order to make sure we don't introduce regressions in the future. Thanks,
Signed-off-by Josef Bacik <[email protected]>
--- fs/btrfs/ctree.h | 3 + fs/btrfs/inode.c | 15 ++++ fs/btrfs/tests/inode-tests.c | 160 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 177 insertions(+), 1 deletion(-)
fs/btrfs/ctree.h +3 -0
@@ -3910,6 +3910,9 @@ int btrfs_prealloc_file_range_trans(struct inode *inode, loff_t actual_len, u64 *alloc_hint);int btrfs_inode_check_errors (struct inode *inode);extern const struct dentry_operations btrfs_dentry_operations; +#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS +void btrfs_test_inode_set_ops (struct inode *inode); +#endif /* ioctl.c */ long btrfs_ioctl (struct file *file,unsigned int cmd,unsigned long arg);
fs/btrfs/inode.c +15 -0
@@ -108,6 +108,13 @@ static struct extent_map *create_pinned_em(struct inode *inode, u64 start,static int btrfs_dirty_inode (struct inode *inode); +#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS +void btrfs_test_inode_set_ops (struct inode *inode) +{ +BTRFS_I (inode)->io_tree.ops = &btrfs_extent_io_ops; +} +#endif +static int btrfs_init_inode_security (struct btrfs_trans_handle *trans,struct inode *inode,struct inode *dir,const struct qstr *qstr)
@@ -1707,6 +1714,10 @@ static void btrfs_set_bit_hook(struct inode *inode,spin_unlock (&BTRFS_I (inode)->lock); } +/* For sanity tests */ +if (btrfs_test_is_dummy_root (root)) +return ; +__percpu_counter_add (&root->fs_info->delalloc_bytes, len, root->fs_info->delalloc_batch);spin_lock (&BTRFS_I (inode)->lock);
@@ -1762,6 +1773,10 @@ static void btrfs_clear_bit_hook(struct inode *inode, root != root->fs_info->tree_root)btrfs_delalloc_release_metadata (inode, len); +/* For sanity tests. */ +if (btrfs_test_is_dummy_root (root)) +return ; +if (root->root_key.objectid !=BTRFS_DATA_RELOC_TREE_OBJECTID && do_list && !(state->state &EXTENT_NORESERVE ))btrfs_free_reserved_data_space (inode, len);
fs/btrfs/tests/inode-tests.c +159 -1
170 lines not on this page · raw message
Signature · 1 line
1.9.3