]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: rely on master to do anchor locks for slave_link_prep
authorSage Weil <sage.weil@dreamhost.com>
Sun, 10 Jul 2011 21:15:38 +0000 (14:15 -0700)
committerSage Weil <sage@newdream.net>
Mon, 11 Jul 2011 19:15:51 +0000 (12:15 -0700)
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 <sage.weil@dreamhost.com>
src/mds/Server.cc

index 5f947e6d492aa314321f0896a95a12c6b05b5746..932948966747d370099915a0d9019339e5a7d7c8 100644 (file)
@@ -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<SimpleLock*> rdlocks = mdr->rdlocks;
-    set<SimpleLock*> wrlocks = mdr->wrlocks;
-    set<SimpleLock*> 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;