5 FIRST_DAMAGE
="first-damage.py"
7 METADATA_POOL
=cephfs_meta
11 printf '%s: [--fs=<fs_name>] [--metadata-pool=<pool>] [--first-damage=</path/to/first-damage.py>]\n'
17 ceph config
set mds mds_bal_fragment_dirs
0
19 DIR_INODE
=$
(stat
-c '%i' dir
)
37 # unlink then create, HEAD not snapped
40 BIG_DIR_INODE
=$
(stat
-c '%i' big
)
41 for i
in `seq 1 15000`; do
42 touch $
(printf 'big/%08d' $i)
47 ceph tell mds.
"$FS":0 flush journal
51 local IS
=$
(printf '%llx.%08llx' "$DIR_INODE" 0)
52 local LS
=$
(ceph tell mds.
"$FS":0 dump snaps | jq .last_created
)
54 local T
=$
(mktemp
-p /tmp
)
56 # nuke snap 1 version of "a"
57 rados
--pool="$METADATA_POOL" getomapval
"$IS" a_$
(printf %x $
((LS-4
))) "$T"
58 printf '\xff\xff\xff\xf0' |
dd of
="$T" count
=4 bs
=1 conv
=notrunc
,nocreat
59 rados
--pool="$METADATA_POOL" setomapval
"$IS" a_$
(printf %x $
((LS-4
))) --input-file="$T"
61 # nuke snap 4 version of "a"
62 rados
--pool="$METADATA_POOL" getomapval
"$IS" a_$
(printf %x $
((LS-1
))) "$T"
63 printf '\xff\xff\xff\xff' |
dd of
="$T" count
=4 bs
=1 conv
=notrunc
,nocreat
64 rados
--pool="$METADATA_POOL" setomapval
"$IS" a_$
(printf %x $
((LS-1
))) --input-file="$T"
67 rados
--pool="$METADATA_POOL" getomapval
"$IS" a_head
"$T"
68 printf '\xfe\xff\xff\xff' |
dd of
="$T" count
=4 bs
=1 conv
=notrunc
,nocreat
69 rados
--pool="$METADATA_POOL" setomapval
"$IS" a_head
--input-file="$T"
71 # screw up HEAD on what dentry in big
72 IS
=$
(printf '%llx.%08llx' "$BIG_DIR_INODE" 0)
73 rados
--pool="$METADATA_POOL" getomapval
"$IS" 00009999_head
"$T"
74 printf '\xfe\xff\xff\xff' |
dd of
="$T" count
=4 bs
=1 conv
=notrunc
,nocreat
75 rados
--pool="$METADATA_POOL" setomapval
"$IS" 00009999_head
--input-file="$T"
84 cephfs-journal-tool
--rank="$FS":0 event recover_dentries summary
85 cephfs-journal-tool
--rank="$FS":0 journal
reset
86 python3
$FIRST_DAMAGE --debug /tmp
/debug1
--memo /tmp
/memo1
"$METADATA_POOL"
87 python3
$FIRST_DAMAGE --debug /tmp
/debug2
--memo /tmp
/memo2
--repair-nosnap "$METADATA_POOL"
88 python3
$FIRST_DAMAGE --debug /tmp
/debug3
--memo /tmp
/memo3
--remove "$METADATA_POOL"
89 ceph fs
set "$FS" joinable true
95 for i
in `seq 1 5`; do
96 stat dir
/.snap
/$i ||
exit 2
98 stat dir
/.snap
/2/a ||
exit 3
99 stat dir
/.snap
/5/a ||
exit 4
100 if stat dir
/.snap
/1/a
; then
104 if stat dir
/.snap
/3/a
; then
105 echo should not ever exist
108 if stat dir
/.snap
/4/a
; then
121 sudo
--preserve-env=CEPH_CONF bin
/mount.ceph
:/ "$MOUNT" -o name
=admin
,noshare
126 eval set -- $
(getopt
--name "$0" --options '' --longoptions 'help,fs:,metadata-pool:,first-damage:,mount:' -- "$@")
128 while [ "$#" -gt 0 ]; do
167 sudo umount
-f "$MOUNT"
169 # flush dentries/inodes to omap
176 sleep 5 # for mds to join
185 sudo umount
-f "$MOUNT"