From 58379770062e6ff4f948caa66fa44407f4ade480 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 26 Jul 2017 07:41:52 -0400 Subject: [PATCH] test/librbd: improved compare_and_write testing Signed-off-by: Jason Dillaman --- src/test/librbd/fsx.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 0376c0d1dca66..940edf6397b56 100644 --- a/src/test/librbd/fsx.cc +++ b/src/test/librbd/fsx.cc @@ -691,7 +691,9 @@ librbd_compare_and_write(struct rbd_ctx *ctx, uint64_t off, size_t len, uint64_t mismatch_off = 0; n = rbd_compare_and_write(ctx->image, off, len, cmp_buf, buf, &mismatch_off, 0); - if (n < 0) { + if (n == -EINVAL) { + return n; + } else if (n < 0) { prt("rbd_compare_and_write mismatch(%llu, %zu, %llu) failed\n", off, len, mismatch_off); return n; @@ -1962,7 +1964,7 @@ docompareandwrite(unsigned offset, unsigned size) offset -= offset % writebdy; if (o_direct) - size -= size % writebdy; + size -= size % writebdy; if (size == 0) { if (!quiet && testcalls > simulatedopcount && !o_direct) @@ -1978,6 +1980,8 @@ docompareandwrite(unsigned offset, unsigned size) return; } + memcpy(temp_buf + offset, good_buf + offset, size); + gendata(original_buf, good_buf, offset, size); log4(OP_COMPARE_AND_WRITE, offset, size, 0); if (testcalls <= simulatedopcount) @@ -1993,11 +1997,13 @@ docompareandwrite(unsigned offset, unsigned size) prt("%lu compareandwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, offset, offset + size - 1, size); - ret = ops->compare_and_write(&ctx, offset, size, good_buf + offset, - good_buf + offset); + ret = ops->compare_and_write(&ctx, offset, size, temp_buf + offset, + good_buf + offset); if (ret != (ssize_t)size) { - if (ret == -EILSEQ || ret == -EINVAL) + if (ret == -EINVAL) { + memcpy(good_buf + offset, temp_buf + offset, size); return; + } if (ret < 0) prterrcode("docompareandwrite: ops->compare_and_write", ret); else -- 2.39.5