From: Kefu Chai Date: Sun, 7 Mar 2021 13:23:54 +0000 (+0800) Subject: crimson/osd: differentiate Notify with and without watchers X-Git-Tag: v17.1.0~2705^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8f6be7ddac7abdb61b669e89621a2942a13022c0;p=ceph.git crimson/osd: differentiate Notify with and without watchers we don't need to arm the timer, if there is no watchers. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/watch.cc b/src/crimson/osd/watch.cc index 590e99227772..261bd18040cb 100644 --- a/src/crimson/osd/watch.cc +++ b/src/crimson/osd/watch.cc @@ -128,6 +128,16 @@ std::ostream &operator<<(std::ostream &out, const notify_reply_t &rhs) return out; } +Notify::Notify(crimson::net::ConnectionRef conn, + const notify_info_t& ninfo, + const uint64_t client_gid, + const uint64_t user_version) + : ninfo(ninfo), + conn(std::move(conn)), + client_gid(client_gid), + user_version(user_version) +{} + seastar::future<> Notify::remove_watcher(WatchRef watch) { if (discarded || complete) { diff --git a/src/crimson/osd/watch.h b/src/crimson/osd/watch.h index b654efa41c43..d9f7325d3acc 100644 --- a/src/crimson/osd/watch.h +++ b/src/crimson/osd/watch.h @@ -130,6 +130,10 @@ class Notify { /// Called on Notify timeout void do_timeout(); + Notify(crimson::net::ConnectionRef conn, + const notify_info_t& ninfo, + const uint64_t client_gid, + const uint64_t user_version); template Notify(WatchIteratorT begin, WatchIteratorT end, @@ -188,6 +192,7 @@ Notify::Notify(WatchIteratorT begin, conn(std::move(conn)), client_gid(client_gid), user_version(user_version) { + assert(!std::empty(watchers)); if (ninfo.timeout) { timeout_timer.arm(std::chrono::seconds{ninfo.timeout}); } @@ -202,14 +207,16 @@ seastar::future<> Notify::create_n_propagate( static_assert( std::is_same_v::value_type, crimson::osd::WatchRef>); - auto notify = seastar::make_shared( - private_ctag_t{}, - begin, - end, - std::forward(args)...); if (begin == end) { + auto notify = seastar::make_shared( + private_ctag_t{}, + std::forward(args)...); return notify->send_completion(); } else { + auto notify = seastar::make_shared( + private_ctag_t{}, + begin, end, + std::forward(args)...); return seastar::do_for_each(begin, end, [=] (auto& watchref) { return watchref->start_notify(notify); });