Skip to content

Commit

Permalink
Merge branch 'allocator' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/arne/btrfs-unstable-arne into inode_numbers

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed May 22, 2011
2 parents 945d896 + 73c5de0 commit aa2dfb3
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 334 deletions.
26 changes: 26 additions & 0 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,32 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
return 0;
}

/* Used to sort the devices by max_avail(descending sort) */
static int btrfs_cmp_device_free_bytes(const void *dev_info1,
const void *dev_info2)
{
if (((struct btrfs_device_info *)dev_info1)->max_avail >
((struct btrfs_device_info *)dev_info2)->max_avail)
return -1;
else if (((struct btrfs_device_info *)dev_info1)->max_avail <
((struct btrfs_device_info *)dev_info2)->max_avail)
return 1;
else
return 0;
}

/*
* sort the devices by max_avail, in which max free extent size of each device
* is stored.(Descending Sort)
*/
static inline void btrfs_descending_sort_devices(
struct btrfs_device_info *devices,
size_t nr_devices)
{
sort(devices, nr_devices, sizeof(struct btrfs_device_info),
btrfs_cmp_device_free_bytes, NULL);
}

/*
* The helper to calc the free space on the devices that can be used to store
* file data.
Expand Down
Loading

0 comments on commit aa2dfb3

Please sign in to comment.