aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-02-11 05:01:55 -0500
committerDavid Sterba <dsterba@suse.com>2016-02-11 09:19:39 -0500
commit74e4d82757f7479bab6b854783f84a5b9f2df78f (patch)
tree431bd5f422a044bd2c74e94c47404ea231796951 /fs/btrfs/disk-io.c
parent58c4e173847af8e63537e11be6c1c3fd4b6153fe (diff)
btrfs: let callers of btrfs_alloc_root pass gfp flags
We don't need to use GFP_NOFS in all contexts, eg. during mount or for dummy root tree, but we might for the the log tree creation. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4545e2e2ad45..40690e90beee 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1296,9 +1296,10 @@ static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
1296 spin_lock_init(&root->root_item_lock); 1296 spin_lock_init(&root->root_item_lock);
1297} 1297}
1298 1298
1299static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info) 1299static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
1300 gfp_t flags)
1300{ 1301{
1301 struct btrfs_root *root = kzalloc(sizeof(*root), GFP_NOFS); 1302 struct btrfs_root *root = kzalloc(sizeof(*root), flags);
1302 if (root) 1303 if (root)
1303 root->fs_info = fs_info; 1304 root->fs_info = fs_info;
1304 return root; 1305 return root;
@@ -1310,7 +1311,7 @@ struct btrfs_root *btrfs_alloc_dummy_root(void)
1310{ 1311{
1311 struct btrfs_root *root; 1312 struct btrfs_root *root;
1312 1313
1313 root = btrfs_alloc_root(NULL); 1314 root = btrfs_alloc_root(NULL, GFP_KERNEL);
1314 if (!root) 1315 if (!root)
1315 return ERR_PTR(-ENOMEM); 1316 return ERR_PTR(-ENOMEM);
1316 __setup_root(4096, 4096, 4096, root, NULL, 1); 1317 __setup_root(4096, 4096, 4096, root, NULL, 1);
@@ -1332,7 +1333,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
1332 int ret = 0; 1333 int ret = 0;
1333 uuid_le uuid; 1334 uuid_le uuid;
1334 1335
1335 root = btrfs_alloc_root(fs_info); 1336 root = btrfs_alloc_root(fs_info, GFP_KERNEL);
1336 if (!root) 1337 if (!root)
1337 return ERR_PTR(-ENOMEM); 1338 return ERR_PTR(-ENOMEM);
1338 1339
@@ -1408,7 +1409,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
1408 struct btrfs_root *tree_root = fs_info->tree_root; 1409 struct btrfs_root *tree_root = fs_info->tree_root;
1409 struct extent_buffer *leaf; 1410 struct extent_buffer *leaf;
1410 1411
1411 root = btrfs_alloc_root(fs_info); 1412 root = btrfs_alloc_root(fs_info, GFP_NOFS);
1412 if (!root) 1413 if (!root)
1413 return ERR_PTR(-ENOMEM); 1414 return ERR_PTR(-ENOMEM);
1414 1415
@@ -1506,7 +1507,7 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
1506 if (!path) 1507 if (!path)
1507 return ERR_PTR(-ENOMEM); 1508 return ERR_PTR(-ENOMEM);
1508 1509
1509 root = btrfs_alloc_root(fs_info); 1510 root = btrfs_alloc_root(fs_info, GFP_NOFS);
1510 if (!root) { 1511 if (!root) {
1511 ret = -ENOMEM; 1512 ret = -ENOMEM;
1512 goto alloc_fail; 1513 goto alloc_fail;
@@ -2385,7 +2386,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
2385 return -EIO; 2386 return -EIO;
2386 } 2387 }
2387 2388
2388 log_tree_root = btrfs_alloc_root(fs_info); 2389 log_tree_root = btrfs_alloc_root(fs_info, GFP_KERNEL);
2389 if (!log_tree_root) 2390 if (!log_tree_root)
2390 return -ENOMEM; 2391 return -ENOMEM;
2391 2392
@@ -2510,8 +2511,8 @@ int open_ctree(struct super_block *sb,
2510 int backup_index = 0; 2511 int backup_index = 0;
2511 int max_active; 2512 int max_active;
2512 2513
2513 tree_root = fs_info->tree_root = btrfs_alloc_root(fs_info); 2514 tree_root = fs_info->tree_root = btrfs_alloc_root(fs_info, GFP_KERNEL);
2514 chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info); 2515 chunk_root = fs_info->chunk_root = btrfs_alloc_root(fs_info, GFP_KERNEL);
2515 if (!tree_root || !chunk_root) { 2516 if (!tree_root || !chunk_root) {
2516 err = -ENOMEM; 2517 err = -ENOMEM;
2517 goto fail; 2518 goto fail;
@@ -2622,7 +2623,7 @@ int open_ctree(struct super_block *sb,
2622 INIT_LIST_HEAD(&fs_info->ordered_roots); 2623 INIT_LIST_HEAD(&fs_info->ordered_roots);
2623 spin_lock_init(&fs_info->ordered_root_lock); 2624 spin_lock_init(&fs_info->ordered_root_lock);
2624 fs_info->delayed_root = kmalloc(sizeof(struct btrfs_delayed_root), 2625 fs_info->delayed_root = kmalloc(sizeof(struct btrfs_delayed_root),
2625 GFP_NOFS); 2626 GFP_KERNEL);
2626 if (!fs_info->delayed_root) { 2627 if (!fs_info->delayed_root) {
2627 err = -ENOMEM; 2628 err = -ENOMEM;
2628 goto fail_iput; 2629 goto fail_iput;