From ef54ec5e5ebf58687e217592e6d291a0f2fe426f Mon Sep 17 00:00:00 2001 From: sageweil Date: Mon, 13 Aug 2007 04:53:18 +0000 Subject: [PATCH] some more client fixes git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1626 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/client/Client.cc | 11 +++++++---- branches/sage/mds/mds/Locker.cc | 19 ++++++++++++++++--- branches/sage/mds/mds/Server.cc | 2 +- branches/sage/mds/mon/MDSMonitor.cc | 23 +++++++++++++++++++++-- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/branches/sage/mds/client/Client.cc b/branches/sage/mds/client/Client.cc index 792aae6435061..8a633e5a40013 100644 --- a/branches/sage/mds/client/Client.cc +++ b/branches/sage/mds/client/Client.cc @@ -1625,6 +1625,8 @@ int Client::_rename(const char *from, const char *to) delete reply; dout(10) << "rename result is " << res << endl; + // renamed item from our cache + trim_cache(); dout(3) << "rename(\"" << from << "\", \"" << to << "\") = " << res << endl; return res; @@ -3269,8 +3271,6 @@ int Client::ll_lookup(inodeno_t parent, const char *name, struct stat *attr) Inode *in = diri->dir->dentries[dname]->inode; fill_stat(in, attr); _ll_get(in); - dout(3) << "ll_lookup " << parent << " " << name << " -> " << in->inode.ino - << " (" << in << ")" << endl; assert(inode_map[in->inode.ino] == in); } else { r = -ENOENT; @@ -3421,12 +3421,15 @@ int Client::ll_readlink(inodeno_t ino, const char **value) tout << ino.val << endl; Inode *in = _ll_get_inode(ino); + int r = 0; if (in->inode.is_symlink()) { *value = in->symlink->c_str(); - return 0; } else { - return -EINVAL; + *value = ""; + r = -EINVAL; } + dout(3) << "ll_readlink " << ino << " = " << r << " (" << *value << ")" << endl; + return r; } int Client::ll_mknod(inodeno_t parent, const char *name, mode_t mode, dev_t rdev, struct stat *attr) diff --git a/branches/sage/mds/mds/Locker.cc b/branches/sage/mds/mds/Locker.cc index f9f0501e559a0..ea87fe8569b0b 100644 --- a/branches/sage/mds/mds/Locker.cc +++ b/branches/sage/mds/mds/Locker.cc @@ -469,7 +469,7 @@ Capability* Locker::issue_new_caps(CInode *in, cap->set_suppress(true); } else { // make sure it has sufficient caps - if (cap->wanted() & ~my_want) { + if (my_want & ~cap->wanted()) { // augment wanted caps for this client cap->set_wanted( cap->wanted() | my_want ); } @@ -679,8 +679,21 @@ void Locker::handle_client_file_caps(MClientFileCaps *m) << endl; // update wanted - if (cap->wanted() != wanted) - cap->set_wanted(wanted); + if (cap->wanted() != wanted) { + if (m->get_seq() < cap->get_last_seq()) { + /* this is awkward. + client may be trying to release caps (i.e. inode closed, etc.) by setting reducing wanted + set. + but it may also be opening the same filename, not sure that it'll map to the same inode. + so, we don't want wanted reductions to clobber mds's notion of wanted unless we're + sure the client has seen all the latest caps. + */ + dout(-10) << "handle_client_file_caps ignoring wanted " << cap_string(m->get_wanted()) + << " bc seq " << m->get_seq() << " < " << cap->get_last_seq() << endl; + } else { + cap->set_wanted(wanted); + } + } // confirm caps int had = cap->confirm_receipt(m->get_seq(), m->get_caps()); diff --git a/branches/sage/mds/mds/Server.cc b/branches/sage/mds/mds/Server.cc index bd9d7f225bb33..f37ace7f30488 100644 --- a/branches/sage/mds/mds/Server.cc +++ b/branches/sage/mds/mds/Server.cc @@ -2885,7 +2885,7 @@ void Server::_rename_finish(MDRequest *mdr, CDentry *srcdn, CDentry *destdn, CDe // reply MClientReply *reply = new MClientReply(mdr->client_request, 0); - reply_request(mdr, reply, destdn->dir->get_inode()); // FIXME: imprecise ref + reply_request(mdr, reply, destdn->get_inode()); // FIXME: imprecise ref // clean up? if (straydn) diff --git a/branches/sage/mds/mon/MDSMonitor.cc b/branches/sage/mds/mon/MDSMonitor.cc index abe37c40d4dda..f4ded2330d20e 100644 --- a/branches/sage/mds/mon/MDSMonitor.cc +++ b/branches/sage/mds/mon/MDSMonitor.cc @@ -556,9 +556,28 @@ void MDSMonitor::do_stop() print_map(mdsmap); for (map::iterator p = mdsmap.mds_state.begin(); p != mdsmap.mds_state.end(); - ++p) - if (mdsmap.is_active(p->first)) + ++p) { + switch (p->second) { + case MDSMap::STATE_ACTIVE: + case MDSMap::STATE_STOPPING: pending_mdsmap.mds_state[p->first] = MDSMap::STATE_STOPPING; + break; + case MDSMap::STATE_CREATING: + case MDSMap::STATE_STANDBY: + pending_mdsmap.mds_state[p->first] = MDSMap::STATE_DNE; + break; + case MDSMap::STATE_STARTING: + pending_mdsmap.mds_state[p->first] = MDSMap::STATE_STOPPED; + break; + case MDSMap::STATE_REPLAY: + case MDSMap::STATE_RESOLVE: + case MDSMap::STATE_RECONNECT: + case MDSMap::STATE_REJOIN: + // BUG: hrm, if this is the case, the STOPPING gusy won't be able to stop, will they? + pending_mdsmap.mds_state[p->first] = MDSMap::STATE_FAILED; + break; + } + } propose_pending(); } -- 2.39.5