]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: filter trimming|purged snaps out of op SnapContext
authorSage Weil <sage@newdream.net>
Sat, 11 Feb 2012 22:55:06 +0000 (14:55 -0800)
committerSage Weil <sage@newdream.net>
Sat, 11 Feb 2012 23:09:02 +0000 (15:09 -0800)
We can receive an op with an old SnapContext that includes snaps that we've
already trimmed or are in the process of trimming.  Filter them out!
Otherwise we will recreate and add links into collections we've already
marked as removed, and we'll get things like ENOTEMPTY when we try to
remove them.  Or just leave them laying around.

Fixes: #1949
Signed-off-by: Sage Weil <sage@newdream.net>
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.cc

index edaae82123aa73e5d3b5eb2b3b742a1316a5d3e3..146d57ebb7a3c6a17b024cb7a1e6702a568d834e 100644 (file)
@@ -2262,6 +2262,36 @@ void PG::update_snap_collections(vector<pg_log_entry_t> &log_entries,
   }
 }
 
+/**
+ * filter trimming|trimmed snaps out of snapcontext
+ */
+void PG::filter_snapc(SnapContext& snapc)
+{
+  bool filtering = false;
+  vector<snapid_t> newsnaps;
+  for (vector<snapid_t>::iterator p = snapc.snaps.begin();
+       p != snapc.snaps.end();
+       ++p) {
+    if (snap_trimq.contains(*p) || info.purged_snaps.contains(*p)) {
+      if (!filtering) {
+       // start building a new vector with what we've seen so far
+       dout(10) << "filter_snapc filtering " << snapc << dendl;
+       newsnaps.insert(newsnaps.begin(), snapc.snaps.begin(), p);
+       filtering = true;
+      }
+      dout(20) << "filter_snapc  removing trimq|purged snap " << *p << dendl;
+    } else {
+      if (filtering)
+       newsnaps.push_back(*p);  // continue building new vector
+    }
+  }
+  if (filtering) {
+    snapc.snaps.swap(newsnaps);
+    dout(10) << "filter_snapc  result " << snapc << dendl;
+  }
+}
+
+
 void PG::adjust_local_snaps()
 {
   interval_set<snapid_t> to_remove;
index 02466b9a8e926b8958bf7cc3dfcc007c35eac440..791cd6721ed1e5d218d1f5dba34ce97d86092878 100644 (file)
@@ -1310,6 +1310,7 @@ public:
   coll_t make_snap_collection(ObjectStore::Transaction& t, snapid_t sn);
   void update_snap_collections(vector<pg_log_entry_t> &log_entries,
                               ObjectStore::Transaction& t);
+  void filter_snapc(SnapContext& snapc);
   void adjust_local_snaps();
 
   void log_weirdness();
index b98a4e6308eff02980fc970b964bbabfe16d34f5..e42c317af07235615d9a61e724bce57d6439c917 100644 (file)
@@ -2427,6 +2427,9 @@ void ReplicatedPG::make_writeable(OpContext *ctx)
     snapc.snaps = ctx->new_snapset.snaps;
     dout(10) << " using newer snapc " << snapc << dendl;
   }
+
+  if (ctx->obs->exists)
+    filter_snapc(snapc);
   
   if (ctx->obs->exists &&               // head exist(ed)
       snapc.snaps.size() &&                 // there are snaps