dout(12) << " new dentry+node with ino " << in_info->inode.ino << endl;
}
- // OK!
+ // OK, we found it!
assert(dn && dn->inode);
// actually update info
// take note of latest distribution on mds's
dn->inode->mds_contacts = in_info->dist;
- dn->inode->mds_auth = in_info->auth;
+ dn->inode->mds_dir_auth = in_info->dir_auth;
return dn->inode;
}
}
if (cur) {
- if (auth_best) {
- mds = cur->mds_auth;
+ if (auth_best) { // hack fixme
+ mds = cur->authority();
} else {
if (cur->mds_contacts.size()) {
dout(9) << "contacting mds from deepest inode " << cur->inode.ino << " " << req->get_filepath() << ": " << cur->mds_contacts << endl;
mds = *it;
}
} else {
- mds = cur->mds_auth;
+ mds = cur->authority();
}
}
} else {
class Inode {
public:
inode_t inode; // the actual inode
- int mds_auth;
+ int mds_dir_auth;
set<int> mds_contacts;
time_t last_updated;
void get() { ref++; }
void put() { ref--; assert(ref >= 0); }
- Inode() : ref(0), dir(0), dn(0), symlink(0), mds_auth(0) { }
+ Inode() : ref(0), dir(0), dn(0), symlink(0), mds_dir_auth(-1), last_updated(0) { }
~Inode() {
if (symlink) { delete symlink; symlink = 0; }
}
+ int authority() {
+ if (mds_dir_auth >= 0)
+ return mds_dir_auth;
+ if (dn && dn->dir && dn->dir->parent_inode)
+ return dn->dir->parent_inode->authority();
+ return 0; // who knows!
+ }
+
// open Dir for an inode. if it's not open, allocated it (and pin dentry in memory).
Dir *open_dir() {
if (!dir) {
#include "msg/Message.h"
#include "mds/CInode.h"
+#include "mds/CDir.h"
#include "mds/CDentry.h"
#include <vector>
bool inode_soft_valid; // true if inode info is valid (ie was readable on mds at the time)
bool inode_hard_valid; // true if inode info is valid (ie was readable on mds at the time)
- int auth;
+ int dir_auth;
set<int> dist; // where am i replicated?
this->ref_dn = ref_dn;
// replicated where?
- auth = in->authority();
+ if (in->dir)
+ dir_auth = in->dir->get_dir_auth();
+ else
+ dir_auth -1;
in->get_dist_spec(this->dist, whoami, now);
}
bl.append((char*)&inode, sizeof(inode));
bl.append((char*)&inode_soft_valid, sizeof(inode_soft_valid));
bl.append((char*)&inode_hard_valid, sizeof(inode_hard_valid));
- bl.append((char*)&auth, sizeof(auth));
+ bl.append((char*)&dir_auth, sizeof(dir_auth));
::_encode(ref_dn, bl);
::_encode(symlink, bl);
off += sizeof(inode_soft_valid);
bl.copy(off, sizeof(inode_hard_valid), (char*)&inode_hard_valid);
off += sizeof(inode_hard_valid);
- bl.copy(off, sizeof(auth), (char*)&auth);
- off += sizeof(auth);
+ bl.copy(off, sizeof(dir_auth), (char*)&dir_auth);
+ off += sizeof(dir_auth);
::_decode(ref_dn, bl, off);
::_decode(symlink, bl, off);