From: Joaquim Rocha Date: Mon, 19 Oct 2015 13:31:45 +0000 (+0200) Subject: tools/rados/rados.cc: Write to different destinations X-Git-Tag: v10.0.0~20^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7524e16f45a53ebdf48894498e040cfd3cc01a63;p=ceph.git tools/rados/rados.cc: Write to different destinations The write benchmark only writes the objects' contents, not the omap nor the extended attributes, which is something also interesting to measure depending on the cluster's configuration. These changes add a way to specify where the contents should be written, allowing to combine any of the destinations mentioned above. Signed-off-by: Joaquim Rocha --- diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 4f4b0863f702..7e9247ed9868 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -822,6 +822,11 @@ void LoadGen::cleanup() } } +enum OpWriteDest { + OP_WRITE_DEST_OBJ = 2 << 0, + OP_WRITE_DEST_OMAP = 2 << 1, + OP_WRITE_DEST_XATTR = 2 << 2, +}; class RadosBencher : public ObjBencher { librados::AioCompletion **completions; @@ -829,6 +834,8 @@ class RadosBencher : public ObjBencher { librados::IoCtx& io_ctx; librados::NObjectIterator oi; bool iterator_valid; + OpWriteDest write_destination; + protected: int completions_init(int concurrentios) { completions = new librados::AioCompletion *[concurrentios]; @@ -856,7 +863,23 @@ protected: } int aio_write(const std::string& oid, int slot, bufferlist& bl, size_t len) { - return io_ctx.aio_write(oid, completions[slot], bl, len, 0); + librados::ObjectWriteOperation op; + + if (write_destination & OP_WRITE_DEST_OBJ) { + op.write(0, bl); + } + + if (write_destination & OP_WRITE_DEST_OMAP) { + std::map omap; + omap["bench-omap-key"] = bl; + op.omap_set(omap); + } + + if (write_destination & OP_WRITE_DEST_XATTR) { + op.setxattr("bench-xattr-key", bl); + } + + return io_ctx.aio_operate(oid, completions[slot], &op); } int aio_remove(const std::string& oid, int slot) { @@ -916,8 +939,12 @@ protected: public: RadosBencher(CephContext *cct_, librados::Rados& _r, librados::IoCtx& _i) - : ObjBencher(cct_), completions(NULL), rados(_r), io_ctx(_i), iterator_valid(false) {} + : ObjBencher(cct_), completions(NULL), rados(_r), io_ctx(_i), iterator_valid(false), write_destination(OP_WRITE_DEST_OBJ) {} ~RadosBencher() { } + + void set_write_destination(OpWriteDest dest) { + write_destination = dest; + } }; static int do_lock_cmd(std::vector &nargs,