6 export BIN="${BIN:-cephfs-journal-tool}"
7 export JOURNAL_FILE=/tmp/journal.bin
8 export JSON_OUTPUT=/tmp/json.tmp
9 export BINARY_OUTPUT=/tmp/binary.tmp
11 if [ -d $BINARY_OUTPUT ] ; then
15 # Check that the import/export stuff really works as expected
16 # first because it's used as the reset method between
18 echo "Testing that export/import cycle preserves state"
19 HEADER_STATE=`$BIN header get`
20 EVENT_LIST=`$BIN event get list`
21 $BIN journal export $JOURNAL_FILE
22 $BIN journal import $JOURNAL_FILE
23 NEW_HEADER_STATE=`$BIN header get`
24 NEW_EVENT_LIST=`$BIN event get list`
26 if [ ! "$HEADER_STATE" = "$NEW_HEADER_STATE" ] ; then
27 echo "Import failed to preserve header state"
29 echo $NEW_HEADER_STATE
33 if [ ! "$EVENT_LIST" = "$NEW_EVENT_LIST" ] ; then
34 echo "Import failed to preserve event state"
40 echo "Testing 'journal' commands..."
42 # Simplest thing: print the vital statistics of the journal
46 # Make a copy of the journal in its original state
47 $BIN journal export $JOURNAL_FILE
48 if [ ! -s $JOURNAL_FILE ] ; then
49 echo "Export to $JOURNAL_FILE failed"
53 # Can we execute a journal reset?
58 echo "Rolling back journal to original state..."
59 $BIN journal import $JOURNAL_FILE
61 echo "Testing 'header' commands..."
63 $BIN header set write_pos 123
64 $BIN header set expire_pos 123
65 $BIN header set trimmed_pos 123
67 echo "Rolling back journal to original state..."
68 $BIN journal import $JOURNAL_FILE
70 echo "Testing 'event' commands..."
71 $BIN event get summary
72 $BIN event get --type=UPDATE --path=/ --inode=0 --frag=0x100 summary
73 $BIN event get json --path $JSON_OUTPUT
74 if [ ! -s $JSON_OUTPUT ] ; then
75 echo "Export to $JSON_OUTPUT failed"
78 $BIN event get binary --path $BINARY_OUTPUT
79 if [ ! -s $BINARY_OUTPUT ] ; then
80 echo "Export to $BINARY_OUTPUT failed"
83 $BIN event recover_dentries summary
84 $BIN event splice summary
87 # Metadata objects have been modified by the 'event recover_dentries' command.
88 # Journal is no long consistent with respect to metadata objects (especially inotable).
89 # To ensure mds successfully replays its journal, we need to do journal reset.
91 cephfs-table-tool all reset session