LCOV - code coverage report
Current view: top level - fs/xfs/scrub - repair.h (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc3-acha @ Mon Jul 31 20:08:06 PDT 2023 Lines: 3 5 60.0 %
Date: 2023-07-31 20:08:07 Functions: 0 1 0.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0-or-later
       2             : /*
       3             :  * Copyright (C) 2018-2023 Oracle.  All Rights Reserved.
       4             :  * Author: Darrick J. Wong <djwong@kernel.org>
       5             :  */
       6             : #ifndef __XFS_SCRUB_REPAIR_H__
       7             : #define __XFS_SCRUB_REPAIR_H__
       8             : 
       9             : #include "xfs_quota_defs.h"
      10             : 
      11             : struct xchk_stats_run;
      12             : 
      13           0 : static inline int xrep_notsupported(struct xfs_scrub *sc)
      14             : {
      15           0 :         return -EOPNOTSUPP;
      16             : }
      17             : 
      18             : #ifdef CONFIG_XFS_ONLINE_REPAIR
      19             : 
      20             : /* Repair helpers */
      21             : 
      22             : int xrep_attempt(struct xfs_scrub *sc, struct xchk_stats_run *run);
      23             : bool xrep_will_attempt(struct xfs_scrub *sc);
      24             : void xrep_failure(struct xfs_mount *mp);
      25             : int xrep_roll_ag_trans(struct xfs_scrub *sc);
      26             : int xrep_roll_trans(struct xfs_scrub *sc);
      27             : int xrep_defer_finish(struct xfs_scrub *sc);
      28             : bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
      29             :                 enum xfs_ag_resv_type type);
      30             : xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
      31             : 
      32             : static inline int
      33             : xrep_trans_commit(
      34             :         struct xfs_scrub        *sc)
      35             : {
      36      373885 :         int                     error = xfs_trans_commit(sc->tp);
      37             : 
      38      373885 :         sc->tp = NULL;
      39      373885 :         return error;
      40             : }
      41             : 
      42             : struct xbitmap;
      43             : struct xagb_bitmap;
      44             : struct xfsb_bitmap;
      45             : 
      46             : int xrep_fix_freelist(struct xfs_scrub *sc, int alloc_flags);
      47             : 
      48             : struct xrep_find_ag_btree {
      49             :         /* in: rmap owner of the btree we're looking for */
      50             :         uint64_t                        rmap_owner;
      51             : 
      52             :         /* in: buffer ops */
      53             :         const struct xfs_buf_ops        *buf_ops;
      54             : 
      55             :         /* in: maximum btree height */
      56             :         unsigned int                    maxlevels;
      57             : 
      58             :         /* out: the highest btree block found and the tree height */
      59             :         xfs_agblock_t                   root;
      60             :         unsigned int                    height;
      61             : };
      62             : 
      63             : int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
      64             :                 struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
      65             : 
      66             : #ifdef CONFIG_XFS_QUOTA
      67             : void xrep_update_qflags(struct xfs_scrub *sc, unsigned int clear_flags,
      68             :                 unsigned int set_flags);
      69             : void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
      70             : int xrep_ino_dqattach(struct xfs_scrub *sc);
      71             : #else
      72             : # define xrep_force_quotacheck(sc, type)        ((void)0)
      73             : # define xrep_ino_dqattach(sc)                  (0)
      74             : #endif /* CONFIG_XFS_QUOTA */
      75             : 
      76             : int xrep_setup_buftarg(struct xfs_scrub *sc, const char *descr);
      77             : 
      78             : int xrep_ino_ensure_extent_count(struct xfs_scrub *sc, int whichfork,
      79             :                 xfs_extnum_t nextents);
      80             : int xrep_reset_perag_resv(struct xfs_scrub *sc);
      81             : int xrep_bmap(struct xfs_scrub *sc, int whichfork, bool allow_unwritten);
      82             : int xrep_metadata_inode_forks(struct xfs_scrub *sc);
      83             : bool xrep_set_nlink(struct xfs_inode *ip, uint64_t nlink);
      84             : int xrep_setup_ag_rmapbt(struct xfs_scrub *sc);
      85             : int xrep_setup_ag_refcountbt(struct xfs_scrub *sc);
      86             : int xrep_setup_rtsummary(struct xfs_scrub *sc, unsigned int *resblks,
      87             :                 size_t *bufsize);
      88             : int xrep_setup_xattr(struct xfs_scrub *sc);
      89             : int xrep_setup_directory(struct xfs_scrub *sc);
      90             : int xrep_setup_parent(struct xfs_scrub *sc);
      91             : int xrep_setup_nlinks(struct xfs_scrub *sc);
      92             : int xrep_setup_symlink(struct xfs_scrub *sc, unsigned int *resblks);
      93             : int xrep_setup_dirtree(struct xfs_scrub *sc);
      94             : 
      95             : /* Repair setup functions */
      96             : int xrep_setup_ag_allocbt(struct xfs_scrub *sc);
      97             : 
      98             : struct xfs_imap;
      99             : int xrep_setup_inode(struct xfs_scrub *sc, struct xfs_imap *imap);
     100             : int xrep_setup_rtbitmap(struct xfs_scrub *sc, unsigned int *resblks);
     101             : 
     102             : void xrep_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);
     103             : int xrep_ag_init(struct xfs_scrub *sc, struct xfs_perag *pag,
     104             :                 struct xchk_ag *sa);
     105             : 
     106             : /* Metadata revalidators */
     107             : 
     108             : int xrep_revalidate_allocbt(struct xfs_scrub *sc);
     109             : int xrep_revalidate_iallocbt(struct xfs_scrub *sc);
     110             : 
     111             : /* Metadata repairers */
     112             : 
     113             : int xrep_probe(struct xfs_scrub *sc);
     114             : int xrep_superblock(struct xfs_scrub *sc);
     115             : int xrep_agf(struct xfs_scrub *sc);
     116             : int xrep_agfl(struct xfs_scrub *sc);
     117             : int xrep_agi(struct xfs_scrub *sc);
     118             : int xrep_allocbt(struct xfs_scrub *sc);
     119             : int xrep_iallocbt(struct xfs_scrub *sc);
     120             : int xrep_rmapbt(struct xfs_scrub *sc);
     121             : int xrep_refcountbt(struct xfs_scrub *sc);
     122             : int xrep_inode(struct xfs_scrub *sc);
     123             : int xrep_bmap_data(struct xfs_scrub *sc);
     124             : int xrep_bmap_attr(struct xfs_scrub *sc);
     125             : int xrep_bmap_cow(struct xfs_scrub *sc);
     126             : int xrep_nlinks(struct xfs_scrub *sc);
     127             : int xrep_fscounters(struct xfs_scrub *sc);
     128             : int xrep_xattr(struct xfs_scrub *sc);
     129             : int xrep_directory(struct xfs_scrub *sc);
     130             : int xrep_parent(struct xfs_scrub *sc);
     131             : int xrep_symlink(struct xfs_scrub *sc);
     132             : int xrep_dirtree(struct xfs_scrub *sc);
     133             : 
     134             : #ifdef CONFIG_XFS_RT
     135             : int xrep_rtbitmap(struct xfs_scrub *sc);
     136             : int xrep_rtsummary(struct xfs_scrub *sc);
     137             : #else
     138             : # define xrep_rtbitmap                  xrep_notsupported
     139             : # define xrep_rtsummary                 xrep_notsupported
     140             : #endif /* CONFIG_XFS_RT */
     141             : 
     142             : #ifdef CONFIG_XFS_QUOTA
     143             : int xrep_quota(struct xfs_scrub *sc);
     144             : int xrep_quotacheck(struct xfs_scrub *sc);
     145             : #else
     146             : # define xrep_quota                     xrep_notsupported
     147             : # define xrep_quotacheck                xrep_notsupported
     148             : #endif /* CONFIG_XFS_QUOTA */
     149             : 
     150             : int xrep_reinit_pagf(struct xfs_scrub *sc);
     151             : int xrep_reinit_pagi(struct xfs_scrub *sc);
     152             : 
     153             : int xrep_trans_alloc_hook_dummy(struct xfs_mount *mp, void **cookiep,
     154             :                 struct xfs_trans **tpp);
     155             : void xrep_trans_cancel_hook_dummy(void **cookiep, struct xfs_trans *tp);
     156             : 
     157             : bool xrep_buf_verify_struct(struct xfs_buf *bp, const struct xfs_buf_ops *ops);
     158             : 
     159             : #else
     160             : 
     161             : #define xrep_ino_dqattach(sc)   (0)
     162             : #define xrep_will_attempt(sc)   (false)
     163             : 
     164             : static inline int
     165             : xrep_attempt(
     166             :         struct xfs_scrub        *sc,
     167             :         struct xchk_stats_run   *run)
     168             : {
     169             :         return -EOPNOTSUPP;
     170             : }
     171             : 
     172             : static inline void xrep_failure(struct xfs_mount *mp) {}
     173             : 
     174             : static inline xfs_extlen_t
     175             : xrep_calc_ag_resblks(
     176             :         struct xfs_scrub        *sc)
     177             : {
     178             :         return 0;
     179             : }
     180             : 
     181             : static inline int
     182             : xrep_reset_perag_resv(
     183             :         struct xfs_scrub        *sc)
     184             : {
     185             :         if (!(sc->flags & XREP_RESET_PERAG_RESV))
     186             :                 return 0;
     187             : 
     188             :         ASSERT(0);
     189             :         return -EOPNOTSUPP;
     190             : }
     191             : 
     192             : /* repair setup functions for no-repair */
     193             : static inline int
     194             : xrep_setup_nothing(
     195             :         struct xfs_scrub        *sc)
     196             : {
     197             :         return 0;
     198             : }
     199             : #define xrep_setup_ag_allocbt           xrep_setup_nothing
     200             : #define xrep_setup_ag_rmapbt            xrep_setup_nothing
     201             : #define xrep_setup_ag_refcountbt        xrep_setup_nothing
     202             : #define xrep_setup_xattr                xrep_setup_nothing
     203             : #define xrep_setup_directory            xrep_setup_nothing
     204             : #define xrep_setup_parent               xrep_setup_nothing
     205             : #define xrep_setup_nlinks               xrep_setup_nothing
     206             : #define xrep_setup_dirtree              xrep_setup_nothing
     207             : 
     208             : #define xrep_setup_inode(sc, imap)      ((void)0)
     209             : 
     210             : static inline int xrep_setup_rtbitmap(struct xfs_scrub *sc, unsigned int *x)
     211             : {
     212             :         return 0;
     213             : }
     214             : 
     215             : static inline int
     216             : xrep_setup_rtsummary(
     217             :         struct xfs_scrub        *sc,
     218             :         unsigned int            *whatever,
     219             :         size_t                  *dontcare)
     220             : {
     221             :         return 0;
     222             : }
     223             : 
     224             : static inline int xrep_setup_symlink(struct xfs_scrub *sc, unsigned int *x)
     225             : {
     226             :         return 0;
     227             : }
     228             : 
     229             : #define xrep_revalidate_allocbt         (NULL)
     230             : #define xrep_revalidate_iallocbt        (NULL)
     231             : 
     232             : #define xrep_probe                      xrep_notsupported
     233             : #define xrep_superblock                 xrep_notsupported
     234             : #define xrep_agf                        xrep_notsupported
     235             : #define xrep_agfl                       xrep_notsupported
     236             : #define xrep_agi                        xrep_notsupported
     237             : #define xrep_allocbt                    xrep_notsupported
     238             : #define xrep_iallocbt                   xrep_notsupported
     239             : #define xrep_rmapbt                     xrep_notsupported
     240             : #define xrep_refcountbt                 xrep_notsupported
     241             : #define xrep_inode                      xrep_notsupported
     242             : #define xrep_bmap_data                  xrep_notsupported
     243             : #define xrep_bmap_attr                  xrep_notsupported
     244             : #define xrep_bmap_cow                   xrep_notsupported
     245             : #define xrep_rtbitmap                   xrep_notsupported
     246             : #define xrep_quota                      xrep_notsupported
     247             : #define xrep_quotacheck                 xrep_notsupported
     248             : #define xrep_nlinks                     xrep_notsupported
     249             : #define xrep_fscounters                 xrep_notsupported
     250             : #define xrep_rtsummary                  xrep_notsupported
     251             : #define xrep_xattr                      xrep_notsupported
     252             : #define xrep_directory                  xrep_notsupported
     253             : #define xrep_parent                     xrep_notsupported
     254             : #define xrep_symlink                    xrep_notsupported
     255             : #define xrep_dirtree                    xrep_notsupported
     256             : 
     257             : #endif /* CONFIG_XFS_ONLINE_REPAIR */
     258             : 
     259             : #endif  /* __XFS_SCRUB_REPAIR_H__ */

Generated by: LCOV version 1.14