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<nstring, Dentry*>::iterator it = in->dir->dentries.begin();
+ for (hash_map<string, Dentry*>::iterator it = in->dir->dentries.begin();
it != in->dir->dentries.end();
it++) {
dout(1) << " dn " << it->first << " ref " << it->second->ref << dendl;
class Dir {
public:
Inode *parent_inode; // my inode
- hash_map<nstring, Dentry*> dentries;
+ hash_map<string, Dentry*> dentries;
__u64 release_count;
Dir(Inode* in) : release_count(0) { parent_inode = in; }
#include "msg/SimpleMessenger.h"
#include "include/CompatSet.h"
-#include "include/nstring.h"
#include "common/Timer.h"
#include "common/common_init.h"
bufferlist magicbl;
store.get_bl_ss(magicbl, "magic", 0);
- nstring magic(magicbl.length()-1, magicbl.c_str()); // ignore trailing \n
+ string magic(magicbl.c_str(), magicbl.length()-1); // ignore trailing \n
if (strcmp(magic.c_str(), CEPH_MON_ONDISK_MAGIC)) {
cerr << "mon fs magic '" << magic << "' != current '" << CEPH_MON_ONDISK_MAGIC << "'" << std::endl;
exit(1);
return;
}
-void ClassHandler::load_class(const nstring& cname)
+void ClassHandler::load_class(const string& cname)
{
ClassData& cls = get_obj(cname);
if (&cls == &null_cls_data) {
cls.mutex->Unlock();
}
-ClassHandler::ClassData& ClassHandler::get_obj(const nstring& cname)
+ClassHandler::ClassData& ClassHandler::get_obj(const string& cname)
{
Mutex::Locker locker(mutex);
- map<nstring, ClassData>::iterator iter = classes.find(cname);
+ map<string, ClassData>::iterator iter = classes.find(cname);
if (iter == classes.end()) {
ClassData& cls = classes[cname];
cls.mutex = new Mutex("ClassData");
return iter->second;
}
-ClassHandler::ClassData *ClassHandler::get_class(const nstring& cname, ClassVersion& version)
+ClassHandler::ClassData *ClassHandler::get_class(const string& cname, ClassVersion& version)
{
ClassHandler::ClassData *ret = NULL;
ClassData *class_data = &get_obj(cname);
void ClassHandler::resend_class_requests()
{
- for (map<nstring,ClassData>::iterator p = classes.begin(); p != classes.end(); p++) {
+ for (map<string,ClassData>::iterator p = classes.begin(); p != classes.end(); p++) {
dout(20) << "resending class request "<< p->first.c_str() << " v" << p->second.version << dendl;
osd->send_class_request(p->first.c_str(), p->second.version);
}
dout(0) << "couldn't get class dep object, out of memory?" << dendl;
return false;
}
- map<nstring, ClassData *>::iterator iter = missing_dependencies.find(dep->name);
+ map<string, ClassData *>::iterator iter = missing_dependencies.find(dep->name);
dependencies[dep->name] = &cls_dep;
dout(0) << "adding dependency " << dep->name << dendl;
void ClassHandler::ClassData::satisfy_dependency(ClassData *cls)
{
Mutex::Locker lock(*mutex);
- map<nstring, ClassData *>::iterator iter = missing_dependencies.find(cls->name);
+ map<string, ClassData *>::iterator iter = missing_dependencies.find(cls->name);
if (iter != missing_dependencies.end()) {
dout(0) << "satisfied dependency name=" << name << " dep=" << cls->name << dendl;
ClassHandler::ClassMethod *ClassHandler::ClassData::get_method(const char *mname)
{
Mutex::Locker lock(*mutex);
- map<nstring, ClassHandler::ClassMethod>::iterator iter = methods_map.find(mname);
+ map<string, ClassHandler::ClassMethod>::iterator iter = methods_map.find(mname);
if (iter == methods_map.end())
return NULL;
void ClassHandler::ClassData::unregister_method(ClassHandler::ClassMethod *method)
{
/* no need for locking, called under the class_init mutex */
- map<nstring, ClassMethod>::iterator iter;
+ map<string, ClassMethod>::iterator iter;
iter = methods_map.find(method->name);
if (iter == methods_map.end())
return ret;
}
-int ClassHandler::get_method_flags(const nstring& cname, const nstring& mname)
+int ClassHandler::get_method_flags(const string& cname, const string& mname)
{
ClassData& cls = get_obj(cname);
if (&cls == &null_cls_data)
ClassVersion version;
time_t timeout;
ClassImpl impl;
- nstring name;
+ string name;
OSD *osd;
ClassHandler *handler;
void *handle;
bool registered;
- map<nstring, ClassMethod> methods_map;
+ map<string, ClassMethod> methods_map;
- map<nstring, ClassData *> dependencies; /* our dependencies */
- map<nstring, ClassData *> missing_dependencies; /* only missing dependencies */
+ map<string, ClassData *> dependencies; /* our dependencies */
+ map<string, ClassData *> missing_dependencies; /* only missing dependencies */
list<ClassData *> dependents; /* classes that depend on us */
bool has_missing_deps() { return (missing_dependencies.size() > 0); }
bool cache_timed_out();
};
Mutex mutex;
- map<nstring, ClassData> classes;
+ map<string, ClassData> classes;
- ClassData& get_obj(const nstring& cname);
+ ClassData& get_obj(const string& cname);
- void load_class(const nstring& cname);
+ void load_class(const string& cname);
void _load_class(ClassData &data);
ClassHandler(OSD *_osd) : osd(_osd), mutex("ClassHandler") {}
- ClassData *get_class(const nstring& cname, ClassVersion& version);
+ ClassData *get_class(const string& cname, ClassVersion& version);
void resend_class_requests();
void handle_class(MClass *m);
ClassData *register_class(const char *cname);
void unregister_class(ClassData *cls);
- int get_method_flags(const nstring& cname, const nstring& mname);
+ int get_method_flags(const string& cname, const string& mname);
};
exit(0);
}
- nstring magic;
+ string magic;
ceph_fsid_t fsid;
int w;
int r = OSD::peek_meta(g_conf.osd_data, magic, fsid, w);
{
ObjectStore::Transaction t;
t.create_collection(*p);
- map<nstring,bufferptr> attrs;
+ map<string,bufferptr> attrs;
src->collection_getattrs(*p, attrs);
t.collection_setattrs(*p, attrs);
dst->apply_transaction(t);
src->read(*p, *q, 0, 0, bl);
cout << "object " << j++ << "/" << numo << " " << *q << " = " << bl.length() << " bytes" << std::endl;
t.write(*p, *q, 0, bl.length(), bl);
- map<nstring,bufferptr> attrs;
+ map<string,bufferptr> attrs;
src->getattrs(*p, *q, attrs);
t.setattrs(*p, *q, attrs);
did_object[*q] = *p;
extent_t cnode_loc;
epoch_t last_alloc_epoch;
- map<nstring,bufferptr> attr;
+ map<string,bufferptr> attr;
public:
Cnode(coll_t cid) : ref(0), dirty(false), coll_id(cid), last_alloc_epoch(0) {
int get_attr_bytes() {
int s = 0;
- for (map<nstring, bufferptr>::iterator i = attr.begin();
+ for (map<string, bufferptr>::iterator i = attr.begin();
i != attr.end();
i++) {
s += i->first.length() + 1;
}
// attr
- for (map<nstring, bufferptr>::iterator i = on->attr.begin();
+ for (map<string, bufferptr>::iterator i = on->attr.begin();
i != on->attr.end();
i++) {
bl.copy_in(off, i->first.length()+1, i->first.c_str());
off += sizeof(ec);
// attr
- for (map<nstring, bufferptr>::iterator i = cn->attr.begin();
+ for (map<string, bufferptr>::iterator i = cn->attr.begin();
i != cn->attr.end();
i++) {
bl.copy_in(off, i->first.length()+1, i->first.c_str());
{
coll_t cid = t.get_cid();
pobject_t oid = t.get_oid();
- map<nstring,bufferptr>& attrset = t.get_attrset();
+ map<string,bufferptr>& attrset = t.get_attrset();
if (_setattrs(oid, attrset) < 0) {
dout(7) << "apply_transaction fail on _setattrs" << dendl;
r &= bit;
Onode *on = get_onode(oid);
if (!on) return -ENOENT;
- nstring n(name);
+ string n(name);
on->attr[n] = buffer::copy((char*)value, size);
dirty_onode(on);
put_onode(on);
return r;
}
-int Ebofs::_setattrs(pobject_t oid, map<nstring,bufferptr>& attrset)
+int Ebofs::_setattrs(pobject_t oid, map<string,bufferptr>& attrset)
{
dout(8) << "setattrs " << oid << dendl;
return 0;
}
-int Ebofs::setattrs(coll_t cid, pobject_t oid, map<nstring,bufferptr>& attrset, Context *onsafe)
+int Ebofs::setattrs(coll_t cid, pobject_t oid, map<string,bufferptr>& attrset, Context *onsafe)
{
ebofs_lock.Lock();
int r = _setattrs(oid, attrset);
return r;
}
-int Ebofs::getattrs(coll_t cid, pobject_t oid, map<nstring,bufferptr> &aset)
+int Ebofs::getattrs(coll_t cid, pobject_t oid, map<string,bufferptr> &aset)
{
ebofs_lock.Lock();
int r = _getattrs(oid, aset);
return r;
}
-int Ebofs::_getattrs(pobject_t oid, map<nstring,bufferptr> &aset)
+int Ebofs::_getattrs(pobject_t oid, map<string,bufferptr> &aset)
{
dout(8) << "_getattrs " << oid << dendl;
return r;
}
-int Ebofs::listattr(coll_t cid, pobject_t oid, vector<nstring>& attrs)
+int Ebofs::listattr(coll_t cid, pobject_t oid, vector<string>& attrs)
{
ebofs_lock.Lock();
dout(8) << "listattr " << oid << dendl;
}
attrs.clear();
- for (map<nstring,bufferptr>::iterator i = on->attr.begin();
+ for (map<string,bufferptr>::iterator i = on->attr.begin();
i != on->attr.end();
i++) {
attrs.push_back(i->first);
return r;
}
-int Ebofs::collection_getattrs(coll_t cid, map<nstring,bufferptr> &aset)
+int Ebofs::collection_getattrs(coll_t cid, map<string,bufferptr> &aset)
{
ebofs_lock.Lock();
int r = _collection_getattrs(cid, aset);
return r;
}
-int Ebofs::_collection_getattrs(coll_t cid, map<nstring,bufferptr> &aset)
+int Ebofs::_collection_getattrs(coll_t cid, map<string,bufferptr> &aset)
{
dout(8) << "_collection_getattrs " << cid << dendl;
return 0;
}
-int Ebofs::collection_setattrs(coll_t cid, map<nstring,bufferptr> &aset)
+int Ebofs::collection_setattrs(coll_t cid, map<string,bufferptr> &aset)
{
ebofs_lock.Lock();
int r = _collection_setattrs(cid, aset);
return r;
}
-int Ebofs::_collection_setattrs(coll_t cid, map<nstring,bufferptr> &aset)
+int Ebofs::_collection_setattrs(coll_t cid, map<string,bufferptr> &aset)
{
dout(8) << "_collection_setattrs " << cid << dendl;
return 0;
}
-int Ebofs::collection_listattr(coll_t cid, vector<nstring>& attrs)
+int Ebofs::collection_listattr(coll_t cid, vector<string>& attrs)
{
ebofs_lock.Lock();
dout(10) << "collection_listattr " << hex << cid << dec << dendl;
}
attrs.clear();
- for (map<nstring,bufferptr>::iterator i = cn->attr.begin();
+ for (map<string,bufferptr>::iterator i = cn->attr.begin();
i != cn->attr.end();
i++) {
attrs.push_back(i->first);
// object attr
int setattr(coll_t cid, pobject_t oid, const char *name, const void *value, size_t size, Context *onsafe=0);
- int setattrs(coll_t cid, pobject_t oid, map<nstring,bufferptr>& attrset, Context *onsafe=0);
+ int setattrs(coll_t cid, pobject_t oid, map<string,bufferptr>& attrset, Context *onsafe=0);
int getattr(coll_t cid, pobject_t oid, const char *name, void *value, size_t size);
int getattr(coll_t cid, pobject_t oid, const char *name, bufferptr& bp);
- int getattrs(coll_t cid, pobject_t oid, map<nstring,bufferptr> &aset);
+ int getattrs(coll_t cid, pobject_t oid, map<string,bufferptr> &aset);
int rmattr(coll_t cid, pobject_t oid, const char *name, Context *onsafe=0);
- int listattr(coll_t cid, pobject_t oid, vector<nstring>& attrs);
+ int listattr(coll_t cid, pobject_t oid, vector<string>& attrs);
int get_object_collections(coll_t cid, pobject_t oid, set<coll_t>& ls);
int collection_list(coll_t c, vector<pobject_t>& o);
int collection_setattr(coll_t cid, const char *name, const void *value, size_t size, Context *onsafe);
- int collection_setattrs(coll_t cid, map<nstring,bufferptr> &aset);
+ int collection_setattrs(coll_t cid, map<string,bufferptr> &aset);
int collection_getattr(coll_t cid, const char *name, void *value, size_t size);
int collection_getattr(coll_t cid, const char *name, bufferlist& bl);
- int collection_getattrs(coll_t cid, map<nstring,bufferptr> &aset);
+ int collection_getattrs(coll_t cid, map<string,bufferptr> &aset);
int collection_rmattr(coll_t cid, const char *name, Context *onsafe);
- int collection_listattr(coll_t oid, vector<nstring>& attrs);
+ int collection_listattr(coll_t oid, vector<string>& attrs);
// maps
int map_lookup(pobject_t o, bufferlist& key, bufferlist& val);
int _stat(pobject_t oid, struct stat *st);
int _getattr(pobject_t oid, const char *name, void *value, size_t size);
int _getattr(pobject_t oid, const char *name, bufferptr& bp);
- int _getattrs(pobject_t oid, map<nstring,bufferptr> &aset);
+ int _getattrs(pobject_t oid, map<string,bufferptr> &aset);
int _get_object_collections(pobject_t oid, set<coll_t>& ls);
bool _write_will_block();
int _clone(coll_t cid, pobject_t from, pobject_t to);
int _clone_range(coll_t cid, pobject_t from, pobject_t to, __u64 off, __u64 len);
int _setattr(pobject_t oid, const char *name, const void *value, size_t size);
- int _setattrs(pobject_t oid, map<nstring,bufferptr>& attrset);
+ int _setattrs(pobject_t oid, map<string,bufferptr>& attrset);
int _rmattr(pobject_t oid, const char *name);
bool _collection_exists(coll_t c);
int _collection_list(coll_t c, vector<pobject_t>& o);
int _destroy_collection(coll_t c);
int _collection_add(coll_t c, pobject_t o);
int _collection_remove(coll_t c, pobject_t o);
- int _collection_getattrs(coll_t oid, map<nstring,bufferptr> &aset);
+ int _collection_getattrs(coll_t oid, map<string,bufferptr> &aset);
int _collection_setattr(coll_t oid, const char *name, const void *value, size_t size);
- int _collection_setattrs(coll_t oid, map<nstring,bufferptr> &aset);
+ int _collection_setattrs(coll_t oid, map<string,bufferptr> &aset);
int _collection_rmattr(coll_t cid, const char *name);
#include "include/interval_set.h"
-#include "include/nstring.h"
-
/*
* object node (like an inode)
*
// onode
set<coll_t> collections;
- map<nstring, bufferptr> attr;
+ map<string, bufferptr> attr;
map<block_t, ExtentCsum> extent_map;
interval_set<__u64> bad_byte_extents;
}
int get_attr_bytes() {
int s = 0;
- for (map<nstring, bufferptr>::iterator i = attr.begin();
+ for (map<string, bufferptr>::iterator i = attr.begin();
i != attr.end();
i++) {
s += i->first.length() + 1;
p.copy(len, s);
}
+inline void encode_nohead(const std::string& s, bufferlist& bl)
+{
+ bl.append(s.data(), s.length());
+}
+inline void decode_nohead(int len, std::string& s, bufferlist::iterator& p)
+{
+ s.clear();
+ p.copy(len, s);
+}
+
// const char* (encode only, string compatible)
inline void encode(const char *s, bufferlist& bl)
{
}
}
-// deque
-template<class T>
-inline void encode(const std::deque<T>& ls, bufferlist& bl)
-{
- __u32 n = ls.size();
- encode(n, bl);
- for (typename std::deque<T>::const_iterator p = ls.begin(); p != ls.end(); ++p)
- encode(*p, bl);
-}
-template<class T>
-inline void decode(std::deque<T>& ls, bufferlist::iterator& p)
-{
- __u32 n;
- decode(n, p);
- ls.clear();
- while (n--) {
- T v;
- decode(v, p);
- ls.push_back(v);
- }
-}
-
// set
template<class T>
inline void encode(const std::set<T>& s, bufferlist& bl)
}
}
+// deque
+template<class T>
+inline void encode(const std::deque<T>& ls, bufferlist& bl)
+{
+ __u32 n = ls.size();
+ encode(n, bl);
+ for (typename std::deque<T>::const_iterator p = ls.begin(); p != ls.end(); ++p)
+ encode(*p, bl);
+}
+template<class T>
+inline void decode(std::deque<T>& ls, bufferlist::iterator& p)
+{
+ __u32 n;
+ decode(n, p);
+ ls.clear();
+ while (n--) {
+ T v;
+ decode(v, p);
+ ls.push_back(v);
+ }
+}
+
#endif
#include "buffer.h"
#include "encoding.h"
-#include "nstring.h"
class filepath {
inodeno_t ino; // base inode. ino=0 implies pure relative path.
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);
using namespace __gnu_cxx;
#include "hash.h"
-#include "nstring.h"
#include "encoding.h"
+#include "ceph_hash.h"
struct object_t {
- nstring name;
+ string name;
- object_t(const char *s = 0) : name(s) {}
+ object_t() {}
+ object_t(const char *s) : name(s) {}
object_t(const string& s) : name(s) {}
void swap(object_t& o) {
name.swap(o.name);
namespace __gnu_cxx {
template<> struct hash<object_t> {
size_t operator()(const object_t& r) const {
- //static hash<nstring> H;
+ //static hash<string> H;
//return H(r.name);
return ceph_str_hash_linux(r.name.c_str(), r.name.length());
}
lock.Lock();
ceph_object_layout layout = objecter->osdmap->make_object_layout(oid, pool.poolid);
- map<nstring, bufferlist> aset;
+ map<string, bufferlist> aset;
objecter->getxattrs(oid, layout, pool.snap_seq,
aset,
0, onack);
lock.Unlock();
attrset.clear();
- for (map<nstring,bufferlist>::iterator p = aset.begin(); p != aset.end(); p++)
+ for (map<string,bufferlist>::iterator p = aset.begin(); p != aset.end(); p++)
attrset[p->first.c_str()] = p->second;
mylock.Lock();
Anchor() : dn_hash(0), nref(0), updated(0) {}
Anchor(inodeno_t i, inodeno_t di, __u32 hash, int nr, version_t u) :
ino(i), dirino(di), dn_hash(hash), nref(nr), updated(u) { }
- Anchor(inodeno_t i, inodeno_t di, const nstring &dname, int nr, version_t u) :
+ Anchor(inodeno_t i, inodeno_t di, const string &dname, int nr, version_t u) :
ino(i), dirino(di),
dn_hash(ceph_str_hash_linux(dname.data(), dname.length())),
nref(nr), updated(u) { }
#include "include/lru.h"
#include "include/elist.h"
#include "include/filepath.h"
-#include "include/nstring.h"
#include "mdstypes.h"
#include "SimpleLock.h"
}
public:
- nstring name;
+ string name;
snapid_t first, last;
dentry_key_t key() {
public:
// cons
- CDentry(const nstring& n,
+ CDentry(const string& n,
snapid_t f, snapid_t l) :
name(n),
first(f), last(l),
g_num_dn++;
g_num_dna++;
}
- CDentry(const nstring& n, inodeno_t ino, unsigned char dt,
+ CDentry(const string& n, inodeno_t ino, unsigned char dt,
snapid_t f, snapid_t l) :
name(n),
first(f), last(l),
CDir *get_dir() const { return dir; }
- const nstring& get_name() const { return name; }
+ const string& get_name() const { return name; }
/*
CInode *get_inode() const { return linkage.inode; }
* linking fun
*/
-CDentry* CDir::add_null_dentry(const nstring& dname,
+CDentry* CDir::add_null_dentry(const string& dname,
snapid_t first, snapid_t last)
{
// foreign
}
-CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in,
+CDentry* CDir::add_primary_dentry(const string& dname, CInode *in,
snapid_t first, snapid_t last)
{
// primary
return dn;
}
-CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type,
+CDentry* CDir::add_remote_dentry(const string& dname, inodeno_t ino, unsigned char d_type,
snapid_t first, snapid_t last)
{
// foreign
* WAITING
*/
-void CDir::add_dentry_waiter(const nstring& dname, snapid_t snapid, Context *c)
+void CDir::add_dentry_waiter(const string& dname, snapid_t snapid, Context *c)
{
if (waiting_on_dentry.empty())
get(PIN_DNWAITER);
<< " " << c << " on " << *this << dendl;
}
-void CDir::take_dentry_waiting(const nstring& dname, snapid_t first, snapid_t last,
+void CDir::take_dentry_waiting(const string& dname, snapid_t first, snapid_t last,
list<Context*>& ls)
{
if (waiting_on_dentry.empty())
map<string_snap_t, list<Context*> >::iterator it =
waiting_on_dentry.begin();
while (it != waiting_on_dentry.end()) {
- nstring name = it->first.name;
+ string name = it->first.name;
snapid_t snap = it->first.snapid;
it++;
take_dentry_waiting(name, snap, snap, ls);
loff_t dn_offset = p.get_off() - baseoff;
// dname
- nstring dname;
+ string dname;
snapid_t first, last;
dentry_key_t::decode_helper(p, dname, last);
// -- dentries and inodes --
public:
- CDentry* lookup_exact_snap(const nstring& dname, snapid_t last) {
+ CDentry* lookup_exact_snap(const string& dname, snapid_t last) {
map_t::iterator p = items.find(dentry_key_t(last, dname.c_str()));
if (p == items.end())
return NULL;
CDentry* lookup(const string& n, snapid_t snap=CEPH_NOSNAP) {
return lookup(n.c_str(), snap);
}
- CDentry* lookup(const nstring& ns, snapid_t snap=CEPH_NOSNAP) {
- return lookup(ns.c_str(), snap);
- }
CDentry* lookup(const char *n, snapid_t snap=CEPH_NOSNAP);
- CDentry* add_null_dentry(const nstring& dname,
+ CDentry* add_null_dentry(const string& dname,
snapid_t first=2, snapid_t last=CEPH_NOSNAP);
- CDentry* add_primary_dentry(const nstring& dname, CInode *in,
+ CDentry* add_primary_dentry(const string& dname, CInode *in,
snapid_t first=2, snapid_t last=CEPH_NOSNAP);
- CDentry* add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type,
+ CDentry* add_remote_dentry(const string& dname, inodeno_t ino, unsigned char d_type,
snapid_t first=2, snapid_t last=CEPH_NOSNAP);
void remove_dentry( CDentry *dn ); // delete dentry
void link_remote_inode( CDentry *dn, inodeno_t ino, unsigned char d_type);
bool is_waiting_for_dentry(const char *dname, snapid_t snap) {
return waiting_on_dentry.count(string_snap_t(dname, snap));
}
- void add_dentry_waiter(const nstring& dentry, snapid_t snap, Context *c);
- void take_dentry_waiting(const nstring& dentry, snapid_t first, snapid_t last, list<Context*>& ls);
+ void add_dentry_waiter(const string& dentry, snapid_t snap, Context *c);
+ void take_dentry_waiting(const string& dentry, snapid_t first, snapid_t last, list<Context*>& ls);
bool is_waiting_for_ino(inodeno_t ino) {
return waiting_on_ino.count(ino);
// dirfrags
-frag_t CInode::pick_dirfrag(const nstring& dn)
+frag_t CInode::pick_dirfrag(const string& dn)
{
if (dirfragtree.empty())
return frag_t(); // avoid the string hash if we can.
assert(is_base());
bufferlist bl;
- nstring magic = CEPH_FS_ONDISK_MAGIC;
+ string magic = CEPH_FS_ONDISK_MAGIC;
::encode(magic, bl);
encode_store(bl);
{
dout(10) << "_fetched" << dendl;
bufferlist::iterator p = bl.begin();
- nstring magic;
+ string magic;
::decode(magic, p);
dout(10) << " magic is '" << magic << "' (expecting '" << CEPH_FS_ONDISK_MAGIC << "')" << dendl;
if (magic != CEPH_FS_ONDISK_MAGIC) {
int stickydir_ref;
public:
- frag_t pick_dirfrag(const nstring &dn);
+ frag_t pick_dirfrag(const string &dn);
bool has_dirfrags() { return !dirfrags.empty(); }
CDir* get_dirfrag(frag_t fg) {
if (dirfrags.count(fg)) {
void Locker::process_cap_update(MDRequest *mdr, client_t client,
inodeno_t ino, __u64 cap_id, int caps, int wanted,
int seq, int issue_seq, int mseq,
- const nstring& dname)
+ const string& dname)
{
CInode *in = mdcache->get_inode(ino);
if (!in)
void process_cap_update(MDRequest *mdr, client_t client,
inodeno_t ino, __u64 cap_id, int caps, int wanted,
int seq, int issue_seq, int mseq,
- const nstring& dname);
+ const string& dname);
void kick_cap_releases(MDRequest *mdr);
protected:
// stray dir
CInode *stray = create_system_inode(MDS_INO_STRAY(mds->whoami), S_IFDIR);
CDir *straydir = stray->get_or_open_dirfrag(this, frag_t());
- nstring name("stray");
+ string name("stray");
mydir->add_primary_dentry(name, stray);
stray->inode.dirstat = straydir->fnode.fragstat;
stray->inode.accounted_rstat = stray->inode.rstat;
}
// open or create stray
- nstring strayname("stray");
+ string strayname("stray");
CDentry *straydn = mydir->lookup(strayname);
if (!straydn || !straydn->get_linkage()->get_inode()) {
_create_system_file(mydir, strayname.c_str(), create_system_inode(MDS_INO_STRAY(mds->whoami), S_IFDIR),
assert(stray);
// open or create journal file
- nstring jname("journal");
+ string jname("journal");
CDentry *jdn = mydir->lookup(jname);
if (!jdn || !jdn->get_linkage()->get_inode()) {
_create_system_file(mydir, jname.c_str(), create_system_inode(MDS_INO_LOG_OFFSET + mds->whoami, S_IFREG),
}
// DENTRIES
- for (map<dirfrag_t, map<pair<nstring,snapid_t>,int> >::iterator pd = p->second.dentries.begin();
+ for (map<dirfrag_t, map<pair<string,snapid_t>,int> >::iterator pd = p->second.dentries.begin();
pd != p->second.dentries.end();
++pd) {
dout(10) << " dn expires in dir " << pd->first << dendl;
assert(dir->is_auth());
}
- for (map<pair<nstring,snapid_t>,int>::iterator p = pd->second.begin();
+ for (map<pair<string,snapid_t>,int>::iterator p = pd->second.begin();
p != pd->second.end();
++p) {
int nonce = p->second;
CDentry *MDCache::add_replica_dentry(bufferlist::iterator& p, CDir *dir, list<Context*>& finished)
{
- nstring name;
+ string name;
snapid_t last;
::decode(name, p);
::decode(last, p);
snapid_t snapid = mdr->snapid;
- nstring offset_str = req->get_path2();
+ string offset_str = req->get_path2();
const char *offset = offset_str.length() ? offset_str.c_str() : 0;
dout(10) << "snapid " << snapid << " offset '" << offset_str << "'" << dendl;
#include <stdlib.h>
-#include "include/nstring.h"
-
#include "../CInode.h"
#include "../CDir.h"
#include "../CDentry.h"
/* fullbit - a regular dentry + inode
*/
struct fullbit {
- nstring dn; // dentry
+ string dn; // dentry
snapid_t dnfirst, dnlast;
version_t dnv;
inode_t inode; // if it's not
bufferlist _enc;
- fullbit(const nstring& d, snapid_t df, snapid_t dl,
+ fullbit(const string& d, snapid_t df, snapid_t dl,
version_t v, inode_t& i, fragtree_t &dft,
map<string,bufferptr> &xa, const string& sym, bufferlist &sbl, bool dr) :
//dn(d), dnfirst(df), dnlast(dl), dnv(v),
/* remotebit - a dentry + remote inode link (i.e. just an ino)
*/
struct remotebit {
- nstring dn;
+ string dn;
snapid_t dnfirst, dnlast;
version_t dnv;
inodeno_t ino;
bufferlist _enc;
- remotebit(const nstring& d, snapid_t df, snapid_t dl, version_t v, inodeno_t i, unsigned char dt, bool dr) :
+ remotebit(const string& d, snapid_t df, snapid_t dl, version_t v, inodeno_t i, unsigned char dt, bool dr) :
//dn(d), dnfirst(df), dnlast(dl), dnv(v), ino(i), d_type(dt), dirty(dr) { }
_enc(256) {
::encode(d, _enc);
* nullbit - a null dentry
*/
struct nullbit {
- nstring dn;
+ string dn;
snapid_t dnfirst, dnlast;
version_t dnv;
bool dirty;
bufferlist _enc;
- nullbit(const nstring& d, snapid_t df, snapid_t dl, version_t v, bool dr) :
+ nullbit(const string& d, snapid_t df, snapid_t dl, version_t v, bool dr) :
//dn(d), dnfirst(df), dnlast(dl), dnv(v), dirty(dr) { }
_enc(128) {
::encode(d, _enc);
else
in->encode_snap_blob(snapbl);
- nstring empty;
+ string empty;
delete root;
root = new fullbit(empty,
in->first, in->last,
utime_t dirfrag_old_mtime;
utime_t dirfrag_old_rctime;
inodeno_t ino, remote_ino;
- nstring dname;
+ string dname;
char remote_d_type;
utime_t old_ctime;
#include "include/frag.h"
#include "include/xlist.h"
-#include "include/nstring.h"
#include <boost/pool/pool.hpp>
bl.append("_", 1);
bl.append(b);
}
- static void decode_helper(bufferlist::iterator& bl, nstring& nm, snapid_t& sn) {
- nstring foo;
+ static void decode_helper(bufferlist::iterator& bl, string& nm, snapid_t& sn) {
+ string foo;
::decode(foo, bl);
int i = foo.length()-1;
while (foo[i] != '_' && i)
i--;
assert(i);
- if (i+5 == foo.length() &&
+ if (i+5 == (int)foo.length() &&
foo[i+1] == 'h' &&
foo[i+2] == 'e' &&
foo[i+3] == 'a' &&
sscanf(foo.c_str() + i + 1, "%llx", &x);
sn = x;
}
- nm = nstring(i, foo.c_str());
+ nm = string(foo.c_str(), i);
}
};
/*
- * string_snap_t is a simple (nstring, snapid_t) pair
+ * string_snap_t is a simple (string, snapid_t) pair
*/
struct string_snap_t {
- nstring name;
+ string name;
snapid_t snapid;
string_snap_t() {}
string_snap_t(const string& n, snapid_t s) : name(n), snapid(s) {}
- string_snap_t(const nstring& n, snapid_t s) : name(n), snapid(s) {}
string_snap_t(const char *n, snapid_t s) : name(n), snapid(s) {}
void encode(bufferlist& bl) const {
__u8 struct_v = 1;
public:
inodeno_t ino;
dirfrag_t dirfrag;
- nstring dname;
+ string dname;
snapid_t snapid;
MDSCacheObjectInfo() : ino(0) {}
__u32 protocol;
__s32 result;
__u64 global_id; // if zero, meaningless
- cstring result_msg;
+ string result_msg;
bufferlist result_bl;
MAuthReply() : Message(CEPH_MSG_AUTH_REPLY), protocol(0), result(0) {}
- MAuthReply(__u32 p, bufferlist *bl = NULL, int r = 0, __u64 gid=0, const char *msg = 0) :
+ MAuthReply(__u32 p, bufferlist *bl = NULL, int r = 0, __u64 gid=0, const char *msg = "") :
Message(CEPH_MSG_AUTH_REPLY),
protocol(p), result(r), global_id(gid),
result_msg(msg) {
struct realm {
map<vinodeno_t, __s32> inodes;
map<dirfrag_t, __s32> dirs;
- map<dirfrag_t, map<pair<nstring,snapid_t>,__s32> > dentries;
+ map<dirfrag_t, map<pair<string,snapid_t>,__s32> > dentries;
void encode(bufferlist &bl) const {
::encode(inodes, bl);
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 nstring& dn, snapid_t last, int nonce) {
- realms[r].dentries[df][pair<nstring,snapid_t>(dn,last)] = nonce;
+ void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, snapid_t last, int nonce) {
+ realms[r].dentries[df][pair<string,snapid_t>(dn,last)] = nonce;
}
void add_realm(dirfrag_t df, realm& r) {
struct MClientLease : public Message {
struct ceph_mds_lease h;
- nstring dname;
+ string dname;
int get_action() { return h.action; }
ceph_seq_t get_seq() { return h.seq; }
h.first = sf;
h.last = sl;
}
- MClientLease(int ac, ceph_seq_t seq, int m, __u64 i, __u64 sf, __u64 sl, const nstring& d) :
+ MClientLease(int ac, ceph_seq_t seq, int m, __u64 i, __u64 sf, __u64 sl, const string& d) :
Message(CEPH_MSG_CLIENT_LEASE),
dname(d) {
h.action = ac;
struct Release {
mutable ceph_mds_request_release item;
- nstring dname;
+ string dname;
Release() : item(), dname() {}
- Release(const ceph_mds_request_release& rel, nstring name) :
+ Release(const ceph_mds_request_release& rel, string name) :
item(rel), dname(name) {}
void encode(bufferlist& bl) const {
class MDentryLink : public Message {
dirfrag_t dirfrag;
- nstring dn;
+ string dn;
bool is_primary;
public:
dirfrag_t get_dirfrag() { return dirfrag; }
- nstring& get_dn() { return dn; }
+ string& get_dn() { return dn; }
bool get_is_primary() { return is_primary; }
bufferlist bl;
MDentryLink() :
Message(MSG_MDS_DENTRYLINK) { }
- MDentryLink(dirfrag_t df, nstring& n, bool p) :
+ MDentryLink(dirfrag_t df, string& n, bool p) :
Message(MSG_MDS_DENTRYLINK),
dirfrag(df),
dn(n),
class MDentryUnlink : public Message {
dirfrag_t dirfrag;
- nstring dn;
+ string dn;
public:
dirfrag_t get_dirfrag() { return dirfrag; }
- nstring& get_dn() { return dn; }
+ string& get_dn() { return dn; }
bufferlist straybl;
MDentryUnlink() :
Message(MSG_MDS_DENTRYUNLINK) { }
- MDentryUnlink(dirfrag_t df, nstring& n) :
+ MDentryUnlink(dirfrag_t df, string& n) :
Message(MSG_MDS_DENTRYUNLINK),
dirfrag(df),
dn(n) {}
void add_weak_primary_dentry(dirfrag_t df, const string& dname, snapid_t first, snapid_t last, inodeno_t ino) {
weak[df][string_snap_t(dname, last)] = dn_weak(first, ino);
}
- void add_strong_dentry(dirfrag_t df, const nstring& dname, snapid_t first, snapid_t last, inodeno_t pi, inodeno_t ri, unsigned char rdt, int n, int ls) {
+ void add_strong_dentry(dirfrag_t df, const string& dname, snapid_t first, snapid_t last, inodeno_t pi, inodeno_t ri, unsigned char rdt, int n, int ls) {
strong_dentries[df][string_snap_t(dname, last)] = dn_strong(first, pi, ri, rdt, n, ls);
}
- void add_dentry_authpin(dirfrag_t df, const nstring& dname, snapid_t last, const metareqid_t& ri) {
+ void add_dentry_authpin(dirfrag_t df, const string& dname, snapid_t last, const metareqid_t& ri) {
authpinned_dentries[df][string_snap_t(dname, last)] = ri;
}
- void add_dentry_xlock(dirfrag_t df, const nstring& dname, snapid_t last, const metareqid_t& ri) {
+ void add_dentry_xlock(dirfrag_t df, const string& dname, snapid_t last, const metareqid_t& ri) {
xlocked_dentries[df][string_snap_t(dname, last)] = ri;
}
#include "msg/Message.h"
struct MMonSubscribe : public Message {
- map<nstring, ceph_mon_subscribe_item> what;
+ map<string, ceph_mon_subscribe_item> what;
MMonSubscribe() : Message(CEPH_MSG_MON_SUBSCRIBE) {}
private:
eversion_t pg_trim_to; // primary->replica: trim to here
osd_peer_stat_t peer_stat;
- map<nstring,bufferptr> attrset;
+ map<string,bufferptr> attrset;
interval_set<__u64> data_subset;
map<sobject_t, interval_set<__u64> > clone_subsets;
void MDSMonitor::check_subs()
{
- nstring type = "mdsmap";
+ string type = "mdsmap";
xlist<Subscription*>::iterator p = mon->session_map.subs[type].begin();
while (!p.end()) {
Subscription *sub = *p;
#include "messages/MAuth.h"
#include "messages/MAuthReply.h"
-#include "include/nstring.h"
-
#include "messages/MMonSubscribe.h"
#include "messages/MMonSubscribeAck.h"
#include "common/ConfUtils.h"
// mon subscriptions
private:
- map<nstring,ceph_mon_subscribe_item> sub_have; // my subs, and current versions
+ map<string,ceph_mon_subscribe_item> sub_have; // my subs, and current versions
utime_t sub_renew_sent, sub_renew_after;
void _renew_subs();
void handle_subscribe_ack(MMonSubscribeAck* m);
- void _sub_want(nstring what, version_t have) {
+ void _sub_want(string what, version_t have) {
sub_have[what].have = have;
sub_have[what].onetime = false;
}
- bool _sub_want_onetime(nstring what, version_t have) {
+ bool _sub_want_onetime(string what, version_t have) {
if (sub_have.count(what) == 0) {
sub_have[what].have = have;
sub_have[what].onetime = true;
sub_have[what].have = have;
return false;
}
- void _sub_got(nstring what, version_t have) {
+ void _sub_got(string what, version_t have) {
if (sub_have.count(what)) {
if (sub_have[what].onetime)
sub_have.erase(what);
Mutex::Locker l(monc_lock);
_renew_subs();
}
- void sub_want(nstring what, version_t have) {
+ void sub_want(string what, version_t have) {
Mutex::Locker l(monc_lock);
_sub_want(what, have);
}
- bool sub_want_onetime(nstring what, version_t have) {
+ bool sub_want_onetime(string what, version_t have) {
Mutex::Locker l(monc_lock);
return _sub_want_onetime(what, have);
}
- void sub_got(nstring what, version_t have) {
+ void sub_got(string what, version_t have) {
Mutex::Locker l(monc_lock);
_sub_got(what, have);
}
for (vector<Paxos*>::iterator p = paxos.begin(); p != paxos.end(); p++)
delete *p;
//clean out MonSessionMap's subscriptions
- for (map<nstring, xlist<Subscription*> >::iterator i
+ for (map<string, xlist<Subscription*> >::iterator i
= session_map.subs.begin();
i != session_map.subs.end();
++i) {
s->until = g_clock.now();
s->until += g_conf.mon_subscribe_interval;
- for (map<nstring,ceph_mon_subscribe_item>::iterator p = m->what.begin();
+ for (map<string,ceph_mon_subscribe_item>::iterator p = m->what.begin();
p != m->what.end();
p++) {
if (!p->second.onetime)
void Monitor::check_subs()
{
- nstring type = "monmap";
+ string type = "monmap";
xlist<Subscription*>::iterator p = session_map.subs[type].begin();
while (!p.end()) {
Subscription *sub = *p;
void OSDMonitor::check_subs()
{
- nstring type = "osdmap";
+ string type = "osdmap";
xlist<Subscription*>::iterator p = mon->session_map.subs[type].begin();
while (!p.end()) {
Subscription *sub = *p;
struct Subscription {
MonSession *session;
- nstring type;
+ string type;
xlist<Subscription*>::item type_item;
version_t last;
bool onetime;
- Subscription(MonSession *s, const nstring& t) : session(s), type(t), type_item(this) {};
+ Subscription(MonSession *s, const string& t) : session(s), type(t), type_item(this) {};
};
struct MonSession : public RefCountedObject {
uint64_t global_id;
uint64_t notified_global_id;
- map<nstring, Subscription*> sub_map;
+ map<string, Subscription*> sub_map;
AuthServiceHandler *auth_handler;
struct MonSessionMap {
xlist<MonSession*> sessions;
- map<nstring, xlist<Subscription*> > subs;
+ map<string, xlist<Subscription*> > subs;
multimap<int, MonSession*> by_osd;
void remove_session(MonSession *s) {
assert(!s->closed);
- for (map<nstring,Subscription*>::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p)
+ for (map<string,Subscription*>::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p)
p->second->type_item.remove_myself();
s->sub_map.clear();
s->item.remove_myself();
}
- void add_update_sub(MonSession *s, const nstring& what, version_t have, bool onetime) {
+ void add_update_sub(MonSession *s, const string& what, version_t have, bool onetime) {
Subscription *sub = 0;
if (s->sub_map.count(what)) {
sub = s->sub_map[what];
class FakeAttrSet {
public:
- map<nstring, bufferptr> attrs;
+ map<string, bufferptr> attrs;
int getattr(const char *name, void *value, size_t size) {
string n = name;
}
return -1;
}
- int getattrs(map<nstring,bufferptr>& aset) {
+ int getattrs(map<string,bufferptr>& aset) {
aset = attrs;
return 0;
}
- int setattrs(map<nstring,bufferptr>& aset) {
+ int setattrs(map<string,bufferptr>& aset) {
attrs = aset;
return 0;
}
faker_lock.Unlock();
return r;
}
- int setattrs(coll_t cid, sobject_t oid, map<nstring,bufferptr>& aset) {
+ int setattrs(coll_t cid, sobject_t oid, map<string,bufferptr>& aset) {
faker_lock.Lock();
int r = fakeoattrs[oid].setattrs(aset);
faker_lock.Unlock();
faker_lock.Unlock();
return r;
}
- int getattrs(coll_t cid, sobject_t oid, map<nstring,bufferptr>& aset) {
+ int getattrs(coll_t cid, sobject_t oid, map<string,bufferptr>& aset) {
faker_lock.Lock();
int r = fakeoattrs[oid].getattrs(aset);
faker_lock.Unlock();
faker_lock.Unlock();
return r;
}
- int collection_setattrs(coll_t cid, map<nstring,bufferptr>& aset) {
+ int collection_setattrs(coll_t cid, map<string,bufferptr>& aset) {
faker_lock.Lock();
int r = fakecattrs[cid].setattrs(aset);
faker_lock.Unlock();
return r;
}
- int collection_getattrs(coll_t cid, map<nstring,bufferptr>& aset) {
+ int collection_getattrs(coll_t cid, map<string,bufferptr>& aset) {
faker_lock.Lock();
int r = fakecattrs[cid].getattrs(aset);
faker_lock.Unlock();
char *t = s + strlen(s);
*t++ = '/';
- char *i = oid.oid.name.c_str();
+ const char *i = oid.oid.name.c_str();
while (*i) {
if (*i == '\\') {
*t++ = '\\';
i++;
}
*t = 0;
- o.oid.name = nstring(t-buf, buf);
+ o.oid.name = string(buf, t-buf);
if (strcmp(bar+1, "head") == 0)
o.snap = CEPH_NOSNAP;
else if (strcmp(bar+1, "snapdir") == 0)
{
coll_t cid = t.get_cid();
sobject_t oid = t.get_oid();
- map<nstring, bufferptr> aset;
+ map<string, bufferptr> aset;
t.get_attrset(aset);
_setattrs(cid, oid, aset);
}
return l;
}
-int FileStore::_getattrs(const char *fn, map<nstring,bufferptr>& aset, bool user_only)
+int FileStore::_getattrs(const char *fn, map<string,bufferptr>& aset, bool user_only)
{
// get attr list
char names1[100];
return r;
}
-int FileStore::getattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr>& aset, bool user_only)
+int FileStore::getattrs(coll_t cid, const sobject_t& oid, map<string,bufferptr>& aset, bool user_only)
{
if (fake_attrs) return attrs.getattrs(cid, oid, aset);
return r;
}
-int FileStore::_setattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr>& aset)
+int FileStore::_setattrs(coll_t cid, const sobject_t& oid, map<string,bufferptr>& aset)
{
if (fake_attrs) return attrs.setattrs(cid, oid, aset);
get_coname(cid, oid, fn, sizeof(fn));
dout(15) << "setattrs " << fn << dendl;
int r = 0;
- for (map<nstring,bufferptr>::iterator p = aset.begin();
+ for (map<string,bufferptr>::iterator p = aset.begin();
p != aset.end();
++p) {
char n[ATTR_MAX];
dout(15) << "rmattrs " << fn << dendl;
- map<nstring,bufferptr> aset;
+ map<string,bufferptr> aset;
int r = _getattrs(fn, aset);
if (r >= 0) {
- for (map<nstring,bufferptr>::iterator p = aset.begin(); p != aset.end(); p++) {
+ for (map<string,bufferptr>::iterator p = aset.begin(); p != aset.end(); p++) {
char n[ATTR_MAX];
get_attrname(p->first.c_str(), n, ATTR_MAX);
r = do_removexattr(fn, n);
return r;
}
-int FileStore::collection_getattrs(coll_t cid, map<nstring,bufferptr>& aset)
+int FileStore::collection_getattrs(coll_t cid, map<string,bufferptr>& aset)
{
if (fake_attrs) return attrs.collection_getattrs(cid, aset);
}
-int FileStore::_collection_setattrs(coll_t cid, map<nstring,bufferptr>& aset)
+int FileStore::_collection_setattrs(coll_t cid, map<string,bufferptr>& aset)
{
if (fake_attrs) return attrs.collection_setattrs(cid, aset);
get_cdir(cid, fn, sizeof(fn));
dout(15) << "collection_setattrs " << fn << dendl;
int r = 0;
- for (map<nstring,bufferptr>::iterator p = aset.begin();
+ for (map<string,bufferptr>::iterator p = aset.begin();
p != aset.end();
++p) {
char n[PATH_MAX];
// attrs
int getattr(coll_t cid, const sobject_t& oid, const char *name, void *value, size_t size);
int getattr(coll_t cid, const sobject_t& oid, const char *name, bufferptr &bp);
- int getattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr>& aset, bool user_only = false);
+ int getattrs(coll_t cid, const sobject_t& oid, map<string,bufferptr>& aset, bool user_only = false);
int _getattr(const char *fn, const char *name, bufferptr& bp);
- int _getattrs(const char *fn, map<nstring,bufferptr>& aset, bool user_only = false);
+ int _getattrs(const char *fn, map<string,bufferptr>& aset, bool user_only = false);
int _setattr(coll_t cid, const sobject_t& oid, const char *name, const void *value, size_t size);
- int _setattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr>& aset);
+ int _setattrs(coll_t cid, const sobject_t& oid, map<string,bufferptr>& aset);
int _rmattr(coll_t cid, const sobject_t& oid, const char *name);
int _rmattrs(coll_t cid, const sobject_t& oid);
int collection_getattr(coll_t c, const char *name, void *value, size_t size);
int collection_getattr(coll_t c, const char *name, bufferlist& bl);
- int collection_getattrs(coll_t cid, map<nstring,bufferptr> &aset);
+ int collection_getattrs(coll_t cid, map<string,bufferptr> &aset);
int _collection_setattr(coll_t c, const char *name, const void *value, size_t size);
int _collection_rmattr(coll_t c, const char *name);
- int _collection_setattrs(coll_t cid, map<nstring,bufferptr> &aset);
+ int _collection_setattrs(coll_t cid, map<string,bufferptr> &aset);
// collections
int list_collections(vector<coll_t>& ls);
#include "include/types.h"
#include "include/Context.h"
#include "include/buffer.h"
-#include "include/nstring.h"
#include "include/Distribution.h"
#include <vector>
using std::vector;
+using std::string;
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a):(b))
// for these guys, just use a pointer.
// but, decode to a full value, and create pointers to that.
//vector<const char*> attrnames;
- vector<nstring> attrnames;
- vector<map<nstring,bufferptr> > attrsets;
+ vector<string> attrnames;
+ deque<map<std::string,bufferptr> > attrsets;
unsigned opp, blp, oidp, cidp, lengthp, attrnamep, attrsetp;
::decode(s, p);
return s;
}
- void get_attrset(map<nstring,bufferptr>& aset) {
+ void get_attrset(map<string,bufferptr>& aset) {
if (old) {
aset = attrsets[attrsetp++];
return;
ops++;
}
void setattr(coll_t cid, const sobject_t& oid, const char* name, const void* val, int len) {
- nstring n(name);
+ string n(name);
bufferlist bl;
bl.append((char*)val, len);
setattr(cid, oid, n, tbl);
}
void setattr(coll_t cid, const sobject_t& oid, const char* name, bufferlist& val) {
- nstring n(name);
+ string n(name);
setattr(cid, oid, n, val);
}
- void setattr(coll_t cid, const sobject_t& oid, nstring& s, bufferlist& val) {
+ void setattr(coll_t cid, const sobject_t& oid, string& s, bufferlist& val) {
__u32 op = OP_SETATTR;
::encode(op, tbl);
::encode(cid, tbl);
::encode(val, tbl);
ops++;
}
- void setattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr>& attrset) {
+ void setattrs(coll_t cid, const sobject_t& oid, map<string,bufferptr>& attrset) {
__u32 op = OP_SETATTRS;
::encode(op, tbl);
::encode(cid, tbl);
ops++;
}
void rmattr(coll_t cid, const sobject_t& oid, const char *name) {
- nstring n(name);
+ string n(name);
rmattr(cid, oid, n);
}
- void rmattr(coll_t cid, const sobject_t& oid, nstring& s) {
+ void rmattr(coll_t cid, const sobject_t& oid, string& s) {
__u32 op = OP_RMATTR;
::encode(op, tbl);
::encode(cid, tbl);
collection_setattr(cid, name, tbl);
}
void collection_setattr(coll_t cid, const char* name, bufferlist& val) {
- nstring n(name);
+ string n(name);
collection_setattr(cid, n, val);
}
- void collection_setattr(coll_t cid, nstring& name, bufferlist& val) {
+ void collection_setattr(coll_t cid, string& name, bufferlist& val) {
__u32 op = OP_COLL_SETATTR;
::encode(op, tbl);
::encode(cid, tbl);
}
void collection_rmattr(coll_t cid, const char* name) {
- nstring n(name);
+ string n(name);
collection_rmattr(cid, n);
}
- void collection_rmattr(coll_t cid, nstring& name) {
+ void collection_rmattr(coll_t cid, string& name) {
__u32 op = OP_COLL_RMATTR;
::encode(op, tbl);
::encode(cid, tbl);
::encode(name, tbl);
ops++;
}
- void collection_setattrs(coll_t cid, map<nstring,bufferptr>& aset) {
+ void collection_setattrs(coll_t cid, map<string,bufferptr>& aset) {
__u32 op = OP_COLL_SETATTRS;
::encode(op, tbl);
::encode(cid, tbl);
::decode(cids, bl);
::decode(lengths, bl);
::decode(attrnames, bl);
- /*for (vector<nstring>::iterator p = attrnames2.begin();
+ /*for (vector<string>::iterator p = attrnames2.begin();
p != attrnames2.end();
++p)
attrnames.push_back((*p).c_str());*/
value.push_back(bp);
return r;
}
- virtual int getattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr>& aset, bool user_only = false) {return 0;};
+ virtual int getattrs(coll_t cid, const sobject_t& oid, map<string,bufferptr>& aset, bool user_only = false) {return 0;};
/*
virtual int _setattr(coll_t cid, sobject_t oid, const char *name, const void *value, size_t size) = 0;
virtual int collection_getattr(coll_t cid, const char *name,
void *value, size_t size) = 0;
virtual int collection_getattr(coll_t cid, const char *name, bufferlist& bl) = 0;
- virtual int collection_getattrs(coll_t cid, map<nstring,bufferptr> &aset) = 0;
+ virtual int collection_getattrs(coll_t cid, map<string,bufferptr> &aset) = 0;
virtual bool collection_empty(coll_t c) = 0;
virtual int collection_list_partial(coll_t c, snapid_t seq, vector<sobject_t>& o, int count, collection_list_handle_t *handle) = 0;
virtual int collection_list(coll_t c, vector<sobject_t>& o) = 0;
return 0;
}
-int OSD::peek_meta(const char *dev, nstring& magic, ceph_fsid_t& fsid, int& whoami)
+int OSD::peek_meta(const char *dev, string& magic, ceph_fsid_t& fsid, int& whoami)
{
char val[80] = { 0 };
// --------------------------------
-int OSD::get_class(const nstring& cname, ClassVersion& version, pg_t pgid, Message *m, ClassHandler::ClassData **cls)
+int OSD::get_class(const string& cname, ClassVersion& version, pg_t pgid, Message *m, ClassHandler::ClassData **cls)
{
Mutex::Locker l(class_lock);
dout(10) << "wait_for_missing_class '" << cname << "' by " << pgid << dendl;
return -EAGAIN;
}
-void OSD::got_class(const nstring& cname)
+void OSD::got_class(const string& cname)
{
// no lock.. this is an upcall from handle_class
dout(10) << "got_class '" << cname << "'" << dendl;
protected:
// -- classes --
Mutex class_lock;
- map<nstring, map<pg_t, list<Message*> > > waiting_for_missing_class;
+ map<string, map<pg_t, list<Message*> > > waiting_for_missing_class;
- int get_class(const nstring& cname, ClassVersion& version, pg_t pgid, Message *m, ClassHandler::ClassData **cls);
+ int get_class(const string& cname, ClassVersion& version, pg_t pgid, Message *m, ClassHandler::ClassData **cls);
void handle_class(MClass *m);
public:
- void got_class(const nstring& cname);
+ void got_class(const string& cname);
void send_class_request(const char *n, ClassVersion& version);
protected:
static int read_meta(const char *base, const char *file, char *val, size_t vallen);
static int write_meta(const char *base, ceph_fsid_t& fsid, int whoami);
public:
- static int peek_meta(const char *dev, nstring& magic, ceph_fsid_t& fsid, int& whoami);
+ static int peek_meta(const char *dev, string& magic, ceph_fsid_t& fsid, int& whoami);
// startup/shutdown
// incremental
int32_t new_max_osd;
map<int32_t,pg_pool_t> new_pools;
- map<int32_t,nstring> new_pool_names;
+ map<int32_t,string> new_pool_names;
set<int32_t> old_pools;
map<int32_t,entity_addr_t> new_up;
map<int32_t,uint8_t> new_down;
map<pg_t,vector<int> > pg_temp; // temp pg mapping (e.g. while we rebuild)
map<int,pg_pool_t> pools;
- map<int32_t,nstring> pool_name;
- map<nstring,int> name_pool;
+ map<int32_t,string> pool_name;
+ map<string,int> name_pool;
hash_map<entity_addr_t,utime_t> blacklist;
pools[p->first] = p->second;
pools[p->first].v.last_change = epoch;
}
- for (map<int32_t,nstring>::iterator p = inc.new_pool_names.begin();
+ for (map<int32_t,string>::iterator p = inc.new_pool_names.begin();
p != inc.new_pool_names.end();
p++) {
pool_name[p->first] = p->second;
// index pool names
name_pool.clear();
- for (map<int,nstring>::iterator i = pool_name.begin(); i != pool_name.end(); i++)
+ for (map<int,string>::iterator i = pool_name.begin(); i != pool_name.end(); i++)
name_pool[i->second] = i->first;
}
peerok = ok = false;
num_bad++;
}
- for (map<nstring,bufferptr>::iterator q = po->attrs.begin(); q != po->attrs.end(); q++) {
+ for (map<string,bufferptr>::iterator q = po->attrs.begin(); q != po->attrs.end(); q++) {
if (p[i]->attrs.count(q->first)) {
if (q->second.cmp(p[i]->attrs[q->first])) {
dout(0) << "scrub osd" << acting[i] << " " << po->poid
case CEPH_OSD_OP_GETXATTR:
{
- nstring name(op.xattr.name_len + 1);
- name[0] = '_';
- bp.copy(op.xattr.name_len, name.data()+1);
+ string aname;
+ bp.copy(op.xattr.name_len, aname);
+ string name = "_" + aname;
int r = osd->store->getattr(coll_t::build_pg_coll(info.pgid), soid, name.c_str(), odata);
if (r >= 0) {
op.xattr.value_len = r;
case CEPH_OSD_OP_GETXATTRS:
{
- map<nstring,bufferptr> attrset;
+ map<string,bufferptr> attrset;
result = osd->store->getattrs(coll_t::build_pg_coll(info.pgid), soid, attrset, true);
- map<nstring, bufferptr>::iterator iter;
- map<nstring, bufferlist> newattrs;
+ map<string, bufferptr>::iterator iter;
+ map<string, bufferlist> newattrs;
for (iter = attrset.begin(); iter != attrset.end(); ++iter) {
bufferlist bl;
bl.append(iter->second);
{
if (!ctx->obs->exists)
t.touch(coll_t::build_pg_coll(info.pgid), soid);
- nstring name(op.xattr.name_len + 1);
- name[0] = '_';
- bp.copy(op.xattr.name_len, name.data()+1);
+ string aname;
+ bp.copy(op.xattr.name_len, aname);
+ string name = "_" + aname;
bufferlist bl;
bp.copy(op.xattr.value_len, bl);
if (!ctx->obs->exists) // create object if it doesn't yet exist.
case CEPH_OSD_OP_RMXATTR:
{
- nstring name(op.xattr.name_len + 1);
- name[0] = '_';
- bp.copy(op.xattr.name_len, name.data()+1);
+ string aname;
+ bp.copy(op.xattr.name_len, aname);
+ string name = "_" + aname;
t.rmattr(coll_t::build_pg_coll(info.pgid), soid, name);
info.stats.num_wr++;
}
// verify
if (0) {
bufferlist header;
- map<nstring, bufferlist> m;
+ map<string, bufferlist> m;
::decode(header, bp);
::decode(m, bp);
assert(bp.end());
if (0) {
// parse
bufferlist header;
- map<nstring, bufferlist> m;
+ map<string, bufferlist> m;
//ibl.hexdump(*_dout);
if (ibl.length()) {
::decode(header, ip);
// do the update(s)
while (!bp.end()) {
__u8 op;
- nstring key;
+ string key;
::decode(op, bp);
switch (op) {
// update keys
bufferlist newkeydata;
- nstring nextkey;
+ string nextkey;
bufferlist nextval;
bool have_next = false;
if (!ip.end()) {
}
while (!bp.end()) {
__u8 op;
- nstring key;
+ string key;
::decode(op, bp);
::decode(key, bp);
{
// read data+attrs
bufferlist bl;
- map<nstring,bufferptr> attrset;
+ map<string,bufferptr> attrset;
__u64 size;
if (data_subset.size() || clone_subsets.size()) {
#include "include/types.h"
#include "include/CompatSet.h"
#include "include/interval_set.h"
-#include "include/nstring.h"
struct pool_snap_info_t {
snapid_t snapid;
utime_t stamp;
- nstring name;
+ string name;
void encode(bufferlist& bl) const {
__u8 struct_v = 1;
::decode(v, bl);
if (v < 3) {
- nstring magic;
+ string magic;
::decode(magic, bl);
}
::decode(fsid, bl);
struct object {
sobject_t poid;
__u64 size;
- map<nstring,bufferptr> attrs;
+ map<string,bufferptr> attrs;
void encode(bufferlist& bl) const {
__u8 struct_v = 1;
WRITE_CLASS_ENCODER(object)
vector<object> objects;
- map<nstring,bufferptr> attrs;
+ map<string,bufferptr> attrs;
bufferlist logbl;
void encode(bufferlist& bl) const {
__s64 expire_pos;
__s64 read_pos;
__s64 write_pos;
- nstring magic;
+ string magic;
ceph_file_layout layout;
Header(const char *m=0) :
struct C_GetAttrs : public Context {
bufferlist bl;
- map<nstring,bufferlist>& attrset;
+ map<string,bufferlist>& attrset;
Context *fin;
- C_GetAttrs(map<nstring, bufferlist>& set, Context *c) : attrset(set), fin(c) {}
+ C_GetAttrs(map<string, bufferlist>& set, Context *c) : attrset(set), fin(c) {}
void finish(int r) {
if (r >= 0) {
bufferlist::iterator p = bl.begin();
}
tid_t getxattrs(const object_t& oid, ceph_object_layout ol, snapid_t snap,
- map<nstring,bufferlist>& attrset,
+ map<string,bufferlist>& attrset,
int flags, Context *onfinish) {
vector<OSDOp> ops(1);
ops[0].op.op = CEPH_OSD_OP_GETXATTRS;
class ACLEntity
{
- nstring name;
+ string name;
map<ACLID, ACLEntity> groups;
};
}
bufferlist::iterator p = bl.begin();
bufferlist header;
- map<nstring,bufferlist> m;
+ map<string,bufferlist> m;
::decode(header, p);
::decode(m, p);
- for (map<nstring,bufferlist>::iterator q = m.begin(); q != m.end(); q++)
+ for (map<string,bufferlist>::iterator q = m.begin(); q != m.end(); q++)
cout << q->first << std::endl;
}
else if (opt_create) {