diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d158530233b7..af7dbca15276 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1213,6 +1213,10 @@ static int btrfs_rm_dev_item(struct btrfs_root *root, | |||
1213 | return -ENOMEM; | 1213 | return -ENOMEM; |
1214 | 1214 | ||
1215 | trans = btrfs_start_transaction(root, 0); | 1215 | trans = btrfs_start_transaction(root, 0); |
1216 | if (IS_ERR(trans)) { | ||
1217 | btrfs_free_path(path); | ||
1218 | return PTR_ERR(trans); | ||
1219 | } | ||
1216 | key.objectid = BTRFS_DEV_ITEMS_OBJECTID; | 1220 | key.objectid = BTRFS_DEV_ITEMS_OBJECTID; |
1217 | key.type = BTRFS_DEV_ITEM_KEY; | 1221 | key.type = BTRFS_DEV_ITEM_KEY; |
1218 | key.offset = device->devid; | 1222 | key.offset = device->devid; |
@@ -1601,11 +1605,19 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1601 | 1605 | ||
1602 | ret = find_next_devid(root, &device->devid); | 1606 | ret = find_next_devid(root, &device->devid); |
1603 | if (ret) { | 1607 | if (ret) { |
1608 | kfree(device->name); | ||
1604 | kfree(device); | 1609 | kfree(device); |
1605 | goto error; | 1610 | goto error; |
1606 | } | 1611 | } |
1607 | 1612 | ||
1608 | trans = btrfs_start_transaction(root, 0); | 1613 | trans = btrfs_start_transaction(root, 0); |
1614 | if (IS_ERR(trans)) { | ||
1615 | kfree(device->name); | ||
1616 | kfree(device); | ||
1617 | ret = PTR_ERR(trans); | ||
1618 | goto error; | ||
1619 | } | ||
1620 | |||
1609 | lock_chunks(root); | 1621 | lock_chunks(root); |
1610 | 1622 | ||
1611 | device->writeable = 1; | 1623 | device->writeable = 1; |
@@ -1873,7 +1885,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, | |||
1873 | return ret; | 1885 | return ret; |
1874 | 1886 | ||
1875 | trans = btrfs_start_transaction(root, 0); | 1887 | trans = btrfs_start_transaction(root, 0); |
1876 | BUG_ON(!trans); | 1888 | BUG_ON(IS_ERR(trans)); |
1877 | 1889 | ||
1878 | lock_chunks(root); | 1890 | lock_chunks(root); |
1879 | 1891 | ||
@@ -2047,7 +2059,7 @@ int btrfs_balance(struct btrfs_root *dev_root) | |||
2047 | BUG_ON(ret); | 2059 | BUG_ON(ret); |
2048 | 2060 | ||
2049 | trans = btrfs_start_transaction(dev_root, 0); | 2061 | trans = btrfs_start_transaction(dev_root, 0); |
2050 | BUG_ON(!trans); | 2062 | BUG_ON(IS_ERR(trans)); |
2051 | 2063 | ||
2052 | ret = btrfs_grow_device(trans, device, old_size); | 2064 | ret = btrfs_grow_device(trans, device, old_size); |
2053 | BUG_ON(ret); | 2065 | BUG_ON(ret); |
@@ -2213,6 +2225,11 @@ again: | |||
2213 | 2225 | ||
2214 | /* Shrinking succeeded, else we would be at "done". */ | 2226 | /* Shrinking succeeded, else we would be at "done". */ |
2215 | trans = btrfs_start_transaction(root, 0); | 2227 | trans = btrfs_start_transaction(root, 0); |
2228 | if (IS_ERR(trans)) { | ||
2229 | ret = PTR_ERR(trans); | ||
2230 | goto done; | ||
2231 | } | ||
2232 | |||
2216 | lock_chunks(root); | 2233 | lock_chunks(root); |
2217 | 2234 | ||
2218 | device->disk_total_bytes = new_size; | 2235 | device->disk_total_bytes = new_size; |