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>

authored by Tsutomu Itoh and committed by Chris Mason 98d5dc13 5df67083

+37 -6
+5 -2
fs/btrfs/extent-tree.c
··· 6271 6271 BUG_ON(!wc); 6272 6272 6273 6273 trans = btrfs_start_transaction(tree_root, 0); 6274 + BUG_ON(IS_ERR(trans)); 6275 + 6274 6276 if (block_rsv) 6275 6277 trans->block_rsv = block_rsv; 6276 6278 ··· 6370 6368 6371 6369 btrfs_end_transaction_throttle(trans, tree_root); 6372 6370 trans = btrfs_start_transaction(tree_root, 0); 6371 + BUG_ON(IS_ERR(trans)); 6373 6372 if (block_rsv) 6374 6373 trans->block_rsv = block_rsv; 6375 6374 } ··· 7590 7587 7591 7588 if (found) { 7592 7589 trans = btrfs_start_transaction(root, 1); 7593 - BUG_ON(!trans); 7590 + BUG_ON(IS_ERR(trans)); 7594 7591 ret = btrfs_commit_transaction(trans, root); 7595 7592 BUG_ON(ret); 7596 7593 } ··· 7834 7831 7835 7832 7836 7833 trans = btrfs_start_transaction(extent_root, 1); 7837 - BUG_ON(!trans); 7834 + BUG_ON(IS_ERR(trans)); 7838 7835 7839 7836 if (extent_key->objectid == 0) { 7840 7837 ret = del_extent_zero(trans, extent_root, path, extent_key);
+1
fs/btrfs/inode.c
··· 2357 2357 */ 2358 2358 if (is_bad_inode(inode)) { 2359 2359 trans = btrfs_start_transaction(root, 0); 2360 + BUG_ON(IS_ERR(trans)); 2360 2361 btrfs_orphan_del(trans, inode); 2361 2362 btrfs_end_transaction(trans, root); 2362 2363 iput(inode);
+8 -2
fs/btrfs/ioctl.c
··· 907 907 908 908 if (new_size > old_size) { 909 909 trans = btrfs_start_transaction(root, 0); 910 + if (IS_ERR(trans)) { 911 + ret = PTR_ERR(trans); 912 + goto out_unlock; 913 + } 910 914 ret = btrfs_grow_device(trans, device, new_size); 911 915 btrfs_commit_transaction(trans, root); 912 916 } else { ··· 2145 2141 path->leave_spinning = 1; 2146 2142 2147 2143 trans = btrfs_start_transaction(root, 1); 2148 - if (!trans) { 2144 + if (IS_ERR(trans)) { 2149 2145 btrfs_free_path(path); 2150 - return -ENOMEM; 2146 + return PTR_ERR(trans); 2151 2147 } 2152 2148 2153 2149 dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); ··· 2341 2337 u64 transid; 2342 2338 2343 2339 trans = btrfs_start_transaction(root, 0); 2340 + if (IS_ERR(trans)) 2341 + return PTR_ERR(trans); 2344 2342 transid = trans->transid; 2345 2343 btrfs_commit_transaction_async(trans, root, 0); 2346 2344
+3
fs/btrfs/relocation.c
··· 2028 2028 2029 2029 while (1) { 2030 2030 trans = btrfs_start_transaction(root, 0); 2031 + BUG_ON(IS_ERR(trans)); 2031 2032 trans->block_rsv = rc->block_rsv; 2032 2033 2033 2034 ret = btrfs_block_rsv_check(trans, root, rc->block_rsv, ··· 3666 3665 3667 3666 while (1) { 3668 3667 trans = btrfs_start_transaction(rc->extent_root, 0); 3668 + BUG_ON(IS_ERR(trans)); 3669 3669 3670 3670 if (update_backref_cache(trans, &rc->backref_cache)) { 3671 3671 btrfs_end_transaction(trans, rc->extent_root); ··· 4035 4033 int ret; 4036 4034 4037 4035 trans = btrfs_start_transaction(root->fs_info->tree_root, 0); 4036 + BUG_ON(IS_ERR(trans)); 4038 4037 4039 4038 memset(&root->root_item.drop_progress, 0, 4040 4039 sizeof(root->root_item.drop_progress));
+2
fs/btrfs/super.c
··· 623 623 btrfs_wait_ordered_extents(root, 0, 0); 624 624 625 625 trans = btrfs_start_transaction(root, 0); 626 + if (IS_ERR(trans)) 627 + return PTR_ERR(trans); 626 628 ret = btrfs_commit_transaction(trans, root); 627 629 return ret; 628 630 }
+1
fs/btrfs/tree-log.c
··· 3112 3112 BUG_ON(!path); 3113 3113 3114 3114 trans = btrfs_start_transaction(fs_info->tree_root, 0); 3115 + BUG_ON(IS_ERR(trans)); 3115 3116 3116 3117 wc.trans = trans; 3117 3118 wc.pin = 1;
+17 -2
fs/btrfs/volumes.c
··· 1212 1212 return -ENOMEM; 1213 1213 1214 1214 trans = btrfs_start_transaction(root, 0); 1215 + if (IS_ERR(trans)) { 1216 + btrfs_free_path(path); 1217 + return PTR_ERR(trans); 1218 + } 1215 1219 key.objectid = BTRFS_DEV_ITEMS_OBJECTID; 1216 1220 key.type = BTRFS_DEV_ITEM_KEY; 1217 1221 key.offset = device->devid; ··· 1608 1604 } 1609 1605 1610 1606 trans = btrfs_start_transaction(root, 0); 1607 + if (IS_ERR(trans)) { 1608 + kfree(device); 1609 + ret = PTR_ERR(trans); 1610 + goto error; 1611 + } 1612 + 1611 1613 lock_chunks(root); 1612 1614 1613 1615 device->barriers = 1; ··· 1882 1872 return ret; 1883 1873 1884 1874 trans = btrfs_start_transaction(root, 0); 1885 - BUG_ON(!trans); 1875 + BUG_ON(IS_ERR(trans)); 1886 1876 1887 1877 lock_chunks(root); 1888 1878 ··· 2056 2046 BUG_ON(ret); 2057 2047 2058 2048 trans = btrfs_start_transaction(dev_root, 0); 2059 - BUG_ON(!trans); 2049 + BUG_ON(IS_ERR(trans)); 2060 2050 2061 2051 ret = btrfs_grow_device(trans, device, old_size); 2062 2052 BUG_ON(ret); ··· 2222 2212 2223 2213 /* Shrinking succeeded, else we would be at "done". */ 2224 2214 trans = btrfs_start_transaction(root, 0); 2215 + if (IS_ERR(trans)) { 2216 + ret = PTR_ERR(trans); 2217 + goto done; 2218 + } 2219 + 2225 2220 lock_chunks(root); 2226 2221 2227 2222 device->disk_total_bytes = new_size;