tools: fix MDS journal import

Previously it only worked on fresh filesystems which
hadn't been trimmed yet, and resulted in an invalid
trimmed_pos when expire_pos wasn't on an object
boundary.

Fixes: #10025

Signed-off-by: John Spray <john.spray@redhat.com>
tools: persist trimmed_pos in journal dump

...rather than inferring something from expire_pos
that could leave trash behind in the range between
the original trimmed_pos and expire_pos.

Be backward compatible with old journal dumps
so that if someone is updating for other reasons
like getting better tools, they can still import
their journal.

Signed-off-by: John Spray <john.spray@redhat.com>
tools: error handling on journal import/export

Actually propagate nonzero returns codes!  Also
add checks on return values of I/O functions so
that someone doesn't think they've successfully
exported a journal if they haven't, and some
validation of the header pointers during import
so that people find out with a nice error
instead of an assertion if something is up.

Signed-off-by: John Spray <john.spray@redhat.com>

Fix compile issue in the position value cout.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
Merge pull request #2878 from ceph/wip-10025

#10025 Fix 'journal import' (aka undump)

Reviewed-by: Greg Farnum <gfarnum@redhat.com>