From: Zhiqiang Wang Date: Wed, 20 May 2015 14:34:34 +0000 (+0800) Subject: test/ceph_test_rados: add tests of pipeline reads X-Git-Tag: v9.0.3~59^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=522b4957410c958d09102e013ffd7f2525114c13;p=ceph.git test/ceph_test_rados: add tests of pipeline reads Send pipelined reads in the ReadOp. This can help testing OSD's behavior in some scenarios. Signed-off-by: Zhiqiang Wang --- diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h index 05141dae561c..e4e0739efa03 100644 --- a/src/test/osd/RadosModel.h +++ b/src/test/osd/RadosModel.h @@ -959,6 +959,7 @@ public: class ReadOp : public TestOp { public: librados::AioCompletion *completion; + vector pipeline_comps; librados::ObjectReadOperation op; string oid; ObjectDesc old_value; @@ -968,6 +969,9 @@ public: bufferlist result; int retval; + vector pipeline_results; + vector pipeline_retvals; + uint64_t waiting_on; map attrs; int attrretval; @@ -985,9 +989,13 @@ public: TestOpStat *stat = 0) : TestOp(n, context, stat), completion(NULL), + pipeline_comps(2), oid(oid), snap(0), retval(0), + pipeline_results(2), + pipeline_retvals(2), + waiting_on(0), attrretval(0) {} @@ -1030,6 +1038,7 @@ public: std::cerr << num << ": notified, waiting" << std::endl; ctx->wait(); } + context->state_lock.Lock(); if (snap >= 0) { context->io_ctx.snap_set_read(context->snaps[snap]); } @@ -1059,15 +1068,48 @@ public: } op.getxattrs(&xattrs, 0); assert(!context->io_ctx.aio_operate(context->prefix+oid, completion, &op, 0)); + waiting_on++; + + // send 2 pipelined reads on the same object/snap. This can help testing + // OSD's read behavior in some scenarios + for (uint32_t i = 0; i < 2; ++i) { + librados::ObjectReadOperation pipeline_op; + + pipeline_op.read(0, + !old_value.has_contents() ? 0 : + old_value.most_recent_gen()->get_length(old_value.most_recent()), + &pipeline_results[i], + &pipeline_retvals[i]); + pipeline_comps[i] = context->rados.aio_create_completion((void *) this, &read_callback, 0); + assert(!context->io_ctx.aio_operate(context->prefix+oid, pipeline_comps[i], &pipeline_op, 0)); + waiting_on++; + } + if (snap >= 0) { context->io_ctx.snap_set_read(0); } + context->state_lock.Unlock(); } void _finish(CallbackInfo *info) { - context->state_lock.Lock(); + Mutex::Locker l(context->state_lock); assert(!done); + assert(waiting_on > 0); + if (--waiting_on) { + return; + } + + for (vector::iterator i = pipeline_comps.begin(); + i != pipeline_comps.end(); ++i) { + assert((*i)->is_complete()); + if (int err = (*i)->get_return_value()) { + cerr << "Error: oid " << oid << " read returned error code " + << err << std::endl; + } + (*i)->release(); + } + context->oid_in_use.erase(oid); context->oid_not_in_use.insert(oid); assert(completion->is_complete()); @@ -1191,7 +1233,6 @@ public: completion->release(); context->kick(); done = true; - context->state_lock.Unlock(); } bool finished()