From: Patrick Donnelly Date: Wed, 18 Jan 2023 19:39:00 +0000 (-0500) Subject: tools/cephfs/first-damage: fix iteration of big dirfrags X-Git-Tag: v18.1.0~471^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F49796%2Fhead;p=ceph.git tools/cephfs/first-damage: fix iteration of big dirfrags We have to iterate in chunks otherwise the get_omap_vals API returns partial results even if the max count is large. Signed-off-by: Patrick Donnelly --- diff --git a/qa/workunits/fs/damage/test-first-damage.sh b/qa/workunits/fs/damage/test-first-damage.sh index c1ae71ed013bf..5cbae5f37fa12 100755 --- a/qa/workunits/fs/damage/test-first-damage.sh +++ b/qa/workunits/fs/damage/test-first-damage.sh @@ -14,6 +14,7 @@ function usage { function create { + ceph config set mds mds_bal_fragment_dirs 0 mkdir dir DIR_INODE=$(stat -c '%i' dir) touch dir/a @@ -35,6 +36,11 @@ function create { 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 { @@ -62,6 +68,12 @@ function damage { 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" } diff --git a/src/tools/cephfs/first-damage.py b/src/tools/cephfs/first-damage.py index db61f972b4664..b7660f590f098 100644 --- a/src/tools/cephfs/first-damage.py +++ b/src/tools/cephfs/first-damage.py @@ -76,26 +76,32 @@ def traverse(MEMO, ioctx): 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(' 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(" 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("