Skip to content

Commit bcd5374

Browse files
author
Arne Jansen
committed
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
1 parent 7cf96da commit bcd5374

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

fs/btrfs/super.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,32 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
913913
return 0;
914914
}
915915

916+
/* Used to sort the devices by max_avail(descending sort) */
917+
static 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+
*/
934+
static 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+
916942
/*
917943
* The helper to calc the free space on the devices that can be used to store
918944
* file data.

fs/btrfs/volumes.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,19 +2282,6 @@ static noinline u64 chunk_bytes_by_type(u64 type, u64 calc_size,
22822282
return calc_size * num_stripes;
22832283
}
22842284

2285-
/* Used to sort the devices by max_avail(descending sort) */
2286-
int 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-
22982285
static int __btrfs_calc_nstripes(struct btrfs_fs_devices *fs_devices, u64 type,
22992286
int *num_stripes, int *min_stripes,
23002287
int *sub_stripes)

fs/btrfs/volumes.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,6 @@ struct map_lookup {
157157
struct btrfs_bio_stripe stripes[];
158158
};
159159

160-
/* Used to sort the devices by max_avail(descending sort) */
161-
int 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-
*/
167-
static 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-
175160
int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
176161
u64 end, u64 *length);
177162

0 commit comments

Comments
 (0)