#include "librados/snap_set_diff.h"
-#ifdef WITH_LTTNG
-#include "tracing/librbd.h"
-#endif
-
#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
#define dout_prefix *_dout << "librbd: "
int create_v1(IoCtx& io_ctx, const char *imgname, uint64_t bid,
uint64_t size, int order)
{
- tracepoint(librbd, create_v1_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), imgname, bid, size, order);
CephContext *cct = (CephContext *)io_ctx.cct();
ldout(cct, 2) << "adding rbd image to directory..." << dendl;
int r = tmap_set(io_ctx, imgname);
if (r < 0) {
lderr(cct) << "error adding image to directory: " << cpp_strerror(r)
<< dendl;
- tracepoint(librbd, create_v1_exit, r);
return r;
}
<< "header creation failed: "
<< cpp_strerror(r) << dendl;
}
- tracepoint(librbd, create_v1_exit, r);
return r;
}
ldout(cct, 2) << "done." << dendl;
- tracepoint(librbd, create_v1_exit, 0);
return 0;
}
int order, uint64_t features, uint64_t stripe_unit,
uint64_t stripe_count)
{
- tracepoint(librbd, create_v2_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), imgname, bid, size, order, features, stripe_unit, stripe_count);
ostringstream bid_ss;
uint32_t extra;
string id, id_obj, header_oid;
if (r < 0) {
lderr(cct) << "error creating rbd id object: " << cpp_strerror(r)
<< dendl;
- tracepoint(librbd, create_v2_exit, r);
return r;
}
}
ldout(cct, 2) << "done." << dendl;
- tracepoint(librbd, create_v2_exit, 0);
return 0;
err_remove_header:
<< cpp_strerror(remove_r) << dendl;
}
- tracepoint(librbd, create_v2_exit, r);
return r;
}
int rename(IoCtx& io_ctx, const char *srcname, const char *dstname)
{
- tracepoint(librbd, rename_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), srcname, dstname);
CephContext *cct = (CephContext *)io_ctx.cct();
ldout(cct, 20) << "rename " << &io_ctx << " " << srcname << " -> "
<< dstname << dendl;
r = cls_client::get_id(&io_ctx, src_oid, &id);
if (r < 0) {
lderr(cct) << "error reading image id: " << cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
}
if (r < 0) {
lderr(cct) << "error reading source object: " << src_oid << ": "
<< cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
if (r < 0) {
lderr(cct) << "error reading source object omap values: "
<< cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
omap_values.insert(outbl.begin(), outbl.end());
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error checking for existing image called "
<< dstname << ":" << cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
if (r == 0) {
lderr(cct) << "rbd image " << dstname << " already exists" << dendl;
- tracepoint(librbd, rename_exit, -EEXIST);
return -EEXIST;
}
if (r < 0) {
lderr(cct) << "error writing destination object: " << dst_oid << ": "
<< cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
io_ctx.remove(dst_oid);
lderr(cct) << "couldn't add " << dstname << " to directory: "
<< cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
r = tmap_rm(io_ctx, srcname);
srcname, dstname, id);
if (r < 0) {
lderr(cct) << "error updating directory: " << cpp_strerror(r) << dendl;
- tracepoint(librbd, rename_exit, r);
return r;
}
}
notify_change(io_ctx, old_header_name(srcname), NULL, NULL);
}
- tracepoint(librbd, rename_exit, 0);
return 0;
}
int remove(IoCtx& io_ctx, const char *imgname, ProgressContext& prog_ctx)
{
- tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), imgname);
CephContext *cct((CephContext *)io_ctx.cct());
ldout(cct, 20) << "remove " << &io_ctx << " " << imgname << dendl;
if (ictx->snaps.size()) {
lderr(cct) << "image has snapshots - not removing" << dendl;
close_image(ictx);
- tracepoint(librbd, remove_exit, -ENOTEMPTY);
return -ENOTEMPTY;
}
if (r < 0) {
lderr(cct) << "error listing watchers" << dendl;
close_image(ictx);
- tracepoint(librbd, remove_exit, r);
return r;
}
if (watchers.size() > 1) {
lderr(cct) << "image has watchers - not removing" << dendl;
close_image(ictx);
- tracepoint(librbd, remove_exit, -EBUSY);
return -EBUSY;
}
assert(watchers.size() == 1);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing child from children list" << dendl;
close_image(ictx);
- tracepoint(librbd, remove_exit, r);
return r;
}
close_image(ictx);
r = io_ctx.remove(header_oid);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing header: " << cpp_strerror(-r) << dendl;
- tracepoint(librbd, remove_exit, r);
return r;
}
}
if (r < 0 && !unknown_format) {
lderr(cct) << "error removing img from old-style directory: "
<< cpp_strerror(-r) << dendl;
- tracepoint(librbd, remove_exit, r);
return r;
}
}
r = io_ctx.remove(id_obj_name(imgname));
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing id object: " << cpp_strerror(r) << dendl;
- tracepoint(librbd, remove_exit, r);
return r;
}
r = cls_client::dir_get_id(&io_ctx, RBD_DIRECTORY, imgname, &id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error getting id of image" << dendl;
- tracepoint(librbd, remove_exit, r);
return r;
}
if (r < 0) {
lderr(cct) << "error removing img from new-style directory: "
<< cpp_strerror(-r) << dendl;
- tracepoint(librbd, remove_exit, r);
return r;
}
}
ldout(cct, 2) << "done." << dendl;
- tracepoint(librbd, remove_exit, 0);
return 0;
}
int resize(ImageCtx *ictx, uint64_t size, ProgressContext& prog_ctx)
{
- tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "resize " << ictx << " " << ictx->size << " -> "
<< size << dendl;
if (ictx->read_only) {
- tracepoint(librbd, resize_exit, -EROFS);
return -EROFS;
}
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, resize_exit, r);
return r;
}
// ObjectCacher doesn't track non-existent objects
r = ictx->invalidate_cache();
if (r < 0) {
- tracepoint(librbd, resize_exit, r);
return r;
}
}
ldout(cct, 2) << "done." << dendl;
ictx->perfcounter->inc(l_librbd_resize);
- tracepoint(librbd, resize_exit, 0);
return 0;
}
int copy(ImageCtx *src, ImageCtx *dest, ProgressContext &prog_ctx)
{
- tracepoint(librbd, copy_enter, src, src->name.c_str(), src->snap_name.c_str(), src->read_only, dest, dest->name.c_str(), dest->snap_name.c_str(), dest->read_only);
src->md_lock.get_read();
src->snap_lock.get_read();
uint64_t src_size = src->get_image_size(src->snap_id);
if (dest_size < src_size) {
lderr(cct) << " src size " << src_size << " >= dest size "
<< dest_size << dendl;
- tracepoint(librbd, copy_exit, -EINVAL);
return -EINVAL;
}
int r;
lderr(cct) << "could not read from source image from "
<< offset << " to " << offset + len << ": "
<< cpp_strerror(r) << dendl;
- tracepoint(librbd, copy_exit, r);
return r;
}
prog_ctx.update_progress(offset, src_size);
r = throttle.wait_for_ret();
if (r >= 0)
prog_ctx.update_progress(src_size, src_size);
- tracepoint(librbd, copy_exit, r);
return r;
}
int open_image(ImageCtx *ictx)
{
- tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
ldout(ictx->cct, 20) << "open_image: ictx = " << ictx
<< " name = '" << ictx->name
<< "' id = '" << ictx->id
if ((r = _snap_set(ictx, ictx->snap_name.c_str())) < 0)
goto err_close;
- tracepoint(librbd, open_image_exit, 0);
return 0;
err_close:
close_image(ictx);
- tracepoint(librbd, open_image_exit, r);
return r;
}
void close_image(ImageCtx *ictx)
{
- tracepoint(librbd, close_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str());
ldout(ictx->cct, 20) << "close_image " << ictx << dendl;
if (ictx->object_cacher)
ictx->shutdown_cache(); // implicitly flushes
ictx->unregister_watch();
delete ictx;
- tracepoint(librbd, close_image_exit);
}
// 'flatten' child image by copying all parent's blocks
ssize_t read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents, char *buf, bufferlist *pbl)
{
- tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- for (vector<pair<uint64_t,uint64_t> >::const_iterator r = image_extents.begin();
- r != image_extents.end();
- ++r) {
- tracepoint(librbd, read_extent, r->first, r->second);
- }
Mutex mylock("IoCtxImpl::write::mylock");
Cond cond;
bool done;
if (r < 0) {
c->release();
delete ctx;
- tracepoint(librbd, read_exit, r);
return r;
}
cond.Wait(mylock);
mylock.Unlock();
- tracepoint(librbd, read_exit, ret);
return ret;
}
ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf)
{
- tracepoint(librbd, write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf);
utime_t start_time, elapsed;
ldout(ictx->cct, 20) << "write " << ictx << " off = " << off << " len = "
<< len << dendl;
uint64_t mylen = len;
int r = clip_io(ictx, off, &mylen);
if (r < 0) {
- tracepoint(librbd, write_exit, r);
return r;
}
if (r < 0) {
c->release();
delete ctx;
- tracepoint(librbd, write_exit, r);
return r;
}
mylock.Unlock();
if (ret < 0) {
- tracepoint(librbd, write_exit, ret);
return ret;
}
ictx->perfcounter->tinc(l_librbd_wr_latency, elapsed);
ictx->perfcounter->inc(l_librbd_wr);
ictx->perfcounter->inc(l_librbd_wr_bytes, mylen);
- tracepoint(librbd, write_exit, mylen);
return mylen;
}
int discard(ImageCtx *ictx, uint64_t off, uint64_t len)
{
- tracepoint(librbd, discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len);
utime_t start_time, elapsed;
ldout(ictx->cct, 20) << "discard " << ictx << " off = " << off << " len = "
<< len << dendl;
if (r < 0) {
c->release();
delete ctx;
- tracepoint(librbd, discard_exit, r);
return r;
}
mylock.Unlock();
if (ret < 0) {
- tracepoint(librbd, discard_exit, ret);
return ret;
}
ictx->perfcounter->inc(l_librbd_discard_latency, elapsed);
ictx->perfcounter->inc(l_librbd_discard);
ictx->perfcounter->inc(l_librbd_discard_bytes, len);
- tracepoint(librbd, discard_exit, len);
return len;
}
int aio_flush(ImageCtx *ictx, AioCompletion *c)
{
- tracepoint(librbd, aio_flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, c);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "aio_flush " << ictx << " completion " << c << dendl;
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, aio_flush_exit, r);
return r;
}
c->put();
ictx->perfcounter->inc(l_librbd_aio_flush);
- tracepoint(librbd, aio_flush_exit, 0);
return 0;
}
int flush(ImageCtx *ictx)
{
- tracepoint(librbd, flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "flush " << ictx << dendl;
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, flush_exit, r);
return r;
}
ictx->user_flushed();
r = _flush(ictx);
ictx->perfcounter->inc(l_librbd_flush);
- tracepoint(librbd, flush_exit, r);
return r;
}
int invalidate_cache(ImageCtx *ictx)
{
- tracepoint(librbd, invalidate_cache_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "invalidate_cache " << ictx << dendl;
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, invalidate_cache_exit, r);
return r;
}
RWLock::WLocker l(ictx->md_lock);
r = ictx->invalidate_cache();
- tracepoint(librbd, invalidate_cache_exit, r);
return r;
}
int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
AioCompletion *c)
{
- tracepoint(librbd, aio_write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, c);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "aio_write " << ictx << " off = " << off << " len = "
<< len << " buf = " << (void*)buf << dendl;
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, aio_write_exit, r);
return r;
}
uint64_t mylen = len;
r = clip_io(ictx, off, &mylen);
if (r < 0) {
- tracepoint(librbd, aio_write_exit, r);
return r;
}
ictx->snap_lock.put_read();
if (snap_id != CEPH_NOSNAP || ictx->read_only) {
- tracepoint(librbd, aio_write_exit, -EROFS);
return -EROFS;
}
ictx->perfcounter->inc(l_librbd_aio_wr_bytes, mylen);
/* FIXME: cleanup all the allocated stuff */
- tracepoint(librbd, aio_write_exit, r);
return r;
}
int aio_discard(ImageCtx *ictx, uint64_t off, uint64_t len, AioCompletion *c)
{
- tracepoint(librbd, aio_discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, c);
CephContext *cct = ictx->cct;
ldout(cct, 20) << "aio_discard " << ictx << " off = " << off << " len = "
<< len << dendl;
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, aio_discard_exit, r);
return r;
}
r = clip_io(ictx, off, &len);
if (r < 0) {
- tracepoint(librbd, aio_discard_exit, r);
return r;
}
ictx->snap_lock.put_read();
if (snap_id != CEPH_NOSNAP || ictx->read_only) {
- tracepoint(librbd, aio_discard_exit, -EROFS);
return -EROFS;
}
ictx->perfcounter->inc(l_librbd_aio_discard_bytes, len);
/* FIXME: cleanup all the allocated stuff */
- tracepoint(librbd, aio_discard_exit, r);
return r;
}
int aio_read(ImageCtx *ictx, const vector<pair<uint64_t,uint64_t> >& image_extents,
char *buf, bufferlist *pbl, AioCompletion *c)
{
- tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, buf, c);
- for (vector<pair<uint64_t,uint64_t> >::const_iterator r = image_extents.begin();
- r != image_extents.end();
- ++r) {
- tracepoint(librbd, aio_read_extent, r->first, r->second);
- }
ldout(ictx->cct, 20) << "aio_read " << ictx << " completion " << c << " " << image_extents << dendl;
int r = ictx_check(ictx);
if (r < 0) {
- tracepoint(librbd, aio_read_exit, r);
return r;
}
uint64_t len = p->second;
r = clip_io(ictx, p->first, &len);
if (r < 0) {
- tracepoint(librbd, aio_read_exit, r);
return r;
}
if (len == 0)
ictx->perfcounter->inc(l_librbd_aio_rd);
ictx->perfcounter->inc(l_librbd_aio_rd_bytes, buffer_ofs);
- tracepoint(librbd, aio_read_exit, ret);
return ret;
}
#include <string>
#include <vector>
+#ifdef WITH_LTTNG
+#include "tracing/librbd.h"
+#endif
+
#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
#define dout_prefix *_dout << "librbd: "
const char *snap_name)
{
ImageCtx *ictx = new ImageCtx(name, "", snap_name, io_ctx, false);
+ tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
int r = librbd::open_image(ictx);
- if (r < 0)
+ if (r < 0) {
+ tracepoint(librbd, open_image_exit, r);
return r;
+ }
image.ctx = (image_ctx_t) ictx;
+ tracepoint(librbd, open_image_exit, 0);
return 0;
}
const char *snap_name)
{
ImageCtx *ictx = new ImageCtx(name, "", snap_name, io_ctx, true);
+ tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
int r = librbd::open_image(ictx);
- if (r < 0)
+ if (r < 0) {
+ tracepoint(librbd, open_image_exit, r);
return r;
+ }
image.ctx = (image_ctx_t) ictx;
+ tracepoint(librbd, open_image_exit, 0);
return 0;
}
int RBD::create(IoCtx& io_ctx, const char *name, uint64_t size, int *order)
{
- return librbd::create(io_ctx, name, size, order);
+ tracepoint(librbd, create_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name, size, *order);
+ int r = librbd::create(io_ctx, name, size, order);
+ tracepoint(librbd, create_exit, r, *order);
+ return r;
}
int RBD::create2(IoCtx& io_ctx, const char *name, uint64_t size,
uint64_t features, int *order)
{
- return librbd::create(io_ctx, name, size, false, features, order, 0, 0);
+ tracepoint(librbd, create2_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name, size, features, *order);
+ int r = librbd::create(io_ctx, name, size, false, features, order, 0, 0);
+ tracepoint(librbd, create2_exit, r, *order);
+ return r;
}
int RBD::create3(IoCtx& io_ctx, const char *name, uint64_t size,
uint64_t features, int *order, uint64_t stripe_unit,
uint64_t stripe_count)
{
- return librbd::create(io_ctx, name, size, false, features, order,
+ tracepoint(librbd, create3_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name, size, features, *order, stripe_unit, stripe_count);
+ int r = librbd::create(io_ctx, name, size, false, features, order,
stripe_unit, stripe_count);
+ tracepoint(librbd, create3_exit, r, *order);
+ return r;
}
int RBD::clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name,
int RBD::remove(IoCtx& io_ctx, const char *name)
{
+ tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
librbd::NoOpProgressContext prog_ctx;
int r = librbd::remove(io_ctx, name, prog_ctx);
+ tracepoint(librbd, remove_exit, r);
return r;
}
int RBD::remove_with_progress(IoCtx& io_ctx, const char *name,
ProgressContext& pctx)
{
+ tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
int r = librbd::remove(io_ctx, name, pctx);
+ tracepoint(librbd, remove_exit, r);
return r;
}
int RBD::rename(IoCtx& src_io_ctx, const char *srcname, const char *destname)
{
+ tracepoint(librbd, rename_enter, src_io_ctx.get_pool_name().c_str(), src_io_ctx.get_id(), srcname, destname);
int r = librbd::rename(src_io_ctx, srcname, destname);
+ tracepoint(librbd, rename_exit, r);
return r;
}
{
if (ctx) {
ImageCtx *ictx = (ImageCtx *)ctx;
+ tracepoint(librbd, close_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str());
close_image(ictx);
+ tracepoint(librbd, close_image_exit);
}
}
int Image::resize(uint64_t size)
{
ImageCtx *ictx = (ImageCtx *)ctx;
+ tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
librbd::NoOpProgressContext prog_ctx;
- return librbd::resize(ictx, size, prog_ctx);
+ int r = librbd::resize(ictx, size, prog_ctx);
+ tracepoint(librbd, resize_exit, r);
+ return r;
}
int Image::resize_with_progress(uint64_t size, librbd::ProgressContext& pctx)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::resize(ictx, size, pctx);
+ tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
+ int r = librbd::resize(ictx, size, pctx);
+ tracepoint(librbd, resize_exit, r);
+ return r;
}
int Image::stat(image_info_t& info, size_t infosize)
int Image::copy(IoCtx& dest_io_ctx, const char *destname)
{
ImageCtx *ictx = (ImageCtx *)ctx;
+ tracepoint(librbd, copy_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, destname);
librbd::NoOpProgressContext prog_ctx;
- return librbd::copy(ictx, dest_io_ctx, destname, prog_ctx);
+ int r = librbd::copy(ictx, dest_io_ctx, destname, prog_ctx);
+ tracepoint(librbd, copy_exit, r);
+ return r;
}
int Image::copy2(Image& dest)
{
ImageCtx *srcctx = (ImageCtx *)ctx;
ImageCtx *destctx = (ImageCtx *)dest.ctx;
+ tracepoint(librbd, copy2_enter, srcctx, srcctx->name.c_str(), srcctx->snap_name.c_str(), srcctx->read_only, destctx, destctx->name.c_str(), destctx->snap_name.c_str(), destctx->read_only);
librbd::NoOpProgressContext prog_ctx;
- return librbd::copy(srcctx, destctx, prog_ctx);
+ int r = librbd::copy(srcctx, destctx, prog_ctx);
+ tracepoint(librbd, copy2_exit, r);
+ return r;
}
int Image::copy_with_progress(IoCtx& dest_io_ctx, const char *destname,
librbd::ProgressContext &pctx)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::copy(ictx, dest_io_ctx, destname, pctx);
+ tracepoint(librbd, copy_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, destname);
+ int r = librbd::copy(ictx, dest_io_ctx, destname, pctx);
+ tracepoint(librbd, copy_exit, r);
+ return r;
}
int Image::copy_with_progress2(Image& dest, librbd::ProgressContext &pctx)
{
ImageCtx *srcctx = (ImageCtx *)ctx;
ImageCtx *destctx = (ImageCtx *)dest.ctx;
- return librbd::copy(srcctx, destctx, pctx);
+ tracepoint(librbd, copy2_enter, srcctx, srcctx->name.c_str(), srcctx->snap_name.c_str(), srcctx->read_only, destctx, destctx->name.c_str(), destctx->snap_name.c_str(), destctx->read_only);
+ int r = librbd::copy(srcctx, destctx, pctx);
+ tracepoint(librbd, copy2_exit, r);
+ return r;
}
int Image::flatten()
ssize_t Image::read(uint64_t ofs, size_t len, bufferlist& bl)
{
ImageCtx *ictx = (ImageCtx *)ctx;
+ // TODO: Should these be merged?
+ tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
+ tracepoint(librbd, read_extent, ofs, len);
bufferptr ptr(len);
bl.push_back(ptr);
- return librbd::read(ictx, ofs, len, bl.c_str());
+ int r = librbd::read(ictx, ofs, len, bl.c_str());
+ tracepoint(librbd, read_exit, r);
+ return r;
}
int64_t Image::read_iterate(uint64_t ofs, size_t len,
ssize_t Image::write(uint64_t ofs, size_t len, bufferlist& bl)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- if (bl.length() < len)
+ tracepoint(librbd, write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len, bl.length() < len ? NULL : bl.c_str());
+ if (bl.length() < len) {
+ tracepoint(librbd, write_exit, -EINVAL);
return -EINVAL;
- return librbd::write(ictx, ofs, len, bl.c_str());
+ }
+ int r = librbd::write(ictx, ofs, len, bl.c_str());
+ tracepoint(librbd, write_exit, r);
+ return r;
}
int Image::discard(uint64_t ofs, uint64_t len)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::discard(ictx, ofs, len);
+ tracepoint(librbd, discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len);
+ int r = librbd::discard(ictx, ofs, len);
+ tracepoint(librbd, discard_exit, r);
+ return r;
}
int Image::aio_write(uint64_t off, size_t len, bufferlist& bl,
RBD::AioCompletion *c)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- if (bl.length() < len)
+ tracepoint(librbd, aio_write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, bl.length() < len ? NULL : bl.c_str(), c->pc);
+ if (bl.length() < len) {
+ tracepoint(librbd, aio_write_exit, -EINVAL);
return -EINVAL;
- return librbd::aio_write(ictx, off, len, bl.c_str(),
+ }
+ int r = librbd::aio_write(ictx, off, len, bl.c_str(),
(librbd::AioCompletion *)c->pc);
+ tracepoint(librbd, aio_write_exit, r);
+ return r;
}
int Image::aio_discard(uint64_t off, uint64_t len, RBD::AioCompletion *c)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::aio_discard(ictx, off, len, (librbd::AioCompletion *)c->pc);
+ tracepoint(librbd, aio_discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, c->pc);
+ int r = librbd::aio_discard(ictx, off, len, (librbd::AioCompletion *)c->pc);
+ tracepoint(librbd, aio_discard_exit, r);
+ return r;
}
int Image::aio_read(uint64_t off, size_t len, bufferlist& bl,
RBD::AioCompletion *c)
{
ImageCtx *ictx = (ImageCtx *)ctx;
+ // TODO: See if these tracepoints should be merged
+ tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, bl.c_str(), c->pc);
+ tracepoint(librbd, aio_read_extent, off, len);
ldout(ictx->cct, 10) << "Image::aio_read() buf=" << (void *)bl.c_str() << "~"
<< (void *)(bl.c_str() + len - 1) << dendl;
- return librbd::aio_read(ictx, off, len, NULL, &bl, (librbd::AioCompletion *)c->pc);
+ int r = librbd::aio_read(ictx, off, len, NULL, &bl, (librbd::AioCompletion *)c->pc);
+ tracepoint(librbd, aio_read_exit, r);
+ return r;
}
int Image::flush()
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::flush(ictx);
+ tracepoint(librbd, flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
+ int r = librbd::flush(ictx);
+ tracepoint(librbd, flush_exit, r);
+ return r;
}
int Image::aio_flush(RBD::AioCompletion *c)
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::aio_flush(ictx, (librbd::AioCompletion *)c->pc);
+ tracepoint(librbd, aio_flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, c->pc);
+ int r = librbd::aio_flush(ictx, (librbd::AioCompletion *)c->pc);
+ tracepoint(librbd, aio_flush_exit, r);
+ return r;
}
int Image::invalidate_cache()
{
ImageCtx *ictx = (ImageCtx *)ctx;
- return librbd::invalidate_cache(ictx);
+ tracepoint(librbd, invalidate_cache_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
+ int r = librbd::invalidate_cache(ictx);
+ tracepoint(librbd, invalidate_cache_exit, r);
+ return r;
}
} // namespace librbd
{
librados::IoCtx io_ctx;
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
- return librbd::create(io_ctx, name, size, order);
+ tracepoint(librbd, create_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name, size, *order);
+ int r = librbd::create(io_ctx, name, size, order);
+ tracepoint(librbd, create_exit, r, *order);
+ return r;
}
extern "C" int rbd_create2(rados_ioctx_t p, const char *name,
{
librados::IoCtx io_ctx;
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
- return librbd::create(io_ctx, name, size, false, features, order, 0, 0);
+ tracepoint(librbd, create2_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name, size, features, *order);
+ int r = librbd::create(io_ctx, name, size, false, features, order, 0, 0);
+ tracepoint(librbd, create2_exit, r, *order);
+ return r;
}
extern "C" int rbd_create3(rados_ioctx_t p, const char *name,
{
librados::IoCtx io_ctx;
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
- return librbd::create(io_ctx, name, size, false, features, order,
+ tracepoint(librbd, create3_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name, size, features, *order, stripe_unit, stripe_count);
+ int r = librbd::create(io_ctx, name, size, false, features, order,
stripe_unit, stripe_count);
+ tracepoint(librbd, create3_exit, r, *order);
+ return r;
}
extern "C" int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,
{
librados::IoCtx io_ctx;
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
+ tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
librbd::NoOpProgressContext prog_ctx;
- return librbd::remove(io_ctx, name, prog_ctx);
+ int r = librbd::remove(io_ctx, name, prog_ctx);
+ tracepoint(librbd, remove_exit, r);
+ return r;
}
extern "C" int rbd_remove_with_progress(rados_ioctx_t p, const char *name,
{
librados::IoCtx io_ctx;
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
+ tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
librbd::CProgressContext prog_ctx(cb, cbdata);
- return librbd::remove(io_ctx, name, prog_ctx);
+ int r = librbd::remove(io_ctx, name, prog_ctx);
+ tracepoint(librbd, remove_exit, r);
+ return r;
}
extern "C" int rbd_copy(rbd_image_t image, rados_ioctx_t dest_p,
{
librados::IoCtx src_io_ctx;
librados::IoCtx::from_rados_ioctx_t(src_p, src_io_ctx);
- return librbd::rename(src_io_ctx, srcname, destname);
+ tracepoint(librbd, rename_enter, src_io_ctx.get_pool_name().c_str(), src_io_ctx.get_id(), srcname, destname);
+ int r = librbd::rename(src_io_ctx, srcname, destname);
+ tracepoint(librbd, rename_exit, r);
+ return r;
}
extern "C" int rbd_open(rados_ioctx_t p, const char *name, rbd_image_t *image,
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
librbd::ImageCtx *ictx = new librbd::ImageCtx(name, "", snap_name, io_ctx,
false);
+ tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
int r = librbd::open_image(ictx);
if (r >= 0)
*image = (rbd_image_t)ictx;
+ tracepoint(librbd, open_image_exit, r);
return r;
}
librados::IoCtx::from_rados_ioctx_t(p, io_ctx);
librbd::ImageCtx *ictx = new librbd::ImageCtx(name, "", snap_name, io_ctx,
true);
+ tracepoint(librbd, open_image_enter, ictx, ictx->name.c_str(), ictx->id.c_str(), ictx->snap_name.c_str(), ictx->read_only);
int r = librbd::open_image(ictx);
if (r >= 0)
*image = (rbd_image_t)ictx;
+ tracepoint(librbd, open_image_exit, r);
return r;
}
extern "C" int rbd_close(rbd_image_t image)
{
librbd::ImageCtx *ctx = (librbd::ImageCtx *)image;
+ tracepoint(librbd, close_image_enter, ctx, ctx->name.c_str(), ctx->id.c_str());
librbd::close_image(ctx);
+ tracepoint(librbd, close_image_exit);
return 0;
}
extern "C" int rbd_resize(rbd_image_t image, uint64_t size)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
+ tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
librbd::NoOpProgressContext prog_ctx;
- return librbd::resize(ictx, size, prog_ctx);
+ int r = librbd::resize(ictx, size, prog_ctx);
+ tracepoint(librbd, resize_exit, r);
+ return r;
}
extern "C" int rbd_resize_with_progress(rbd_image_t image, uint64_t size,
librbd_progress_fn_t cb, void *cbdata)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
+ tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
librbd::CProgressContext prog_ctx(cb, cbdata);
- return librbd::resize(ictx, size, prog_ctx);
+ int r = librbd::resize(ictx, size, prog_ctx);
+ tracepoint(librbd, resize_exit, r);
+ return r;
}
extern "C" int rbd_stat(rbd_image_t image, rbd_image_info_t *info,
char *buf)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
- return librbd::read(ictx, ofs, len, buf);
+ // TODO: Should these tracepoints be combined?
+ tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
+ tracepoint(librbd, read_extent, ofs, len);
+ int r = librbd::read(ictx, ofs, len, buf);
+ tracepoint(librbd, read_exit, r);
+ return r;
}
extern "C" int64_t rbd_read_iterate(rbd_image_t image, uint64_t ofs, size_t len,
const char *buf)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
- return librbd::write(ictx, ofs, len, buf);
+ tracepoint(librbd, write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len, buf);
+ int r = librbd::write(ictx, ofs, len, buf);
+ tracepoint(librbd, write_exit, r);
+ return r;
}
extern "C" int rbd_discard(rbd_image_t image, uint64_t ofs, uint64_t len)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
- return librbd::discard(ictx, ofs, len);
+ tracepoint(librbd, discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len);
+ int r = librbd::discard(ictx, ofs, len);
+ tracepoint(librbd, discard_exit, r);
+ return r;
}
extern "C" int rbd_aio_create_completion(void *cb_arg,
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
- return librbd::aio_write(ictx, off, len, buf,
+ tracepoint(librbd, aio_write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc);
+ int r = librbd::aio_write(ictx, off, len, buf,
(librbd::AioCompletion *)comp->pc);
+ tracepoint(librbd, aio_write_exit, r);
+ return r;
}
extern "C" int rbd_aio_discard(rbd_image_t image, uint64_t off, uint64_t len,
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
- return librbd::aio_discard(ictx, off, len, (librbd::AioCompletion *)comp->pc);
+ tracepoint(librbd, aio_discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, comp->pc);
+ int r = librbd::aio_discard(ictx, off, len, (librbd::AioCompletion *)comp->pc);
+ tracepoint(librbd, aio_discard_exit, r);
+ return r;
}
extern "C" int rbd_aio_read(rbd_image_t image, uint64_t off, size_t len,
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
- return librbd::aio_read(ictx, off, len, buf, NULL,
+ // TODO: See if these tracepoints can be combined
+ tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, buf, comp->pc);
+ tracepoint(librbd, aio_read_extent, off, len);
+ int r = librbd::aio_read(ictx, off, len, buf, NULL,
(librbd::AioCompletion *)comp->pc);
+ tracepoint(librbd, aio_read_exit, r);
+ return r;
}
extern "C" int rbd_flush(rbd_image_t image)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
- return librbd::flush(ictx);
+ tracepoint(librbd, flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
+ int r = librbd::flush(ictx);
+ tracepoint(librbd, flush_exit, r);
+ return r;
}
extern "C" int rbd_aio_flush(rbd_image_t image, rbd_completion_t c)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
- return librbd::aio_flush(ictx, (librbd::AioCompletion *)comp->pc);
+ tracepoint(librbd, aio_flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, comp->pc);
+ int r = librbd::aio_flush(ictx, (librbd::AioCompletion *)comp->pc);
+ tracepoint(librbd, aio_flush_exit, r);
+ return r;
}
extern "C" int rbd_invalidate_cache(rbd_image_t image)
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
- return librbd::invalidate_cache(ictx);
+ tracepoint(librbd, invalidate_cache_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
+ int r = librbd::invalidate_cache(ictx);
+ tracepoint(librbd, invalidate_cache_exit, r);
+ return r;
}
extern "C" int rbd_aio_is_complete(rbd_completion_t c)