diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2010-05-16 10:48:46 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-05-25 10:34:50 -0400 |
commit | a22285a6a32390195235171b89d157ed1a1fe932 (patch) | |
tree | 3fabc88a029e1af4f2fdcc708e7b62ef3cf3703a /fs/btrfs/volumes.c | |
parent | f0486c68e4bd9a06a5904d3eeb3a0d73a83befb8 (diff) |
Btrfs: Integrate metadata reservation with start_transaction
Besides simplify the code, this change makes sure all metadata
reservation for normal metadata operations are released after
committing transaction.
Changes since V1:
Add code that check if unlink and rmdir will free space.
Add ENOSPC handling for clone ioctl.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8db7b14bbae8..d6e3af8be95b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1097,7 +1097,7 @@ static int btrfs_rm_dev_item(struct btrfs_root *root, | |||
1097 | if (!path) | 1097 | if (!path) |
1098 | return -ENOMEM; | 1098 | return -ENOMEM; |
1099 | 1099 | ||
1100 | trans = btrfs_start_transaction(root, 1); | 1100 | trans = btrfs_start_transaction(root, 0); |
1101 | key.objectid = BTRFS_DEV_ITEMS_OBJECTID; | 1101 | key.objectid = BTRFS_DEV_ITEMS_OBJECTID; |
1102 | key.type = BTRFS_DEV_ITEM_KEY; | 1102 | key.type = BTRFS_DEV_ITEM_KEY; |
1103 | key.offset = device->devid; | 1103 | key.offset = device->devid; |
@@ -1486,7 +1486,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1486 | goto error; | 1486 | goto error; |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | trans = btrfs_start_transaction(root, 1); | 1489 | trans = btrfs_start_transaction(root, 0); |
1490 | lock_chunks(root); | 1490 | lock_chunks(root); |
1491 | 1491 | ||
1492 | device->barriers = 1; | 1492 | device->barriers = 1; |
@@ -1751,9 +1751,10 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, | |||
1751 | 1751 | ||
1752 | /* step one, relocate all the extents inside this chunk */ | 1752 | /* step one, relocate all the extents inside this chunk */ |
1753 | ret = btrfs_relocate_block_group(extent_root, chunk_offset); | 1753 | ret = btrfs_relocate_block_group(extent_root, chunk_offset); |
1754 | BUG_ON(ret); | 1754 | if (ret) |
1755 | return ret; | ||
1755 | 1756 | ||
1756 | trans = btrfs_start_transaction(root, 1); | 1757 | trans = btrfs_start_transaction(root, 0); |
1757 | BUG_ON(!trans); | 1758 | BUG_ON(!trans); |
1758 | 1759 | ||
1759 | lock_chunks(root); | 1760 | lock_chunks(root); |
@@ -1925,7 +1926,7 @@ int btrfs_balance(struct btrfs_root *dev_root) | |||
1925 | break; | 1926 | break; |
1926 | BUG_ON(ret); | 1927 | BUG_ON(ret); |
1927 | 1928 | ||
1928 | trans = btrfs_start_transaction(dev_root, 1); | 1929 | trans = btrfs_start_transaction(dev_root, 0); |
1929 | BUG_ON(!trans); | 1930 | BUG_ON(!trans); |
1930 | 1931 | ||
1931 | ret = btrfs_grow_device(trans, device, old_size); | 1932 | ret = btrfs_grow_device(trans, device, old_size); |
@@ -2094,11 +2095,7 @@ again: | |||
2094 | } | 2095 | } |
2095 | 2096 | ||
2096 | /* Shrinking succeeded, else we would be at "done". */ | 2097 | /* Shrinking succeeded, else we would be at "done". */ |
2097 | trans = btrfs_start_transaction(root, 1); | 2098 | trans = btrfs_start_transaction(root, 0); |
2098 | if (!trans) { | ||
2099 | ret = -ENOMEM; | ||
2100 | goto done; | ||
2101 | } | ||
2102 | lock_chunks(root); | 2099 | lock_chunks(root); |
2103 | 2100 | ||
2104 | device->disk_total_bytes = new_size; | 2101 | device->disk_total_bytes = new_size; |