From: Xiubo Li Date: Wed, 30 Aug 2023 04:56:59 +0000 (+0800) Subject: Revert "mds: wait reintegrate to finish when unlinking" X-Git-Tag: v18.2.1~94^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=432773fa5302c50b3264b8ada55fe471399fb2b0;p=ceph.git Revert "mds: wait reintegrate to finish when unlinking" This reverts commit c3b36723defae32b0a3ef1ac37b58ec57d356b65. Fixes: https://tracker.ceph.com/issues/61818 Signed-off-by: Xiubo Li (cherry picked from commit b0b279aeb7a74e8edc7cee9f133b0fa7a078c8a6) --- diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 6f20f53d144d..55f2191346fa 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -108,8 +108,6 @@ ostream& operator<<(ostream& out, const CDentry& dn) out << " state=" << dn.get_state(); if (dn.is_new()) out << "|new"; if (dn.state_test(CDentry::STATE_BOTTOMLRU)) out << "|bottomlru"; - if (dn.state_test(CDentry::STATE_UNLINKING)) out << "|unlinking"; - if (dn.state_test(CDentry::STATE_REINTEGRATING)) out << "|reintegrating"; if (dn.get_num_ref()) { out << " |"; diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index c4acf87682d9..9b7e1846f7cd 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -88,7 +88,6 @@ public: static const int STATE_PURGINGPINNED = (1<<5); static const int STATE_BOTTOMLRU = (1<<6); static const int STATE_UNLINKING = (1<<7); - static const int STATE_REINTEGRATING = (1<<8); // stray dentry needs notification of releasing reference static const int STATE_STRAY = STATE_NOTIFYREF; static const int MASK_STATE_IMPORT_KEPT = STATE_BOTTOMLRU; @@ -102,9 +101,8 @@ public: static const unsigned EXPORT_NONCE = 1; - const static uint64_t WAIT_UNLINK_STATE = (1<<0); - const static uint64_t WAIT_UNLINK_FINISH = (1<<1); - const static uint64_t WAIT_REINTEGRATE_FINISH = (1<<2); + const static uint64_t WAIT_UNLINK_STATE = (1<<0); + const static uint64_t WAIT_UNLINK_FINISH = (1<<1); uint32_t replica_unlinking_ref = 0; CDentry(std::string_view n, __u32 h, diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 2bb5b7d7bb8a..bc57483c603f 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -1178,7 +1178,6 @@ bool MDSRank::is_valid_message(const cref_t &m) { type == CEPH_MSG_CLIENT_RECONNECT || type == CEPH_MSG_CLIENT_RECLAIM || type == CEPH_MSG_CLIENT_REQUEST || - type == CEPH_MSG_CLIENT_REPLY || type == MSG_MDS_PEER_REQUEST || type == MSG_MDS_HEARTBEAT || type == MSG_MDS_TABLE_REQUEST || @@ -1232,7 +1231,6 @@ void MDSRank::handle_message(const cref_t &m) ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_CLIENT); // fall-thru case CEPH_MSG_CLIENT_REQUEST: - case CEPH_MSG_CLIENT_REPLY: server->dispatch(m); break; case MSG_MDS_PEER_REQUEST: diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index c52c837083b9..7e147c94c96e 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -151,29 +151,6 @@ class Finisher; class ScrubStack; class C_ExecAndReply; -struct MDSMetaRequest { -private: - int _op; - CDentry *_dentry; - ceph_tid_t _tid; -public: - explicit MDSMetaRequest(int op, CDentry *dn, ceph_tid_t tid) : - _op(op), _dentry(dn), _tid(tid) { - if (_dentry) { - _dentry->get(CDentry::PIN_PURGING); - } - } - ~MDSMetaRequest() { - if (_dentry) { - _dentry->put(CDentry::PIN_PURGING); - } - } - - CDentry *get_dentry() { return _dentry; } - int get_op() { return _op; } - ceph_tid_t get_tid() { return _tid; } -}; - /** * The public part of this class's interface is what's exposed to all * the various subsystems (server, mdcache, etc), such as pointers @@ -439,8 +416,6 @@ class MDSRank { PerfCounters *logger = nullptr, *mlogger = nullptr; OpTracker op_tracker; - std::map internal_client_requests; - // The last different state I held before current MDSMap::DaemonState last_state = MDSMap::STATE_BOOT; // The state assigned to me by the MDSMap diff --git a/src/mds/Server.cc b/src/mds/Server.cc index b765642d7887..2d3dc89aef25 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -31,7 +31,6 @@ #include "Mutation.h" #include "MetricsHandler.h" #include "cephfs_features.h" -#include "MDSContext.h" #include "msg/Messenger.h" @@ -359,9 +358,6 @@ void Server::dispatch(const cref_t &m) case CEPH_MSG_CLIENT_REQUEST: handle_client_request(ref_cast(m)); return; - case CEPH_MSG_CLIENT_REPLY: - handle_client_reply(ref_cast(m)); - return; case CEPH_MSG_CLIENT_RECLAIM: handle_client_reclaim(ref_cast(m)); return; @@ -2295,10 +2291,6 @@ void Server::reply_client_request(MDRequestRef& mdr, const ref_t & mds->send_message_client(reply, session); } - if (client_inst.name.is_mds() && reply->get_op() == CEPH_MDS_OP_RENAME) { - mds->send_message(reply, mdr->client_request->get_connection()); - } - if (req->is_queued_for_replay() && (mdr->has_completed || reply->get_result() < 0)) { if (reply->get_result() < 0) { @@ -2530,38 +2522,6 @@ void Server::handle_client_request(const cref_t &req) return; } -void Server::handle_client_reply(const cref_t &reply) -{ - dout(4) << "handle_client_reply " << *reply << dendl; - - ceph_assert(reply->is_safe()); - ceph_tid_t tid = reply->get_tid(); - - if (mds->internal_client_requests.count(tid) == 0) { - dout(1) << " no pending request on tid " << tid << dendl; - return; - } - - auto &req = mds->internal_client_requests.at(tid); - CDentry *dn = req.get_dentry(); - - switch (reply->get_op()) { - case CEPH_MDS_OP_RENAME: - if (dn) { - dn->state_clear(CDentry::STATE_REINTEGRATING); - - MDSContext::vec finished; - dn->take_waiting(CDentry::WAIT_REINTEGRATE_FINISH, finished); - mds->queue_waiters(finished); - } - break; - default: - dout(5) << " unknown client op " << reply->get_op() << dendl; - } - - mds->internal_client_requests.erase(tid); -} - void Server::handle_osd_map() { /* Note that we check the OSDMAP_FULL flag directly rather than @@ -6859,45 +6819,6 @@ void Server::wait_for_pending_unlink(CDentry *dn, MDRequestRef& mdr) dn->add_waiter(CDentry::WAIT_UNLINK_FINISH, new C_WaitUnlinkToFinish(mdcache, dn, fin)); } -struct C_WaitReintegrateToFinish : public MDSContext { -protected: - MDCache *mdcache; - CDentry *dn; - MDSContext *fin; - - MDSRank *get_mds() override - { - ceph_assert(mdcache != NULL); - return mdcache->mds; - } - -public: - C_WaitReintegrateToFinish(MDCache *m, CDentry *d, MDSContext *f) : - mdcache(m), dn(d), fin(f) {} - void finish(int r) override { - fin->complete(r); - dn->put(CDentry::PIN_PURGING); - } -}; - -bool Server::is_reintegrate_pending(CDentry *dn) -{ - CDentry::linkage_t *dnl = dn->get_projected_linkage(); - if (!dnl->is_null() && dn->state_test(CDentry::STATE_REINTEGRATING)) { - return true; - } - return false; -} - -void Server::wait_for_pending_reintegrate(CDentry *dn, MDRequestRef& mdr) -{ - dout(20) << __func__ << " dn " << *dn << dendl; - mds->locker->drop_locks(mdr.get()); - auto fin = new C_MDS_RetryRequest(mdcache, mdr); - dn->get(CDentry::PIN_PURGING); - dn->add_waiter(CDentry::WAIT_REINTEGRATE_FINISH, new C_WaitReintegrateToFinish(mdcache, dn, fin)); -} - // MKNOD class C_MDS_mknod_finish : public ServerLogContext { @@ -7961,11 +7882,6 @@ void Server::handle_client_unlink(MDRequestRef& mdr) if (!dn) return; - if (is_reintegrate_pending(dn)) { - wait_for_pending_reintegrate(dn, mdr); - return; - } - // notify replica MDSes the dentry is under unlink if (!dn->state_test(CDentry::STATE_UNLINKING)) { dn->state_set(CDentry::STATE_UNLINKING); diff --git a/src/mds/Server.h b/src/mds/Server.h index a269d6cb4790..a7965a90a8e5 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -158,7 +158,6 @@ public: // -- requests -- void handle_client_request(const cref_t &m); - void handle_client_reply(const cref_t &m); void journal_and_reply(MDRequestRef& mdr, CInode *tracei, CDentry *tracedn, LogEvent *le, MDSLogContextBase *fin); @@ -239,9 +238,6 @@ public: bool is_unlink_pending(CDentry *dn); void wait_for_pending_unlink(CDentry *dn, MDRequestRef& mdr); - bool is_reintegrate_pending(CDentry *dn); - void wait_for_pending_reintegrate(CDentry *dn, MDRequestRef& mdr); - // open void handle_client_open(MDRequestRef& mdr); void handle_client_openc(MDRequestRef& mdr); // O_CREAT variant. diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index e3e8afd2b567..d288ce6617e7 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -676,27 +676,19 @@ void StrayManager::reintegrate_stray(CDentry *straydn, CDentry *rdn) dout(10) << __func__ << " " << *straydn << " to " << *rdn << dendl; logger->inc(l_mdc_strays_reintegrated); - + // rename it to remote linkage . filepath src(straydn->get_name(), straydn->get_dir()->ino()); filepath dst(rdn->get_name(), rdn->get_dir()->ino()); - ceph_tid_t tid = mds->issue_tid(); - auto req = make_message(CEPH_MDS_OP_RENAME); req->set_filepath(dst); req->set_filepath2(src); - req->set_tid(tid); - - rdn->state_set(CDentry::STATE_REINTEGRATING); - mds->internal_client_requests.emplace(std::piecewise_construct, - std::make_tuple(tid), - std::make_tuple(CEPH_MDS_OP_RENAME, - rdn, tid)); + req->set_tid(mds->issue_tid()); mds->send_message_mds(req, rdn->authority().first); } - + void StrayManager::migrate_stray(CDentry *dn, mds_rank_t to) { dout(10) << __func__ << " " << *dn << " to mds." << to << dendl; @@ -710,17 +702,10 @@ void StrayManager::migrate_stray(CDentry *dn, mds_rank_t to) filepath src(dn->get_name(), dirino); filepath dst(dn->get_name(), MDS_INO_STRAY(to, MDS_INO_STRAY_INDEX(dirino))); - ceph_tid_t tid = mds->issue_tid(); - auto req = make_message(CEPH_MDS_OP_RENAME); req->set_filepath(dst); req->set_filepath2(src); - req->set_tid(tid); - - mds->internal_client_requests.emplace(std::piecewise_construct, - std::make_tuple(tid), - std::make_tuple(CEPH_MDS_OP_RENAME, - nullptr, tid)); + req->set_tid(mds->issue_tid()); mds->send_message_mds(req, to); }