last_tid = 0;
last_flush_seq = 0;
- cwd = NULL;
-
//
root = 0;
delete root;
root = 0;
root_ancestor = 0;
- while (!root_parents.empty()) {
- Inode *in = root_parents.begin()->second;
+ while (!root_parents.empty())
root_parents.erase(root_parents.begin());
- delete in;
- }
inode_map.clear();
}
delete root;
root = 0;
root_ancestor = 0;
- while (!root_parents.empty()) {
- Inode *in = root_parents.begin()->second;
+ while (!root_parents.empty())
root_parents.erase(root_parents.begin());
- delete in;
- }
inode_map.clear();
}
}
root = in;
root_ancestor = in;
cwd = root;
- cwd->get();
} else if (!mounted) {
root_parents[root_ancestor] = in;
root_ancestor = in;
- in->get();
}
// immutable bits
if (in == root) {
root = 0;
root_ancestor = 0;
- while (!root_parents.empty()) {
- Inode *in = root_parents.begin()->second;
+ while (!root_parents.empty())
root_parents.erase(root_parents.begin());
- put_inode(in);
- }
}
if (!in->oset.objects.empty()) {
timer.cancel_event(tick_event);
tick_event = 0;
- if (cwd)
- put_inode(cwd);
- cwd = NULL;
+ cwd.reset();
// clean up any unclosed files
while (!fd_map.empty()) {
int r = path_walk(path, &in);
if (r < 0)
return r;
- if (cwd != in.get()) {
- put_inode(cwd);
- cwd = in.get();
- cwd->get();
- }
+ if (cwd != in)
+ cwd.swap(in);
ldout(cct, 3) << "chdir(" << relpath << ") cwd now " << cwd->ino << dendl;
return 0;
}
filepath path;
ldout(cct, 10) << "getcwd " << *cwd << dendl;
- Inode *in = cwd;
+ Inode *in = cwd.get();
while (in != root) {
assert(in->dn_set.size() < 2); // dirs can't be hard-linked
Dentry *dn = in->get_first_parent();
// start over
path = filepath();
- in = cwd;
+ in = cwd.get();
continue;
}
path.push_front_dentry(dn->name);
if (!in->dn_set.empty())
in = in->get_first_parent()->dir->parent_inode;
else if (root_parents.count(in))
- in = root_parents[in];
+ in = root_parents[in].get();
else
in = NULL;
}
// cache
ceph::unordered_map<vinodeno_t, Inode*> inode_map;
Inode* root;
- map<Inode*, Inode*> root_parents;
+ map<Inode*, InodeRef> root_parents;
Inode* root_ancestor;
LRU lru; // lru list of Dentry's in our local metadata cache.
void unlink(Dentry *dn, bool keepdir, bool keepdentry);
// path traversal for high-level interface
- Inode *cwd;
+ InodeRef cwd;
int path_walk(const filepath& fp, InodeRef *end, bool followsym=true);
int fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat=0, nest_info_t *rstat=0);
int fill_stat(InodeRef& in, struct stat *st, frag_info_t *dirstat=0, nest_info_t *rstat=0) {