]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: set_updated on scatterlocks
authorSage Weil <sage@newdream.net>
Sun, 25 May 2008 20:44:39 +0000 (13:44 -0700)
committerSage Weil <sage@newdream.net>
Sun, 25 May 2008 20:44:39 +0000 (13:44 -0700)
src/mds/Locker.cc
src/mds/MDCache.h

index b7f7e1a4bfdef59bc6f816d02a4174c4848b714e..7f8faa9d924b3cf2b9c1445b44cf32efc926ec5e 100644 (file)
@@ -1223,12 +1223,12 @@ void Locker::revoke_client_leases(SimpleLock *lock)
 
 void Locker::predirty_nested(Mutation *mut, EMetaBlob *blob,
                             CInode *in, CDir *parent,
-                            bool do_nested, bool do_parent, int linkunlink)
+                            bool primary_dn, bool do_parent, int linkunlink)
 {
   dout(10) << "predirty_nested "
           << (do_parent ? "do_parent_mtime ":"")
           << "linkunlink=" <<  linkunlink
-          << (do_nested ? "do_nested ":"")
+          << (primary_dn ? "primary_dn ":"remote_dn ")
           << " " << *in << dendl;
 
   if (!parent)
@@ -1254,17 +1254,6 @@ void Locker::predirty_nested(Mutation *mut, EMetaBlob *blob,
       //assert(mut->wrlocks.count(&pin->nestedlock));
     }
 
-    if (do_nested &&
-       mut->wrlocks.count(&pin->dirlock) == 0 &&
-       !scatter_wrlock_try(&pin->dirlock, mut)) {
-      dout(10) << "predirty_nested can't wrlock " << pin->dirlock << " on " << *pin << dendl;
-      do_nested = false;
-      break;
-    }
-
-    if (!do_parent && !do_nested)
-      break;
-
     // inode -> dirfrag
     mut->add_projected_fnode(parent);
 
@@ -1281,7 +1270,7 @@ void Locker::predirty_nested(Mutation *mut, EMetaBlob *blob,
          pf->fraginfo.nfiles += linkunlink;
       }
     }
-    if (do_nested) {
+    if (primary_dn) {
       if (linkunlink == 0) {
        drbytes = curi->nested.rbytes - curi->accounted_nested.rbytes;
        drfiles = curi->nested.rfiles - curi->accounted_nested.rfiles;
@@ -1312,12 +1301,25 @@ void Locker::predirty_nested(Mutation *mut, EMetaBlob *blob,
       pf->nested.rfiles += linkunlink;
     }
 
+
+    // stop?
     if (pin->is_base())
       break;
-    if (!pin->is_auth()) {
-      if (do_parent)
-       mut->ls->dirty_dirfrag_dir.push_back(&pin->xlist_dirty_dirfrag_dir);
-      mut->ls->dirty_dirfrag_nested.push_back(&pin->xlist_dirty_dirfrag_nested);
+
+    bool stop = false;
+    if (mut->wrlocks.count(&pin->dirlock) == 0 &&
+       !scatter_wrlock_try(&pin->dirlock, mut)) {
+      dout(10) << "predirty_nested can't wrlock " << pin->dirlock << " on " << *pin << dendl;
+      stop = true;
+    }
+    if (!pin->is_auth() || pin->is_ambiguous_auth()) {
+      dout(10) << "predirty_nested !auth or ambig on " << *pin << dendl;
+      stop = true;
+    }
+    if (stop) {
+      dout(10) << "predirty_nested stop.  marking dirty dirfrag/scatterlock on " << *pin << dendl;
+      mut->add_updated_scatterlock(&pin->dirlock);
+      mut->ls->dirty_dirfrag_nested.push_back(&pin->xlist_dirty_dirfrag_dir);
       break;
     }
 
@@ -1355,6 +1357,7 @@ void Locker::predirty_nested(Mutation *mut, EMetaBlob *blob,
     parent = cur->get_projected_parent_dn()->get_dir();
     linkunlink = 0;
     do_parent = false;
+    primary_dn = true;
   }
 
   // now, stick it in the blob
index b797e1b1715f3ca9baed9a36b57e5078273c07f5..0049a1f3a7ddd37d9df98ac1488d9b2a58a7d14e 100644 (file)
@@ -103,6 +103,7 @@ struct Mutation {
   // for applying projected inode changes
   list<CInode*> projected_inodes;
   list<CDir*> projected_fnodes;
+  list<ScatterLock*> updated_scatterlocks;
 
   Mutation() : ls(0),
               done_locking(false), committing(false), aborted(false) {}
@@ -171,10 +172,18 @@ struct Mutation {
       dir->pop_and_dirty_projected_fnode(ls);
     }
   }
+  
+  void add_updated_scatterlock(ScatterLock *lock) {
+    updated_scatterlocks.push_back(lock);
+  }
 
   void apply() {
     pop_and_dirty_projected_inodes();
     pop_and_dirty_projected_fnodes();
+    for (list<ScatterLock*>::iterator p = updated_scatterlocks.begin();
+        p != updated_scatterlocks.end();
+        p++)
+      (*p)->set_updated();
   }
 
   virtual void print(ostream &out) {