From: Frank Li <[email protected]>

Remove the dependency on the async_tx framework from dm-integrity's
xor_journal() function.  The async_xor() + async_tx_issue_pending_all()
pattern is replaced with direct kmap_local_page() + memcpy() +
crypto_xor() + kunmap_local() per page, which is simpler and removes
the need for #include <linux/async_tx.h>.

async_tx adds significant complexity and maintenance overhead while
providing little practical benefit on modern systems, where RAID parity
computation is typically performed more efficiently by CPU-based XOR/PQ
implementations than by DMA engine offload.

Signed-off-by: Frank Li <[email protected]>
---
 drivers/md/dm-integrity.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 802b377613b06..6bd0623b6402a 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -23,7 +23,6 @@
 #include <crypto/hash.h>
 #include <crypto/skcipher.h>
 #include <crypto/utils.h>
-#include <linux/async_tx.h>
 #include <linux/dm-bufio.h>
 
 #include "dm-audit.h"
@@ -896,7 +895,6 @@ static void complete_journal_op(void *context)
 static void xor_journal(struct dm_integrity_c *ic, bool encrypt, unsigned int 
section,
                        unsigned int n_sections, struct journal_completion 
*comp)
 {
-       struct async_submit_ctl submit;
        size_t n_bytes = (size_t)(n_sections * ic->journal_section_sectors) << 
SECTOR_SHIFT;
        unsigned int pl_index, pl_offset, section_index;
        struct page_list *source_pl, *target_pl;
@@ -913,14 +911,11 @@ static void xor_journal(struct dm_integrity_c *ic, bool 
encrypt, unsigned int se
 
        atomic_add(roundup(pl_offset + n_bytes, PAGE_SIZE) >> PAGE_SHIFT, 
&comp->in_flight);
 
-       init_async_submit(&submit, ASYNC_TX_XOR_ZERO_DST, NULL, 
complete_journal_op, comp, NULL);
-
        section_index = pl_index;
 
        do {
                size_t this_step;
-               struct page *src_pages[2];
-               struct page *dst_page;
+               void *src0, *src1, *dst;
 
                while (unlikely(pl_index == section_index)) {
                        unsigned int dummy;
@@ -935,11 +930,20 @@ static void xor_journal(struct dm_integrity_c *ic, bool 
encrypt, unsigned int se
                }
 
                this_step = min(n_bytes, (size_t)PAGE_SIZE - pl_offset);
-               dst_page = target_pl[pl_index].page;
-               src_pages[0] = source_pl[pl_index].page;
-               src_pages[1] = ic->journal_xor[pl_index].page;
 
-               async_xor(dst_page, src_pages, pl_offset, 2, this_step, 
&submit);
+               src0 = kmap_local_page(source_pl[pl_index].page);
+               src1 = kmap_local_page(ic->journal_xor[pl_index].page);
+               dst  = kmap_local_page(target_pl[pl_index].page);
+
+               memcpy(dst + pl_offset, src0 + pl_offset, this_step);
+               crypto_xor(dst + pl_offset, src1 + pl_offset, this_step);
+
+               kunmap_local(dst);
+               kunmap_local(src1);
+               kunmap_local(src0);
+
+               /* mirror async_tx per-page completion accounting */
+               complete_journal_op(comp);
 
                pl_index++;
                pl_offset = 0;
@@ -947,8 +951,6 @@ static void xor_journal(struct dm_integrity_c *ic, bool 
encrypt, unsigned int se
        } while (n_bytes);
 
        BUG_ON(n_sections);
-
-       async_tx_issue_pending_all();
 }
 
 static void complete_journal_encrypt(void *data, int err)

-- 
2.43.0


Reply via email to