aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2016-06-20 14:14:09 -0400
committerDavid Sterba <dsterba@suse.com>2016-07-26 07:53:18 -0400
commit7c0260ee098db7a05fd68812b2e21ce2e19dfcf0 (patch)
tree25e787514a685917ab6b11535275e831001d24f5 /fs/btrfs/disk-io.c
parent8632daae40c1a5b8fcc1d66d788c143353fd70b7 (diff)
btrfs: tests, require fs_info for root
This allows the upcoming patchset to push nodesize and sectorsize into fs_info. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 802a3113854f..8e838b1cc806 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1233,6 +1233,7 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
1233 struct btrfs_root *root, struct btrfs_fs_info *fs_info, 1233 struct btrfs_root *root, struct btrfs_fs_info *fs_info,
1234 u64 objectid) 1234 u64 objectid)
1235{ 1235{
1236 bool dummy = test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
1236 root->node = NULL; 1237 root->node = NULL;
1237 root->commit_root = NULL; 1238 root->commit_root = NULL;
1238 root->sectorsize = sectorsize; 1239 root->sectorsize = sectorsize;
@@ -1287,14 +1288,14 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
1287 root->log_transid = 0; 1288 root->log_transid = 0;
1288 root->log_transid_committed = -1; 1289 root->log_transid_committed = -1;
1289 root->last_log_commit = 0; 1290 root->last_log_commit = 0;
1290 if (fs_info) 1291 if (!dummy)
1291 extent_io_tree_init(&root->dirty_log_pages, 1292 extent_io_tree_init(&root->dirty_log_pages,
1292 fs_info->btree_inode->i_mapping); 1293 fs_info->btree_inode->i_mapping);
1293 1294
1294 memset(&root->root_key, 0, sizeof(root->root_key)); 1295 memset(&root->root_key, 0, sizeof(root->root_key));
1295 memset(&root->root_item, 0, sizeof(root->root_item)); 1296 memset(&root->root_item, 0, sizeof(root->root_item));
1296 memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); 1297 memset(&root->defrag_progress, 0, sizeof(root->defrag_progress));
1297 if (fs_info) 1298 if (!dummy)
1298 root->defrag_trans_start = fs_info->generation; 1299 root->defrag_trans_start = fs_info->generation;
1299 else 1300 else
1300 root->defrag_trans_start = 0; 1301 root->defrag_trans_start = 0;
@@ -1315,15 +1316,19 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
1315 1316
1316#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 1317#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1317/* Should only be used by the testing infrastructure */ 1318/* Should only be used by the testing infrastructure */
1318struct btrfs_root *btrfs_alloc_dummy_root(u32 sectorsize, u32 nodesize) 1319struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info,
1320 u32 sectorsize, u32 nodesize)
1319{ 1321{
1320 struct btrfs_root *root; 1322 struct btrfs_root *root;
1321 1323
1322 root = btrfs_alloc_root(NULL, GFP_KERNEL); 1324 if (!fs_info)
1325 return ERR_PTR(-EINVAL);
1326
1327 root = btrfs_alloc_root(fs_info, GFP_KERNEL);
1323 if (!root) 1328 if (!root)
1324 return ERR_PTR(-ENOMEM); 1329 return ERR_PTR(-ENOMEM);
1325 /* We don't use the stripesize in selftest, set it as sectorsize */ 1330 /* We don't use the stripesize in selftest, set it as sectorsize */
1326 __setup_root(nodesize, sectorsize, sectorsize, root, NULL, 1331 __setup_root(nodesize, sectorsize, sectorsize, root, fs_info,
1327 BTRFS_ROOT_TREE_OBJECTID); 1332 BTRFS_ROOT_TREE_OBJECTID);
1328 set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state); 1333 set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state);
1329 root->alloc_bytenr = 0; 1334 root->alloc_bytenr = 0;