[PATCH 23/28] xor: add a better public API

Christoph Hellwig
2026-03-27T06:22:57Z

xor_blocks is very annoying to use, because it is limited to 4 + 1
sources / destinations, has an odd argument order and is completely
undocumented.

Lift the code that loops around it from btrfs and async_tx/async_xor into
common code under the name xor_gen and properly document it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
lib/raid/xor/xor-core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/lib/raid/xor/xor-core.c b/lib/raid/xor/xor-core.c
index 07e06db32731..2e46b6b83b0a 100644
--- a/lib/raid/xor/xor-core.c
+++ b/lib/raid/xor/xor-core.c
@@ -65,6 +65,8 @@ void xor_gen(void *dest, void **srcs, unsigned int src_cnt, unsigned int bytes)
{
unsigned int src_off = 0;

+ WARN_ON_ONCE(in_interrupt());
+ WARN_ON_ONCE(bytes == 0);
WARN_ON_ONCE(bytes & 511);

while (src_cnt > 0) {
--
2.47.3