From 48837e3c93540513d96480be50148f99ed81bcc1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 10 Jul 2011 14:15:38 -0700 Subject: [PATCH] mds: rely on master to do anchor locks for slave_link_prep The replica can't take all these locks without confusing things, since it maybe need to unlock/relock, may screw up auth_pins, and worse. The master can take the locks. The only problem is that the master may not know if the inode has already been anchored if the lock hasn't cycled since then. In that case, we take more locks than we need to. Signed-off-by: Sage Weil --- src/mds/Server.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5f947e6d492aa..932948966747d 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3726,6 +3726,12 @@ void Server::handle_client_link(MDRequest *mdr) xlocks.insert(&targeti->linklock); // take any locks needed for anchor creation/verification + // NOTE: we do this on the master even if the anchor/link update may happen + // on the slave. That means we may have out of date anchor state on our + // end. That's fine: either, we xlock when we don't need to (slow but + // not a problem), or we rdlock when we need to xlock, but then discover we + // need to xlock and on our next pass through we adjust the locks (this works + // as long as the linklock rdlock isn't the very last lock we take). mds->mdcache->anchor_create_prep_locks(mdr, targeti, rdlocks, xlocks); if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks)) @@ -4001,15 +4007,7 @@ void Server::handle_slave_link_prep(MDRequest *mdr) // anchor? if (mdr->slave_request->get_op() == MMDSSlaveRequest::OP_LINKPREP) { - set rdlocks = mdr->rdlocks; - set wrlocks = mdr->wrlocks; - set xlocks = mdr->xlocks; - - // take any locks needed for anchor creation/verification - mds->mdcache->anchor_create_prep_locks(mdr, targeti, rdlocks, xlocks); - - if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks)) - return; + // NOTE: the master took any locks needed for anchor creation/verification. if (targeti->is_anchored()) { dout(7) << "target anchored already (nlink=" << targeti->inode.nlink << "), sweet" << dendl; -- 2.39.5