aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Jansen <sensille@gmx.net>2011-04-12 04:43:21 -0400
committerArne Jansen <sensille@gmx.net>2011-05-13 09:36:05 -0400
commitbcd53741cc2af4342ac3ff6983bddc4a1b63b9b4 (patch)
tree5be83348abb93689effda63918fdec4fb0b5461c
parent7cf96da3ec7ca225acf4f284b0e904a1f5f98821 (diff)
btrfs: move btrfs_cmp_device_free_bytes to super.c
this function won't be used here anymore, so move it super.c where it is used for df-calculation
-rw-r--r--fs/btrfs/super.c26
-rw-r--r--fs/btrfs/volumes.c13
-rw-r--r--fs/btrfs/volumes.h15
3 files changed, 26 insertions, 28 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 0ac712efcdf2..32fe8b33cc1c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -913,6 +913,32 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
913 return 0; 913 return 0;
914} 914}
915 915
916/* Used to sort the devices by max_avail(descending sort) */
917static int btrfs_cmp_device_free_bytes(const void *dev_info1,
918 const void *dev_info2)
919{
920 if (((struct btrfs_device_info *)dev_info1)->max_avail >
921 ((struct btrfs_device_info *)dev_info2)->max_avail)
922 return -1;
923 else if (((struct btrfs_device_info *)dev_info1)->max_avail <
924 ((struct btrfs_device_info *)dev_info2)->max_avail)
925 return 1;
926 else
927 return 0;
928}
929
930/*
931 * sort the devices by max_avail, in which max free extent size of each device
932 * is stored.(Descending Sort)
933 */
934static inline void btrfs_descending_sort_devices(
935 struct btrfs_device_info *devices,
936 size_t nr_devices)
937{
938 sort(devices, nr_devices, sizeof(struct btrfs_device_info),
939 btrfs_cmp_device_free_bytes, NULL);
940}
941
916/* 942/*
917 * The helper to calc the free space on the devices that can be used to store 943 * The helper to calc the free space on the devices that can be used to store
918 * file data. 944 * file data.
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8b9fb8c7683d..a9f1fc23278b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2282,19 +2282,6 @@ static noinline u64 chunk_bytes_by_type(u64 type, u64 calc_size,
2282 return calc_size * num_stripes; 2282 return calc_size * num_stripes;
2283} 2283}
2284 2284
2285/* Used to sort the devices by max_avail(descending sort) */
2286int btrfs_cmp_device_free_bytes(const void *dev_info1, const void *dev_info2)
2287{
2288 if (((struct btrfs_device_info *)dev_info1)->max_avail >
2289 ((struct btrfs_device_info *)dev_info2)->max_avail)
2290 return -1;
2291 else if (((struct btrfs_device_info *)dev_info1)->max_avail <
2292 ((struct btrfs_device_info *)dev_info2)->max_avail)
2293 return 1;
2294 else
2295 return 0;
2296}
2297
2298static int __btrfs_calc_nstripes(struct btrfs_fs_devices *fs_devices, u64 type, 2285static int __btrfs_calc_nstripes(struct btrfs_fs_devices *fs_devices, u64 type,
2299 int *num_stripes, int *min_stripes, 2286 int *num_stripes, int *min_stripes,
2300 int *sub_stripes) 2287 int *sub_stripes)
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index cc2eadaf7a27..b502f01f79ed 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -157,21 +157,6 @@ struct map_lookup {
157 struct btrfs_bio_stripe stripes[]; 157 struct btrfs_bio_stripe stripes[];
158}; 158};
159 159
160/* Used to sort the devices by max_avail(descending sort) */
161int btrfs_cmp_device_free_bytes(const void *dev_info1, const void *dev_info2);
162
163/*
164 * sort the devices by max_avail, in which max free extent size of each device
165 * is stored.(Descending Sort)
166 */
167static inline void btrfs_descending_sort_devices(
168 struct btrfs_device_info *devices,
169 size_t nr_devices)
170{
171 sort(devices, nr_devices, sizeof(struct btrfs_device_info),
172 btrfs_cmp_device_free_bytes, NULL);
173}
174
175int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start, 160int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
176 u64 end, u64 *length); 161 u64 end, u64 *length);
177 162