aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>2011-01-20 01:19:37 -0500
committerChris Mason <chris.mason@oracle.com>2011-02-01 07:17:27 -0500
commit98d5dc13e7e74b77ca3b4c3cbded9f48d2dbbbb7 (patch)
tree8e75f67b28b5b0d909483a06bb5258e0ba0c9789
parent5df67083488ccbad925f583b698ab38f8629a016 (diff)
btrfs: fix return value check of btrfs_start_transaction()
The error check of btrfs_start_transaction() is added, and the mistake of the error check on several places is corrected. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/extent-tree.c7
-rw-r--r--fs/btrfs/inode.c1
-rw-r--r--fs/btrfs/ioctl.c10
-rw-r--r--fs/btrfs/relocation.c3
-rw-r--r--fs/btrfs/super.c2
-rw-r--r--fs/btrfs/tree-log.c1
-rw-r--r--fs/btrfs/volumes.c19
7 files changed, 37 insertions, 6 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9de4ff03882a..f07ba21cbf06 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6271,6 +6271,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
6271 BUG_ON(!wc); 6271 BUG_ON(!wc);
6272 6272
6273 trans = btrfs_start_transaction(tree_root, 0); 6273 trans = btrfs_start_transaction(tree_root, 0);
6274 BUG_ON(IS_ERR(trans));
6275
6274 if (block_rsv) 6276 if (block_rsv)
6275 trans->block_rsv = block_rsv; 6277 trans->block_rsv = block_rsv;
6276 6278
@@ -6368,6 +6370,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
6368 6370
6369 btrfs_end_transaction_throttle(trans, tree_root); 6371 btrfs_end_transaction_throttle(trans, tree_root);
6370 trans = btrfs_start_transaction(tree_root, 0); 6372 trans = btrfs_start_transaction(tree_root, 0);
6373 BUG_ON(IS_ERR(trans));
6371 if (block_rsv) 6374 if (block_rsv)
6372 trans->block_rsv = block_rsv; 6375 trans->block_rsv = block_rsv;
6373 } 6376 }
@@ -7587,7 +7590,7 @@ int btrfs_cleanup_reloc_trees(struct btrfs_root *root)
7587 7590
7588 if (found) { 7591 if (found) {
7589 trans = btrfs_start_transaction(root, 1); 7592 trans = btrfs_start_transaction(root, 1);
7590 BUG_ON(!trans); 7593 BUG_ON(IS_ERR(trans));
7591 ret = btrfs_commit_transaction(trans, root); 7594 ret = btrfs_commit_transaction(trans, root);
7592 BUG_ON(ret); 7595 BUG_ON(ret);
7593 } 7596 }
@@ -7831,7 +7834,7 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root,
7831 7834
7832 7835
7833 trans = btrfs_start_transaction(extent_root, 1); 7836 trans = btrfs_start_transaction(extent_root, 1);
7834 BUG_ON(!trans); 7837 BUG_ON(IS_ERR(trans));
7835 7838
7836 if (extent_key->objectid == 0) { 7839 if (extent_key->objectid == 0) {
7837 ret = del_extent_zero(trans, extent_root, path, extent_key); 7840 ret = del_extent_zero(trans, extent_root, path, extent_key);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5621818921f8..36bc3f49ebf9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2357,6 +2357,7 @@ void btrfs_orphan_cleanup(struct btrfs_root *root)
2357 */ 2357 */
2358 if (is_bad_inode(inode)) { 2358 if (is_bad_inode(inode)) {
2359 trans = btrfs_start_transaction(root, 0); 2359 trans = btrfs_start_transaction(root, 0);
2360 BUG_ON(IS_ERR(trans));
2360 btrfs_orphan_del(trans, inode); 2361 btrfs_orphan_del(trans, inode);
2361 btrfs_end_transaction(trans, root); 2362 btrfs_end_transaction(trans, root);
2362 iput(inode); 2363 iput(inode);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 12dabe28cf54..02d224e8c83f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -907,6 +907,10 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
907 907
908 if (new_size > old_size) { 908 if (new_size > old_size) {
909 trans = btrfs_start_transaction(root, 0); 909 trans = btrfs_start_transaction(root, 0);
910 if (IS_ERR(trans)) {
911 ret = PTR_ERR(trans);
912 goto out_unlock;
913 }
910 ret = btrfs_grow_device(trans, device, new_size); 914 ret = btrfs_grow_device(trans, device, new_size);
911 btrfs_commit_transaction(trans, root); 915 btrfs_commit_transaction(trans, root);
912 } else { 916 } else {
@@ -2141,9 +2145,9 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
2141 path->leave_spinning = 1; 2145 path->leave_spinning = 1;
2142 2146
2143 trans = btrfs_start_transaction(root, 1); 2147 trans = btrfs_start_transaction(root, 1);
2144 if (!trans) { 2148 if (IS_ERR(trans)) {
2145 btrfs_free_path(path); 2149 btrfs_free_path(path);
2146 return -ENOMEM; 2150 return PTR_ERR(trans);
2147 } 2151 }
2148 2152
2149 dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); 2153 dir_id = btrfs_super_root_dir(&root->fs_info->super_copy);
@@ -2337,6 +2341,8 @@ static noinline long btrfs_ioctl_start_sync(struct file *file, void __user *argp
2337 u64 transid; 2341 u64 transid;
2338 2342
2339 trans = btrfs_start_transaction(root, 0); 2343 trans = btrfs_start_transaction(root, 0);
2344 if (IS_ERR(trans))
2345 return PTR_ERR(trans);
2340 transid = trans->transid; 2346 transid = trans->transid;
2341 btrfs_commit_transaction_async(trans, root, 0); 2347 btrfs_commit_transaction_async(trans, root, 0);
2342 2348
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index ea9965430241..1f5556acb530 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2028,6 +2028,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
2028 2028
2029 while (1) { 2029 while (1) {
2030 trans = btrfs_start_transaction(root, 0); 2030 trans = btrfs_start_transaction(root, 0);
2031 BUG_ON(IS_ERR(trans));
2031 trans->block_rsv = rc->block_rsv; 2032 trans->block_rsv = rc->block_rsv;
2032 2033
2033 ret = btrfs_block_rsv_check(trans, root, rc->block_rsv, 2034 ret = btrfs_block_rsv_check(trans, root, rc->block_rsv,
@@ -3665,6 +3666,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3665 3666
3666 while (1) { 3667 while (1) {
3667 trans = btrfs_start_transaction(rc->extent_root, 0); 3668 trans = btrfs_start_transaction(rc->extent_root, 0);
3669 BUG_ON(IS_ERR(trans));
3668 3670
3669 if (update_backref_cache(trans, &rc->backref_cache)) { 3671 if (update_backref_cache(trans, &rc->backref_cache)) {
3670 btrfs_end_transaction(trans, rc->extent_root); 3672 btrfs_end_transaction(trans, rc->extent_root);
@@ -4033,6 +4035,7 @@ static noinline_for_stack int mark_garbage_root(struct btrfs_root *root)
4033 int ret; 4035 int ret;
4034 4036
4035 trans = btrfs_start_transaction(root->fs_info->tree_root, 0); 4037 trans = btrfs_start_transaction(root->fs_info->tree_root, 0);
4038 BUG_ON(IS_ERR(trans));
4036 4039
4037 memset(&root->root_item.drop_progress, 0, 4040 memset(&root->root_item.drop_progress, 0,
4038 sizeof(root->root_item.drop_progress)); 4041 sizeof(root->root_item.drop_progress));
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f4e45fdded30..0209b5fc772c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -623,6 +623,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
623 btrfs_wait_ordered_extents(root, 0, 0); 623 btrfs_wait_ordered_extents(root, 0, 0);
624 624
625 trans = btrfs_start_transaction(root, 0); 625 trans = btrfs_start_transaction(root, 0);
626 if (IS_ERR(trans))
627 return PTR_ERR(trans);
626 ret = btrfs_commit_transaction(trans, root); 628 ret = btrfs_commit_transaction(trans, root);
627 return ret; 629 return ret;
628} 630}
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 6d66e5caff97..a4bbb854dfd2 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3112,6 +3112,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
3112 BUG_ON(!path); 3112 BUG_ON(!path);
3113 3113
3114 trans = btrfs_start_transaction(fs_info->tree_root, 0); 3114 trans = btrfs_start_transaction(fs_info->tree_root, 0);
3115 BUG_ON(IS_ERR(trans));
3115 3116
3116 wc.trans = trans; 3117 wc.trans = trans;
3117 wc.pin = 1; 3118 wc.pin = 1;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f2d2f4ccc738..7cad59353b09 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1212,6 +1212,10 @@ static int btrfs_rm_dev_item(struct btrfs_root *root,
1212 return -ENOMEM; 1212 return -ENOMEM;
1213 1213
1214 trans = btrfs_start_transaction(root, 0); 1214 trans = btrfs_start_transaction(root, 0);
1215 if (IS_ERR(trans)) {
1216 btrfs_free_path(path);
1217 return PTR_ERR(trans);
1218 }
1215 key.objectid = BTRFS_DEV_ITEMS_OBJECTID; 1219 key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
1216 key.type = BTRFS_DEV_ITEM_KEY; 1220 key.type = BTRFS_DEV_ITEM_KEY;
1217 key.offset = device->devid; 1221 key.offset = device->devid;
@@ -1604,6 +1608,12 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1604 } 1608 }
1605 1609
1606 trans = btrfs_start_transaction(root, 0); 1610 trans = btrfs_start_transaction(root, 0);
1611 if (IS_ERR(trans)) {
1612 kfree(device);
1613 ret = PTR_ERR(trans);
1614 goto error;
1615 }
1616
1607 lock_chunks(root); 1617 lock_chunks(root);
1608 1618
1609 device->barriers = 1; 1619 device->barriers = 1;
@@ -1872,7 +1882,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
1872 return ret; 1882 return ret;
1873 1883
1874 trans = btrfs_start_transaction(root, 0); 1884 trans = btrfs_start_transaction(root, 0);
1875 BUG_ON(!trans); 1885 BUG_ON(IS_ERR(trans));
1876 1886
1877 lock_chunks(root); 1887 lock_chunks(root);
1878 1888
@@ -2046,7 +2056,7 @@ int btrfs_balance(struct btrfs_root *dev_root)
2046 BUG_ON(ret); 2056 BUG_ON(ret);
2047 2057
2048 trans = btrfs_start_transaction(dev_root, 0); 2058 trans = btrfs_start_transaction(dev_root, 0);
2049 BUG_ON(!trans); 2059 BUG_ON(IS_ERR(trans));
2050 2060
2051 ret = btrfs_grow_device(trans, device, old_size); 2061 ret = btrfs_grow_device(trans, device, old_size);
2052 BUG_ON(ret); 2062 BUG_ON(ret);
@@ -2212,6 +2222,11 @@ again:
2212 2222
2213 /* Shrinking succeeded, else we would be at "done". */ 2223 /* Shrinking succeeded, else we would be at "done". */
2214 trans = btrfs_start_transaction(root, 0); 2224 trans = btrfs_start_transaction(root, 0);
2225 if (IS_ERR(trans)) {
2226 ret = PTR_ERR(trans);
2227 goto done;
2228 }
2229
2215 lock_chunks(root); 2230 lock_chunks(root);
2216 2231
2217 device->disk_total_bytes = new_size; 2232 device->disk_total_bytes = new_size;