aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2011-05-22 12:36:34 -0400
committerChris Mason <chris.mason@oracle.com>2011-05-22 12:36:34 -0400
commitaa2dfb372a2a647beedac163ce6f8b0fcbefac29 (patch)
treeff64f4d4921df2f0fbe5b356dc9b2384c7957dc1 /fs/btrfs/super.c
parent945d8962ceee6bb273365d0bdf42f763225b290f (diff)
parent73c5de0051533cbdf2bb656586c3eb21a475aa7d (diff)
Merge branch 'allocator' of git://git.kernel.org/pub/scm/linux/kernel/git/arne/btrfs-unstable-arne into inode_numbers
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index fb72e2bea882..006655c1d1f7 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -914,6 +914,32 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
914 return 0; 914 return 0;
915} 915}
916 916
917/* Used to sort the devices by max_avail(descending sort) */
918static int btrfs_cmp_device_free_bytes(const void *dev_info1,
919 const void *dev_info2)
920{
921 if (((struct btrfs_device_info *)dev_info1)->max_avail >
922 ((struct btrfs_device_info *)dev_info2)->max_avail)
923 return -1;
924 else if (((struct btrfs_device_info *)dev_info1)->max_avail <
925 ((struct btrfs_device_info *)dev_info2)->max_avail)
926 return 1;
927 else
928 return 0;
929}
930
931/*
932 * sort the devices by max_avail, in which max free extent size of each device
933 * is stored.(Descending Sort)
934 */
935static inline void btrfs_descending_sort_devices(
936 struct btrfs_device_info *devices,
937 size_t nr_devices)
938{
939 sort(devices, nr_devices, sizeof(struct btrfs_device_info),
940 btrfs_cmp_device_free_bytes, NULL);
941}
942
917/* 943/*
918 * The helper to calc the free space on the devices that can be used to store 944 * The helper to calc the free space on the devices that can be used to store
919 * file data. 945 * file data.