]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs: Purge trailing objects during import
authorJohn Spray <john.spray@inktank.com>
Wed, 21 May 2014 13:07:45 +0000 (14:07 +0100)
committerJohn Spray <john.spray@redhat.com>
Fri, 13 Jun 2014 10:39:17 +0000 (11:39 +0100)
Reviewed-by: Gregory Farnum <greg@inktank.com>
Signed-off-by: John Spray <john.spray@inktank.com>
qa/workunits/suites/cephfs_journal_tool_smoke.sh
src/tools/cephfs/Dumper.cc

index 30da44334feb3e49d74838fd9f23d2feccf0032b..91ec952f4d44107193059c6aff234fae4d790c20 100644 (file)
@@ -25,6 +25,11 @@ if [ ! -s $JOURNAL_FILE ] ; then
     exit -1
 fi
 
+# Can we execute a journal reset?
+$BIN journal reset
+$BIN journal inspect
+$BIN header get
+
 # Can we import what we exported?
 $BIN journal import $JOURNAL_FILE
 
@@ -57,11 +62,3 @@ $BIN header set trimmed_pos 123
 echo "Rolling back journal to original state..."
 $BIN journal import $JOURNAL_FILE
 
-# XXX doing this *last* because journal reset appends to the journal,
-# and import does not truncated the appended part, resulting in
-# corruption when trying to do an 'import' after a 'reset'.
-# Can we execute a journal reset?
-$BIN journal reset
-$BIN journal inspect
-$BIN header get
-
index 838a296a0c3ab13891dc8367f90ede0f5bdedf3f..72d14e8add2e5e9825ec8e555859064f39dd7a04 100644 (file)
@@ -182,9 +182,28 @@ void Dumper::undump(const char *dump_file)
     derr << "Failed to write header: " << cpp_strerror(r) << dendl;
     return;
   }
+
+  Filer filer(objecter);
+
+  /* Erase any objects at the end of the region to which we shall write
+   * the new log data.  This is to avoid leaving trailing junk after
+   * the newly written data.  Any junk more than one object ahead
+   * will be taken care of during normal operation by Journaler's
+   * prezeroing behaviour */
+  {
+    uint32_t const object_size = h.layout.fl_object_size;
+    assert(object_size > 0);
+    uint64_t const last_obj = h.write_pos / object_size;
+    uint64_t const purge_count = 2;
+    C_SaferCond purge_cond;
+    cout << "Purging " << purge_count << " objects from " << last_obj << std::endl;
+    lock.Lock();
+    filer.purge_range(ino, &h.layout, snapc, last_obj, purge_count, ceph_clock_now(g_ceph_context), 0, &purge_cond);
+    lock.Unlock();
+    purge_cond.wait();
+  }
   
   // Stream from `fd` to `filer`
-  Filer filer(objecter);
   uint64_t pos = start;
   uint64_t left = len;
   while (left > 0) {