]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PG: use remove_object_with_snap_hardlinks for divergent objects
authorSamuel Just <sam.just@inktank.com>
Fri, 2 Nov 2012 20:02:15 +0000 (13:02 -0700)
committerSamuel Just <sam.just@inktank.com>
Mon, 5 Nov 2012 18:48:16 +0000 (10:48 -0800)
Otherwise, we end up leaving snap hardlinks in the snapshot
index directories.  This eventually results in an EEXIST error
when we attempt to re-link the clone into place during
recovery.

Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index ec9a495074b374f2d858bb4e1a350b4467f98c4a..7799ceec1cb05fcdb7ab56dc13f0fb1b42229e31 100644 (file)
@@ -319,6 +319,23 @@ bool PG::proc_replica_info(int from, const pg_info_t &oinfo)
   return true;
 }
 
+void PG::remove_object_with_snap_hardlinks(
+  ObjectStore::Transaction& t, const hobject_t& soid)
+{
+  t.remove(coll, soid);
+  if (soid.snap < CEPH_MAXSNAP) {
+    bufferlist ba;
+    int r = osd->store->getattr(coll, soid, OI_ATTR, ba);
+    if (r >= 0) {
+      // grr, need first snap bound, too.
+      object_info_t oi(ba);
+      if (oi.snaps.size() > 1)
+       t.remove(coll_t(info.pgid, oi.snaps[oi.snaps.size() - 1]), soid);
+      t.remove(coll_t(info.pgid, oi.snaps[0]), soid);
+    }
+  }
+}
+
 
 /*
  * merge an old (possibly divergent) log entry into the new log.  this 
@@ -371,13 +388,13 @@ bool PG::merge_old_entry(ObjectStore::Transaction& t, pg_log_entry_t& oe)
     dout(20) << "merge_old_entry  had " << oe
             << ", clone with no non-divergent log entries, "
             << "deleting" << dendl;
-    t.remove(coll, oe.soid);
+    remove_object_with_snap_hardlinks(t, oe.soid);
     if (missing.is_missing(oe.soid))
       missing.rm(oe.soid, missing.missing[oe.soid].need);
   } else {
     if (!oe.is_delete()) {
       dout(20) << "merge_old_entry  had " << oe << " deleting" << dendl;
-      t.remove(coll, oe.soid);
+      remove_object_with_snap_hardlinks(t, oe.soid);
     }
     dout(20) << "merge_old_entry  had " << oe << " reverting to "
             << oe.prior_version << dendl;
@@ -530,7 +547,7 @@ void PG::merge_log(ObjectStore::Transaction& t,
       if (ne.soid <= info.last_backfill) {
        missing.add_next_event(ne);
        if (ne.is_delete())
-         t.remove(coll, ne.soid);
+         remove_object_with_snap_hardlinks(t, ne.soid);
       }
     }
       
index 15a00610731476514637833fce039b6450e6998d..5d9f2280c796e03d3fae897570fd8f7e8b77496d 100644 (file)
@@ -715,6 +715,8 @@ public:
   void proc_master_log(ObjectStore::Transaction& t, pg_info_t &oinfo, pg_log_t &olog,
                       pg_missing_t& omissing, int from);
   bool proc_replica_info(int from, const pg_info_t &info);
+  void remove_object_with_snap_hardlinks(
+    ObjectStore::Transaction& t, const hobject_t& soid);
   bool merge_old_entry(ObjectStore::Transaction& t, pg_log_entry_t& oe);
 
   /**
index c7225f5aa9000647c8c406884b5e4c7cd9cdd773..2b48ca816bbcb96b85eb4a1179afb4ae610fdcda 100644 (file)
@@ -6710,22 +6710,6 @@ void ReplicatedPG::scan_range(hobject_t begin, int min, int max, BackfillInterva
 }
 
 
-void ReplicatedPG::remove_object_with_snap_hardlinks(ObjectStore::Transaction& t, const hobject_t& soid)
-{
-  t.remove(coll, soid);
-  if (soid.snap < CEPH_MAXSNAP) {
-    bufferlist ba;
-    int r = osd->store->getattr(coll, soid, OI_ATTR, ba);
-    if (r >= 0) {
-      // grr, need first snap bound, too.
-      object_info_t oi(ba);
-      if (oi.snaps.size() > 1)
-       t.remove(coll_t(info.pgid, oi.snaps[oi.snaps.size() - 1]), soid);
-      t.remove(coll_t(info.pgid, oi.snaps[0]), soid);
-    }
-  }
-}
-
 /** clean_up_local
  * remove any objects that we're storing but shouldn't.
  * as determined by log.
index 7302e0bd6f5bbb53d3042daea6b615d465dfabd9..a786e2b966a5e1620c23e8e8c25619032da10bcf 100644 (file)
@@ -783,7 +783,6 @@ protected:
   int prepare_transaction(OpContext *ctx);
   
   // pg on-disk content
-  void remove_object_with_snap_hardlinks(ObjectStore::Transaction& t, const hobject_t& soid);
   void clean_up_local(ObjectStore::Transaction& t);
 
   void _clear_recovery_state();