LCOV - code coverage report
Current view: top level - fs/xfs/scrub - orphanage.h (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc4-xfsx @ Mon Jul 31 20:08:34 PDT 2023 Lines: 5 6 83.3 %
Date: 2023-07-31 20:08:34 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0-or-later
       2             : /*
       3             :  * Copyright (C) 2021-2023 Oracle.  All Rights Reserved.
       4             :  * Author: Darrick J. Wong <djwong@kernel.org>
       5             :  */
       6             : #ifndef __XFS_SCRUB_ORPHANAGE_H__
       7             : #define __XFS_SCRUB_ORPHANAGE_H__
       8             : 
       9             : #ifdef CONFIG_XFS_ONLINE_REPAIR
      10             : int xrep_orphanage_create(struct xfs_scrub *sc);
      11             : 
      12             : /*
      13             :  * If we're doing a repair, ensure that the orphanage exists and attach it to
      14             :  * the scrub context.
      15             :  */
      16             : static inline int
      17     5150339 : xrep_orphanage_try_create(
      18             :         struct xfs_scrub        *sc)
      19             : {
      20     5150339 :         int                     error;
      21             : 
      22     5150339 :         ASSERT(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR);
      23             : 
      24     5150339 :         error = xrep_orphanage_create(sc);
      25     5150765 :         switch (error) {
      26             :         case 0:
      27             :         case -ENOENT:
      28             :         case -ENOTDIR:
      29             :         case -ENOSPC:
      30             :                 /*
      31             :                  * If the orphanage can't be found or isn't a directory, we'll
      32             :                  * keep going, but we won't be able to attach the file to the
      33             :                  * orphanage if we can't find the parent.
      34             :                  */
      35             :                 return 0;
      36             :         }
      37             : 
      38           0 :         return error;
      39             : }
      40             : 
      41             : int xrep_orphanage_iolock_two(struct xfs_scrub *sc);
      42             : 
      43             : /* Information about a request to add a file to the orphanage. */
      44             : struct xrep_adoption {
      45             :         /* Name structure; caller must provide a buffer separately. */
      46             :         struct xfs_name         xname;
      47             : 
      48             :         struct xfs_scrub        *sc;
      49             : 
      50             :         struct xfs_parent_defer *parent;
      51             : 
      52             :         /* Block reservations for orphanage and child (if directory). */
      53             :         unsigned int            orphanage_blkres;
      54             :         unsigned int            child_blkres;
      55             : 
      56             :         /*
      57             :          * Does the caller want us to bump the child link count?  This is not
      58             :          * needed when reattaching files that have become disconnected but have
      59             :          * nlink > 1.  It is necessary when changing the directory tree
      60             :          * structure.
      61             :          */
      62             :         bool                    bump_child_nlink:1;
      63             : };
      64             : 
      65             : int xrep_adoption_init(struct xfs_scrub *sc, struct xrep_adoption *adopt);
      66             : int xrep_adoption_compute_name(struct xrep_adoption *adopt,
      67             :                 unsigned char *namebuf);
      68             : int xrep_adoption_prep(struct xrep_adoption *adopt);
      69             : int xrep_adoption_commit(struct xrep_adoption *adopt);
      70             : void xrep_adoption_cancel(struct xrep_adoption *adopt, int error);
      71             : 
      72             : void xrep_orphanage_ilock(struct xfs_scrub *sc, unsigned int ilock_flags);
      73             : bool xrep_orphanage_ilock_nowait(struct xfs_scrub *sc,
      74             :                 unsigned int ilock_flags);
      75             : void xrep_orphanage_iunlock(struct xfs_scrub *sc, unsigned int ilock_flags);
      76             : 
      77             : bool xrep_orphanage_can_adopt(struct xfs_scrub *sc);
      78             : 
      79             : void xrep_orphanage_rele(struct xfs_scrub *sc);
      80             : #else
      81             : struct xrep_adoption { /* empty */ };
      82             : # define xrep_orphanage_rele(sc)
      83             : #endif /* CONFIG_XFS_ONLINE_REPAIR */
      84             : 
      85             : #endif /* __XFS_SCRUB_ORPHANAGE_H__ */

Generated by: LCOV version 1.14