]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: store CRC32C with initial value -1 to match msgr2 validation wip-baum-20251126-01
authorAlexander Indenbaum <aindenba@redhat.com>
Sun, 23 Nov 2025 12:21:39 +0000 (14:21 +0200)
committerAlexander Indenbaum <aindenba@redhat.com>
Wed, 26 Nov 2025 08:05:34 +0000 (10:05 +0200)
Fix runtime error, using test command:
   sudo dd if=/dev/zero bs=32k of=/dev/nvme0n1 count=1

The error log:
   2025-11-23T11:24:10.512+0000 7f30f4ec0640  1 --2- [v2:192.168.13.2:6802/3444906816,v1:192.168.13.2:6803/3444906816] >> 192.168.13.3:0/3916714748 conn(0x527d400 0x728f700 crc :-1 s=THROTTLE_DONE pgs=2038703 gs=2038723 cs=0 l=1 c_cookie=0 s_cookie=0 reconnecting=0 rev1=1 crypto rx=0 tx=0 comp rx=0 tx=0)._handle_read_frame_epilogue_main bad segment crc calculated=1136411986 expected=4294967295

Ceph msgr2 validation (ceph/src/msg/async/frames_v2.cc:47):
   uint32_t crc = segment_bl.crc32c(-1);  // Uses initial value -1

Co-authored-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Alexander Indenbaum <aindenba@redhat.com>
src/include/rbd/librbd.h
src/librbd/librbd.cc

index 97576bb10d56d511a5354f9e19ee4230ed1a9544..58fba47f0da54b184af6c2d338d2cec9f301ef0a 100644 (file)
@@ -1280,9 +1280,11 @@ CEPH_RBD_API int rbd_aio_write(rbd_image_t image, uint64_t off, size_t len,
 CEPH_RBD_API int rbd_aio_write2(rbd_image_t image, uint64_t off, size_t len,
                                 const char *buf, rbd_completion_t c,
                                 int op_flags);
-
 /*
- * @param precomputed_crc32c: CRC32C checksum that was precomputed (e.g., by SPDK NVMf)
+ * @param precomputed_crc32c: CRC32C checksum that was precomputed with -1
+ *        as the initial value (i.e. with the CRC "register" initialized to
+ *        0xFFFFFFFF)
+ * @param op_flags: see librados.h constants beginning with LIBRADOS_OP_FLAG
  */
 CEPH_RBD_API int rbd_aio_write_with_crc32c(rbd_image_t image, uint64_t off,
                                            size_t len, const char *buf,
index 872fdc991cd6a5b3e6555264e02c1a505a9c3686..fac2c5a29497ff05d93c44660565e1fe771a9c09 100644 (file)
@@ -6418,8 +6418,9 @@ extern "C" int rbd_aio_write_with_crc32c(rbd_image_t image, uint64_t off,
 
   auto aio_completion = get_aio_completion(comp);
   auto raw = create_write_raw(ictx, buf, len, aio_completion);
+  // store with initial value -1
   raw->set_crc(std::make_pair(0, len),
-               std::make_pair(0, precomputed_crc32c));
+               std::make_pair(-1, precomputed_crc32c));
   bufferlist bl;
   bl.push_back(std::move(raw));
   librbd::api::Io<>::aio_write(