LCOV - code coverage report
Current view: top level - fs/xfs/scrub - rgsuper.c (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc4-xfsx @ Mon Jul 31 20:08:34 PDT 2023 Lines: 24 25 96.0 %
Date: 2023-07-31 20:08:34 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0-or-later
       2             : /*
       3             :  * Copyright (C) 2022-2023 Oracle.  All Rights Reserved.
       4             :  * Author: Darrick J. Wong <djwong@kernel.org>
       5             :  */
       6             : #include "xfs.h"
       7             : #include "xfs_fs.h"
       8             : #include "xfs_shared.h"
       9             : #include "xfs_format.h"
      10             : #include "xfs_trans_resv.h"
      11             : #include "xfs_mount.h"
      12             : #include "xfs_rtgroup.h"
      13             : #include "scrub/scrub.h"
      14             : #include "scrub/common.h"
      15             : 
      16             : /* Set us up with a transaction and an empty context. */
      17             : int
      18       61053 : xchk_setup_rgsuperblock(
      19             :         struct xfs_scrub        *sc)
      20             : {
      21       61053 :         return xchk_trans_alloc(sc, 0);
      22             : }
      23             : 
      24             : /* Cross-reference with the other rt metadata. */
      25             : STATIC void
      26       61050 : xchk_rgsuperblock_xref(
      27             :         struct xfs_scrub        *sc)
      28             : {
      29       61050 :         struct xfs_mount        *mp = sc->mp;
      30       61050 :         xfs_rgnumber_t          rgno = sc->sr.rtg->rtg_rgno;
      31       61050 :         xfs_rtblock_t           rtbno;
      32             : 
      33       61050 :         if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
      34             :                 return;
      35             : 
      36       61050 :         rtbno = xfs_rgbno_to_rtb(mp, rgno, 0);
      37       61085 :         xchk_xref_is_used_rt_space(sc, rtbno, 1);
      38             : }
      39             : 
      40             : int
      41       61040 : xchk_rgsuperblock(
      42             :         struct xfs_scrub        *sc)
      43             : {
      44       61040 :         struct xfs_buf          *bp;
      45       61040 :         xfs_rgnumber_t          rgno = sc->sm->sm_agno;
      46       61040 :         int                     error;
      47             : 
      48             :         /*
      49             :          * Grab an active reference to the rtgroup structure.  If we can't get
      50             :          * it, we're racing with something that's tearing down the group, so
      51             :          * signal that the group no longer exists.  Take the rtbitmap in shared
      52             :          * mode so that the group can't change while we're doing things.
      53             :          */
      54       61040 :         error = xchk_rtgroup_init(sc, rgno, &sc->sr, XFS_RTGLOCK_BITMAP_SHARED);
      55       61060 :         if (error)
      56             :                 return error;
      57             : 
      58             :         /*
      59             :          * If this is the primary rtgroup superblock, we know it passed the
      60             :          * verifier checks at mount time and do not need to load the buffer
      61             :          * again.
      62             :          */
      63       61060 :         if (sc->sr.rtg->rtg_rgno == 0) {
      64       11257 :                 xchk_rgsuperblock_xref(sc);
      65       11257 :                 return 0;
      66             :         }
      67             : 
      68             :         /* The secondary rt super is checked by the read verifier. */
      69      149439 :         error = xfs_buf_read_uncached(sc->mp->m_rtdev_targp, XFS_RTSB_DADDR,
      70       49803 :                         XFS_FSB_TO_BB(sc->mp, 1), 0, &bp, &xfs_rtsb_buf_ops);
      71       49833 :         if (!xchk_process_rt_error(sc, rgno, 0, &error))
      72           0 :                 return error;
      73             : 
      74       49753 :         xchk_rgsuperblock_xref(sc);
      75       49814 :         xfs_buf_relse(bp);
      76       49784 :         return 0;
      77             : }

Generated by: LCOV version 1.14