function create {
+ ceph config set mds mds_bal_fragment_dirs 0
mkdir dir
DIR_INODE=$(stat -c '%i' dir)
touch dir/a
touch dir/a
# unlink then create, HEAD not snapped
ls dir/.snap/*/
+ mkdir big
+ BIG_DIR_INODE=$(stat -c '%i' big)
+ for i in `seq 1 15000`; do
+ touch $(printf 'big/%08d' $i)
+ done
}
function flush {
printf '\xfe\xff\xff\xff' | dd of="$T" count=4 bs=1 conv=notrunc,nocreat
rados --pool="$METADATA_POOL" setomapval "$IS" a_head --input-file="$T"
+ # screw up HEAD on what dentry in big
+ IS=$(printf '%llx.%08llx' "$BIG_DIR_INODE" 0)
+ rados --pool="$METADATA_POOL" getomapval "$IS" 00009999_head "$T"
+ printf '\xfe\xff\xff\xff' | dd of="$T" count=4 bs=1 conv=notrunc,nocreat
+ rados --pool="$METADATA_POOL" setomapval "$IS" 00009999_head --input-file="$T"
+
rm -f "$T"
}
log.info("examining: %s", o.key)
with rados.ReadOpCtx() as rctx:
- it = ioctx.get_omap_vals(rctx, None, None, 100000)[0]
- ioctx.operate_read_op(rctx, o.key)
- for (dnk, val) in it:
- log.debug('\t%s: val size %d', dnk, len(val))
- (first,) = struct.unpack('<I', val[:4])
- if first > NEXT_SNAP:
- log.warning(f"found {o.key}:{dnk} first (0x{first:x}) > NEXT_SNAP (0x{NEXT_SNAP:x})")
- if REPAIR_NOSNAP and dnk.endswith("_head") and first == CEPH_NOSNAP:
- log.warning(f"repairing first==CEPH_NOSNAP damage, setting to NEXT_SNAP (0x{NEXT_SNAP:x})")
- first = NEXT_SNAP
- nval = bytearray(val)
- struct.pack_into("<I", nval, 0, NEXT_SNAP)
- with rados.WriteOpCtx() as wctx:
- ioctx.set_omap(wctx, (dnk,), (bytes(nval),))
- ioctx.operate_write_op(wctx, o.key)
- elif REMOVE:
- log.warning(f"removing {o.key}:{dnk}")
- with rados.WriteOpCtx() as wctx:
- ioctx.remove_omap_keys(wctx, [dnk])
- ioctx.operate_write_op(wctx, o.key)
+ nkey = None
+ while True:
+ it = ioctx.get_omap_vals(rctx, nkey, None, 100)[0]
+ ioctx.operate_read_op(rctx, o.key)
+ nkey = None
+ for (dnk, val) in it:
+ log.debug('\t%s: val size %d', dnk, len(val))
+ (first,) = struct.unpack('<I', val[:4])
+ if first > NEXT_SNAP:
+ log.warning(f"found {o.key}:{dnk} first (0x{first:x}) > NEXT_SNAP (0x{NEXT_SNAP:x})")
+ if REPAIR_NOSNAP and dnk.endswith("_head") and first == CEPH_NOSNAP:
+ log.warning(f"repairing first==CEPH_NOSNAP damage, setting to NEXT_SNAP (0x{NEXT_SNAP:x})")
+ first = NEXT_SNAP
+ nval = bytearray(val)
+ struct.pack_into("<I", nval, 0, NEXT_SNAP)
+ with rados.WriteOpCtx() as wctx:
+ ioctx.set_omap(wctx, (dnk,), (bytes(nval),))
+ ioctx.operate_write_op(wctx, o.key)
+ elif REMOVE:
+ log.warning(f"removing {o.key}:{dnk}")
+ with rados.WriteOpCtx() as wctx:
+ ioctx.remove_omap_keys(wctx, [dnk])
+ ioctx.operate_write_op(wctx, o.key)
+ nkey = dnk
+ if nkey is None:
+ break
MEMO.write(f"{o.key}\n")
if __name__ == '__main__':