From 8269159d2ab4c8fb6d187a9f9079d43ba8eca360 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 22 Sep 2016 11:07:32 -0400 Subject: [PATCH] librados: only request ack if AioComplete has an ack callback Probalby no librados users are actually using the ack callback, but we are still requesting an ack message from the OSD. Only request it if the AioCompletion has a callback defined for it. This might make users who are no setting the callback but are install polling the completion or using wait_for_complete() unhappy, but I don't think they actually exist. And even if they do, they are highly unlikely to notice the difference given the way the OSDs are implemented. Signed-off-by: Sage Weil --- src/librados/AioCompletionImpl.h | 4 ++++ src/librados/IoCtxImpl.cc | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/librados/AioCompletionImpl.h b/src/librados/AioCompletionImpl.h index 982f2bd7eee1..c8b570d1be41 100644 --- a/src/librados/AioCompletionImpl.h +++ b/src/librados/AioCompletionImpl.h @@ -59,6 +59,10 @@ struct librados::AioCompletionImpl { is_read(false), blp(nullptr), out_buf(nullptr), io(NULL), aio_write_seq(0), aio_write_list_item(this) { } + bool wants_ack() { + return is_read || callback_complete; + } + int set_complete_callback(void *cb_arg, rados_callback_t cb) { lock.Lock(); callback_complete = cb; diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 1b29d1eeea87..001ce4183711 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -766,7 +766,7 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid, if (snap_seq != CEPH_NOSNAP) return -EROFS; - Context *onack = new C_aio_Ack(c); + Context *onack = c->wants_ack() ? new C_aio_Ack(c) : NULL; Context *oncommit = new C_aio_Safe(c); c->io = this; @@ -874,7 +874,7 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c, if (snap_seq != CEPH_NOSNAP) return -EROFS; - Context *onack = new C_aio_Ack(c); + Context *onack = c->wants_ack() ? new C_aio_Ack(c) : NULL; Context *onsafe = new C_aio_Safe(c); c->io = this; @@ -900,7 +900,7 @@ int librados::IoCtxImpl::aio_append(const object_t &oid, AioCompletionImpl *c, if (snap_seq != CEPH_NOSNAP) return -EROFS; - Context *onack = new C_aio_Ack(c); + Context *onack = c->wants_ack() ? new C_aio_Ack(c) : NULL; Context *onsafe = new C_aio_Safe(c); c->io = this; @@ -927,7 +927,7 @@ int librados::IoCtxImpl::aio_write_full(const object_t &oid, if (snap_seq != CEPH_NOSNAP) return -EROFS; - Context *onack = new C_aio_Ack(c); + Context *onack = c->wants_ack() ? new C_aio_Ack(c) : NULL; Context *onsafe = new C_aio_Safe(c); c->io = this; @@ -958,7 +958,7 @@ int librados::IoCtxImpl::aio_writesame(const object_t &oid, if (snap_seq != CEPH_NOSNAP) return -EROFS; - Context *onack = new C_aio_Ack(c); + Context *onack = c->wants_ack() ? new C_aio_Ack(c) : NULL; Context *onsafe = new C_aio_Safe(c); c->io = this; @@ -982,7 +982,7 @@ int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c) if (snap_seq != CEPH_NOSNAP) return -EROFS; - Context *onack = new C_aio_Ack(c); + Context *onack = c->wants_ack() ? new C_aio_Ack(c) : NULL; Context *onsafe = new C_aio_Safe(c); c->io = this; -- 2.47.3