aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-05-24 14:04:53 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commit0ef3e66b6700eb8f052daa8b89443ff872fbbdfc (patch)
tree26bce57770b4f093199b6f87ab8ed3a54e951337 /fs/btrfs/volumes.c
parent515dc3228c568f9df8b634f82b3471e20205ac16 (diff)
Btrfs: Allocator fix variety pack
* Force chunk allocation when find_free_extent has to do a full scan * Record the max key at the start of defrag so it doesn't run forever * Block groups might not be contiguous, make a forward search for the next block group in extent-tree.c * Get rid of extra checks for total fs size * Fix relocate_one_reference to avoid relocating the same file data block twice when referenced by an older transaction * Use the open device count when allocating chunks so that we don't try to allocate from devices that don't exist Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 333e5269577a..722eb4550154 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -750,10 +750,6 @@ static int btrfs_rm_dev_item(struct btrfs_root *root,
750 if (bdev == fs_devices->latest_bdev) 750 if (bdev == fs_devices->latest_bdev)
751 fs_devices->latest_bdev = next_dev->bdev; 751 fs_devices->latest_bdev = next_dev->bdev;
752 752
753 total_bytes = btrfs_super_total_bytes(&root->fs_info->super_copy);
754 btrfs_set_super_total_bytes(&root->fs_info->super_copy,
755 total_bytes - device->total_bytes);
756
757 total_bytes = btrfs_super_num_devices(&root->fs_info->super_copy); 753 total_bytes = btrfs_super_num_devices(&root->fs_info->super_copy);
758 btrfs_set_super_num_devices(&root->fs_info->super_copy, 754 btrfs_set_super_num_devices(&root->fs_info->super_copy,
759 total_bytes - 1); 755 total_bytes - 1);
@@ -849,6 +845,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
849 845
850 } 846 }
851 root->fs_info->fs_devices->num_devices--; 847 root->fs_info->fs_devices->num_devices--;
848 root->fs_info->fs_devices->open_devices--;
852 849
853 ret = btrfs_shrink_device(device, 0); 850 ret = btrfs_shrink_device(device, 0);
854 if (ret) 851 if (ret)
@@ -873,7 +870,6 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
873 if (device->bdev) { 870 if (device->bdev) {
874 /* one close for the device struct or super_block */ 871 /* one close for the device struct or super_block */
875 close_bdev_excl(device->bdev); 872 close_bdev_excl(device->bdev);
876 root->fs_info->fs_devices->open_devices--;
877 } 873 }
878 if (bdev) { 874 if (bdev) {
879 /* one close for us */ 875 /* one close for us */
@@ -1450,7 +1446,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
1450 return -ENOSPC; 1446 return -ENOSPC;
1451 1447
1452 if (type & (BTRFS_BLOCK_GROUP_RAID0)) { 1448 if (type & (BTRFS_BLOCK_GROUP_RAID0)) {
1453 num_stripes = btrfs_super_num_devices(&info->super_copy); 1449 num_stripes = extent_root->fs_info->fs_devices->open_devices;
1454 min_stripes = 2; 1450 min_stripes = 2;
1455 } 1451 }
1456 if (type & (BTRFS_BLOCK_GROUP_DUP)) { 1452 if (type & (BTRFS_BLOCK_GROUP_DUP)) {
@@ -1459,13 +1455,13 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
1459 } 1455 }
1460 if (type & (BTRFS_BLOCK_GROUP_RAID1)) { 1456 if (type & (BTRFS_BLOCK_GROUP_RAID1)) {
1461 num_stripes = min_t(u64, 2, 1457 num_stripes = min_t(u64, 2,
1462 btrfs_super_num_devices(&info->super_copy)); 1458 extent_root->fs_info->fs_devices->open_devices);
1463 if (num_stripes < 2) 1459 if (num_stripes < 2)
1464 return -ENOSPC; 1460 return -ENOSPC;
1465 min_stripes = 2; 1461 min_stripes = 2;
1466 } 1462 }
1467 if (type & (BTRFS_BLOCK_GROUP_RAID10)) { 1463 if (type & (BTRFS_BLOCK_GROUP_RAID10)) {
1468 num_stripes = btrfs_super_num_devices(&info->super_copy); 1464 num_stripes = extent_root->fs_info->fs_devices->open_devices;
1469 if (num_stripes < 4) 1465 if (num_stripes < 4)
1470 return -ENOSPC; 1466 return -ENOSPC;
1471 num_stripes &= ~(u32)1; 1467 num_stripes &= ~(u32)1;