aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/ctree.c3
-rw-r--r--fs/btrfs/disk-io.c5
-rw-r--r--fs/btrfs/extent-tree.c25
-rw-r--r--fs/btrfs/file-item.c3
-rw-r--r--fs/btrfs/inode-map.c3
-rw-r--r--fs/btrfs/ioctl.c5
-rw-r--r--fs/btrfs/root-tree.c6
-rw-r--r--fs/btrfs/transaction.c12
-rw-r--r--fs/btrfs/tree-log.c15
9 files changed, 54 insertions, 23 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 465b5d7d6b48..4edcbe915736 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3709,7 +3709,8 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
3709 unsigned long ptr; 3709 unsigned long ptr;
3710 3710
3711 path = btrfs_alloc_path(); 3711 path = btrfs_alloc_path();
3712 BUG_ON(!path); 3712 if (!path)
3713 return -ENOMEM;
3713 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); 3714 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
3714 if (!ret) { 3715 if (!ret) {
3715 leaf = path->nodes[0]; 3716 leaf = path->nodes[0];
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9f31e110b481..00cbb41af660 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1248,7 +1248,10 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root,
1248 root, fs_info, location->objectid); 1248 root, fs_info, location->objectid);
1249 1249
1250 path = btrfs_alloc_path(); 1250 path = btrfs_alloc_path();
1251 BUG_ON(!path); 1251 if (!path) {
1252 kfree(root);
1253 return ERR_PTR(-ENOMEM);
1254 }
1252 ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0); 1255 ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);
1253 if (ret == 0) { 1256 if (ret == 0) {
1254 l = path->nodes[0]; 1257 l = path->nodes[0];
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 86ea471d3801..a6a8159c5d1e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5463,7 +5463,8 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
5463 size = sizeof(*extent_item) + btrfs_extent_inline_ref_size(type); 5463 size = sizeof(*extent_item) + btrfs_extent_inline_ref_size(type);
5464 5464
5465 path = btrfs_alloc_path(); 5465 path = btrfs_alloc_path();
5466 BUG_ON(!path); 5466 if (!path)
5467 return -ENOMEM;
5467 5468
5468 path->leave_spinning = 1; 5469 path->leave_spinning = 1;
5469 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, 5470 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
@@ -6457,10 +6458,14 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
6457 BUG_ON(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID); 6458 BUG_ON(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
6458 6459
6459 path = btrfs_alloc_path(); 6460 path = btrfs_alloc_path();
6460 BUG_ON(!path); 6461 if (!path)
6462 return -ENOMEM;
6461 6463
6462 wc = kzalloc(sizeof(*wc), GFP_NOFS); 6464 wc = kzalloc(sizeof(*wc), GFP_NOFS);
6463 BUG_ON(!wc); 6465 if (!wc) {
6466 btrfs_free_path(path);
6467 return -ENOMEM;
6468 }
6464 6469
6465 btrfs_assert_tree_locked(parent); 6470 btrfs_assert_tree_locked(parent);
6466 parent_level = btrfs_header_level(parent); 6471 parent_level = btrfs_header_level(parent);
@@ -6918,7 +6923,11 @@ static noinline int get_new_locations(struct inode *reloc_inode,
6918 } 6923 }
6919 6924
6920 path = btrfs_alloc_path(); 6925 path = btrfs_alloc_path();
6921 BUG_ON(!path); 6926 if (!path) {
6927 if (exts != *extents)
6928 kfree(exts);
6929 return -ENOMEM;
6930 }
6922 6931
6923 cur_pos = extent_key->objectid - offset; 6932 cur_pos = extent_key->objectid - offset;
6924 last_byte = extent_key->objectid + extent_key->offset; 6933 last_byte = extent_key->objectid + extent_key->offset;
@@ -7442,7 +7451,8 @@ static noinline int replace_extents_in_leaf(struct btrfs_trans_handle *trans,
7442 int ret; 7451 int ret;
7443 7452
7444 new_extent = kmalloc(sizeof(*new_extent), GFP_NOFS); 7453 new_extent = kmalloc(sizeof(*new_extent), GFP_NOFS);
7445 BUG_ON(!new_extent); 7454 if (!new_extent)
7455 return -ENOMEM;
7446 7456
7447 ref = btrfs_lookup_leaf_ref(root, leaf->start); 7457 ref = btrfs_lookup_leaf_ref(root, leaf->start);
7448 BUG_ON(!ref); 7458 BUG_ON(!ref);
@@ -7647,7 +7657,8 @@ static noinline int init_reloc_tree(struct btrfs_trans_handle *trans,
7647 return 0; 7657 return 0;
7648 7658
7649 root_item = kmalloc(sizeof(*root_item), GFP_NOFS); 7659 root_item = kmalloc(sizeof(*root_item), GFP_NOFS);
7650 BUG_ON(!root_item); 7660 if (!root_item)
7661 return -ENOMEM;
7651 7662
7652 ret = btrfs_copy_root(trans, root, root->commit_root, 7663 ret = btrfs_copy_root(trans, root, root->commit_root,
7653 &eb, BTRFS_TREE_RELOC_OBJECTID); 7664 &eb, BTRFS_TREE_RELOC_OBJECTID);
@@ -7673,7 +7684,7 @@ static noinline int init_reloc_tree(struct btrfs_trans_handle *trans,
7673 7684
7674 reloc_root = btrfs_read_fs_root_no_radix(root->fs_info->tree_root, 7685 reloc_root = btrfs_read_fs_root_no_radix(root->fs_info->tree_root,
7675 &root_key); 7686 &root_key);
7676 BUG_ON(!reloc_root); 7687 BUG_ON(IS_ERR(reloc_root));
7677 reloc_root->last_trans = trans->transid; 7688 reloc_root->last_trans = trans->transid;
7678 reloc_root->commit_root = NULL; 7689 reloc_root->commit_root = NULL;
7679 reloc_root->ref_tree = &root->fs_info->reloc_ref_tree; 7690 reloc_root->ref_tree = &root->fs_info->reloc_ref_tree;
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 4f19a3e1bf32..a2134195a85e 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -48,7 +48,8 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
48 struct extent_buffer *leaf; 48 struct extent_buffer *leaf;
49 49
50 path = btrfs_alloc_path(); 50 path = btrfs_alloc_path();
51 BUG_ON(!path); 51 if (!path)
52 return -ENOMEM;
52 file_key.objectid = objectid; 53 file_key.objectid = objectid;
53 file_key.offset = pos; 54 file_key.offset = pos;
54 btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY); 55 btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index c56eb5909172..c05a08f4c411 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -30,7 +30,8 @@ int btrfs_find_highest_inode(struct btrfs_root *root, u64 *objectid)
30 int slot; 30 int slot;
31 31
32 path = btrfs_alloc_path(); 32 path = btrfs_alloc_path();
33 BUG_ON(!path); 33 if (!path)
34 return -ENOMEM;
34 35
35 search_key.objectid = BTRFS_LAST_FREE_OBJECTID; 36 search_key.objectid = BTRFS_LAST_FREE_OBJECTID;
36 search_key.type = -1; 37 search_key.type = -1;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ad9b8c0e930b..88d3cb2eaf75 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2350,12 +2350,15 @@ static noinline long btrfs_ioctl_start_sync(struct file *file, void __user *argp
2350 struct btrfs_root *root = BTRFS_I(file->f_dentry->d_inode)->root; 2350 struct btrfs_root *root = BTRFS_I(file->f_dentry->d_inode)->root;
2351 struct btrfs_trans_handle *trans; 2351 struct btrfs_trans_handle *trans;
2352 u64 transid; 2352 u64 transid;
2353 int ret;
2353 2354
2354 trans = btrfs_start_transaction(root, 0); 2355 trans = btrfs_start_transaction(root, 0);
2355 if (IS_ERR(trans)) 2356 if (IS_ERR(trans))
2356 return PTR_ERR(trans); 2357 return PTR_ERR(trans);
2357 transid = trans->transid; 2358 transid = trans->transid;
2358 btrfs_commit_transaction_async(trans, root, 0); 2359 ret = btrfs_commit_transaction_async(trans, root, 0);
2360 if (ret)
2361 return ret;
2359 2362
2360 if (argp) 2363 if (argp)
2361 if (copy_to_user(argp, &transid, sizeof(transid))) 2364 if (copy_to_user(argp, &transid, sizeof(transid)))
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 6a1086e83ffc..29b2d7c930eb 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -88,7 +88,8 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
88 search_key.offset = (u64)-1; 88 search_key.offset = (u64)-1;
89 89
90 path = btrfs_alloc_path(); 90 path = btrfs_alloc_path();
91 BUG_ON(!path); 91 if (!path)
92 return -ENOMEM;
92 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); 93 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
93 if (ret < 0) 94 if (ret < 0)
94 goto out; 95 goto out;
@@ -332,7 +333,8 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
332 struct extent_buffer *leaf; 333 struct extent_buffer *leaf;
333 334
334 path = btrfs_alloc_path(); 335 path = btrfs_alloc_path();
335 BUG_ON(!path); 336 if (!path)
337 return -ENOMEM;
336 ret = btrfs_search_slot(trans, root, key, path, -1, 1); 338 ret = btrfs_search_slot(trans, root, key, path, -1, 1);
337 if (ret < 0) 339 if (ret < 0)
338 goto out; 340 goto out;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5b4bc685bb0e..ce48eb59d615 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -57,7 +57,8 @@ static noinline int join_transaction(struct btrfs_root *root)
57 if (!cur_trans) { 57 if (!cur_trans) {
58 cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, 58 cur_trans = kmem_cache_alloc(btrfs_transaction_cachep,
59 GFP_NOFS); 59 GFP_NOFS);
60 BUG_ON(!cur_trans); 60 if (!cur_trans)
61 return -ENOMEM;
61 root->fs_info->generation++; 62 root->fs_info->generation++;
62 cur_trans->num_writers = 1; 63 cur_trans->num_writers = 1;
63 cur_trans->num_joined = 0; 64 cur_trans->num_joined = 0;
@@ -195,7 +196,11 @@ again:
195 wait_current_trans(root); 196 wait_current_trans(root);
196 197
197 ret = join_transaction(root); 198 ret = join_transaction(root);
198 BUG_ON(ret); 199 if (ret < 0) {
200 if (type != TRANS_JOIN_NOLOCK)
201 mutex_unlock(&root->fs_info->trans_mutex);
202 return ERR_PTR(ret);
203 }
199 204
200 cur_trans = root->fs_info->running_transaction; 205 cur_trans = root->fs_info->running_transaction;
201 cur_trans->use_count++; 206 cur_trans->use_count++;
@@ -1156,7 +1161,8 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
1156 struct btrfs_transaction *cur_trans; 1161 struct btrfs_transaction *cur_trans;
1157 1162
1158 ac = kmalloc(sizeof(*ac), GFP_NOFS); 1163 ac = kmalloc(sizeof(*ac), GFP_NOFS);
1159 BUG_ON(!ac); 1164 if (!ac)
1165 return -ENOMEM;
1160 1166
1161 INIT_DELAYED_WORK(&ac->work, do_async_commit); 1167 INIT_DELAYED_WORK(&ac->work, do_async_commit);
1162 ac->root = root; 1168 ac->root = root;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 429cfcfadf90..f9425e33e358 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1828,7 +1828,8 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
1828 int orig_level; 1828 int orig_level;
1829 1829
1830 path = btrfs_alloc_path(); 1830 path = btrfs_alloc_path();
1831 BUG_ON(!path); 1831 if (!path)
1832 return -ENOMEM;
1832 1833
1833 level = btrfs_header_level(log->node); 1834 level = btrfs_header_level(log->node);
1834 orig_level = level; 1835 orig_level = level;
@@ -3114,9 +3115,11 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
3114 .stage = 0, 3115 .stage = 0,
3115 }; 3116 };
3116 3117
3117 fs_info->log_root_recovering = 1;
3118 path = btrfs_alloc_path(); 3118 path = btrfs_alloc_path();
3119 BUG_ON(!path); 3119 if (!path)
3120 return -ENOMEM;
3121
3122 fs_info->log_root_recovering = 1;
3120 3123
3121 trans = btrfs_start_transaction(fs_info->tree_root, 0); 3124 trans = btrfs_start_transaction(fs_info->tree_root, 0);
3122 BUG_ON(IS_ERR(trans)); 3125 BUG_ON(IS_ERR(trans));
@@ -3124,7 +3127,8 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
3124 wc.trans = trans; 3127 wc.trans = trans;
3125 wc.pin = 1; 3128 wc.pin = 1;
3126 3129
3127 walk_log_tree(trans, log_root_tree, &wc); 3130 ret = walk_log_tree(trans, log_root_tree, &wc);
3131 BUG_ON(ret);
3128 3132
3129again: 3133again:
3130 key.objectid = BTRFS_TREE_LOG_OBJECTID; 3134 key.objectid = BTRFS_TREE_LOG_OBJECTID;
@@ -3148,8 +3152,7 @@ again:
3148 3152
3149 log = btrfs_read_fs_root_no_radix(log_root_tree, 3153 log = btrfs_read_fs_root_no_radix(log_root_tree,
3150 &found_key); 3154 &found_key);
3151 BUG_ON(!log); 3155 BUG_ON(IS_ERR(log));
3152
3153 3156
3154 tmp_key.objectid = found_key.offset; 3157 tmp_key.objectid = found_key.offset;
3155 tmp_key.type = BTRFS_ROOT_ITEM_KEY; 3158 tmp_key.type = BTRFS_ROOT_ITEM_KEY;