Commit eeb6f172 authored by David Sterba's avatar David Sterba

btrfs: raid56: simplify sort_parity_stripes

Remove trivial comprator and open coded swap of two values.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7e8f19e5
...@@ -5353,31 +5353,19 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info, ...@@ -5353,31 +5353,19 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
return preferred_mirror; return preferred_mirror;
} }
static inline int parity_smaller(u64 a, u64 b)
{
return a > b;
}
/* Bubble-sort the stripe set to put the parity/syndrome stripes last */ /* Bubble-sort the stripe set to put the parity/syndrome stripes last */
static void sort_parity_stripes(struct btrfs_bio *bbio, int num_stripes) static void sort_parity_stripes(struct btrfs_bio *bbio, int num_stripes)
{ {
struct btrfs_bio_stripe s;
int i; int i;
u64 l;
int again = 1; int again = 1;
while (again) { while (again) {
again = 0; again = 0;
for (i = 0; i < num_stripes - 1; i++) { for (i = 0; i < num_stripes - 1; i++) {
if (parity_smaller(bbio->raid_map[i], /* Swap if parity is on a smaller index */
bbio->raid_map[i+1])) { if (bbio->raid_map[i] > bbio->raid_map[i + 1]) {
s = bbio->stripes[i]; swap(bbio->stripes[i], bbio->stripes[i + 1]);
l = bbio->raid_map[i]; swap(bbio->raid_map[i], bbio->raid_map[i + 1]);
bbio->stripes[i] = bbio->stripes[i+1];
bbio->raid_map[i] = bbio->raid_map[i+1];
bbio->stripes[i+1] = s;
bbio->raid_map[i+1] = l;
again = 1; again = 1;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment