From 88e48bc86135b546847c0a4b444f161331d5bbf9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 16 Jul 2008 13:54:02 -0700 Subject: [PATCH] mds: rename IdAllocator -> InoTable --- src/Makefile.am | 4 ++-- src/mds/{IdAllocator.cc => InoTable.cc} | 22 ++++++------------- src/mds/{IdAllocator.h => InoTable.h} | 9 ++++---- src/mds/MDCache.cc | 4 ++-- src/mds/MDS.cc | 18 ++++++++-------- src/mds/MDS.h | 4 ++-- src/mds/Server.cc | 10 ++++----- src/mds/journal.cc | 28 ++++++++++++------------- 8 files changed, 44 insertions(+), 55 deletions(-) rename src/mds/{IdAllocator.cc => InoTable.cc} (74%) rename src/mds/{IdAllocator.h => InoTable.h} (82%) diff --git a/src/Makefile.am b/src/Makefile.am index 5583879187f4f..d504fea2d41c2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -203,7 +203,7 @@ libmds_a_SOURCES = \ mds/CInode.cc \ mds/LogEvent.cc \ mds/MDSTable.cc \ - mds/IdAllocator.cc \ + mds/InoTable.cc \ mds/MDSTableClient.cc \ mds/MDSTableServer.cc \ mds/AnchorServer.cc \ @@ -340,7 +340,7 @@ noinst_HEADERS = \ mds/AnchorClient.h\ mds/CDentry.h\ mds/CDir.h\ - mds/IdAllocator.h\ + mds/InoTable.h\ mds/LocalLock.h\ mds/LogEvent.h\ mds/MDBalancer.h\ diff --git a/src/mds/IdAllocator.cc b/src/mds/InoTable.cc similarity index 74% rename from src/mds/IdAllocator.cc rename to src/mds/InoTable.cc index 2dfddbbe4c65e..a0eb62fd1628a 100644 --- a/src/mds/IdAllocator.cc +++ b/src/mds/InoTable.cc @@ -12,22 +12,22 @@ * */ -#include "IdAllocator.h" +#include "InoTable.h" #include "MDS.h" #include "include/types.h" #include "config.h" -#define dout(x) if (x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << mds->get_nodeid() << ".idalloc: " +#define dout(x) if (x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << mds->get_nodeid() << ".inotable: " -void IdAllocator::init_inode() +void InoTable::init_inode() { ino = MDS_INO_IDS_OFFSET + mds->get_nodeid(); layout = g_default_file_layout; } -void IdAllocator::reset_state() +void InoTable::reset_state() { // use generic range. FIXME THIS IS CRAP free.clear(); @@ -42,27 +42,17 @@ void IdAllocator::reset_state() free.insert(start, end); } -inodeno_t IdAllocator::alloc_id() +inodeno_t InoTable::alloc_id() { assert(is_active()); // pick one inodeno_t id = free.start(); free.erase(id); - dout(10) << "idalloc " << this << ": alloc id " << id << dendl; + dout(10) << "alloc id " << id << dendl; version++; return id; } -void IdAllocator::reclaim_id(inodeno_t id) -{ - assert(is_active()); - - dout(10) << "idalloc " << this << ": reclaim id " << id << dendl; - free.insert(id); - - version++; -} - diff --git a/src/mds/IdAllocator.h b/src/mds/InoTable.h similarity index 82% rename from src/mds/IdAllocator.h rename to src/mds/InoTable.h index ab46c168494c8..1ca30f99280aa 100644 --- a/src/mds/IdAllocator.h +++ b/src/mds/InoTable.h @@ -13,23 +13,22 @@ */ -#ifndef __IDALLOCATOR_H -#define __IDALLOCATOR_H +#ifndef __INOTABLE_H +#define __INOTABLE_H #include "MDSTable.h" #include "include/interval_set.h" class MDS; -class IdAllocator : public MDSTable { +class InoTable : public MDSTable { interval_set free; // unused ids public: - IdAllocator(MDS *m) : MDSTable(m, "idalloc") { } + InoTable(MDS *m) : MDSTable(m, "idalloc") { } // alloc or reclaim ids inodeno_t alloc_id(); - void reclaim_id(inodeno_t ino); void init_inode(); void reset_state(); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 55d54f258a26b..9ee21fdbac55d 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -72,7 +72,7 @@ #include "messages/MMDSFragmentNotify.h" -#include "IdAllocator.h" +#include "InoTable.h" #include "common/Timer.h" @@ -150,7 +150,7 @@ CInode *MDCache::create_inode() CInode *in = new CInode(this); // assign ino - in->inode.ino = mds->idalloc->alloc_id(); + in->inode.ino = mds->inotable->alloc_id(); in->inode.version = 1; in->inode.nlink = 1; // FIXME diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index fa4cedb1d22d5..e619f9df9bad8 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -36,7 +36,7 @@ #include "AnchorServer.h" #include "AnchorClient.h" -#include "IdAllocator.h" +#include "InoTable.h" #include "SnapTable.h" #include "common/Logger.h" @@ -90,7 +90,7 @@ MDS::MDS(int whoami, Messenger *m, MonMap *mm) : mdlog = new MDLog(this); balancer = new MDBalancer(this); - idalloc = new IdAllocator(this); + inotable = new InoTable(this); snaptable = new SnapTable(this); anchorserver = new AnchorServer(this); @@ -126,7 +126,7 @@ MDS::~MDS() { if (mdcache) { delete mdcache; mdcache = NULL; } if (mdlog) { delete mdlog; mdlog = NULL; } if (balancer) { delete balancer; balancer = NULL; } - if (idalloc) { delete idalloc; idalloc = NULL; } + if (inotable) { delete inotable; inotable = NULL; } if (anchorserver) { delete anchorserver; anchorserver = NULL; } if (snaptable) { delete snaptable; snaptable = NULL; } if (anchorclient) { delete anchorclient; anchorclient = NULL; } @@ -761,10 +761,10 @@ void MDS::boot_create() straydir->mark_dirty(straydir->pre_dirty(), mdlog->get_current_segment()); straydir->commit(0, fin->new_sub()); - // fixme: fake out idalloc (reset, pretend loaded) - dout(10) << "boot_create creating fresh idalloc table" << dendl; - idalloc->reset(); - idalloc->save(fin->new_sub()); + // fixme: fake out inotable (reset, pretend loaded) + dout(10) << "boot_create creating fresh inotable table" << dendl; + inotable->reset(); + inotable->save(fin->new_sub()); // write empty sessionmap sessionmap.save(fin->new_sub()); @@ -813,8 +813,8 @@ void MDS::boot_start(int step, int r) case 1: { C_Gather *gather = new C_Gather(new C_MDS_BootStart(this, 2)); - dout(2) << "boot_start " << step << ": opening idalloc" << dendl; - idalloc->load(gather->new_sub()); + dout(2) << "boot_start " << step << ": opening inotable" << dendl; + inotable->load(gather->new_sub()); dout(2) << "boot_start " << step << ": opening sessionmap" << dendl; sessionmap.load(gather->new_sub()); diff --git a/src/mds/MDS.h b/src/mds/MDS.h index 453b65f1c9dcd..a5bbc1ac0b6b7 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -72,7 +72,7 @@ class MHashReaddirReply; class MMDSBeacon; -class IdAllocator; +class InoTable; class SnapTable; class MDSTableClient; @@ -104,7 +104,7 @@ class MDS : public Dispatcher { MDLog *mdlog; MDBalancer *balancer; - IdAllocator *idalloc; + InoTable *inotable; AnchorServer *anchorserver; AnchorClient *anchorclient; diff --git a/src/mds/Server.cc b/src/mds/Server.cc index d81d9ef5b36ef..b096096f4e42e 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -20,7 +20,7 @@ #include "Migrator.h" #include "MDBalancer.h" #include "AnchorClient.h" -#include "IdAllocator.h" +#include "InoTable.h" #include "SnapTable.h" #include "msg/Messenger.h" @@ -2080,7 +2080,7 @@ void Server::handle_client_mknod(MDRequest *mdr) mdr->ls = mdlog->get_current_segment(); EUpdate *le = new EUpdate(mdlog, "mknod"); le->metablob.add_client_req(req->get_reqid()); - le->metablob.add_allocated_ino(newi->ino(), mds->idalloc->get_version()); + le->metablob.add_allocated_ino(newi->ino(), mds->inotable->get_version()); mds->locker->predirty_nested(mdr, &le->metablob, newi, dn->dir, PREDIRTY_PRIMARY|PREDIRTY_DIR, 1); le->metablob.add_primary_dentry(dn, true, newi); @@ -2129,7 +2129,7 @@ void Server::handle_client_mkdir(MDRequest *mdr) mdr->ls = mdlog->get_current_segment(); EUpdate *le = new EUpdate(mdlog, "mkdir"); le->metablob.add_client_req(req->get_reqid()); - le->metablob.add_allocated_ino(newi->ino(), mds->idalloc->get_version()); + le->metablob.add_allocated_ino(newi->ino(), mds->inotable->get_version()); mds->locker->predirty_nested(mdr, &le->metablob, newi, dn->dir, PREDIRTY_PRIMARY|PREDIRTY_DIR, 1); le->metablob.add_primary_dentry(dn, true, newi, &newi->inode); le->metablob.add_dir(newdir, true, true); // dirty AND complete @@ -2170,7 +2170,7 @@ void Server::handle_client_symlink(MDRequest *mdr) mdr->ls = mdlog->get_current_segment(); EUpdate *le = new EUpdate(mdlog, "symlink"); le->metablob.add_client_req(req->get_reqid()); - le->metablob.add_allocated_ino(newi->ino(), mds->idalloc->get_version()); + le->metablob.add_allocated_ino(newi->ino(), mds->inotable->get_version()); mds->locker->predirty_nested(mdr, &le->metablob, newi, dn->dir, PREDIRTY_PRIMARY|PREDIRTY_DIR, 1); le->metablob.add_primary_dentry(dn, true, newi); @@ -4704,7 +4704,7 @@ void Server::handle_client_openc(MDRequest *mdr) mdr->ls = mdlog->get_current_segment(); EUpdate *le = new EUpdate(mdlog, "openc"); le->metablob.add_client_req(req->get_reqid()); - le->metablob.add_allocated_ino(in->ino(), mds->idalloc->get_version()); + le->metablob.add_allocated_ino(in->ino(), mds->inotable->get_version()); mds->locker->predirty_nested(mdr, &le->metablob, in, dn->dir, PREDIRTY_PRIMARY|PREDIRTY_DIR, 1); le->metablob.add_primary_dentry(dn, true, in); diff --git a/src/mds/journal.cc b/src/mds/journal.cc index bc6eb1ff6ea31..1e338abf84ee7 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -42,7 +42,7 @@ #include "MDCache.h" #include "Server.h" #include "Migrator.h" -#include "IdAllocator.h" +#include "InoTable.h" #include "SnapTable.h" #include "MDSTableClient.h" @@ -170,13 +170,13 @@ C_Gather *LogSegment::try_to_expire(MDS *mds) } // idalloc - if (allocv > mds->idalloc->get_committed_version()) { - dout(10) << "try_to_expire saving idalloc table, need " << allocv - << ", committed is " << mds->idalloc->get_committed_version() - << " (" << mds->idalloc->get_committing_version() << ")" + if (allocv > mds->inotable->get_committed_version()) { + dout(10) << "try_to_expire saving inotable table, need " << allocv + << ", committed is " << mds->inotable->get_committed_version() + << " (" << mds->inotable->get_committing_version() << ")" << dendl; if (!gather) gather = new C_Gather; - mds->idalloc->save(gather->new_sub(), allocv); + mds->inotable->save(gather->new_sub(), allocv); } // sessionmap @@ -485,21 +485,21 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg) // allocated_inos if (!allocated_inos.empty()) { - if (mds->idalloc->get_version() >= alloc_tablev) { - dout(10) << "EMetaBlob.replay idalloc tablev " << alloc_tablev - << " <= table " << mds->idalloc->get_version() << dendl; + if (mds->inotable->get_version() >= alloc_tablev) { + dout(10) << "EMetaBlob.replay inotable tablev " << alloc_tablev + << " <= table " << mds->inotable->get_version() << dendl; } else { for (list::iterator p = allocated_inos.begin(); p != allocated_inos.end(); ++p) { - dout(10) << " EMetaBlob.replay idalloc " << *p << " tablev " << alloc_tablev - << " - 1 == table " << mds->idalloc->get_version() << dendl; - assert(alloc_tablev-1 == mds->idalloc->get_version()); + dout(10) << " EMetaBlob.replay inotable " << *p << " tablev " << alloc_tablev + << " - 1 == table " << mds->inotable->get_version() << dendl; + assert(alloc_tablev-1 == mds->inotable->get_version()); - inodeno_t ino = mds->idalloc->alloc_id(); + inodeno_t ino = mds->inotable->alloc_id(); assert(ino == *p); // this should match. } - assert(alloc_tablev == mds->idalloc->get_version()); + assert(alloc_tablev == mds->inotable->get_version()); } } -- 2.39.5