Skip to content

Commit ef82492

Browse files
authored
Merge pull request ceph#65901 from baum/rbd_aio_write_with_crc32c
librbd: add rbd_aio_write_with_crc32c API for precomputed checksums Reviewed-by: Ilya Dryomov <[email protected]>
2 parents dea5782 + b187ff0 commit ef82492

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/include/rbd/librbd.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,14 @@ CEPH_RBD_API int rbd_aio_write(rbd_image_t image, uint64_t off, size_t len,
12801280
CEPH_RBD_API int rbd_aio_write2(rbd_image_t image, uint64_t off, size_t len,
12811281
const char *buf, rbd_completion_t c,
12821282
int op_flags);
1283+
1284+
/*
1285+
* @param precomputed_crc32c: CRC32C checksum that was precomputed (e.g., by SPDK NVMf)
1286+
*/
1287+
CEPH_RBD_API int rbd_aio_write_with_crc32c(rbd_image_t image, uint64_t off,
1288+
size_t len, const char *buf,
1289+
uint32_t precomputed_crc32c,
1290+
rbd_completion_t c, int op_flags);
12831291
CEPH_RBD_API int rbd_aio_writev(rbd_image_t image, const struct iovec *iov,
12841292
int iovcnt, uint64_t off, rbd_completion_t c);
12851293
CEPH_RBD_API int rbd_aio_read(rbd_image_t image, uint64_t off, size_t len,

src/librbd/librbd.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "common/dout.h"
2727
#include "common/errno.h"
2828
#include "common/TracepointProvider.h"
29+
#include "include/buffer_raw.h"
2930
#include "include/Context.h"
3031

3132
#include "cls/rbd/cls_rbd_client.h"
@@ -6407,6 +6408,25 @@ extern "C" int rbd_aio_write2(rbd_image_t image, uint64_t off, size_t len,
64076408
return 0;
64086409
}
64096410

6411+
extern "C" int rbd_aio_write_with_crc32c(rbd_image_t image, uint64_t off,
6412+
size_t len, const char *buf,
6413+
uint32_t precomputed_crc32c,
6414+
rbd_completion_t c, int op_flags)
6415+
{
6416+
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
6417+
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
6418+
6419+
auto aio_completion = get_aio_completion(comp);
6420+
auto raw = create_write_raw(ictx, buf, len, aio_completion);
6421+
raw->set_crc(std::make_pair(0, len),
6422+
std::make_pair(0, precomputed_crc32c));
6423+
bufferlist bl;
6424+
bl.push_back(std::move(raw));
6425+
librbd::api::Io<>::aio_write(
6426+
*ictx, aio_completion, off, len, std::move(bl), op_flags, true);
6427+
return 0;
6428+
}
6429+
64106430
extern "C" int rbd_aio_writev(rbd_image_t image, const struct iovec *iov,
64116431
int iovcnt, uint64_t off, rbd_completion_t c)
64126432
{

0 commit comments

Comments
 (0)