]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use nstring class
authorSage Weil <sage@newdream.net>
Fri, 13 Jun 2008 14:33:57 +0000 (07:33 -0700)
committerSage Weil <sage@newdream.net>
Fri, 13 Jun 2008 14:33:57 +0000 (07:33 -0700)
21 files changed:
src/Makefile.am
src/client/Client.cc
src/client/Client.h
src/include/filepath.h
src/include/nstring.h [new file with mode: 0644]
src/mds/Anchor.h
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/MDCache.cc
src/mds/events/EMetaBlob.h
src/mds/events/ESlaveUpdate.h
src/mds/mdstypes.h
src/messages/MCacheExpire.h
src/messages/MClientLease.h
src/messages/MDentryUnlink.h
src/messages/MExportDirPrep.h
src/messages/MMDSCacheRejoin.h

index 71adef9c7c91d08f64e0e5183c8c203522ebcb08..fa66f5dee9b3d1c4a33ac1dd011df4465306ce07 100644 (file)
@@ -149,7 +149,7 @@ noinst_LIBRARIES = \
        libmon.a libmds.a libosdc.a libosd.a libclient.a \
        libos.a libebofs.a 
 
-noinst_LIBRARIES += libcrush_so.a libcephclient_so.a
+noinst_LIBRARIES += libcrush_so.a #libcephclient_so.a
 
 # extra bits
 EXTRA_DIST = mkcephfs.sh mkfs.sh restart.sh startnew.sh stop.sh
index 83bf5b16bd726c9925995d406f78826f6f8ffa77..600ac9c70dfd6622a0eda70afce89d86594efe71 100644 (file)
@@ -192,7 +192,7 @@ void Client::dump_inode(Inode *in, set<Inode*>& did)
   if (in->dir) {
     dout(1) << "  dir size " << in->dir->dentries.size() << dendl;
     //for (hash_map<const char*, Dentry*, hash<const char*>, eqstr>::iterator it = in->dir->dentries.begin();
-    for (hash_map<string, Dentry*>::iterator it = in->dir->dentries.begin();
+    for (hash_map<nstring, Dentry*>::iterator it = in->dir->dentries.begin();
          it != in->dir->dentries.end();
          it++) {
       dout(1) << "    dn " << it->first << " ref " << it->second->ref << dendl;
index 2646b82bc1b7fcbac4e45ddb320e295f1bbd1a73..ec61d08a93d06fc19745e09e515886127ba19cc8 100644 (file)
@@ -117,7 +117,7 @@ class Dir {
  public:
   Inode    *parent_inode;  // my inode
   //hash_map<const char*, Dentry*, hash<const char*>, eqstr> dentries;
-  hash_map<string, Dentry*> dentries;
+  hash_map<nstring, Dentry*> dentries;
 
   Dir(Inode* in) { parent_inode = in; }
 
index a0cf53a3397a6b0e62fb6572de9f50ba55854592..b25d0c893a7908513625b9cb95f7a22f50697165 100644 (file)
@@ -31,6 +31,7 @@ using namespace std;
 
 #include "buffer.h"
 #include "encoding.h"
+#include "nstring.h"
 
 class filepath {
   inodeno_t ino;   // base inode.  ino=0 implies pure relative path.
@@ -182,6 +183,14 @@ class filepath {
     path += s;
     bits.push_back(s);
   }
+  void push_dentry(const nstring &ns) {
+    string s = ns.c_str();
+    push_dentry(s);
+  }
+  void push_dentry(const char *cs) {
+    string s = cs;
+    push_dentry(s);
+  }
   void append(const filepath& a) {
     assert(a.pure_relative());
     for (unsigned i=0; i<a.depth(); i++) 
diff --git a/src/include/nstring.h b/src/include/nstring.h
new file mode 100644 (file)
index 0000000..7bee230
--- /dev/null
@@ -0,0 +1,146 @@
+#ifndef _CEPH_NSTRING
+#define _CEPH_NSTRING
+
+/*
+ * nstring - a simple string class
+ *
+ * the key difference between this and std::string is that the string
+ * is stored with a null terminator, providing an efficient c_str()
+ * method.
+ */
+class nstring {
+ private:
+  int _len;
+  char *_data;
+  
+ public:
+  nstring() : _len(0), _data(0) {}
+  nstring(int l, const char *d=0) : _len(l) {
+    _data = new char[_len + 1];
+    if (d) {
+      memcpy(_data, d, l);
+      _data[l] = 0;
+    }
+  }
+  nstring(const char *s) { 
+    _len = strlen(s);
+    _data = new char[_len + 1];
+    memcpy(_data, s, _len);
+    _data[_len] = 0;
+  }
+  nstring(const string &s) {
+    _len = s.length();
+    _data = new char[_len + 1];
+    memcpy(_data, s.data(), _len);
+    _data[_len] = 0;
+  }
+  nstring(const nstring &s) {
+    _len = s.length();
+    _data = new char[_len + 1];
+    memcpy(_data, s.data(), _len);
+    _data[_len] = 0;
+  }
+  ~nstring() {
+    if (_data) delete[] _data;
+  }
+
+  // accessors
+  int length() const { return _len; }
+  bool empty() const { return _len == 0; }
+  const char *c_str() const { return _data; }
+  const char *data() const { return _data; }
+
+  //const char *operator() const { return _data; }
+
+  // modifiers
+  const nstring& operator=(const char *s) {
+    if (_data) delete[] _data;
+    _len = strlen(s);
+    _data = new char[_len + 1];
+    memcpy(_data, s, _len);
+    _data[_len] = 0;
+    return *this;
+  }
+  const nstring& operator=(const string &s) {
+    if (_data) delete[] _data;
+    _len = s.length();
+    _data = new char[_len + 1];
+    memcpy(_data, s.data(), _len);
+    _data[_len] = 0;
+    return *this;
+  }
+  const nstring& operator=(const nstring &ns) {
+    if (_data) delete[] _data;
+    _len = ns.length();
+    _data = new char[_len + 1];
+    memcpy(_data, ns.data(), _len);
+    _data[_len] = 0;
+    return *this;
+  }
+  void swap(nstring &other) {
+    int tlen = _len;
+    char *tdata = _data;
+    _len = other._len;
+    _data = other._data;
+    other._len = tlen;
+    other._data = tdata;
+  }
+  void clear() {
+    _len = 0;
+    delete _data;
+    _data = 0;
+  }
+
+  // encoding
+  void encode(bufferlist &bl) const {
+    __u32 l = _len;
+    ::encode(l, bl);
+    bl.append(_data, _len);
+  }
+  void decode(bufferlist::iterator &bl) {
+    if (_data) delete[] _data;
+    __u32 l;
+    ::decode(l, bl);
+    _len = l;
+    _data = new char[_len + 1];
+    bl.copy(_len, _data);
+    _data[_len] = 0;
+  }
+};
+WRITE_CLASS_ENCODER(nstring)
+
+static inline bool operator==(const nstring &l, const nstring &r) {
+  return l.length() == r.length() && memcmp(l.data(), r.data(), l.length()) == 0;
+}
+static inline bool operator!=(const nstring &l, const nstring &r) {
+  return l.length() != r.length() || memcmp(l.data(), r.data(), l.length()) != 0;
+}
+static inline bool operator<(const nstring &l, const nstring &r) {
+  return strcmp(l.c_str(), r.c_str()) < 0;
+}
+static inline bool operator<=(const nstring &l, const nstring &r) {
+  return strcmp(l.c_str(), r.c_str()) <= 0;
+}
+static inline bool operator>(const nstring &l, const nstring &r) {
+  return strcmp(l.c_str(), r.c_str()) > 0;
+}
+static inline bool operator>=(const nstring &l, const nstring &r) {
+  return strcmp(l.c_str(), r.c_str()) >= 0;
+}
+
+static inline ostream& operator<<(ostream &out, const nstring &s) {
+  return out << s.c_str();
+}
+
+namespace __gnu_cxx {
+  template<> struct hash< nstring >
+  {
+    size_t operator()( const nstring& x ) const
+    {
+      static hash<const char*> H;
+      return H(x.c_str());
+    }
+  };
+}
+
+#endif
index 7cdf8182fa8e2365a38f4a77f8112ebdb93a1921..af4165d81828df28f53aecb9427ba2bc5870662c 100644 (file)
@@ -77,7 +77,7 @@ public:
   Anchor() : dn_hash(0), nref(0) {}
   Anchor(inodeno_t i, inodeno_t di, __u32 hash, int nr=0) :
     ino(i), dirino(di), dn_hash(hash), nref(nr) { }
-  Anchor(inodeno_t i, inodeno_t di, const string &dname, int nr=0) :
+  Anchor(inodeno_t i, inodeno_t di, const nstring &dname, int nr=0) :
     ino(i), dirino(di),
     dn_hash(ceph_full_name_hash(dname.data(), dname.length())),
     nref(nr) { }
index 95f4c7b61d1a151a47392ecd57e8b6026f611d3e..94bed64f3800d4a0355607d7b79a6fb202ef8332 100644 (file)
@@ -198,7 +198,7 @@ void CDentry::make_path_string(string& s)
     s = "???";
   }
   s += "/";
-  s += name;
+  s.append(name.data(), name.length());
 }
 
 void CDentry::make_path(filepath& fp)
index 55f2a49c117239c06907f080921e0477fe9a6da1..06efe67fdc3eee9cb0f63854d37f1556ad13b3cc 100644 (file)
@@ -27,6 +27,7 @@ using namespace std;
 #include "include/lru.h"
 #include "include/xlist.h"
 #include "include/filepath.h"
+#include "include/nstring.h"
 #include "mdstypes.h"
 
 #include "SimpleLock.h"
@@ -76,7 +77,7 @@ class CDentry : public MDSCacheObject, public LRUObject {
   }
 
  protected:
-  string name;
+  nstring name;
 
   inodeno_t remote_ino;      // if remote dentry
   unsigned char remote_d_type;
@@ -120,7 +121,7 @@ public:
     dir_offset(0),
     auth_pins(0), nested_auth_pins(0), nested_anchors(0),
     lock(this, CEPH_LOCK_DN, WAIT_LOCK_OFFSET) { }
-  CDentry(const string& n, CInode *in) :
+  CDentry(const nstring& n, CInode *in) :
     name(n),
     remote_ino(0), remote_d_type(0),
     inode(in), dir(0),
@@ -129,7 +130,7 @@ public:
     dir_offset(0),
     auth_pins(0), nested_auth_pins(0), nested_anchors(0),
     lock(this, CEPH_LOCK_DN, WAIT_LOCK_OFFSET) { }
-  CDentry(const string& n, inodeno_t ino, unsigned char dt, CInode *in=0) :
+  CDentry(const nstring& n, inodeno_t ino, unsigned char dt, CInode *in=0) :
     name(n),
     remote_ino(ino), remote_d_type(dt),
     inode(in), dir(0),
@@ -141,7 +142,7 @@ public:
 
   CInode *get_inode() const { return inode; }
   CDir *get_dir() const { return dir; }
-  const string& get_name() const { return name; }
+  const nstring& get_name() const { return name; }
   inodeno_t get_ino();
 
   off_t get_dir_offset() { return dir_offset; }
@@ -273,7 +274,7 @@ ostream& operator<<(ostream& out, CDentry& dn);
 
 
 class CDentryDiscover {
-  string dname;
+  nstring dname;
   __s32  replica_nonce;
   __s32  lockstate;
   __s64  dir_offset;
@@ -289,7 +290,7 @@ public:
     remote_ino(dn->get_remote_ino()), remote_d_type(dn->get_remote_d_type()) { }
   CDentryDiscover(bufferlist::iterator &p) { decode(p); }
 
-  string& get_dname() { return dname; }
+  nstring& get_dname() { return dname; }
   int get_nonce() { return replica_nonce; }
   bool is_remote() { return remote_ino ? true:false; }
   inodeno_t get_remote_ino() { return remote_ino; }
index 5347bfcbe22144bb100154b8821ea9dd3d0e29a6..84b840cccd4c0afc099dc84803d0a9fa4fe47758 100644 (file)
@@ -186,7 +186,7 @@ CDir::CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth) :
  * linking fun
  */
 
-CDentry* CDir::add_null_dentry(const string& dname)
+CDentry* CDir::add_null_dentry(const nstring& dname)
 {
   // foreign
   assert(lookup(dname) == 0);
@@ -201,10 +201,10 @@ CDentry* CDir::add_null_dentry(const string& dname)
   dn->version = get_projected_version();
   
   // add to dir
-  assert(items.count(dn->name) == 0);
+  assert(items.count(dn->name.c_str()) == 0);
   //assert(null_items.count(dn->name) == 0);
 
-  items[dn->name] = dn;
+  items[dn->name.c_str()] = dn;
   nnull++;
 
   dout(12) << "add_null_dentry " << *dn << dendl;
@@ -218,7 +218,7 @@ CDentry* CDir::add_null_dentry(const string& dname)
 }
 
 
-CDentry* CDir::add_primary_dentry(const string& dname, CInode *in) 
+CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in) 
 {
   // primary
   assert(lookup(dname) == 0);
@@ -233,10 +233,10 @@ CDentry* CDir::add_primary_dentry(const string& dname, CInode *in)
   dn->version = get_projected_version();
   
   // add to dir
-  assert(items.count(dn->name) == 0);
+  assert(items.count(dn->name.c_str()) == 0);
   //assert(null_items.count(dn->name) == 0);
 
-  items[dn->name] = dn;
+  items[dn->name.c_str()] = dn;
   link_inode_work( dn, in );
 
   dout(12) << "add_primary_dentry " << *dn << dendl;
@@ -249,7 +249,7 @@ CDentry* CDir::add_primary_dentry(const string& dname, CInode *in)
   return dn;
 }
 
-CDentry* CDir::add_remote_dentry(const string& dname, inodeno_t ino, unsigned char d_type) 
+CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type) 
 {
   // foreign
   assert(lookup(dname) == 0);
@@ -264,10 +264,10 @@ CDentry* CDir::add_remote_dentry(const string& dname, inodeno_t ino, unsigned ch
   dn->version = get_projected_version();
   
   // add to dir
-  assert(items.count(dn->name) == 0);
+  assert(items.count(dn->name.c_str()) == 0);
   //assert(null_items.count(dn->name) == 0);
 
-  items[dn->name] = dn;
+  items[dn->name.c_str()] = dn;
   nitems++;
 
   dout(12) << "add_remote_dentry " << *dn << dendl;
@@ -297,8 +297,8 @@ void CDir::remove_dentry(CDentry *dn)
   }
   
   // remove from list
-  assert(items.count(dn->name) == 1);
-  items.erase(dn->name);
+  assert(items.count(dn->name.c_str()) == 1);
+  items.erase(dn->name.c_str());
 
   // adjust dirty counter?
   if (dn->state_test(CDentry::STATE_DIRTY))
@@ -498,9 +498,9 @@ void CDir::steal_dentry(CDentry *dn)
 {
   dout(15) << "steal_dentry " << *dn << dendl;
 
-  items[dn->name] = dn;
+  items[dn->name.c_str()] = dn;
 
-  dn->dir->items.erase(dn->name);
+  dn->dir->items.erase(dn->name.c_str());
   if (dn->dir->items.empty())
     dn->dir->put(PIN_CHILD);
 
@@ -679,7 +679,7 @@ CDirDiscover *CDir::replicate_to(int mds)
  * WAITING
  */
 
-void CDir::add_dentry_waiter(const string& dname, Context *c) 
+void CDir::add_dentry_waiter(const nstring& dname, Context *c) 
 {
   if (waiting_on_dentry.empty())
     get(PIN_DNWAITER);
@@ -687,7 +687,7 @@ void CDir::add_dentry_waiter(const string& dname, Context *c)
   dout(10) << "add_dentry_waiter dentry " << dname << " " << c << " on " << *this << dendl;
 }
 
-void CDir::take_dentry_waiting(const string& dname, list<Context*>& ls)
+void CDir::take_dentry_waiting(const nstring& dname, list<Context*>& ls)
 {
   if (waiting_on_dentry.empty()) return;
   if (waiting_on_dentry.count(dname) == 0) return;
@@ -724,7 +724,7 @@ void CDir::take_ino_waiting(inodeno_t ino, list<Context*>& ls)
 void CDir::take_sub_waiting(list<Context*>& ls)
 {
   dout(10) << "take_sub_waiting" << dendl;
-  for (hash_map<string, list<Context*> >::iterator p = waiting_on_dentry.begin(); 
+  for (hash_map<nstring, list<Context*> >::iterator p = waiting_on_dentry.begin(); 
        p != waiting_on_dentry.end();
        ++p) 
     ls.splice(ls.end(), p->second);
@@ -773,7 +773,7 @@ void CDir::take_waiting(int mask, list<Context*>& ls)
 {
   if (mask & WAIT_DENTRY) {
     // take each each dentry waiter
-    hash_map<string, list<Context*> >::iterator it = 
+    hash_map<nstring, list<Context*> >::iterator it = 
       waiting_on_dentry.begin(); 
     while (it != waiting_on_dentry.end()) {
       take_dentry_waiting((it++)->first, ls);   // not post-inc
index 9835409834cfb8e8d379bbcebe8cedd7d45b1a6b..1975679e6ed01a5c816fced45bc28089939a9f8f 100644 (file)
@@ -193,7 +193,7 @@ public:
 
 public:
   //typedef hash_map<string, CDentry*> map_t;   // there is a bug somewhere, valgrind me.
-  typedef map<string, CDentry*> map_t;
+  typedef map<const char *, CDentry*, ltstr> map_t;
 protected:
 
   // contents
@@ -279,17 +279,21 @@ protected:
 
   // -- dentries and inodes --
  public:
-  CDentry* lookup(const string& n) {
-    map_t::iterator iter = items.find(n);
+  CDentry* lookup(const string& s) {
+    nstring ns(s);
+    return lookup(ns);
+  }
+  CDentry* lookup(const nstring& ns) {
+    map_t::iterator iter = items.find(ns.c_str());
     if (iter == items.end()) 
       return 0;
     else
       return iter->second;
   }
 
-  CDentry* add_null_dentry(const string& dname);
-  CDentry* add_primary_dentry(const string& dname, CInode *in);
-  CDentry* add_remote_dentry(const string& dname, inodeno_t ino, unsigned char d_type);
+  CDentry* add_null_dentry(const nstring& dname);
+  CDentry* add_primary_dentry(const nstring& dname, CInode *in);
+  CDentry* add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type);
   void remove_dentry( CDentry *dn );         // delete dentry
   void link_remote_inode( CDentry *dn, inodeno_t ino, unsigned char d_type);
   void link_remote_inode( CDentry *dn, CInode *in );
@@ -406,15 +410,15 @@ private:
     
   // -- waiters --
 protected:
-  hash_map< string, list<Context*> > waiting_on_dentry;
+  hash_map< nstring, list<Context*> > waiting_on_dentry;
   hash_map< inodeno_t, list<Context*> > waiting_on_ino;
 
 public:
   bool is_waiting_for_dentry(const string& dn) {
     return waiting_on_dentry.count(dn);
   }
-  void add_dentry_waiter(const string& dentry, Context *c);
-  void take_dentry_waiting(const string& dentry, list<Context*>& ls);
+  void add_dentry_waiter(const nstring& dentry, Context *c);
+  void take_dentry_waiting(const nstring& dentry, list<Context*>& ls);
 
   bool is_waiting_for_ino(inodeno_t ino) {
     return waiting_on_ino.count(ino);
index c61205d5c4f7061d3f832ac931b18f6bb9110e8a..f93136d9b3dcc9aa1f22ea49fa580119ac188cd5 100644 (file)
@@ -163,7 +163,7 @@ void CInode::pop_and_dirty_projected_inode(LogSegment *ls)
 
 // dirfrags
 
-frag_t CInode::pick_dirfrag(const string& dn)
+frag_t CInode::pick_dirfrag(const nstring& dn)
 {
   if (dirfragtree.empty())
     return frag_t();          // avoid the string hash if we can.
index e6bc6143d58d9b3e6e9001797c40ba8efc29686f..05b6b32844d06e2a41ede6d44ba002280b167a49 100644 (file)
@@ -177,7 +177,7 @@ private:
   int stickydir_ref;
 
 public:
-  frag_t pick_dirfrag(const string &dn);
+  frag_t pick_dirfrag(const nstring &dn);
   bool has_dirfrags() { return !dirfrags.empty(); }
   CDir* get_dirfrag(frag_t fg) {
     if (dirfrags.count(fg)) {
index 6cf7187969b7b28988df05b7536a04dff9b99ef4..c245a86a2d18b3cfa7cd59ae5fbf533315db9b5e 100644 (file)
@@ -2107,7 +2107,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
   }
   
   // walk weak map
-  for (map<dirfrag_t, map<string, MMDSCacheRejoin::dn_weak> >::iterator p = weak->weak.begin();
+  for (map<dirfrag_t, map<nstring, MMDSCacheRejoin::dn_weak> >::iterator p = weak->weak.begin();
        p != weak->weak.end();
        ++p) {
     CDir *dir = get_dirfrag(p->first);
@@ -2120,7 +2120,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
       ack->add_strong_dirfrag(p->first, nonce, dir->dir_rep);
     
     // weak dentries
-    for (map<string,MMDSCacheRejoin::dn_weak>::iterator q = p->second.begin();
+    for (map<nstring,MMDSCacheRejoin::dn_weak>::iterator q = p->second.begin();
         q != p->second.end();
         ++q) {
       CDentry *dn = dir->lookup(q->first);
@@ -2355,7 +2355,7 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
     dir->add_replica(from);
     dir->dir_rep = p->second.dir_rep;
 
-    for (map<string,MMDSCacheRejoin::dn_strong>::iterator q = strong->strong_dentries[p->first].begin();
+    for (map<nstring,MMDSCacheRejoin::dn_strong>::iterator q = strong->strong_dentries[p->first].begin();
         q != strong->strong_dentries[p->first].end();
         ++q) {
       CDentry *dn = dir->lookup(q->first);
@@ -2511,7 +2511,7 @@ void MDCache::handle_cache_rejoin_ack(MMDSCacheRejoin *ack)
     dout(10) << " got " << *dir << dendl;
 
     // dentries
-    for (map<string,MMDSCacheRejoin::dn_strong>::iterator q = ack->strong_dentries[p->first].begin();
+    for (map<nstring,MMDSCacheRejoin::dn_strong>::iterator q = ack->strong_dentries[p->first].begin();
         q != ack->strong_dentries[p->first].end();
         ++q) {
       CDentry *dn = dir->lookup(q->first);
@@ -3602,7 +3602,7 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
     }
     
     // DENTRIES
-    for (map<dirfrag_t, map<string,int> >::iterator pd = p->second.dentries.begin();
+    for (map<dirfrag_t, map<nstring,int> >::iterator pd = p->second.dentries.begin();
         pd != p->second.dentries.end();
         ++pd) {
       dout(10) << " dn expires in dir " << pd->first << dendl;
@@ -3617,7 +3617,7 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
        assert(dir->is_auth());
       }
       
-      for (map<string,int>::iterator p = pd->second.begin();
+      for (map<nstring,int>::iterator p = pd->second.begin();
           p != pd->second.end();
           ++p) {
        int nonce = p->second;
index 08c648b69574714f9b89217f348b42db833478a6..51a9c7e9949971d78bf4a7d430e316c0215d91eb 100644 (file)
@@ -16,8 +16,8 @@
 #define __MDS_EMETABLOB_H
 
 #include <stdlib.h>
-#include <string>
-using std::string;
+
+#include "include/nstring.h"
 
 #include "../CInode.h"
 #include "../CDir.h"
@@ -50,7 +50,7 @@ public:
   /* fullbit - a regular dentry + inode
    */
   struct fullbit {
-    string  dn;         // dentry
+    nstring  dn;         // dentry
     version_t dnv;
     inode_t inode;      // if it's not
     fragtree_t dirfragtree;
@@ -58,7 +58,7 @@ public:
     string symlink;
     bool dirty;
 
-    fullbit(const string& d, version_t v, inode_t& i, fragtree_t &dft, map<string,bufferptr> &xa, string& sym, bool dr) :
+    fullbit(const nstring& d, version_t v, inode_t& i, fragtree_t &dft, map<string,bufferptr> &xa, const string& sym, bool dr) :
       dn(d), dnv(v), inode(i), dirfragtree(dft), xattrs(xa), symlink(sym), dirty(dr) { }
     fullbit(bufferlist::iterator &p) { decode(p); }
     fullbit() {}
@@ -94,13 +94,13 @@ public:
   /* remotebit - a dentry + remote inode link (i.e. just an ino)
    */
   struct remotebit {
-    string dn;
+    nstring dn;
     version_t dnv;
     inodeno_t ino;
     unsigned char d_type;
     bool dirty;
 
-    remotebit(const string& d, version_t v, inodeno_t i, unsigned char dt, bool dr) : 
+    remotebit(const nstring& d, version_t v, inodeno_t i, unsigned char dt, bool dr) : 
       dn(d), dnv(v), ino(i), d_type(dt), dirty(dr) { }
     remotebit(bufferlist::iterator &p) { decode(p); }
     remotebit() {}
@@ -131,11 +131,11 @@ public:
    * nullbit - a null dentry
    */
   struct nullbit {
-    string dn;
+    nstring dn;
     version_t dnv;
     bool dirty;
 
-    nullbit(const string& d, version_t v, bool dr) : dn(d), dnv(v), dirty(dr) { }
+    nullbit(const nstring& d, version_t v, bool dr) : dn(d), dnv(v), dirty(dr) { }
     nullbit(bufferlist::iterator &p) { decode(p); }
     nullbit() {}
 
index d8d2443b0967edb76e68b3f47d799acb5427e27b..3c348ead0c05bccb18cd3da06d9be60abc8c6fbc 100644 (file)
@@ -56,7 +56,7 @@ struct rename_rollback {
     utime_t dirfrag_old_mtime;
     utime_t dirfrag_old_rctime;
     inodeno_t ino, remote_ino;
-    string dname;
+    nstring dname;
     char remote_d_type;
     utime_t old_ctime;
     
index 1b8f5aeca0c75eeb8f503277b901bb7b3cc1ef12..597d0779cced57891394f02f65b1d9e5953a096f 100644 (file)
@@ -18,6 +18,7 @@ using namespace std;
 
 #include "include/frag.h"
 #include "include/xlist.h"
+#include "include/nstring.h"
 
 #define MDS_REF_SET    // define me for improved debug output, sanity checking
 //#define MDS_VERIFY_FRAGSTAT    // do do (slow) sanity checking on frags
@@ -640,7 +641,7 @@ class MDSCacheObjectInfo {
 public:
   inodeno_t ino;
   dirfrag_t dirfrag;
-  string dname;
+  nstring dname;
 
   MDSCacheObjectInfo() : ino(0) {}
 
index 43d69dcd321acea44014d495e6f19b70740751e4..ecab919dba296356b4703ffc86b5276dcb58bba9 100644 (file)
@@ -26,7 +26,7 @@ public:
   struct realm {
     map<inodeno_t, __s32> inodes;
     map<dirfrag_t, __s32> dirs;
-    map<dirfrag_t, map<string,__s32> > dentries;
+    map<dirfrag_t, map<nstring,__s32> > dentries;
 
     void encode(bufferlist &bl) const {
       ::encode(inodes, bl);
@@ -58,7 +58,7 @@ public:
   void add_dir(dirfrag_t r, dirfrag_t df, int nonce) {
     realms[r].dirs[df] = nonce;
   }
-  void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, int nonce) {
+  void add_dentry(dirfrag_t r, dirfrag_t df, const nstring& dn, int nonce) {
     realms[r].dentries[df][dn] = nonce;
   }
 
@@ -72,10 +72,10 @@ public:
         p != r.dirs.end();
         ++p)
       myr.dirs[p->first] = p->second;
-    for (map<dirfrag_t, map<string,int> >::iterator p = r.dentries.begin();
+    for (map<dirfrag_t, map<nstring,int> >::iterator p = r.dentries.begin();
         p != r.dentries.end();
         ++p)
-      for (map<string,int>::iterator q = p->second.begin();
+      for (map<nstring,int>::iterator q = p->second.begin();
           q != p->second.end();
           ++q) 
        myr.dentries[p->first][q->first] = q->second;
index c4e54e52496548453871c0ca627f66aad8b9263a..0e12803dd751280db07890f55666f59fbcf5885c 100644 (file)
@@ -31,7 +31,7 @@ static const char *get_lease_action_name(int a) {
 
 struct MClientLease : public Message {
   struct ceph_mds_lease h;
-  string dname;
+  nstring dname;
   
   int get_action() { return h.action; }
   int get_mask() { return h.mask; }
@@ -44,7 +44,7 @@ struct MClientLease : public Message {
     h.mask = m;
     h.ino = i;
   }
-  MClientLease(int ac, int m, __u64 i, const string& d) :
+  MClientLease(int ac, int m, __u64 i, const nstring& d) :
     Message(CEPH_MSG_CLIENT_LEASE),
     dname(d) {
     h.action = ac;
index 0a50487667192391534489c18a5c4b26cac80776..074e149b66e780a1f9efa8fc2f0f17bc3bb97cbb 100644 (file)
 
 class MDentryUnlink : public Message {
   dirfrag_t dirfrag;
-  string dn;
+  nstring dn;
 
  public:
   dirfrag_t get_dirfrag() { return dirfrag; }
-  string& get_dn() { return dn; }
+  nstring& get_dn() { return dn; }
 
   CInodeDiscover *strayin;
   CDirDiscover *straydir;
@@ -31,7 +31,7 @@ class MDentryUnlink : public Message {
   MDentryUnlink() :
     Message(MSG_MDS_DENTRYUNLINK),
     strayin(0), straydir(0), straydn(0) { }
-  MDentryUnlink(dirfrag_t df, string& n) :
+  MDentryUnlink(dirfrag_t df, nstring& n) :
     Message(MSG_MDS_DENTRYUNLINK),
     dirfrag(df),
     dn(n),
index 206cc966efcca9533f03ce67d5c58a947faa3a28..7ee9f5f5ac16d4f402bb43d4940d13e23180f9fa 100644 (file)
@@ -33,7 +33,7 @@ class MExportDirPrep : public Message {
   list<CInodeDiscover*>          inodes;
   list<CDentryDiscover*>         dentries;
   map<inodeno_t,dirfrag_t>       inode_dirfrag;
-  map<inodeno_t,string>          inode_dentry;
+  map<inodeno_t,nstring>          inode_dentry;
 
   map<inodeno_t,list<frag_t> >   frags_by_ino;
   map<dirfrag_t,CDirDiscover*>   dirfrags;
@@ -53,7 +53,7 @@ class MExportDirPrep : public Message {
   dirfrag_t get_containing_dirfrag(inodeno_t ino) {
     return inode_dirfrag[ino];
   }
-  string& get_dentry(inodeno_t ino) {
+  nstring& get_dentry(inodeno_t ino) {
     return inode_dentry[ino];
   }
   bool have_dirfrag(dirfrag_t df) {
@@ -98,7 +98,7 @@ class MExportDirPrep : public Message {
   void add_export(dirfrag_t df) {
     bounds.push_back( df );
   }
-  void add_inode(dirfrag_t df, const string& name, CDentryDiscover *dn, CInodeDiscover *in) {
+  void add_inode(dirfrag_t df, const nstring& name, CDentryDiscover *dn, CInodeDiscover *in) {
     inodes.push_back(in);
     dentries.push_back(dn);
     inode_dirfrag[in->get_ino()] = df;
index d687b1fa4150b14be30267544ec82ac3dfed84ef..7928d580bf34a83afb9f62310525b38e8096fa26 100644 (file)
@@ -160,12 +160,12 @@ class MMDSCacheRejoin : public Message {
 
   // weak
   map<dirfrag_t, pair<frag_info_t, frag_info_t> > dirfrag_stat;
-  map<dirfrag_t, map<string, dn_weak> > weak;
+  map<dirfrag_t, map<nstring, dn_weak> > weak;
   set<inodeno_t> weak_inodes;
 
   // strong
   map<dirfrag_t, dirfrag_strong> strong_dirfrags;
-  map<dirfrag_t, map<string, dn_strong> > strong_dentries;
+  map<dirfrag_t, map<nstring, dn_strong> > strong_dentries;
   map<inodeno_t, inode_strong> strong_inodes;
 
   // open
@@ -179,8 +179,8 @@ class MMDSCacheRejoin : public Message {
   // authpins, xlocks
   map<inodeno_t, metareqid_t> authpinned_inodes;
   map<inodeno_t, map<__s32, metareqid_t> > xlocked_inodes;
-  map<dirfrag_t, map<string, metareqid_t> > authpinned_dentries;
-  map<dirfrag_t, map<string, metareqid_t> > xlocked_dentries;
+  map<dirfrag_t, map<nstring, metareqid_t> > authpinned_dentries;
+  map<dirfrag_t, map<nstring, metareqid_t> > xlocked_dentries;
 
   MMDSCacheRejoin() : Message(MSG_MDS_CACHEREJOIN) {}
   MMDSCacheRejoin(int o) : 
@@ -222,7 +222,7 @@ class MMDSCacheRejoin : public Message {
   void add_weak_dirfrag(dirfrag_t df) {
     weak[df];
   }
-  void add_weak_dirfrag(dirfrag_t df, map<string,dn_weak>& dnmap) {
+  void add_weak_dirfrag(dirfrag_t df, map<nstring,dn_weak>& dnmap) {
     weak[df] = dnmap;
   }
   void add_strong_dirfrag(dirfrag_t df, int n, int dr) {
@@ -236,13 +236,13 @@ class MMDSCacheRejoin : public Message {
   void add_weak_primary_dentry(dirfrag_t df, const string& dname, inodeno_t ino) {
     weak[df][dname] = dn_weak(ino);
   }
-  void add_strong_dentry(dirfrag_t df, const string& dname, inodeno_t pi, inodeno_t ri, unsigned char rdt, int n, int ls) {
+  void add_strong_dentry(dirfrag_t df, const nstring& dname, inodeno_t pi, inodeno_t ri, unsigned char rdt, int n, int ls) {
     strong_dentries[df][dname] = dn_strong(pi, ri, rdt, n, ls);
   }
-  void add_dentry_authpin(dirfrag_t df, const string& dname, const metareqid_t& ri) {
+  void add_dentry_authpin(dirfrag_t df, const nstring& dname, const metareqid_t& ri) {
     authpinned_dentries[df][dname] = ri;
   }
-  void add_dentry_xlock(dirfrag_t df, const string& dname, const metareqid_t& ri) {
+  void add_dentry_xlock(dirfrag_t df, const nstring& dname, const metareqid_t& ri) {
     xlocked_dentries[df][dname] = ri;
   }