in->dir_replicated = true; // FIXME
// dist
+ /*
if (!st->dirfrag_dist.empty()) { // FIXME
set<int> dist = st->dirfrag_dist.begin()->second;
if (dist.empty() && !in->dir_contacts.empty())
<< " " << dist << dendl;
in->dir_contacts = dist;
}
+ */
}
int missing_dn = -1; // which dn we miss on (if we miss)
unsigned depth = req->get_filepath().depth();
- for (unsigned i=0; i<depth; i++) {
+ unsigned i;
+ for (i=0; i<depth; i++) {
// dir?
if (diri && diri->inode.mode & INODE_MODE_DIR && diri->dir) {
Dir *dir = diri->dir;
}
} else {
// balance our traffic!
- mds = diri->pick_replica(mdsmap);
+ mds = diri->pick_replica(mdsmap); // for the _inode_
+ dout(20) << "for " << req->get_filepath() << " diri " << diri->inode.ino << " rep "
+ << diri->dir_contacts
+ << " mds" << mds << dendl;
}
}
dout(20) << "mds is " << mds << dendl;
m->clear_payload(); // for if/when we send back to MDS
// note push seq increment
- assert(mds_sessions.count(mds));
+ if (mds_sessions.count(mds) == 0)
+ dout(0) << "got file_caps without session from mds" << mds << " msg " << *m << dendl;
+ //assert(mds_sessions.count(mds)); // HACK FIXME SOON
mds_sessions[mds]++;
// reap?
int pick_replica(MDSMap *mdsmap) {
// replicas?
- if (ino() > 1ULL && dir_contacts.size()) {
+ /* fixme
+ if (//ino() > 1ULL &&
+ dir_contacts.size()) {
set<int>::iterator it = dir_contacts.begin();
if (dir_contacts.size() == 1)
return *it;
else {
//cout << "dir_contacts on " << inode.ino << " is " << dir_contacts << std::endl;
- int r = rand() % dir_contacts.size();
+ int r = 1 + (rand() % dir_contacts.size());
+ int a = authority();
while (r--) {
it++;
- if (mdsmap->is_down(*it))
- it++;
- if (it == dir_contacts.end())
- it = dir_contacts.begin();
+ if (mdsmap->is_down(*it)) it++;
+ if (it == dir_contacts.end()) it = dir_contacts.begin();
+ if (*it == a) it++; // skip the authority
+ if (it == dir_contacts.end()) it = dir_contacts.begin();
}
return *it;
}
}
-
- if (dir_replicated || ino() == 1) {
+ */
+
+ if (dir_replicated) {// || ino() == 1) {
+ // pick a random mds that isn't the auth
+ set<int> s;
+ mdsmap->get_in_mds_set(s);
+ set<int>::iterator it = s.begin();
+ if (s.empty())
+ return 0;
+ if (s.size() == 1)
+ return *it;
+ else {
+ //cout << "dir_contacts on " << inode.ino << " is " << dir_contacts << std::endl;
+ int r = 1 + (rand() % s.size());
+ int a = authority();
+ while (r--) {
+ it++;
+ if (mdsmap->is_down(*it)) it++;
+ if (it == s.end()) it = s.begin();
+ if (*it == a) it++; // skip the authority
+ if (it == s.end()) it = s.begin();
+ }
+ //if (inode.ino == 1) cout << "chose " << *it << " from " << s << std::endl;
+ return *it;
+ }
//cout << "num_mds is " << mdcluster->get_num_mds() << endl;
- return mdsmap->get_random_in_mds();
+ //return mdsmap->get_random_in_mds();
//return rand() % mdsmap->get_num_mds(); // huh.. pick a random mds!
}
else
const char *a = t.get_string(buf, p);
if (strcmp(a, p) != 0 &&
strcmp(a, "/") != 0 &&
- strcmp(a, "") != 0) // stop stating the root directory already
+ strcmp(a, "/lib") != 0 && // or /lib.. that would be a lookup. hack.
+ a[0] != 0) // stop stating the root directory already
client->lstat(a, &st);
} else if (strcmp(op, "chmod") == 0) {
const char *a = t.get_string(buf, p);
// print
char *tm = ctime(&st.st_mtime);
tm[strlen(tm)-1] = 0;
- printf("%c%c%c%c%c%c%c%c%c%c %2d %5d %5d %8d %12s %s\n",
+ printf("%llx %c%c%c%c%c%c%c%c%c%c %2d %5d %5d %8d %12s %s\n",
+ st.st_ino,
S_ISDIR(st.st_mode) ? 'd':'-',
(st.st_mode & 0400) ? 'r':'-',
(st.st_mode & 0200) ? 'w':'-',