From: John Spray Date: Wed, 21 May 2014 13:07:45 +0000 (+0100) Subject: tools/cephfs: Purge trailing objects during import X-Git-Tag: v0.83~86^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ee487b422bd85b683751267a0f2f155bcc05f5f3;p=ceph.git tools/cephfs: Purge trailing objects during import Reviewed-by: Gregory Farnum Signed-off-by: John Spray --- diff --git a/qa/workunits/suites/cephfs_journal_tool_smoke.sh b/qa/workunits/suites/cephfs_journal_tool_smoke.sh index 30da44334feb..91ec952f4d44 100644 --- a/qa/workunits/suites/cephfs_journal_tool_smoke.sh +++ b/qa/workunits/suites/cephfs_journal_tool_smoke.sh @@ -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 - diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc index 838a296a0c3a..72d14e8add2e 100644 --- a/src/tools/cephfs/Dumper.cc +++ b/src/tools/cephfs/Dumper.cc @@ -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) {