diff options
author | Darrick J. Wong <djwong@kernel.org> | 2023-06-05 08:36:18 -0700 |
---|---|---|
committer | Carlos Maiolino <cem@kernel.org> | 2023-07-12 09:15:19 +0200 |
commit | ad662cc1734675623a484e111fa2422a08ee45d6 (patch) | |
tree | 81aec812bb2ff5d53b63cc86e5900bfd1bcf3e7d | |
parent | 4a16ce6837ce6f41f11dc51783470d00400a85bd (diff) | |
download | xfsprogs-dev-ad662cc1734675623a484e111fa2422a08ee45d6.tar.gz |
xfs_repair: warn about unwritten bits set in rmap btree keys
Now that we've changed libxfs to handle the rmapbt flags correctly when
creating and comparing rmapbt keys, teach repair to warn about keys that
have the unwritten bit erroneously set. The old broken behavior never
caused any problems, so we only warn once per filesystem and don't set
the exitcode to 1 if we're running in dry run mode.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r-- | repair/scan.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/repair/scan.c b/repair/scan.c index d66ce60cbb..008ef65ac7 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -966,6 +966,30 @@ verify_rmap_agbno( return agbno < libxfs_ag_block_count(mp, agno); } +static inline void +warn_rmap_unwritten_key( + xfs_agblock_t agno) +{ + static bool warned = false; + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + + if (warned) + return; + + pthread_mutex_lock(&lock); + if (!warned) { + if (no_modify) + do_log( + _("would clear unwritten flag on rmapbt key in agno 0x%x\n"), + agno); + else + do_warn( + _("clearing unwritten flag on rmapbt key in agno 0x%x\n"), + agno); + warned = true; + } + pthread_mutex_unlock(&lock); +} static void scan_rmapbt( @@ -1218,6 +1242,8 @@ advance: key.rm_flags = 0; key.rm_startblock = be32_to_cpu(kp->rm_startblock); key.rm_owner = be64_to_cpu(kp->rm_owner); + if (kp->rm_offset & cpu_to_be64(XFS_RMAP_OFF_UNWRITTEN)) + warn_rmap_unwritten_key(agno); if (libxfs_rmap_irec_offset_unpack(be64_to_cpu(kp->rm_offset), &key)) { /* Look for impossible flags. */ @@ -1239,6 +1265,8 @@ advance: key.rm_flags = 0; key.rm_startblock = be32_to_cpu(kp->rm_startblock); key.rm_owner = be64_to_cpu(kp->rm_owner); + if (kp->rm_offset & cpu_to_be64(XFS_RMAP_OFF_UNWRITTEN)) + warn_rmap_unwritten_key(agno); if (libxfs_rmap_irec_offset_unpack(be64_to_cpu(kp->rm_offset), &key)) { /* Look for impossible flags. */ |