Use the new xor_gen helper instead of open coding the loop around
xor_blocks.  This helper is very similar to the existing run_xor helper
in btrfs, except that the destination buffer is passed explicitly.

Signed-off-by: Christoph Hellwig <[email protected]>
---
 fs/btrfs/raid56.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index b4511f560e92..dab07442f634 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -617,26 +617,6 @@ static void cache_rbio(struct btrfs_raid_bio *rbio)
        spin_unlock(&table->cache_lock);
 }
 
-/*
- * helper function to run the xor_blocks api.  It is only
- * able to do MAX_XOR_BLOCKS at a time, so we need to
- * loop through.
- */
-static void run_xor(void **pages, int src_cnt, ssize_t len)
-{
-       int src_off = 0;
-       int xor_src_cnt = 0;
-       void *dest = pages[src_cnt];
-
-       while(src_cnt > 0) {
-               xor_src_cnt = min(src_cnt, MAX_XOR_BLOCKS);
-               xor_blocks(xor_src_cnt, len, dest, pages + src_off);
-
-               src_cnt -= xor_src_cnt;
-               src_off += xor_src_cnt;
-       }
-}
-
 /*
  * Returns true if the bio list inside this rbio covers an entire stripe (no
  * rmw required).
@@ -1434,7 +1414,8 @@ static void generate_pq_vertical_step(struct 
btrfs_raid_bio *rbio, unsigned int
        } else {
                /* raid5 */
                memcpy(pointers[rbio->nr_data], pointers[0], step);
-               run_xor(pointers + 1, rbio->nr_data - 1, step);
+               xor_gen(pointers[rbio->nr_data], pointers + 1, rbio->nr_data - 
1,
+                               step);
        }
        for (stripe = stripe - 1; stripe >= 0; stripe--)
                kunmap_local(pointers[stripe]);
@@ -2034,7 +2015,7 @@ static void recover_vertical_step(struct btrfs_raid_bio 
*rbio,
                pointers[rbio->nr_data - 1] = p;
 
                /* Xor in the rest */
-               run_xor(pointers, rbio->nr_data - 1, step);
+               xor_gen(p, pointers, rbio->nr_data - 1, step);
        }
 
 cleanup:
@@ -2664,7 +2645,7 @@ static bool verify_one_parity_step(struct btrfs_raid_bio 
*rbio,
        } else {
                /* RAID5. */
                memcpy(pointers[nr_data], pointers[0], step);
-               run_xor(pointers + 1, nr_data - 1, step);
+               xor_gen(pointers[nr_data], pointers + 1, nr_data - 1, step);
        }
 
        /* Check scrubbing parity and repair it. */
-- 
2.47.3


Reply via email to