aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.h
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2011-01-05 05:07:28 -0500
committerChris Mason <chris.mason@oracle.com>2011-01-16 11:30:19 -0500
commitb2117a39fa96cf4814e7cab8c11494149ba6f29d (patch)
tree9327d1332d68f91931767ee7bc6233251ab41565 /fs/btrfs/volumes.h
parent7bfc837df935d850fe996dfe92ef48975cd4170a (diff)
btrfs: make the chunk allocator utilize the devices better
With this patch, we change the handling method when we can not get enough free extents with default size. Implementation: 1. Look up the suitable free extent on each device and keep the search result. If not find a suitable free extent, keep the max free extent 2. If we get enough suitable free extents with default size, chunk allocation succeeds. 3. If we can not get enough free extents, but the number of the extent with default size is >= min_stripes, we just change the mapping information (reduce the number of stripes in the extent map), and chunk allocation succeeds. 4. If the number of the extent with default size is < min_stripes, sort the devices by its max free extent's size descending 5. Use the size of the max free extent on the (num_stripes - 1)th device as the stripe size to allocate the device space By this way, the chunk allocator can allocate chunks as large as possible when the devices' space is not enough and make full use of the devices. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.h')
-rw-r--r--fs/btrfs/volumes.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index a668c0116982..a5cfedf393f9 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -20,8 +20,11 @@
20#define __BTRFS_VOLUMES_ 20#define __BTRFS_VOLUMES_
21 21
22#include <linux/bio.h> 22#include <linux/bio.h>
23#include <linux/sort.h>
23#include "async-thread.h" 24#include "async-thread.h"
24 25
26#define BTRFS_STRIPE_LEN (64 * 1024)
27
25struct buffer_head; 28struct buffer_head;
26struct btrfs_pending_bios { 29struct btrfs_pending_bios {
27 struct bio *head; 30 struct bio *head;
@@ -137,6 +140,27 @@ struct btrfs_multi_bio {
137 struct btrfs_bio_stripe stripes[]; 140 struct btrfs_bio_stripe stripes[];
138}; 141};
139 142
143struct btrfs_device_info {
144 struct btrfs_device *dev;
145 u64 dev_offset;
146 u64 max_avail;
147};
148
149/* Used to sort the devices by max_avail(descending sort) */
150int btrfs_cmp_device_free_bytes(const void *dev_info1, const void *dev_info2);
151
152/*
153 * sort the devices by max_avail, in which max free extent size of each device
154 * is stored.(Descending Sort)
155 */
156static inline void btrfs_descending_sort_devices(
157 struct btrfs_device_info *devices,
158 size_t nr_devices)
159{
160 sort(devices, nr_devices, sizeof(struct btrfs_device_info),
161 btrfs_cmp_device_free_bytes, NULL);
162}
163
140#define btrfs_multi_bio_size(n) (sizeof(struct btrfs_multi_bio) + \ 164#define btrfs_multi_bio_size(n) (sizeof(struct btrfs_multi_bio) + \
141 (sizeof(struct btrfs_bio_stripe) * (n))) 165 (sizeof(struct btrfs_bio_stripe) * (n)))
142 166