aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 160b55b3e132..bcc461a9695f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -416,7 +416,7 @@ again:
416 } 416 }
417 if (start == 0) { 417 if (start == 0) {
418 trans = btrfs_join_transaction(root, 1); 418 trans = btrfs_join_transaction(root, 1);
419 BUG_ON(!trans); 419 BUG_ON(IS_ERR(trans));
420 btrfs_set_trans_block_group(trans, inode); 420 btrfs_set_trans_block_group(trans, inode);
421 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 421 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
422 422
@@ -612,6 +612,7 @@ retry:
612 GFP_NOFS); 612 GFP_NOFS);
613 613
614 trans = btrfs_join_transaction(root, 1); 614 trans = btrfs_join_transaction(root, 1);
615 BUG_ON(IS_ERR(trans));
615 ret = btrfs_reserve_extent(trans, root, 616 ret = btrfs_reserve_extent(trans, root,
616 async_extent->compressed_size, 617 async_extent->compressed_size,
617 async_extent->compressed_size, 618 async_extent->compressed_size,
@@ -771,7 +772,7 @@ static noinline int cow_file_range(struct inode *inode,
771 772
772 BUG_ON(root == root->fs_info->tree_root); 773 BUG_ON(root == root->fs_info->tree_root);
773 trans = btrfs_join_transaction(root, 1); 774 trans = btrfs_join_transaction(root, 1);
774 BUG_ON(!trans); 775 BUG_ON(IS_ERR(trans));
775 btrfs_set_trans_block_group(trans, inode); 776 btrfs_set_trans_block_group(trans, inode);
776 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 777 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
777 778
@@ -1049,7 +1050,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1049 } else { 1050 } else {
1050 trans = btrfs_join_transaction(root, 1); 1051 trans = btrfs_join_transaction(root, 1);
1051 } 1052 }
1052 BUG_ON(!trans); 1053 BUG_ON(IS_ERR(trans));
1053 1054
1054 cow_start = (u64)-1; 1055 cow_start = (u64)-1;
1055 cur_offset = start; 1056 cur_offset = start;
@@ -1557,6 +1558,7 @@ out:
1557out_page: 1558out_page:
1558 unlock_page(page); 1559 unlock_page(page);
1559 page_cache_release(page); 1560 page_cache_release(page);
1561 kfree(fixup);
1560} 1562}
1561 1563
1562/* 1564/*
@@ -1703,7 +1705,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
1703 trans = btrfs_join_transaction_nolock(root, 1); 1705 trans = btrfs_join_transaction_nolock(root, 1);
1704 else 1706 else
1705 trans = btrfs_join_transaction(root, 1); 1707 trans = btrfs_join_transaction(root, 1);
1706 BUG_ON(!trans); 1708 BUG_ON(IS_ERR(trans));
1707 btrfs_set_trans_block_group(trans, inode); 1709 btrfs_set_trans_block_group(trans, inode);
1708 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 1710 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
1709 ret = btrfs_update_inode(trans, root, inode); 1711 ret = btrfs_update_inode(trans, root, inode);
@@ -1720,6 +1722,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
1720 trans = btrfs_join_transaction_nolock(root, 1); 1722 trans = btrfs_join_transaction_nolock(root, 1);
1721 else 1723 else
1722 trans = btrfs_join_transaction(root, 1); 1724 trans = btrfs_join_transaction(root, 1);
1725 BUG_ON(IS_ERR(trans));
1723 btrfs_set_trans_block_group(trans, inode); 1726 btrfs_set_trans_block_group(trans, inode);
1724 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 1727 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
1725 1728
@@ -2354,6 +2357,7 @@ void btrfs_orphan_cleanup(struct btrfs_root *root)
2354 */ 2357 */
2355 if (is_bad_inode(inode)) { 2358 if (is_bad_inode(inode)) {
2356 trans = btrfs_start_transaction(root, 0); 2359 trans = btrfs_start_transaction(root, 0);
2360 BUG_ON(IS_ERR(trans));
2357 btrfs_orphan_del(trans, inode); 2361 btrfs_orphan_del(trans, inode);
2358 btrfs_end_transaction(trans, root); 2362 btrfs_end_transaction(trans, root);
2359 iput(inode); 2363 iput(inode);
@@ -2381,6 +2385,7 @@ void btrfs_orphan_cleanup(struct btrfs_root *root)
2381 2385
2382 if (root->orphan_block_rsv || root->orphan_item_inserted) { 2386 if (root->orphan_block_rsv || root->orphan_item_inserted) {
2383 trans = btrfs_join_transaction(root, 1); 2387 trans = btrfs_join_transaction(root, 1);
2388 BUG_ON(IS_ERR(trans));
2384 btrfs_end_transaction(trans, root); 2389 btrfs_end_transaction(trans, root);
2385 } 2390 }
2386 2391
@@ -2641,7 +2646,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2641 path = btrfs_alloc_path(); 2646 path = btrfs_alloc_path();
2642 if (!path) { 2647 if (!path) {
2643 ret = -ENOMEM; 2648 ret = -ENOMEM;
2644 goto err; 2649 goto out;
2645 } 2650 }
2646 2651
2647 path->leave_spinning = 1; 2652 path->leave_spinning = 1;
@@ -2714,9 +2719,10 @@ static int check_path_shared(struct btrfs_root *root,
2714 struct extent_buffer *eb; 2719 struct extent_buffer *eb;
2715 int level; 2720 int level;
2716 u64 refs = 1; 2721 u64 refs = 1;
2717 int uninitialized_var(ret);
2718 2722
2719 for (level = 0; level < BTRFS_MAX_LEVEL; level++) { 2723 for (level = 0; level < BTRFS_MAX_LEVEL; level++) {
2724 int ret;
2725
2720 if (!path->nodes[level]) 2726 if (!path->nodes[level])
2721 break; 2727 break;
2722 eb = path->nodes[level]; 2728 eb = path->nodes[level];
@@ -2727,7 +2733,7 @@ static int check_path_shared(struct btrfs_root *root,
2727 if (refs > 1) 2733 if (refs > 1)
2728 return 1; 2734 return 1;
2729 } 2735 }
2730 return ret; /* XXX callers? */ 2736 return 0;
2731} 2737}
2732 2738
2733/* 2739/*
@@ -4134,7 +4140,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
4134 } 4140 }
4135 srcu_read_unlock(&root->fs_info->subvol_srcu, index); 4141 srcu_read_unlock(&root->fs_info->subvol_srcu, index);
4136 4142
4137 if (root != sub_root) { 4143 if (!IS_ERR(inode) && root != sub_root) {
4138 down_read(&root->fs_info->cleanup_work_sem); 4144 down_read(&root->fs_info->cleanup_work_sem);
4139 if (!(inode->i_sb->s_flags & MS_RDONLY)) 4145 if (!(inode->i_sb->s_flags & MS_RDONLY))
4140 btrfs_orphan_cleanup(sub_root); 4146 btrfs_orphan_cleanup(sub_root);
@@ -4347,6 +4353,8 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc)
4347 trans = btrfs_join_transaction_nolock(root, 1); 4353 trans = btrfs_join_transaction_nolock(root, 1);
4348 else 4354 else
4349 trans = btrfs_join_transaction(root, 1); 4355 trans = btrfs_join_transaction(root, 1);
4356 if (IS_ERR(trans))
4357 return PTR_ERR(trans);
4350 btrfs_set_trans_block_group(trans, inode); 4358 btrfs_set_trans_block_group(trans, inode);
4351 if (nolock) 4359 if (nolock)
4352 ret = btrfs_end_transaction_nolock(trans, root); 4360 ret = btrfs_end_transaction_nolock(trans, root);
@@ -4372,6 +4380,7 @@ void btrfs_dirty_inode(struct inode *inode)
4372 return; 4380 return;
4373 4381
4374 trans = btrfs_join_transaction(root, 1); 4382 trans = btrfs_join_transaction(root, 1);
4383 BUG_ON(IS_ERR(trans));
4375 btrfs_set_trans_block_group(trans, inode); 4384 btrfs_set_trans_block_group(trans, inode);
4376 4385
4377 ret = btrfs_update_inode(trans, root, inode); 4386 ret = btrfs_update_inode(trans, root, inode);
@@ -5176,6 +5185,8 @@ again:
5176 em = NULL; 5185 em = NULL;
5177 btrfs_release_path(root, path); 5186 btrfs_release_path(root, path);
5178 trans = btrfs_join_transaction(root, 1); 5187 trans = btrfs_join_transaction(root, 1);
5188 if (IS_ERR(trans))
5189 return ERR_CAST(trans);
5179 goto again; 5190 goto again;
5180 } 5191 }
5181 map = kmap(page); 5192 map = kmap(page);
@@ -5280,8 +5291,8 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode,
5280 btrfs_drop_extent_cache(inode, start, start + len - 1, 0); 5291 btrfs_drop_extent_cache(inode, start, start + len - 1, 0);
5281 5292
5282 trans = btrfs_join_transaction(root, 0); 5293 trans = btrfs_join_transaction(root, 0);
5283 if (!trans) 5294 if (IS_ERR(trans))
5284 return ERR_PTR(-ENOMEM); 5295 return ERR_CAST(trans);
5285 5296
5286 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 5297 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
5287 5298
@@ -5505,7 +5516,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
5505 * while we look for nocow cross refs 5516 * while we look for nocow cross refs
5506 */ 5517 */
5507 trans = btrfs_join_transaction(root, 0); 5518 trans = btrfs_join_transaction(root, 0);
5508 if (!trans) 5519 if (IS_ERR(trans))
5509 goto must_cow; 5520 goto must_cow;
5510 5521
5511 if (can_nocow_odirect(trans, inode, start, len) == 1) { 5522 if (can_nocow_odirect(trans, inode, start, len) == 1) {
@@ -5640,7 +5651,7 @@ again:
5640 BUG_ON(!ordered); 5651 BUG_ON(!ordered);
5641 5652
5642 trans = btrfs_join_transaction(root, 1); 5653 trans = btrfs_join_transaction(root, 1);
5643 if (!trans) { 5654 if (IS_ERR(trans)) {
5644 err = -ENOMEM; 5655 err = -ENOMEM;
5645 goto out; 5656 goto out;
5646 } 5657 }