btrfs: raid56: simplify sort_parity_stripes
authorDavid Sterba <dsterba@suse.com>
Thu, 28 Nov 2019 14:31:17 +0000 (15:31 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:45 +0000 (17:01 +0100)
Remove trivial comprator and open coded swap of two values.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index c93cafe83280fcf8b7899d07dc1a9242ff3795f1..2d8ffefeef3428bee3aa3c5c40fdee40c8968ed7 100644 (file)
@@ -5353,31 +5353,19 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
        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 */
 static void sort_parity_stripes(struct btrfs_bio *bbio, int num_stripes)
 {
-       struct btrfs_bio_stripe s;
        int i;
-       u64 l;
        int again = 1;
 
        while (again) {
                again = 0;
                for (i = 0; i < num_stripes - 1; i++) {
-                       if (parity_smaller(bbio->raid_map[i],
-                                          bbio->raid_map[i+1])) {
-                               s = bbio->stripes[i];
-                               l = bbio->raid_map[i];
-                               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;
-
+                       /* Swap if parity is on a smaller index */
+                       if (bbio->raid_map[i] > bbio->raid_map[i + 1]) {
+                               swap(bbio->stripes[i], bbio->stripes[i + 1]);
+                               swap(bbio->raid_map[i], bbio->raid_map[i + 1]);
                                again = 1;
                        }
                }