librbd: support bufferlist payload for AioImageWrite

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2016-05-12 22:41:20 -04:00
parent 1c59945c13
commit 9176900300
2 changed files with 29 additions and 17 deletions

View File

@ -149,30 +149,35 @@ private:
} // anonymous namespace
template <typename I>
void AioImageRequest<I>::aio_read(
I *ictx, AioCompletion *c,
const std::vector<std::pair<uint64_t,uint64_t> > &extents,
char *buf, bufferlist *pbl, int op_flags) {
void AioImageRequest<I>::aio_read(I *ictx, AioCompletion *c,
const Extents &extents, char *buf,
bufferlist *pbl, int op_flags) {
AioImageRead<I> req(*ictx, c, extents, buf, pbl, op_flags);
req.send();
}
template <typename I>
void AioImageRequest<I>::aio_read(I *ictx, AioCompletion *c,
uint64_t off, size_t len, char *buf,
bufferlist *pbl, int op_flags) {
void AioImageRequest<I>::aio_read(I *ictx, AioCompletion *c, uint64_t off,
size_t len, char *buf, bufferlist *pbl,
int op_flags) {
AioImageRead<I> req(*ictx, c, off, len, buf, pbl, op_flags);
req.send();
}
template <typename I>
void AioImageRequest<I>::aio_write(I *ictx, AioCompletion *c,
uint64_t off, size_t len, const char *buf,
int op_flags) {
void AioImageRequest<I>::aio_write(I *ictx, AioCompletion *c, uint64_t off,
size_t len, const char *buf, int op_flags) {
AioImageWrite<I> req(*ictx, c, off, len, buf, op_flags);
req.send();
}
template <typename I>
void AioImageRequest<I>::aio_write(I *ictx, AioCompletion *c, uint64_t off,
bufferlist &&bl, int op_flags) {
AioImageWrite<I> req(*ictx, c, off, std::move(bl), op_flags);
req.send();
}
template <typename I>
void AioImageRequest<I>::aio_discard(I *ictx, AioCompletion *c,
uint64_t off, uint64_t len) {
@ -393,19 +398,18 @@ void AioImageWrite<I>::assemble_extent(const ObjectExtent &object_extent,
bufferlist *bl) {
for (auto q = object_extent.buffer_extents.begin();
q != object_extent.buffer_extents.end(); ++q) {
bl->append(m_buf + q->first, q->second);;
bufferlist sub_bl;
sub_bl.substr_of(m_bl, q->first, q->second);
bl->claim_append(sub_bl);
}
}
template <typename I>
uint64_t AioImageWrite<I>::append_journal_event(
const AioObjectRequests &requests, bool synchronous) {
bufferlist bl;
bl.append(m_buf, this->m_len);
I &image_ctx = this->m_image_ctx;
uint64_t tid = image_ctx.journal->append_write_event(this->m_off, this->m_len,
bl, requests,
m_bl, requests,
synchronous);
if (image_ctx.object_cacher == NULL) {
AioCompletion *aio_comp = this->m_aio_comp;

View File

@ -33,6 +33,8 @@ public:
size_t len, char *buf, bufferlist *pbl, int op_flags);
static void aio_write(ImageCtxT *ictx, AioCompletion *c, uint64_t off,
size_t len, const char *buf, int op_flags);
static void aio_write(ImageCtxT *ictx, AioCompletion *c, uint64_t off,
bufferlist &&bl, int op_flags);
static void aio_discard(ImageCtxT *ictx, AioCompletion *c, uint64_t off,
uint64_t len);
static void aio_flush(ImageCtxT *ictx, AioCompletion *c);
@ -153,7 +155,13 @@ public:
AioImageWrite(ImageCtxT &image_ctx, AioCompletion *aio_comp, uint64_t off,
size_t len, const char *buf, int op_flags)
: AbstractAioImageWrite<ImageCtxT>(image_ctx, aio_comp, off, len),
m_buf(buf), m_op_flags(op_flags) {
m_op_flags(op_flags) {
m_bl.append(buf, len);
}
AioImageWrite(ImageCtxT &image_ctx, AioCompletion *aio_comp, uint64_t off,
bufferlist &&bl, int op_flags)
: AbstractAioImageWrite<ImageCtxT>(image_ctx, aio_comp, off, bl.length()),
m_bl(std::move(bl)), m_op_flags(op_flags) {
}
protected:
@ -183,7 +191,7 @@ protected:
bool synchronous);
virtual void update_stats(size_t length);
private:
const char *m_buf;
bufferlist m_bl;
int m_op_flags;
};