#include "xfs_platform.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_rtgroup.h"
#include "xfs_log_format.h"
#include "xfs_trans.h"
#include "xfs_sb.h"
#include "xfs_rmap.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/repair.h"
int
xchk_setup_rgsuperblock(
struct xfs_scrub *sc)
{
if (xchk_need_intent_drain(sc))
xchk_fsgates_enable(sc, XCHK_FSGATES_DRAIN);
return xchk_trans_alloc(sc, 0);
}
STATIC void
xchk_rgsuperblock_xref(
struct xfs_scrub *sc)
{
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return;
xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1);
xchk_xref_is_only_rt_owned_by(sc, 0, 1, &XFS_RMAP_OINFO_FS);
}
int
xchk_rgsuperblock(
struct xfs_scrub *sc)
{
xfs_rgnumber_t rgno = sc->sm->sm_agno;
unsigned int flags;
int error;
if (rgno != 0)
return -ENOENT;
error = xchk_rtgroup_init_existing(sc, rgno, &sc->sr);
if (!xchk_xref_process_error(sc, 0, 0, &error))
return error;
if (xfs_has_rtrmapbt(sc->mp))
flags = XFS_RTGLOCK_BITMAP | XFS_RTGLOCK_RMAP;
else
flags = XFS_RTGLOCK_BITMAP_SHARED;
error = xchk_rtgroup_lock(sc, &sc->sr, flags);
if (error)
return error;
xchk_rgsuperblock_xref(sc);
return 0;
}
#ifdef CONFIG_XFS_ONLINE_REPAIR
int
xrep_rgsuperblock(
struct xfs_scrub *sc)
{
struct xfs_buf *sb_bp;
ASSERT(rtg_rgno(sc->sr.rtg) == 0);
sb_bp = xfs_trans_getsb(sc->tp);
xfs_log_sb(sc->tp);
xfs_log_rtsb(sc->tp, sb_bp);
return 0;
}
#endif