From: Casey Bodley Date: Mon, 22 May 2023 21:36:43 +0000 (-0400) Subject: librados: aio_operate() supports ObjectWriteOperation::mtime2() X-Git-Tag: v17.2.7~278^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1f4152df9c1272e7d04193270af6fa3724c71f01;p=ceph.git librados: aio_operate() supports ObjectWriteOperation::mtime2() copy the optional mtime logic from operate(), so that mtimes set on the ObjectOperation are propagated through aio_operate() as well Fixes: https://tracker.ceph.com/issues/61349 Signed-off-by: Casey Bodley (cherry picked from commit cdf54ff1ca5ab95ee0559329b0820a1686d21c54) --- diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index b9a73c87ca861..e1d38fd014a4b 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -751,12 +751,13 @@ int librados::IoCtxImpl::aio_operate_read(const object_t &oid, int librados::IoCtxImpl::aio_operate(const object_t& oid, ::ObjectOperation *o, AioCompletionImpl *c, - const SnapContext& snap_context, int flags, + const SnapContext& snap_context, + const ceph::real_time *pmtime, int flags, const blkin_trace_info *trace_info) { FUNCTRACE(client->cct); OID_EVENT_TRACE(oid.name.c_str(), "RADOS_WRITE_OP_BEGIN"); - auto ut = ceph::real_clock::now(); + const ceph::real_time ut = (pmtime ? *pmtime : ceph::real_clock::now()); /* can't write to a snapshot */ if (snap_seq != CEPH_NOSNAP) return -EROFS; @@ -1137,7 +1138,7 @@ int librados::IoCtxImpl::aio_rmxattr(const object_t& oid, AioCompletionImpl *c, ::ObjectOperation op; prepare_assert_ops(&op); op.rmxattr(name); - return aio_operate(oid, &op, c, snapc, 0); + return aio_operate(oid, &op, c, snapc, nullptr, 0); } int librados::IoCtxImpl::aio_setxattr(const object_t& oid, AioCompletionImpl *c, @@ -1146,7 +1147,7 @@ int librados::IoCtxImpl::aio_setxattr(const object_t& oid, AioCompletionImpl *c, ::ObjectOperation op; prepare_assert_ops(&op); op.setxattr(name, bl); - return aio_operate(oid, &op, c, snapc, 0); + return aio_operate(oid, &op, c, snapc, nullptr, 0); } namespace { diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 4ab8a5b747b07..477768ef78a4f 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -158,7 +158,8 @@ struct librados::IoCtxImpl { int operate_read(const object_t& oid, ::ObjectOperation *o, bufferlist *pbl, int flags=0); int aio_operate(const object_t& oid, ::ObjectOperation *o, AioCompletionImpl *c, const SnapContext& snap_context, - int flags, const blkin_trace_info *trace_info = nullptr); + const ceph::real_time *pmtime, int flags, + const blkin_trace_info *trace_info = nullptr); int aio_operate_read(const object_t& oid, ::ObjectOperation *o, AioCompletionImpl *c, int flags, bufferlist *pbl, const blkin_trace_info *trace_info = nullptr); diff --git a/src/librados/librados_c.cc b/src/librados/librados_c.cc index 792768b9d8f96..7419bc4df199f 100644 --- a/src/librados/librados_c.cc +++ b/src/librados/librados_c.cc @@ -4018,7 +4018,7 @@ extern "C" int LIBRADOS_C_API_DEFAULT_F(rados_aio_write_op_operate)( ::ObjectOperation *oo = (::ObjectOperation *) write_op; librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; librados::AioCompletionImpl *c = (librados::AioCompletionImpl*)completion; - int retval = ctx->aio_operate(obj, oo, c, ctx->snapc, translate_flags(flags)); + int retval = ctx->aio_operate(obj, oo, c, ctx->snapc, nullptr, translate_flags(flags)); tracepoint(librados, rados_aio_write_op_operate_exit, retval); return retval; } diff --git a/src/librados/librados_cxx.cc b/src/librados/librados_cxx.cc index 46aa8d80ce37b..ce2e523d2c4bd 100644 --- a/src/librados/librados_cxx.cc +++ b/src/librados/librados_cxx.cc @@ -1559,7 +1559,7 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, if (unlikely(!o->impl)) return -EINVAL; return io_ctx_impl->aio_operate(obj, &o->impl->o, c->pc, - io_ctx_impl->snapc, 0); + io_ctx_impl->snapc, o->impl->prt, 0); } int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, ObjectWriteOperation *o, int flags) @@ -1568,7 +1568,7 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, if (unlikely(!o->impl)) return -EINVAL; return io_ctx_impl->aio_operate(obj, &o->impl->o, c->pc, - io_ctx_impl->snapc, + io_ctx_impl->snapc, o->impl->prt, translate_flags(flags)); } @@ -1585,7 +1585,7 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, snv[i] = snaps[i]; SnapContext snapc(snap_seq, snv); return io_ctx_impl->aio_operate(obj, &o->impl->o, c->pc, - snapc, 0); + snapc, o->impl->prt, 0); } int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, @@ -1602,7 +1602,7 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, snv[i] = snaps[i]; SnapContext snapc(snap_seq, snv); return io_ctx_impl->aio_operate(obj, &o->impl->o, c->pc, - snapc, 0, trace_info); + snapc, o->impl->prt, 0, trace_info); } int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, @@ -1618,7 +1618,7 @@ int librados::IoCtx::aio_operate(const std::string& oid, AioCompletion *c, for (size_t i = 0; i < snaps.size(); ++i) snv[i] = snaps[i]; SnapContext snapc(snap_seq, snv); - return io_ctx_impl->aio_operate(obj, &o->impl->o, c->pc, snapc, + return io_ctx_impl->aio_operate(obj, &o->impl->o, c->pc, snapc, o->impl->prt, translate_flags(flags), trace_info); } diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index c19de9a865989..238cffa1999cf 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -446,7 +446,7 @@ int IoCtx::aio_operate(const std::string& oid, AioCompletion *c, ObjectWriteOperation *op) { TestIoCtxImpl *ctx = reinterpret_cast(io_ctx_impl); TestObjectOperationImpl *ops = reinterpret_cast(op->impl); - return ctx->aio_operate(oid, *ops, c->pc, NULL, 0); + return ctx->aio_operate(oid, *ops, c->pc, nullptr, nullptr, 0); } int IoCtx::aio_operate(const std::string& oid, AioCompletion *c, @@ -462,7 +462,7 @@ int IoCtx::aio_operate(const std::string& oid, AioCompletion *c, snv[i] = snaps[i]; SnapContext snapc(seq, snv); - return ctx->aio_operate(oid, *ops, c->pc, &snapc, flags); + return ctx->aio_operate(oid, *ops, c->pc, &snapc, nullptr, flags); } int IoCtx::aio_operate(const std::string& oid, AioCompletion *c, diff --git a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h index 7937e221ad7d4..aed431c11b9eb 100644 --- a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h +++ b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h @@ -44,11 +44,13 @@ public: return TestMemIoCtxImpl::aio_notify(o, c, bl, timeout_ms, pbl); } - MOCK_METHOD5(aio_operate, int(const std::string&, TestObjectOperationImpl&, - AioCompletionImpl*, SnapContext*, int)); + MOCK_METHOD6(aio_operate, int(const std::string&, TestObjectOperationImpl&, + AioCompletionImpl*, SnapContext*, + const ceph::real_time*, int)); int do_aio_operate(const std::string& o, TestObjectOperationImpl& ops, - AioCompletionImpl* c, SnapContext* snapc, int flags) { - return TestMemIoCtxImpl::aio_operate(o, ops, c, snapc, flags); + AioCompletionImpl* c, SnapContext* snapc, + const ceph::real_time* pmtime, int flags) { + return TestMemIoCtxImpl::aio_operate(o, ops, c, snapc, pmtime, flags); } MOCK_METHOD4(aio_watch, int(const std::string& o, AioCompletionImpl *c, @@ -214,7 +216,7 @@ public: ON_CALL(*this, clone()).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_clone)); ON_CALL(*this, aio_notify(_, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_notify)); - ON_CALL(*this, aio_operate(_, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_operate)); + ON_CALL(*this, aio_operate(_, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_operate)); ON_CALL(*this, aio_watch(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_watch)); ON_CALL(*this, aio_unwatch(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_unwatch)); ON_CALL(*this, assert_exists(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_assert_exists)); diff --git a/src/test/librados_test_stub/NeoradosTestStub.cc b/src/test/librados_test_stub/NeoradosTestStub.cc index 882e80820c7e1..540d86cd8c09b 100644 --- a/src/test/librados_test_stub/NeoradosTestStub.cc +++ b/src/test/librados_test_stub/NeoradosTestStub.cc @@ -548,7 +548,7 @@ void RADOS::execute(const Object& o, const IOContext& ioc, WriteOp&& op, } auto completion = create_aio_completion(std::move(c)); - auto r = io_ctx->aio_operate(std::string{o}, *ops, completion, &snapc, 0U); + auto r = io_ctx->aio_operate(std::string{o}, *ops, completion, &snapc, nullptr, 0U); ceph_assert(r == 0); } diff --git a/src/test/librados_test_stub/TestIoCtxImpl.cc b/src/test/librados_test_stub/TestIoCtxImpl.cc index 0b106e1d122cd..8a953ff7c36ef 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestIoCtxImpl.cc @@ -107,7 +107,7 @@ void TestIoCtxImpl::aio_notify(const std::string& oid, AioCompletionImpl *c, int TestIoCtxImpl::aio_operate(const std::string& oid, TestObjectOperationImpl &ops, AioCompletionImpl *c, SnapContext *snap_context, - int flags) { + const ceph::real_time *pmtime, int flags) { // TODO flags for now ops.get(); m_pending_ops++; diff --git a/src/test/librados_test_stub/TestIoCtxImpl.h b/src/test/librados_test_stub/TestIoCtxImpl.h index 3c6ff590da628..fdda17cfdf916 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.h +++ b/src/test/librados_test_stub/TestIoCtxImpl.h @@ -88,7 +88,7 @@ public: bufferlist& bl, uint64_t timeout_ms, bufferlist *pbl); virtual int aio_operate(const std::string& oid, TestObjectOperationImpl &ops, AioCompletionImpl *c, SnapContext *snap_context, - int flags); + const ceph::real_time *pmtime, int flags); virtual int aio_operate_read(const std::string& oid, TestObjectOperationImpl &ops, AioCompletionImpl *c, int flags, bufferlist *pbl, uint64_t snap_id, diff --git a/src/test/rbd_mirror/test_mock_MirrorStatusUpdater.cc b/src/test/rbd_mirror/test_mock_MirrorStatusUpdater.cc index 4db576eb4343b..ef2af00f26140 100644 --- a/src/test/rbd_mirror/test_mock_MirrorStatusUpdater.cc +++ b/src/test/rbd_mirror/test_mock_MirrorStatusUpdater.cc @@ -169,7 +169,7 @@ public: void expect_mirror_status_update( const MirrorImageSiteStatuses& mirror_image_site_statuses, const std::string& mirror_uuid, int r) { - EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _)) + EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _, _)) .WillOnce(Invoke([this](auto&&... args) { int r = m_mock_local_io_ctx->do_aio_operate(decltype(args)(args)...); m_mock_local_io_ctx->aio_flush(); @@ -203,7 +203,7 @@ public: void expect_mirror_status_removes(const std::set& mirror_images, int r) { - EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _)) + EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _, _)) .WillOnce(Invoke([this](auto&&... args) { int r = m_mock_local_io_ctx->do_aio_operate(decltype(args)(args)...); m_mock_local_io_ctx->aio_flush(); @@ -439,7 +439,7 @@ TEST_F(TestMockMirrorStatusUpdater, RemoveStatus) { fire_timer_event(&timer_event, &update_task); C_SaferCond remove_flush_ctx; - EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _)) + EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _, _)) .WillOnce(Invoke([this, &remove_flush_ctx](auto&&... args) { int r = m_mock_local_io_ctx->do_aio_operate(decltype(args)(args)...); m_mock_local_io_ctx->aio_flush(); @@ -506,7 +506,7 @@ TEST_F(TestMockMirrorStatusUpdater, OverwriteStatusInFlight) { Context* update_task = nullptr; fire_timer_event(&timer_event, &update_task); - EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _)) + EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _, _)) .WillOnce(Invoke([this, &mock_mirror_status_updater](auto&&... args) { mock_mirror_status_updater.set_mirror_image_status( "1", {"", cls::rbd::MIRROR_IMAGE_STATUS_STATE_REPLAYING, @@ -617,7 +617,7 @@ TEST_F(TestMockMirrorStatusUpdater, RemoveRefreshInFlightStatus) { fire_timer_event(&timer_event, &update_task); C_SaferCond on_removed; - EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _)) + EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _, _)) .WillOnce(Invoke( [this, &mock_mirror_status_updater, &on_removed](auto&&... args) { mock_mirror_status_updater.remove_refresh_mirror_image_status( @@ -652,7 +652,7 @@ TEST_F(TestMockMirrorStatusUpdater, ShutDownWhileUpdating) { fire_timer_event(&timer_event, &update_task); C_SaferCond on_shutdown; - EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _)) + EXPECT_CALL(*m_mock_local_io_ctx, aio_operate(_, _, _, _, _, _)) .WillOnce(Invoke( [this, &mock_mirror_status_updater, &on_shutdown](auto&&... args) { mock_mirror_status_updater.shut_down(&on_shutdown);