Skip to content

Commit

Permalink
btrfs: move btrfs_cmp_device_free_bytes to super.c
Browse files Browse the repository at this point in the history
this function won't be used here anymore, so move it super.c where it is
used for df-calculation
  • Loading branch information
Arne Jansen committed May 13, 2011
1 parent 7cf96da commit bcd5374
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
26 changes: 26 additions & 0 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,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
13 changes: 0 additions & 13 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2282,19 +2282,6 @@ static noinline u64 chunk_bytes_by_type(u64 type, u64 calc_size,
return calc_size * num_stripes;
}

/* Used to sort the devices by max_avail(descending sort) */
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;
}

static int __btrfs_calc_nstripes(struct btrfs_fs_devices *fs_devices, u64 type,
int *num_stripes, int *min_stripes,
int *sub_stripes)
Expand Down
15 changes: 0 additions & 15 deletions fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,6 @@ struct map_lookup {
struct btrfs_bio_stripe stripes[];
};

/* Used to sort the devices by max_avail(descending sort) */
int btrfs_cmp_device_free_bytes(const void *dev_info1, const void *dev_info2);

/*
* 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);
}

int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
u64 end, u64 *length);

Expand Down

0 comments on commit bcd5374

Please sign in to comment.