From 3636ef21413d831e33c3dc5f265066946e50db5b Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 23 Jul 2019 09:41:30 +0800 Subject: [PATCH] mds: rename {CDir,Migrator}::cache to mdcache make it be consistant with CInode::mdcache Signed-off-by: "Yan, Zheng" --- src/mds/CDentry.cc | 4 +- src/mds/CDir.cc | 176 +++++++++++++++---------------- src/mds/CDir.h | 4 +- src/mds/Migrator.cc | 248 ++++++++++++++++++++++---------------------- src/mds/Migrator.h | 2 +- src/mds/journal.cc | 2 +- 6 files changed, 218 insertions(+), 218 deletions(-) diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index cd85d9d950550..335ee402fec82 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -28,12 +28,12 @@ #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mds #undef dout_prefix -#define dout_prefix *_dout << "mds." << dir->cache->mds->get_nodeid() << ".cache.den(" << dir->dirfrag() << " " << name << ") " +#define dout_prefix *_dout << "mds." << dir->mdcache->mds->get_nodeid() << ".cache.den(" << dir->dirfrag() << " " << name << ") " ostream& CDentry::print_db_line_prefix(ostream& out) { - return out << ceph_clock_now() << " mds." << dir->cache->mds->get_nodeid() << ".cache.den(" << dir->ino() << " " << name << ") "; + return out << ceph_clock_now() << " mds." << dir->mdcache->mds->get_nodeid() << ".cache.den(" << dir->ino() << " " << name << ") "; } LockType CDentry::lock_type(CEPH_LOCK_DN); diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 235b432107287..21a4c8e63a7dd 100755 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -41,7 +41,7 @@ #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mds #undef dout_prefix -#define dout_prefix *_dout << "mds." << cache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") " +#define dout_prefix *_dout << "mds." << mdcache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") " int CDir::num_frozen_trees = 0; int CDir::num_freezing_trees = 0; @@ -52,7 +52,7 @@ class CDirContext : public MDSContext { protected: CDir *dir; - MDSRank* get_mds() override {return dir->cache->mds;} + MDSRank* get_mds() override {return dir->mdcache->mds;} public: explicit CDirContext(CDir *d) : dir(d) { @@ -65,7 +65,7 @@ class CDirIOContext : public MDSIOContextBase { protected: CDir *dir; - MDSRank* get_mds() override {return dir->cache->mds;} + MDSRank* get_mds() override {return dir->mdcache->mds;} public: explicit CDirIOContext(CDir *d) : dir(d) { @@ -184,7 +184,7 @@ void CDir::print(ostream& out) ostream& CDir::print_db_line_prefix(ostream& out) { - return out << ceph_clock_now() << " mds." << cache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") "; + return out << ceph_clock_now() << " mds." << mdcache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") "; } @@ -192,19 +192,19 @@ ostream& CDir::print_db_line_prefix(ostream& out) // ------------------------------------------------------------------- // CDir -CDir::CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth) : - cache(mdcache), inode(in), frag(fg), +CDir::CDir(CInode *in, frag_t fg, MDCache *mdc, bool auth) : + mdcache(mdc), inode(in), frag(fg), dirty_rstat_inodes(member_offset(CInode, dirty_rstat_item)), dirty_dentries(member_offset(CDentry, item_dir_dirty)), item_dirty(this), item_new(this), lock_caches_with_auth_pins(member_offset(MDLockCache::DirItem, item_dir)), freezing_inodes(member_offset(CInode, item_freezing_inode)), dir_rep(REP_NONE), - pop_me(mdcache->decayrate), - pop_nested(mdcache->decayrate), - pop_auth_subtree(mdcache->decayrate), - pop_auth_subtree_nested(mdcache->decayrate), - pop_spread(mdcache->decayrate), + pop_me(mdc->decayrate), + pop_nested(mdc->decayrate), + pop_auth_subtree(mdc->decayrate), + pop_auth_subtree_nested(mdc->decayrate), + pop_spread(mdc->decayrate), pop_lru_subdirs(member_offset(CInode, item_pop_lru)), dir_auth(CDIR_AUTH_DEFAULT) { @@ -301,9 +301,9 @@ void CDir::adjust_num_inodes_with_caps(int d) { // FIXME: smarter way to decide if adding 'this' to open file table if (num_inodes_with_caps == 0 && d > 0) - cache->open_file_table.add_dirfrag(this); + mdcache->open_file_table.add_dirfrag(this); else if (num_inodes_with_caps > 0 && num_inodes_with_caps == -d) - cache->open_file_table.remove_dirfrag(this); + mdcache->open_file_table.remove_dirfrag(this); num_inodes_with_caps += d; ceph_assert(num_inodes_with_caps >= 0); @@ -348,7 +348,7 @@ CDentry* CDir::add_null_dentry(std::string_view dname, if (is_auth()) dn->state_set(CDentry::STATE_AUTH); - cache->bottom_lru.lru_insert_mid(dn); + mdcache->bottom_lru.lru_insert_mid(dn); dn->state_set(CDentry::STATE_BOTTOMLRU); dn->dir = this; @@ -391,9 +391,9 @@ CDentry* CDir::add_primary_dentry(std::string_view dname, CInode *in, if (is_auth()) dn->state_set(CDentry::STATE_AUTH); if (is_auth() || !inode->is_stray()) { - cache->lru.lru_insert_mid(dn); + mdcache->lru.lru_insert_mid(dn); } else { - cache->bottom_lru.lru_insert_mid(dn); + mdcache->bottom_lru.lru_insert_mid(dn); dn->state_set(CDentry::STATE_BOTTOMLRU); } @@ -439,7 +439,7 @@ CDentry* CDir::add_remote_dentry(std::string_view dname, inodeno_t ino, unsigned CDentry* dn = new CDentry(dname, inode->hash_dentry_name(dname), ino, d_type, first, last); if (is_auth()) dn->state_set(CDentry::STATE_AUTH); - cache->lru.lru_insert_mid(dn); + mdcache->lru.lru_insert_mid(dn); dn->dir = this; dn->version = get_projected_version(); @@ -508,9 +508,9 @@ void CDir::remove_dentry(CDentry *dn) dn->mark_clean(); if (dn->state_test(CDentry::STATE_BOTTOMLRU)) - cache->bottom_lru.lru_remove(dn); + mdcache->bottom_lru.lru_remove(dn); else - cache->lru.lru_remove(dn); + mdcache->lru.lru_remove(dn); delete dn; // unpin? @@ -532,8 +532,8 @@ void CDir::link_remote_inode(CDentry *dn, inodeno_t ino, unsigned char d_type) dn->get_linkage()->set_remote(ino, d_type); if (dn->state_test(CDentry::STATE_BOTTOMLRU)) { - cache->bottom_lru.lru_remove(dn); - cache->lru.lru_insert_mid(dn); + mdcache->bottom_lru.lru_remove(dn); + mdcache->lru.lru_insert_mid(dn); dn->state_clear(CDentry::STATE_BOTTOMLRU); } @@ -558,8 +558,8 @@ void CDir::link_primary_inode(CDentry *dn, CInode *in) if (dn->state_test(CDentry::STATE_BOTTOMLRU) && (is_auth() || !inode->is_stray())) { - cache->bottom_lru.lru_remove(dn); - cache->lru.lru_insert_mid(dn); + mdcache->bottom_lru.lru_remove(dn); + mdcache->lru.lru_insert_mid(dn); dn->state_clear(CDentry::STATE_BOTTOMLRU); } @@ -587,7 +587,7 @@ void CDir::link_inode_work( CDentry *dn, CInode *in) dn->get(CDentry::PIN_INODEPIN); if (in->state_test(CInode::STATE_TRACKEDBYOFT)) - inode->mdcache->open_file_table.notify_link(in); + mdcache->open_file_table.notify_link(in); if (in->is_any_caps()) adjust_num_inodes_with_caps(1); @@ -618,8 +618,8 @@ void CDir::unlink_inode(CDentry *dn, bool adjust_lru) unlink_inode_work(dn); if (adjust_lru && !dn->state_test(CDentry::STATE_BOTTOMLRU)) { - cache->lru.lru_remove(dn); - cache->bottom_lru.lru_insert_mid(dn); + mdcache->lru.lru_remove(dn); + mdcache->bottom_lru.lru_insert_mid(dn); dn->state_set(CDentry::STATE_BOTTOMLRU); } @@ -673,7 +673,7 @@ void CDir::unlink_inode_work(CDentry *dn) dn->put(CDentry::PIN_INODEPIN); if (in->state_test(CInode::STATE_TRACKEDBYOFT)) - inode->mdcache->open_file_table.notify_unlink(in); + mdcache->open_file_table.notify_unlink(in); if (in->is_any_caps()) adjust_num_inodes_with_caps(-1); @@ -706,7 +706,7 @@ void CDir::add_to_bloom(CDentry *dn) /* don't maintain bloom filters in standby replay (saves cycles, and also * avoids need to implement clearing it in EExport for #16924) */ - if (cache->mds->is_standby_replay()) { + if (mdcache->mds->is_standby_replay()) { return; } @@ -768,7 +768,7 @@ void CDir::try_remove_dentries_for_stray() // It's OK to remove lease prematurely because we will never link // the dentry to inode again. if (dn->is_any_leases()) - dn->remove_client_leases(cache->mds->locker); + dn->remove_client_leases(mdcache->mds->locker); if (dn->get_num_ref() == 0) remove_dentry(dn); } else { @@ -785,7 +785,7 @@ void CDir::try_remove_dentries_for_stray() if (dn->get_num_ref() == 0) { remove_dentry(dn); if (in) - cache->remove_inode(in); + mdcache->remove_inode(in); } } } @@ -811,7 +811,7 @@ bool CDir::try_trim_snap_dentry(CDentry *dn, const set& snaps) remove_dentry(dn); if (in) { dout(10) << " purging snapped " << *in << dendl; - cache->remove_inode(in); + mdcache->remove_inode(in); } return true; } @@ -1026,7 +1026,7 @@ void CDir::split(int bits, std::vector* subs, MDSContext::vec& waiters, b // create subfrag dirs int n = 0; for (const auto& fg : frags) { - CDir *f = new CDir(inode, fg, cache, is_auth()); + CDir *f = new CDir(inode, fg, mdcache, is_auth()); f->state_set(state & (MASK_STATE_FRAGMENT_KEPT | STATE_COMPLETE)); f->get_replicas() = get_replicas(); f->pop_me = pop_me; @@ -1232,7 +1232,7 @@ void CDir::assimilate_dirty_rstat_inodes(MutationRef& mut) auto pi = in->project_inode(mut); pi.inode->version = in->pre_dirty(); - inode->mdcache->project_rstat_inode_to_frag(mut, in, this, 0, 0, nullptr); + mdcache->project_rstat_inode_to_frag(mut, in, this, 0, 0, nullptr); } state_set(STATE_ASSIMRSTAT); dout(10) << __func__ << " done" << dendl; @@ -1259,7 +1259,7 @@ void CDir::assimilate_dirty_rstat_inodes_finish(EMetaBlob *blob) } if (!dirty_rstat_inodes.empty()) - inode->mdcache->mds->locker->mark_updated_scatterlock(&inode->nestlock); + mdcache->mds->locker->mark_updated_scatterlock(&inode->nestlock); } @@ -1371,7 +1371,7 @@ void CDir::finish_waiting(uint64_t mask, int result) if (result < 0) finish_contexts(g_ceph_context, finished, result); else - cache->mds->queue_waiters(finished); + mdcache->mds->queue_waiters(finished); } @@ -1465,7 +1465,7 @@ void CDir::mark_new(LogSegment *ls) MDSContext::vec waiters; take_waiting(CDir::WAIT_CREATED, waiters); - cache->mds->queue_waiters(waiters); + mdcache->mds->queue_waiters(waiters); } void CDir::mark_clean() @@ -1489,7 +1489,7 @@ void CDir::log_mark_dirty() auto _fnode = allocate_fnode(*get_fnode()); _fnode->version = pre_dirty(); reset_fnode(std::move(_fnode)); - mark_dirty(cache->mds->mdlog->get_current_segment()); + mark_dirty(mdcache->mds->mdlog->get_current_segment()); } void CDir::mark_complete() { @@ -1548,15 +1548,15 @@ void CDir::fetch(MDSContext *c, std::string_view want_dn, bool ignore_authpinnab reset_fnode(std::move(_fnode)); if (state_test(STATE_REJOINUNDEF)) { - ceph_assert(cache->mds->is_rejoin()); + ceph_assert(mdcache->mds->is_rejoin()); state_clear(STATE_REJOINUNDEF); - cache->opened_undef_dirfrag(this); + mdcache->opened_undef_dirfrag(this); } } mark_complete(); if (c) - cache->mds->queue_waiter(c); + mdcache->mds->queue_waiter(c); return; } @@ -1572,7 +1572,7 @@ void CDir::fetch(MDSContext *c, std::string_view want_dn, bool ignore_authpinnab auth_pin(this); state_set(CDir::STATE_FETCHING); - if (cache->mds->logger) cache->mds->logger->inc(l_mds_dir_fetch); + if (mdcache->mds->logger) mdcache->mds->logger->inc(l_mds_dir_fetch); std::set empty; _omap_fetch(NULL, empty); @@ -1597,7 +1597,7 @@ void CDir::fetch(MDSContext *c, const std::set& keys) } auth_pin(this); - if (cache->mds->logger) cache->mds->logger->inc(l_mds_dir_fetch); + if (mdcache->mds->logger) mdcache->mds->logger->inc(l_mds_dir_fetch); _omap_fetch(c, keys); } @@ -1666,7 +1666,7 @@ void CDir::_omap_fetch(MDSContext *c, const std::set& keys) { C_IO_Dir_OMAP_Fetched *fin = new C_IO_Dir_OMAP_Fetched(this, c); object_t oid = get_ondisk_object(); - object_locator_t oloc(cache->mds->mdsmap->get_metadata_pool()); + object_locator_t oloc(mdcache->mds->mdsmap->get_metadata_pool()); ObjectOperation rd; rd.omap_get_header(&fin->hdrbl, &fin->ret1); if (keys.empty()) { @@ -1691,8 +1691,8 @@ void CDir::_omap_fetch(MDSContext *c, const std::set& keys) fin->ret3 = -ECANCELED; } - cache->mds->objecter->read(oid, oloc, rd, CEPH_NOSNAP, NULL, 0, - new C_OnFinisher(fin, cache->mds->finisher)); + mdcache->mds->objecter->read(oid, oloc, rd, CEPH_NOSNAP, NULL, 0, + new C_OnFinisher(fin, mdcache->mds->finisher)); } void CDir::_omap_fetch_more( @@ -1702,7 +1702,7 @@ void CDir::_omap_fetch_more( { // we have more omap keys to fetch! object_t oid = get_ondisk_object(); - object_locator_t oloc(cache->mds->mdsmap->get_metadata_pool()); + object_locator_t oloc(mdcache->mds->mdsmap->get_metadata_pool()); C_IO_Dir_OMAP_FetchedMore *fin = new C_IO_Dir_OMAP_FetchedMore(this, c); fin->hdrbl = std::move(hdrbl); fin->omap.swap(omap); @@ -1713,8 +1713,8 @@ void CDir::_omap_fetch_more( &fin->omap_more, &fin->more, &fin->ret); - cache->mds->objecter->read(oid, oloc, rd, CEPH_NOSNAP, NULL, 0, - new C_OnFinisher(fin, cache->mds->finisher)); + mdcache->mds->objecter->read(oid, oloc, rd, CEPH_NOSNAP, NULL, 0, + new C_OnFinisher(fin, mdcache->mds->finisher)); } CDentry *CDir::_load_dentry( @@ -1793,7 +1793,7 @@ CDentry *CDir::_load_dentry( dn = add_remote_dentry(dname, ino, d_type, first, last); // link to inode? - CInode *in = cache->get_inode(ino); // we may or may not have it. + CInode *in = mdcache->get_inode(ino); // we may or may not have it. if (in) { dn->link_remote(dn->get_linkage(), in); dout(12) << "_fetched got remote link " << ino << " which we have " << *in << dendl; @@ -1852,12 +1852,12 @@ CDentry *CDir::_load_dentry( if (!dn || undef_inode) { // add inode - CInode *in = cache->get_inode(inode_data.inode->ino, last); + CInode *in = mdcache->get_inode(inode_data.inode->ino, last); if (!in || undef_inode) { if (undef_inode && in) in->first = first; else - in = new CInode(cache, true, first, last); + in = new CInode(mdcache, true, first, last); in->reset_inode(std::move(inode_data.inode)); in->reset_xattrs(std::move(inode_data.xattrs)); @@ -1879,7 +1879,7 @@ CDentry *CDir::_load_dentry( in->purge_stale_snap_data(*snaps); if (!undef_inode) { - cache->add_inode(in); // add + mdcache->add_inode(in); // add dn = add_primary_dentry(dname, in, first, last); // link } dout(12) << "_fetched got " << *dn << " " << *in << dendl; @@ -1901,7 +1901,7 @@ CDentry *CDir::_load_dentry( string dirpath, inopath; this->inode->make_path_string(dirpath); in->make_path_string(inopath); - cache->mds->clog->error() << "loaded dup inode " << inode_data.inode->ino + mdcache->mds->clog->error() << "loaded dup inode " << inode_data.inode->ino << " [" << first << "," << last << "] v" << inode_data.inode->version << " at " << dirpath << "/" << dname << ", but inode " << in->vino() << " v" << in->get_version() @@ -1921,7 +1921,7 @@ CDentry *CDir::_load_dentry( void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, bool complete, int r) { - LogChannelRef clog = cache->mds->clog; + LogChannelRef clog = mdcache->mds->clog; dout(10) << "_fetched header " << hdrbl.length() << " bytes " << omap.size() << " keys for " << *this << dendl; @@ -1973,9 +1973,9 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, projected_version = committing_version = committed_version = get_version(); if (state_test(STATE_REJOINUNDEF)) { - ceph_assert(cache->mds->is_rejoin()); + ceph_assert(mdcache->mds->is_rejoin()); state_clear(STATE_REJOINUNDEF); - cache->opened_undef_dirfrag(this); + mdcache->opened_undef_dirfrag(this); } } @@ -2014,7 +2014,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, p->first, dname, last, p->second, pos, snaps, rand_threshold, &force_dirty); } catch (const buffer::error &err) { - cache->mds->clog->warn() << "Corrupt dentry '" << dname << "' in " + mdcache->mds->clog->warn() << "Corrupt dentry '" << dname << "' in " "dir frag " << dirfrag() << ": " << err.what() << "(" << get_path() << ")"; @@ -2040,7 +2040,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, if (wanted_items.count(mempool::mds_co::string(dname)) > 0 || !complete) { dout(10) << " touching wanted dn " << *dn << dendl; - inode->mdcache->touch_dentry(dn); + mdcache->touch_dentry(dn); } } @@ -2063,11 +2063,11 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, CInode *in = undef_inodes.front(); undef_inodes.pop_front(); in->state_clear(CInode::STATE_REJOINUNDEF); - cache->opened_undef_inode(in); + mdcache->opened_undef_inode(in); } // dirty myself to remove stale snap dentries - if (force_dirty && !inode->mdcache->is_readonly()) + if (force_dirty && !mdcache->is_readonly()) log_mark_dirty(); auth_unpin(this); @@ -2084,10 +2084,10 @@ void CDir::go_bad_dentry(snapid_t last, std::string_view dname) std::string path(get_path()); path += "/"; path += dname; - const bool fatal = cache->mds->damage_table.notify_dentry( + const bool fatal = mdcache->mds->damage_table.notify_dentry( inode->ino(), frag, last, dname, path); if (fatal) { - cache->mds->damaged(); + mdcache->mds->damaged(); ceph_abort(); // unreachable, damaged() respawns us } } @@ -2095,10 +2095,10 @@ void CDir::go_bad_dentry(snapid_t last, std::string_view dname) void CDir::go_bad(bool complete) { dout(10) << __func__ << " " << frag << dendl; - const bool fatal = cache->mds->damage_table.notify_dirfrag( + const bool fatal = mdcache->mds->damage_table.notify_dirfrag( inode->ino(), frag, get_path()); if (fatal) { - cache->mds->damaged(); + mdcache->mds->damaged(); ceph_abort(); // unreachable, damaged() respawns us } @@ -2172,7 +2172,7 @@ void CDir::_omap_commit(int op_prio) { dout(10) << __func__ << dendl; - unsigned max_write_size = cache->max_dir_commit_size; + unsigned max_write_size = mdcache->max_dir_commit_size; unsigned write_size = 0; if (op_prio < 0) @@ -2197,11 +2197,11 @@ void CDir::_omap_commit(int op_prio) C_GatherBuilder gather(g_ceph_context, new C_OnFinisher(new C_IO_Dir_Committed(this, get_version()), - cache->mds->finisher)); + mdcache->mds->finisher)); SnapContext snapc; object_t oid = get_ondisk_object(); - object_locator_t oloc(cache->mds->mdsmap->get_metadata_pool()); + object_locator_t oloc(mdcache->mds->mdsmap->get_metadata_pool()); if (!stale_items.empty()) { for (const auto &p : stale_items) { @@ -2248,7 +2248,7 @@ void CDir::_omap_commit(int op_prio) if (!to_remove.empty()) op.omap_rm_keys(to_remove); - cache->mds->objecter->mutate(oid, oloc, op, snapc, + mdcache->mds->objecter->mutate(oid, oloc, op, snapc, ceph::real_clock::now(), 0, gather.new_sub()); @@ -2299,7 +2299,7 @@ void CDir::_omap_commit(int op_prio) if (!to_remove.empty()) op.omap_rm_keys(to_remove); - cache->mds->objecter->mutate(oid, oloc, op, snapc, + mdcache->mds->objecter->mutate(oid, oloc, op, snapc, ceph::real_clock::now(), 0, gather.new_sub()); @@ -2345,7 +2345,7 @@ void CDir::_encode_dentry(CDentry *dn, bufferlist& bl, bufferlist snap_blob; in->encode_snap_blob(snap_blob); - in->encode_bare(bl, cache->mds->mdsmap->get_up_features(), &snap_blob); + in->encode_bare(bl, mdcache->mds->mdsmap->get_up_features(), &snap_blob); } else { ceph_assert(!dn->linkage.is_null()); } @@ -2389,7 +2389,7 @@ void CDir::_commit(version_t want, int op_prio) state_set(STATE_COMMITTING); } - if (cache->mds->logger) cache->mds->logger->inc(l_mds_dir_commit); + if (mdcache->mds->logger) mdcache->mds->logger->inc(l_mds_dir_commit); _omap_commit(op_prio); } @@ -2412,9 +2412,9 @@ void CDir::_committed(int r, version_t v) } if (r < 0) { dout(1) << "commit error " << r << " v " << v << dendl; - cache->mds->clog->error() << "failed to commit dir " << dirfrag() << " object," + mdcache->mds->clog->error() << "failed to commit dir " << dirfrag() << " object," << " errno " << r; - cache->mds->handle_write_error(r); + mdcache->mds->handle_write_error(r); return; } } @@ -2494,7 +2494,7 @@ void CDir::_committed(int r, version_t v) MDSContext::vec t; for (const auto &waiter : it->second) t.push_back(waiter); - cache->mds->queue_waiters(t); + mdcache->mds->queue_waiters(t); waiting_for_commit.erase(it); it = _it; } @@ -2502,7 +2502,7 @@ void CDir::_committed(int r, version_t v) // try drop dentries in this dirfrag if it's about to be purged if (!inode->is_base() && get_parent_dir()->inode->is_stray() && inode->snaprealm) - cache->maybe_eval_stray(inode, true); + mdcache->maybe_eval_stray(inode, true); // unpin if we kicked the last waiter. if (were_waiters && @@ -2589,11 +2589,11 @@ void CDir::decode_import(bufferlist::const_iterator& blp, LogSegment *ls) // did we import some dirty scatterlock data? if (dirty_old_rstat.size() || !(fnode->rstat == fnode->accounted_rstat)) { - cache->mds->locker->mark_updated_scatterlock(&inode->nestlock); + mdcache->mds->locker->mark_updated_scatterlock(&inode->nestlock); ls->dirty_dirfrag_nest.push_back(&inode->item_dirty_dirfrag_nest); } if (!(fnode->fragstat == fnode->accounted_fragstat)) { - cache->mds->locker->mark_updated_scatterlock(&inode->filelock); + mdcache->mds->locker->mark_updated_scatterlock(&inode->filelock); ls->dirty_dirfrag_dir.push_back(&inode->item_dirty_dirfrag_dir); } if (is_dirty_dft()) { @@ -2602,7 +2602,7 @@ void CDir::decode_import(bufferlist::const_iterator& blp, LogSegment *ls) // clear stale dirtydft state_clear(STATE_DIRTYDFT); } else { - cache->mds->locker->mark_updated_scatterlock(&inode->dirfragtreelock); + mdcache->mds->locker->mark_updated_scatterlock(&inode->dirfragtreelock); ls->dirty_dirfrag_dirfragtree.push_back(&inode->item_dirty_dirfrag_dirfragtree); } } @@ -2746,7 +2746,7 @@ void CDir::set_dir_auth(const mds_authority_t &a) if (was_ambiguous && dir_auth.second == CDIR_AUTH_UNKNOWN) { MDSContext::vec ls; take_waiting(WAIT_SINGLEAUTH, ls); - cache->mds->queue_waiters(ls); + mdcache->mds->queue_waiters(ls); } } @@ -2916,7 +2916,7 @@ bool CDir::freeze_tree() freeze_tree_state = std::make_shared(this); freeze_tree_state->auth_pins += get_auth_pins() + get_dir_auth_pins(); if (!lock_caches_with_auth_pins.empty()) - cache->mds->locker->invalidate_lock_caches(this); + mdcache->mds->locker->invalidate_lock_caches(this); _walk_tree([this](CDir *dir) { if (dir->freeze_tree_state) @@ -2924,7 +2924,7 @@ bool CDir::freeze_tree() dir->freeze_tree_state = freeze_tree_state; freeze_tree_state->auth_pins += dir->get_auth_pins() + dir->get_dir_auth_pins(); if (!dir->lock_caches_with_auth_pins.empty()) - cache->mds->locker->invalidate_lock_caches(dir); + mdcache->mds->locker->invalidate_lock_caches(dir); return true; } ); @@ -2968,7 +2968,7 @@ void CDir::_freeze_tree() _walk_tree([this, &auth] (CDir *dir) { if (dir->freeze_tree_state != freeze_tree_state) { - inode->mdcache->adjust_subtree_auth(dir, auth); + mdcache->adjust_subtree_auth(dir, auth); return false; } return true; @@ -2978,7 +2978,7 @@ void CDir::_freeze_tree() ceph_assert(auth.first >= 0); ceph_assert(auth.second == CDIR_AUTH_UNKNOWN); auth.second = auth.first; - inode->mdcache->adjust_subtree_auth(this, auth); + mdcache->adjust_subtree_auth(this, auth); if (!was_subtree) inode->auth_unpin(this); } else { @@ -3035,7 +3035,7 @@ void CDir::unfreeze_tree() ceph_assert(auth.first >= 0); ceph_assert(auth.second == auth.first); auth.second = CDIR_AUTH_UNKNOWN; - inode->mdcache->adjust_subtree_auth(this, auth); + mdcache->adjust_subtree_auth(this, auth); } freeze_tree_state.reset(); } else { @@ -3050,7 +3050,7 @@ void CDir::unfreeze_tree() auth_unpin(this); } - cache->mds->queue_waiters(unfreeze_waiters); + mdcache->mds->queue_waiters(unfreeze_waiters); } void CDir::adjust_freeze_after_rename(CDir *dir) @@ -3081,7 +3081,7 @@ void CDir::adjust_freeze_after_rename(CDir *dir) unfreeze(dir); dir->_walk_tree(unfreeze); - cache->mds->queue_waiters(unfreeze_waiters); + mdcache->mds->queue_waiters(unfreeze_waiters); } bool CDir::can_auth_pin(int *err_ret) const @@ -3170,7 +3170,7 @@ bool CDir::freeze_dir() } else { state_set(STATE_FREEZINGDIR); if (!lock_caches_with_auth_pins.empty()) - cache->mds->locker->invalidate_lock_caches(this); + mdcache->mds->locker->invalidate_lock_caches(this); dout(10) << "freeze_dir + wait " << *this << dendl; return false; } @@ -3540,7 +3540,7 @@ bool CDir::scrub_local() } else { scrub_infop->pending_scrub_error = true; if (scrub_infop->header->get_repair()) - cache->repair_dirfrag_stats(this); + mdcache->repair_dirfrag_stats(this); } return rval; } diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 8edcc4a38b368..bca656567739b 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -204,7 +204,7 @@ public: static const int DUMP_ALL = (-1); static const int DUMP_DEFAULT = DUMP_ALL & (~DUMP_ITEMS); - CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth); + CDir(CInode *in, frag_t fg, MDCache *mdc, bool auth); std::string_view pin_name(int p) const override { switch (p) { @@ -627,7 +627,7 @@ public: void dump_load(ceph::Formatter *f); // context - MDCache *cache; + MDCache *mdcache; CInode *inode; // my inode frag_t frag; // my frag diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index faee202f846cd..7c51d956be732 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -289,7 +289,7 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) it->second.state = EXPORT_CANCELLED; dir->unfreeze_tree(); // cancel the freeze if (dir->is_subtree_root()) - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); if (notify_peer && (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(it->second.peer))) // tell them. @@ -313,7 +313,7 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) { // unpin bounds set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); for (set::iterator q = bounds.begin(); q != bounds.end(); ++q) { @@ -325,11 +325,11 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) // notify bystanders export_notify_abort(dir, it->second, bounds); // process delayed expires - cache->process_delayed_expire(dir); + mdcache->process_delayed_expire(dir); } } dir->unfreeze_tree(); - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); if (notify_peer && (!mds->is_cluster_degraded() || mds->mdsmap->is_clientreplay_or_active_or_stopping(it->second.peer))) // tell them. @@ -370,13 +370,13 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer) if (state == EXPORT_LOCKING || state == EXPORT_DISCOVERING) { MDRequestRef mdr = static_cast(mut.get()); ceph_assert(mdr); - mds->mdcache->request_kill(mdr); + mdcache->request_kill(mdr); } else if (mut) { mds->locker->drop_locks(mut.get()); mut->cleanup(); } - cache->show_subtrees(); + mdcache->show_subtrees(); maybe_do_queued_export(); } @@ -399,7 +399,7 @@ void Migrator::export_cancel_finish(export_state_iterator& it) dir->auth_unpin(this); } // send pending import_maps? (these need to go out when all exports have finished.) - cache->maybe_send_pending_resolves(); + mdcache->maybe_send_pending_resolves(); if (parent) child_export_finish(parent, false); @@ -491,8 +491,8 @@ void Migrator::handle_mds_failure_or_stop(mds_rank_t who) map::iterator next = q; ++next; dirfrag_t df = q->first; - CInode *diri = mds->mdcache->get_inode(df.ino); - CDir *dir = mds->mdcache->get_dirfrag(df); + CInode *diri = mdcache->get_inode(df.ino); + CDir *dir = mdcache->get_dirfrag(df); if (q->second.peer == who) { if (dir) @@ -525,11 +525,11 @@ void Migrator::handle_mds_failure_or_stop(mds_rank_t who) dout(10) << "import state=prepped : unpinning base+bounds, unfreezing " << *dir << dendl; { set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); import_remove_pins(dir, bounds); // adjust auth back to the exporter - cache->adjust_subtree_auth(dir, q->second.peer); + mdcache->adjust_subtree_auth(dir, q->second.peer); // notify bystanders ; wait in aborting state q->second.state = IMPORT_ABORTING; @@ -550,8 +550,8 @@ void Migrator::handle_mds_failure_or_stop(mds_rank_t who) dout(10) << "import state=acking : noting ambiguous import " << *dir << dendl; { set bounds; - cache->get_subtree_bounds(dir, bounds); - cache->add_ambiguous_import(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); + mdcache->add_ambiguous_import(dir, bounds); } break; @@ -599,7 +599,7 @@ void Migrator::show_importing() for (map::iterator p = import_state.begin(); p != import_state.end(); ++p) { - CDir *dir = mds->mdcache->get_dirfrag(p->first); + CDir *dir = mdcache->get_dirfrag(p->first); if (dir) { dout(10) << " importing from " << p->second.peer << ": (" << p->second.state << ") " << get_import_statename(p->second.state) @@ -637,11 +637,11 @@ void Migrator::audit() if (p->second.state == IMPORT_DISCOVERING) continue; if (p->second.state == IMPORT_DISCOVERED) { - CInode *in = cache->get_inode(p->first.ino); + CInode *in = mdcache->get_inode(p->first.ino); ceph_assert(in); continue; } - CDir *dir = cache->get_dirfrag(p->first); + CDir *dir = mdcache->get_dirfrag(p->first); ceph_assert(dir); if (p->second.state == IMPORT_PREPPING) continue; @@ -710,7 +710,7 @@ void Migrator::maybe_do_queued_export() mds_rank_t dest = export_queue.front().second; export_queue.pop_front(); - CDir *dir = mds->mdcache->get_dirfrag(df); + CDir *dir = mdcache->get_dirfrag(df); if (!dir) continue; if (!dir->is_auth()) continue; @@ -753,7 +753,7 @@ bool Migrator::export_try_grab_locks(CDir *dir, MutationRef& mut) set wouldbe_bounds; set bound_inodes; - cache->get_wouldbe_subtree_bounds(dir, wouldbe_bounds); + mdcache->get_wouldbe_subtree_bounds(dir, wouldbe_bounds); for (auto& bound : wouldbe_bounds) bound_inodes.insert(bound->get_inode()); for (auto& in : bound_inodes) @@ -796,7 +796,7 @@ void Migrator::export_dir(CDir *dir, mds_rank_t dest) } else if (!(mds->is_active() || mds->is_stopping())) { dout(7) << "Cannot export to mds." << dest << " " << *dir << ": not active" << dendl; return; - } else if (mds->mdcache->is_readonly()) { + } else if (mdcache->is_readonly()) { dout(7) << "Cannot export to mds." << dest << " " << *dir << ": read-only FS, no exports for now" << dendl; return; } else if (!mds->mdsmap->is_active(dest)) { @@ -842,7 +842,7 @@ void Migrator::export_dir(CDir *dir, mds_rank_t dest) if (!(bd->is_frozen() || bd->is_freezing())) { ceph_assert(bd->is_auth()); dir->state_set(CDir::STATE_AUXSUBTREE); - mds->mdcache->adjust_subtree_auth(dir, mds->get_nodeid()); + mdcache->adjust_subtree_auth(dir, mds->get_nodeid()); dout(7) << "create aux subtree " << *bd << " under " << *dir << dendl; } } @@ -855,7 +855,7 @@ void Migrator::export_dir(CDir *dir, mds_rank_t dest) dir->auth_pin(this); dir->mark_exporting(); - MDRequestRef mdr = mds->mdcache->request_start_internal(CEPH_MDS_OP_EXPORTDIR); + MDRequestRef mdr = mdcache->request_start_internal(CEPH_MDS_OP_EXPORTDIR); mdr->more()->export_dir = dir; mdr->pin(dir); @@ -867,7 +867,7 @@ void Migrator::export_dir(CDir *dir, mds_rank_t dest) stat.tid = mdr->reqid.tid; stat.mut = mdr; - mds->mdcache->dispatch_request(mdr); + mdcache->dispatch_request(mdr); } /* @@ -1029,7 +1029,7 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) ceph_assert(mdr->killed || mdr->aborted); if (mdr->aborted) { mdr->aborted = false; - mds->mdcache->request_kill(mdr); + mdcache->request_kill(mdr); } return; } @@ -1099,7 +1099,7 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) // dirfrag's portion in the local (auth OR replica) dirfrag. set wouldbe_bounds; set bound_inodes; - cache->get_wouldbe_subtree_bounds(dir, wouldbe_bounds); + mdcache->get_wouldbe_subtree_bounds(dir, wouldbe_bounds); for (auto& bound : wouldbe_bounds) bound_inodes.insert(bound->get_inode()); for (auto& in : bound_inodes) @@ -1167,7 +1167,7 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) sub->auth_pin(this); sub->mark_exporting(); - MDRequestRef _mdr = mds->mdcache->request_start_internal(CEPH_MDS_OP_EXPORTDIR); + MDRequestRef _mdr = mdcache->request_start_internal(CEPH_MDS_OP_EXPORTDIR); _mdr->more()->export_dir = sub; _mdr->pin(sub); @@ -1179,7 +1179,7 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) stat.tid = _mdr->reqid.tid; stat.mut = _mdr; stat.parent = parent; - mds->mdcache->dispatch_request(_mdr); + mdcache->dispatch_request(_mdr); } // cancel the original one @@ -1193,7 +1193,7 @@ void Migrator::child_export_finish(std::shared_ptr& parent, bool if (--parent->pending_children == 0) { if (parent->restart && parent->export_queue_gen == export_queue_gen) { - CDir *origin = mds->mdcache->get_dirfrag(parent->dirfrag); + CDir *origin = mdcache->get_dirfrag(parent->dirfrag); if (origin && origin->is_auth()) { dout(7) << "child_export_finish requeue " << *origin << dendl; export_queue.emplace_front(origin->dirfrag(), parent->dest); @@ -1208,7 +1208,7 @@ void Migrator::child_export_finish(std::shared_ptr& parent, bool */ void Migrator::handle_export_discover_ack(const cref_t &m) { - CDir *dir = cache->get_dirfrag(m->get_dirfrag()); + CDir *dir = mdcache->get_dirfrag(m->get_dirfrag()); mds_rank_t dest(m->get_source().num()); ceph_assert(dir); @@ -1229,7 +1229,7 @@ void Migrator::handle_export_discover_ack(const cref_t &m // release locks to avoid deadlock MDRequestRef mdr = static_cast(it->second.mut.get()); ceph_assert(mdr); - mds->mdcache->request_finish(mdr); + mdcache->request_finish(mdr); it->second.mut.reset(); // freeze the subtree it->second.state = EXPORT_FREEZING; @@ -1298,9 +1298,9 @@ void Migrator::encode_export_prep_trace(bufferlist &final_bl, CDir *bound, // prepend dentry + inode ceph_assert(cur->inode->is_auth()); bufferlist bl; - cache->encode_replica_dentry(cur->inode->parent, es.peer, bl); + mdcache->encode_replica_dentry(cur->inode->parent, es.peer, bl); dout(7) << " added " << *cur->inode->parent << dendl; - cache->encode_replica_inode(cur->inode, es.peer, bl, mds->mdsmap->get_up_features()); + mdcache->encode_replica_inode(cur->inode, es.peer, bl, mds->mdsmap->get_up_features()); dout(7) << " added " << *cur->inode << dendl; bl.claim_append(tracebl); tracebl = std::move(bl); @@ -1314,7 +1314,7 @@ void Migrator::encode_export_prep_trace(bufferlist &final_bl, CDir *bound, dirfrags_added.insert(cur->dirfrag()); // prepend dir - cache->encode_replica_dir(cur, es.peer, bl); + mdcache->encode_replica_dir(cur, es.peer, bl); dout(7) << " added " << *cur << dendl; bl.claim_append(tracebl); tracebl = std::move(bl); @@ -1356,13 +1356,13 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid) if (diri->is_auth()) it->second.mut->auth_pin(diri); - cache->show_subtrees(); + mdcache->show_subtrees(); // CDir::_freeze_tree() should have forced it into subtree. ceph_assert(dir->get_dir_auth() == mds_authority_t(mds->get_nodeid(), mds->get_nodeid())); // note the bounds. set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); // generate prep message, log entry. auto prep = make_message(dir->dirfrag(), it->second.tid); @@ -1376,7 +1376,7 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid) } // include base dirfrag - cache->encode_replica_dir(dir, it->second.peer, prep->basedir); + mdcache->encode_replica_dir(dir, it->second.peer, prep->basedir); /* * include spanning tree for all nested exports. @@ -1463,7 +1463,7 @@ void Migrator::get_export_client_set(CInode *in, set& client_set) void Migrator::handle_export_prep_ack(const cref_t &m) { - CDir *dir = cache->get_dirfrag(m->get_dirfrag()); + CDir *dir = mdcache->get_dirfrag(m->get_dirfrag()); mds_rank_t dest(m->get_source().num()); ceph_assert(dir); @@ -1490,7 +1490,7 @@ void Migrator::handle_export_prep_ack(const cref_t &m) assert (g_conf()->mds_kill_export_at != 5); // send warnings set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); ceph_assert(it->second.warning_ack_waiting.empty() || (it->second.warning_ack_waiting.size() == 1 && @@ -1564,7 +1564,7 @@ void Migrator::export_go_synced(CDir *dir, uint64_t tid) dout(7) << *dir << " to " << dest << dendl; - cache->show_subtrees(); + mdcache->show_subtrees(); it->second.state = EXPORT_EXPORTING; ceph_assert(g_conf()->mds_kill_export_at != 7); @@ -1572,7 +1572,7 @@ void Migrator::export_go_synced(CDir *dir, uint64_t tid) ceph_assert(dir->is_frozen_tree_root()); // set ambiguous auth - cache->adjust_subtree_auth(dir, mds->get_nodeid(), dest); + mdcache->adjust_subtree_auth(dir, mds->get_nodeid(), dest); // take away the popularity we're sending. mds->balancer->subtract_export(dir); @@ -1590,7 +1590,7 @@ void Migrator::export_go_synced(CDir *dir, uint64_t tid) // add bounds to message set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); for (set::iterator p = bounds.begin(); p != bounds.end(); ++p) @@ -1606,7 +1606,7 @@ void Migrator::export_go_synced(CDir *dir, uint64_t tid) if (mds->logger) mds->logger->inc(l_mds_exported); if (mds->logger) mds->logger->inc(l_mds_exported_inodes, num_exported_inodes); - cache->show_subtrees(); + mdcache->show_subtrees(); } @@ -1865,7 +1865,7 @@ void Migrator::finish_export_dir(CDir *dir, mds_rank_t peer, subdirs.insert(std::end(subdirs), std::begin(dirs), std::end(dirs)); } - cache->touch_dentry_bottom(dn); // move dentry to tail of LRU + mdcache->touch_dentry_bottom(dn); // move dentry to tail of LRU ++(*num_dentries); } @@ -1890,7 +1890,7 @@ public: */ void Migrator::handle_export_ack(const cref_t &m) { - CDir *dir = cache->get_dirfrag(m->get_dirfrag()); + CDir *dir = mdcache->get_dirfrag(m->get_dirfrag()); mds_rank_t dest(m->get_source().num()); ceph_assert(dir); ceph_assert(dir->is_frozen_tree_root()); // i'm exporting! @@ -1911,7 +1911,7 @@ void Migrator::handle_export_ack(const cref_t &m) it->second.state = EXPORT_LOGGINGFINISH; assert (g_conf()->mds_kill_export_at != 9); set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); // log completion. // include export bounds, to ensure they're in the journal. @@ -1931,7 +1931,7 @@ void Migrator::handle_export_ack(const cref_t &m) // list us second, them first. // this keeps authority().first in sync with subtree auth state in the journal. - cache->adjust_subtree_auth(dir, it->second.peer, mds->get_nodeid()); + mdcache->adjust_subtree_auth(dir, it->second.peer, mds->get_nodeid()); // log export completion, then finish (unfreeze, trigger finish context, etc.) mds->mdlog->submit_entry(le, new C_MDS_ExportFinishLogged(this, dir)); @@ -1976,7 +1976,7 @@ void Migrator::export_reverse(CDir *dir, export_state_t& stat) set to_eval; set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); // remove exporting pins std::deque rq; @@ -2015,13 +2015,13 @@ void Migrator::export_reverse(CDir *dir, export_state_t& stat) export_notify_abort(dir, stat, bounds); // unfreeze tree, with possible subtree merge. - cache->adjust_subtree_auth(dir, mds->get_nodeid(), mds->get_nodeid()); + mdcache->adjust_subtree_auth(dir, mds->get_nodeid(), mds->get_nodeid()); // process delayed expires - cache->process_delayed_expire(dir); + mdcache->process_delayed_expire(dir); dir->unfreeze_tree(); - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); // revoke/resume stale caps for (auto in : to_eval) { @@ -2038,7 +2038,7 @@ void Migrator::export_reverse(CDir *dir, export_state_t& stat) mds->locker->issue_caps(in); } - cache->show_cache(); + mdcache->show_cache(); } @@ -2055,7 +2055,7 @@ void Migrator::export_logged_finish(CDir *dir) // send notifies set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); for (set::iterator p = stat.notify_ack_waiting.begin(); p != stat.notify_ack_waiting.end(); @@ -2098,7 +2098,7 @@ void Migrator::export_logged_finish(CDir *dir) */ void Migrator::handle_export_notify_ack(const cref_t &m) { - CDir *dir = cache->get_dirfrag(m->get_dirfrag()); + CDir *dir = mdcache->get_dirfrag(m->get_dirfrag()); mds_rank_t dest(m->get_source().num()); ceph_assert(dir); mds_rank_t from = mds_rank_t(m->get_source().num()); @@ -2176,11 +2176,11 @@ void Migrator::export_finish(CDir *dir) it->second.peer_imported, finished, &num_dentries); ceph_assert(!dir->is_auth()); - cache->adjust_subtree_auth(dir, it->second.peer); + mdcache->adjust_subtree_auth(dir, it->second.peer); // unpin bounds set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); for (set::iterator p = bounds.begin(); p != bounds.end(); ++p) { @@ -2193,14 +2193,14 @@ void Migrator::export_finish(CDir *dir) dir->state_clear(CDir::STATE_AUXSUBTREE); // discard delayed expires - cache->discard_delayed_expire(dir); + mdcache->discard_delayed_expire(dir); dout(7) << "unfreezing" << dendl; // unfreeze tree, with possible subtree merge. // (we do this _after_ removing EXPORTBOUND pins, to allow merges) dir->unfreeze_tree(); - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); // no more auth subtree? clear scatter dirty if (!dir->get_inode()->is_auth() && @@ -2222,13 +2222,13 @@ void Migrator::export_finish(CDir *dir) ceph_assert(dir->state_test(CDir::STATE_EXPORTING)); dir->clear_exporting(); - cache->show_subtrees(); + mdcache->show_subtrees(); audit(); - cache->trim(num_dentries); // try trimming exported dentries + mdcache->trim(num_dentries); // try trimming exported dentries // send pending import_maps? - mds->mdcache->maybe_send_pending_resolves(); + mdcache->maybe_send_pending_resolves(); // drop locks, unpin path if (mut) { @@ -2306,7 +2306,7 @@ void Migrator::handle_export_discover(const cref_t &m, bool } C_MDS_ExportDiscoverFactory cf(this, m); - if (!mds->mdcache->is_open()) { + if (!mdcache->is_open()) { dout(10) << " waiting for root" << dendl; mds->mdcache->wait_for_open(cf.build()); return; @@ -2315,15 +2315,15 @@ void Migrator::handle_export_discover(const cref_t &m, bool assert (g_conf()->mds_kill_import_at != 1); // do we have it? - CInode *in = cache->get_inode(m->get_dirfrag().ino); + CInode *in = mdcache->get_inode(m->get_dirfrag().ino); if (!in) { // must discover it! filepath fpath(m->get_path()); vector trace; MDRequestRef null_ref; - int r = cache->path_traverse(null_ref, cf, fpath, - MDS_TRAVERSE_DISCOVER | MDS_TRAVERSE_PATH_LOCKED, - &trace); + int r = mdcache->path_traverse(null_ref, cf, fpath, + MDS_TRAVERSE_DISCOVER | MDS_TRAVERSE_PATH_LOCKED, + &trace); if (r > 0) return; if (r < 0) { dout(7) << "failed to discover or not dir " << m->get_path() << ", NAK" << dendl; @@ -2363,7 +2363,7 @@ void Migrator::import_reverse_discovered(dirfrag_t df, CInode *diri) void Migrator::import_reverse_prepping(CDir *dir, import_state_t& stat) { set bounds; - cache->map_dirfrag_set(stat.bound_ls, bounds); + mdcache->map_dirfrag_set(stat.bound_ls, bounds); import_remove_pins(dir, bounds); import_reverse_final(dir); } @@ -2378,21 +2378,21 @@ void Migrator::handle_export_cancel(const cref_t &m) } else if (it->second.state == IMPORT_DISCOVERING) { import_reverse_discovering(df); } else if (it->second.state == IMPORT_DISCOVERED) { - CInode *in = cache->get_inode(df.ino); + CInode *in = mdcache->get_inode(df.ino); ceph_assert(in); import_reverse_discovered(df, in); } else if (it->second.state == IMPORT_PREPPING) { - CDir *dir = mds->mdcache->get_dirfrag(df); + CDir *dir = mdcache->get_dirfrag(df); ceph_assert(dir); import_reverse_prepping(dir, it->second); } else if (it->second.state == IMPORT_PREPPED) { - CDir *dir = mds->mdcache->get_dirfrag(df); + CDir *dir = mdcache->get_dirfrag(df); ceph_assert(dir); set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); import_remove_pins(dir, bounds); // adjust auth back to the exportor - cache->adjust_subtree_auth(dir, it->second.peer); + mdcache->adjust_subtree_auth(dir, it->second.peer); import_reverse_unfreeze(dir); } else { ceph_abort_msg("got export_cancel in weird state"); @@ -2431,14 +2431,14 @@ void Migrator::decode_export_prep_trace(bufferlist::const_iterator& blp, mds_ran CDir *cur = nullptr; if (start == 'd') { - cur = cache->get_dirfrag(df); + cur = mdcache->get_dirfrag(df); ceph_assert(cur); dout(10) << " had " << *cur << dendl; } else if (start == 'f') { - CInode *in = cache->get_inode(df.ino); + CInode *in = mdcache->get_inode(df.ino); ceph_assert(in); dout(10) << " had " << *in << dendl; - cache->decode_replica_dir(cur, blp, in, oldauth, finished); + mdcache->decode_replica_dir(cur, blp, in, oldauth, finished); dout(10) << " added " << *cur << dendl; } else if (start == '-') { // nothing @@ -2447,14 +2447,14 @@ void Migrator::decode_export_prep_trace(bufferlist::const_iterator& blp, mds_ran while (!blp.end()) { CDentry *dn = nullptr; - cache->decode_replica_dentry(dn, blp, cur, finished); + mdcache->decode_replica_dentry(dn, blp, cur, finished); dout(10) << " added " << *dn << dendl; CInode *in = nullptr; - cache->decode_replica_inode(in, blp, dn, finished); + mdcache->decode_replica_inode(in, blp, dn, finished); dout(10) << " added " << *in << dendl; if (blp.end()) break; - cache->decode_replica_dir(cur, blp, in, oldauth, finished); + mdcache->decode_replica_dir(cur, blp, in, oldauth, finished); dout(10) << " added " << *cur << dendl; } @@ -2476,10 +2476,10 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi ceph_assert(it != import_state.end()); ceph_assert(it->second.state == IMPORT_DISCOVERED); ceph_assert(it->second.peer == oldauth); - diri = cache->get_inode(m->get_dirfrag().ino); + diri = mdcache->get_inode(m->get_dirfrag().ino); ceph_assert(diri); auto p = m->basedir.cbegin(); - cache->decode_replica_dir(dir, p, diri, oldauth, finished); + mdcache->decode_replica_dir(dir, p, diri, oldauth, finished); dout(7) << "on " << *dir << " (first pass)" << dendl; } else { if (it == import_state.end() || @@ -2491,14 +2491,14 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi ceph_assert(it->second.state == IMPORT_PREPPING); ceph_assert(it->second.peer == oldauth); - dir = cache->get_dirfrag(m->get_dirfrag()); + dir = mdcache->get_dirfrag(m->get_dirfrag()); ceph_assert(dir); dout(7) << "on " << *dir << " (subsequent pass)" << dendl; diri = dir->get_inode(); } ceph_assert(dir->is_auth() == false); - cache->show_subtrees(); + mdcache->show_subtrees(); // build import bound map map import_bound_fragset; @@ -2536,7 +2536,7 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi p != import_bound_fragset.end(); ++p) { p->second.simplify(); - CInode *in = cache->get_inode(p->first); + CInode *in = mdcache->get_inode(p->first); ceph_assert(in); in->get_stickydirs(); dout(7) << " set stickydirs on bound inode " << *in << dendl; @@ -2559,7 +2559,7 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi for (map::iterator p = import_bound_fragset.begin(); p != import_bound_fragset.end(); ++p) { - CInode *in = cache->get_inode(p->first); + CInode *in = mdcache->get_inode(p->first); ceph_assert(in); // map fragset into a frag_t list, based on the inode fragtree @@ -2570,10 +2570,10 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi dout(10) << " bound inode " << p->first << " fragset " << p->second << " maps to " << leaves << dendl; for (const auto& leaf : leaves) { - CDir *bound = cache->get_dirfrag(dirfrag_t(p->first, leaf)); + CDir *bound = mdcache->get_dirfrag(dirfrag_t(p->first, leaf)); if (!bound) { dout(7) << " opening bounding dirfrag " << leaf << " on " << *in << dendl; - cache->open_remote_dirfrag(in, leaf, gather.new_sub()); + mdcache->open_remote_dirfrag(in, leaf, gather.new_sub()); continue; } @@ -2597,7 +2597,7 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi dout(7) << " all ready, noting auth and freezing import region" << dendl; - if (!mds->mdcache->is_readonly() && + if (!mdcache->is_readonly() && // for pinning scatter gather. loner has a higher chance to get wrlock diri->filelock.can_wrlock(diri->get_loner()) && diri->nestlock.can_wrlock(diri->get_loner())) { @@ -2608,9 +2608,9 @@ void Migrator::handle_export_prep(const cref_t &m, bool did_assi // note that i am an ambiguous auth for this subtree. // specify bounds, since the exporter explicitly defines the region. - cache->adjust_bounded_subtree_auth(dir, import_bounds, + mdcache->adjust_bounded_subtree_auth(dir, import_bounds, pair(oldauth, mds->get_nodeid())); - cache->verify_subtree_bounds(dir, import_bounds); + mdcache->verify_subtree_bounds(dir, import_bounds); // freeze. dir->_freeze_tree(); // note new state @@ -2657,7 +2657,7 @@ public: void Migrator::handle_export_dir(const cref_t &m) { assert (g_conf()->mds_kill_import_at != 5); - CDir *dir = cache->get_dirfrag(m->dirfrag); + CDir *dir = mdcache->get_dirfrag(m->dirfrag); ceph_assert(dir); mds_rank_t oldauth = mds_rank_t(m->get_source().num()); @@ -2675,7 +2675,7 @@ void Migrator::handle_export_dir(const cref_t &m) if (!dir->get_inode()->dirfragtree.is_leaf(dir->get_frag())) dir->get_inode()->dirfragtree.force_to_leaf(g_ceph_context, dir->get_frag()); - cache->show_subtrees(); + mdcache->show_subtrees(); C_MDS_ImportDirLoggedStart *onlogged = new C_MDS_ImportDirLoggedStart(this, dir, oldauth); @@ -2686,7 +2686,7 @@ void Migrator::handle_export_dir(const cref_t &m) le->metablob.add_dir_context(dir); // adjust auth (list us _first_) - cache->adjust_subtree_auth(dir, mds->get_nodeid(), oldauth); + mdcache->adjust_subtree_auth(dir, mds->get_nodeid(), oldauth); // new client sessions, open these after we journal // include imported sessions in EImportStart @@ -2718,12 +2718,12 @@ void Migrator::handle_export_dir(const cref_t &m) // include bounds in EImportStart set import_bounds; for (const auto &bound : m->bounds) { - CDir *bd = cache->get_dirfrag(bound); + CDir *bd = mdcache->get_dirfrag(bound); ceph_assert(bd); le->metablob.add_dir(bd, false); // note that parent metadata is already in the event import_bounds.insert(bd); } - cache->verify_subtree_bounds(dir, import_bounds); + mdcache->verify_subtree_bounds(dir, import_bounds); // adjust popularity mds->balancer->add_import(dir); @@ -2765,7 +2765,7 @@ void Migrator::import_remove_pins(CDir *dir, set& bounds) if (did.count(p->ino)) continue; did.insert(p->ino); - CInode *in = cache->get_inode(p->ino); + CInode *in = mdcache->get_inode(p->ino); ceph_assert(in); in->put_stickydirs(); } @@ -2811,7 +2811,7 @@ void Migrator::import_reverse(CDir *dir) stat.state = IMPORT_ABORTING; set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); // remove pins import_remove_pins(dir, bounds); @@ -2819,9 +2819,9 @@ void Migrator::import_reverse(CDir *dir) // update auth, with possible subtree merge. ceph_assert(dir->is_subtree_root()); if (mds->is_resolve()) - cache->trim_non_auth_subtree(dir); + mdcache->trim_non_auth_subtree(dir); - cache->adjust_subtree_auth(dir, stat.peer); + mdcache->adjust_subtree_auth(dir, stat.peer); auto fin = new C_MDC_QueueContexts(this); if (!dir->get_inode()->is_auth() && @@ -2883,7 +2883,7 @@ void Migrator::import_reverse(CDir *dir) } } - cache->touch_dentry_bottom(dn); // move dentry to tail of LRU + mdcache->touch_dentry_bottom(dn); // move dentry to tail of LRU ++num_dentries; } } @@ -2918,7 +2918,7 @@ void Migrator::import_reverse(CDir *dir) // log our failure mds->mdlog->start_submit_entry(new EImportFinish(dir, false)); // log failure - cache->trim(num_dentries); // try trimming dentries + mdcache->trim(num_dentries); // try trimming dentries // notify bystanders; wait in aborting state import_notify_abort(dir, bounds); @@ -2974,10 +2974,10 @@ void Migrator::import_reverse_unfreeze(CDir *dir) { dout(7) << *dir << dendl; ceph_assert(!dir->is_auth()); - cache->discard_delayed_expire(dir); + mdcache->discard_delayed_expire(dir); dir->unfreeze_tree(); if (dir->is_subtree_root()) - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); import_reverse_final(dir); } @@ -2993,14 +2993,14 @@ void Migrator::import_reverse_final(CDir *dir) import_state.erase(it); // send pending import_maps? - mds->mdcache->maybe_send_pending_resolves(); + mdcache->maybe_send_pending_resolves(); if (mut) { mds->locker->drop_locks(mut.get()); mut->cleanup(); } - cache->show_subtrees(); + mdcache->show_subtrees(); //audit(); // this fails, bc we munge up the subtree map during handle_import_map (resolve phase) } @@ -3051,12 +3051,12 @@ void Migrator::import_logged_start(dirfrag_t df, CDir *dir, mds_rank_t from, mds->send_message_mds(ack, from); assert (g_conf()->mds_kill_import_at != 8); - cache->show_subtrees(); + mdcache->show_subtrees(); } void Migrator::handle_export_finish(const cref_t &m) { - CDir *dir = cache->get_dirfrag(m->get_dirfrag()); + CDir *dir = mdcache->get_dirfrag(m->get_dirfrag()); ceph_assert(dir); dout(7) << *dir << (m->is_last() ? " last" : "") << dendl; @@ -3077,7 +3077,7 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) if (it->second.state == IMPORT_ACKING) { ceph_assert(dir->is_auth()); - cache->adjust_subtree_auth(dir, mds->get_nodeid(), mds->get_nodeid()); + mdcache->adjust_subtree_auth(dir, mds->get_nodeid(), mds->get_nodeid()); } // log finish @@ -3101,7 +3101,7 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) ceph_assert(cap); cap->merge(q->second, true); cap->clear_importing(); - mds->mdcache->do_cap_import(session, in, cap, q->second.cap_id, q->second.seq, + mdcache->do_cap_import(session, in, cap, q->second.cap_id, q->second.seq, q->second.mseq - 1, it->second.peer, CEPH_CAP_FLAG_AUTH); } p->second.clear(); @@ -3121,7 +3121,7 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) // remove pins set bounds; - cache->get_subtree_bounds(dir, bounds); + mdcache->get_subtree_bounds(dir, bounds); if (notify) import_notify_finish(dir, bounds); @@ -3138,13 +3138,13 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) mds->mdlog->start_submit_entry(new EImportFinish(dir, true)); // process delayed expires - cache->process_delayed_expire(dir); + mdcache->process_delayed_expire(dir); // unfreeze tree, with possible subtree merge. dir->unfreeze_tree(); - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); - cache->show_subtrees(); + mdcache->show_subtrees(); //audit(); // this fails, bc we munge up the subtree map during handle_import_map (resolve phase) if (mut) { @@ -3162,11 +3162,11 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) } // send pending import_maps? - mds->mdcache->maybe_send_pending_resolves(); + mdcache->maybe_send_pending_resolves(); // did i just import mydir? if (dir->ino() == MDS_INO_MDSDIR(mds->get_nodeid())) - cache->populate_mydir(); + mdcache->populate_mydir(); // is it empty? if (dir->get_num_head_items() == 0 && @@ -3191,7 +3191,7 @@ void Migrator::decode_import_inode(CDentry *dn, bufferlist::const_iterator& blp, decode(ino, blp); decode(last, blp); - in = cache->get_inode(ino, last); + in = mdcache->get_inode(ino, last); if (!in) { in = new CInode(mds->mdcache, true, 2, last); added = true; @@ -3216,7 +3216,7 @@ void Migrator::decode_import_inode(CDentry *dn, bufferlist::const_iterator& blp, // add inode? if (added) { - cache->add_inode(in); + mdcache->add_inode(in); dout(10) << "added " << *in << dendl; } else { dout(10) << " had " << *in << dendl; @@ -3310,7 +3310,7 @@ void Migrator::finish_import_inode_caps(CInode *in, mds_rank_t peer, bool auth_c if (peer >= 0) { cap->merge(it.second, auth_cap); - mds->mdcache->do_cap_import(session, in, cap, it.second.cap_id, + mdcache->do_cap_import(session, in, cap, it.second.cap_id, it.second.seq, it.second.mseq - 1, peer, auth_cap ? CEPH_CAP_FLAG_AUTH : CEPH_CAP_FLAG_RELEASE); } @@ -3335,7 +3335,7 @@ void Migrator::decode_import_dir(bufferlist::const_iterator& blp, dirfrag_t df; decode(df, blp); - CInode *diri = cache->get_inode(df.ino); + CInode *diri = mdcache->get_inode(df.ino); ceph_assert(diri); CDir *dir = diri->get_or_open_dirfrag(mds->mdcache, df.frag); ceph_assert(dir); @@ -3459,7 +3459,7 @@ void Migrator::handle_export_notify(const cref_t &m) return; } - CDir *dir = cache->get_dirfrag(m->get_dirfrag()); + CDir *dir = mdcache->get_dirfrag(m->get_dirfrag()); mds_rank_t from = mds_rank_t(m->get_source().num()); mds_authority_t old_auth = m->get_old_auth(); @@ -3477,11 +3477,11 @@ void Migrator::handle_export_notify(const cref_t &m) << " on " << *dir << dendl; // adjust auth set have; - cache->map_dirfrag_set(m->get_bounds(), have); - cache->adjust_bounded_subtree_auth(dir, have, new_auth); + mdcache->map_dirfrag_set(m->get_bounds(), have); + mdcache->adjust_bounded_subtree_auth(dir, have, new_auth); // induce a merge? - cache->try_subtree_merge(dir); + mdcache->try_subtree_merge(dir); } // send ack @@ -3515,7 +3515,7 @@ void Migrator::export_caps(CInode *in) void Migrator::handle_export_caps_ack(const cref_t &ack) { mds_rank_t from = ack->get_source().num(); - CInode *in = cache->get_inode(ack->ino); + CInode *in = mdcache->get_inode(ack->ino); if (in) { ceph_assert(!in->is_auth()); @@ -3551,7 +3551,7 @@ void Migrator::handle_export_caps_ack(const cref_t &ack) void Migrator::handle_gather_caps(const cref_t &m) { - CInode *in = cache->get_inode(m->ino); + CInode *in = mdcache->get_inode(m->ino); if (!in) return; @@ -3581,7 +3581,7 @@ public: void Migrator::handle_export_caps(const cref_t &ex) { dout(10) << *ex << " from " << ex->get_source() << dendl; - CInode *in = cache->get_inode(ex->ino); + CInode *in = mdcache->get_inode(ex->ino); ceph_assert(in); ceph_assert(in->is_auth()); @@ -3648,7 +3648,7 @@ void Migrator::logged_import_caps(CInode *in, in->auth_unpin(this); } -Migrator::Migrator(MDSRank *m, MDCache *c) : mds(m), cache(c) { +Migrator::Migrator(MDSRank *m, MDCache *c) : mds(m), mdcache(c) { max_export_size = g_conf().get_val("mds_max_export_size"); inject_session_race = g_conf().get_val("mds_inject_migrator_session_race"); } diff --git a/src/mds/Migrator.h b/src/mds/Migrator.h index eb536f5476a86..f7c094294ae1d 100644 --- a/src/mds/Migrator.h +++ b/src/mds/Migrator.h @@ -370,7 +370,7 @@ protected: private: MDSRank *mds; - MDCache *cache; + MDCache *mdcache; uint64_t max_export_size = 0; bool inject_session_race = false; }; diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 7ba28cc5fbe12..535e522c970c7 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -279,7 +279,7 @@ void LogSegment::try_to_expire(MDSRank *mds, MDSGatherBuilder &gather_bld, int o void EMetaBlob::add_dir_context(CDir *dir, int mode) { - MDSRank *mds = dir->cache->mds; + MDSRank *mds = dir->mdcache->mds; list parents; -- 2.39.5