#include "btrfs-tests.h"
 #include "../ctree.h"
 #include "../extent_io.h"
+#include "../disk-io.h"
 #include "../btrfs_inode.h"
 
 #define PROCESS_UNLOCK         (1 << 0)
        }
 }
 
-static int test_find_delalloc(u32 sectorsize)
+static int test_find_delalloc(u32 sectorsize, u32 nodesize)
 {
-       struct inode *inode;
+       struct btrfs_fs_info *fs_info;
+       struct btrfs_root *root = NULL;
+       struct inode *inode = NULL;
        struct extent_io_tree *tmp;
        struct page *page;
        struct page *locked_page = NULL;
 
        test_msg("running find delalloc tests");
 
+       fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+       if (!fs_info) {
+               test_std_err(TEST_ALLOC_FS_INFO);
+               return -ENOMEM;
+       }
+
+       root = btrfs_alloc_dummy_root(fs_info);
+       if (IS_ERR(root)) {
+               test_std_err(TEST_ALLOC_ROOT);
+               ret = PTR_ERR(root);
+               goto out;
+       }
+
        inode = btrfs_new_test_inode();
        if (!inode) {
                test_std_err(TEST_ALLOC_INODE);
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto out;
        }
        tmp = &BTRFS_I(inode)->io_tree;
+       BTRFS_I(inode)->root = root;
 
        /*
         * Passing NULL as we don't have fs_info but tracepoints are not used
        process_page_range(inode, 0, total_dirty - 1,
                           PROCESS_UNLOCK | PROCESS_RELEASE);
        iput(inode);
+       btrfs_free_dummy_root(root);
+       btrfs_free_dummy_fs_info(fs_info);
        return ret;
 }
 
 
        test_msg("running extent I/O tests");
 
-       ret = test_find_delalloc(sectorsize);
+       ret = test_find_delalloc(sectorsize, nodesize);
        if (ret)
                goto out;