]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: set primary lock state to LOCK from strong replica when appropriate
authorSage Weil <sage@newdream.net>
Tue, 4 Aug 2009 23:07:24 +0000 (16:07 -0700)
committerSage Weil <sage@newdream.net>
Tue, 4 Aug 2009 23:07:24 +0000 (16:07 -0700)
This is needed only because we identify_files_to_recover() before
sending the rejoin acks, and that may twiddle the lock state, so
we need to be in a compatible state.

src/mds/MDCache.cc
src/mds/ScatterLock.h

index a0b8ab768ec5eb1bf61046c01005e64536abb880..dd77483250ec2e8c2c0d43600306952faeed37dd 100644 (file)
@@ -3440,13 +3440,13 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
                     << " on " << *in << dendl;
          } 
          
-         // scatterlock?
-         if (is.filelock == LOCK_MIX ||
-             is.filelock == LOCK_MIX_LOCK)  // replica still has wrlocks
-           in->filelock.set_state(LOCK_MIX);
-         if (is.nestlock == LOCK_MIX ||
-             is.nestlock == LOCK_MIX_LOCK)  // replica still has wrlocks
-           in->nestlock.set_state(LOCK_MIX);
+         // scatterlocks?
+         //  infer state from replica state:
+         //   * go to MIX if they might have wrlocks
+         //   * go to LOCK if they are LOCK (just bc identify_files_to_recover might start twiddling filelock)
+         in->filelock.infer_state_from_strong_rejoin(is.filelock, true);  // maybe also go to LOCK
+         in->nestlock.infer_state_from_strong_rejoin(is.nestlock, false);
+         in->dirfragtreelock.infer_state_from_strong_rejoin(is.dftlock, false);
          
          // auth pin?
          if (strong->authpinned_inodes.count(in->vino())) {
index 211be26da46e41ffe1eff9af60cbf68c9f2b6228..d31bf72752c9c4f6461cf98a10d6010d1982a9e3 100644 (file)
@@ -67,6 +67,16 @@ public:
   void set_last_scatter(utime_t t) { last_scatter = t; }
   utime_t get_last_scatter() { return last_scatter; }
 
+  void infer_state_from_strong_rejoin(int rstate, bool locktoo) {
+    if (rstate == LOCK_MIX || 
+       rstate == LOCK_MIX_LOCK || // replica still has wrlocks?
+       rstate == LOCK_MIX_SYNC || // "
+       rstate == LOCK_MIX_TSYN)  // "
+      state = LOCK_MIX;
+    else if (locktoo && rstate == LOCK_LOCK)
+      state = LOCK_LOCK;
+  }
+
   void print(ostream& out) {
     out << "(";
     _print(out);