1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2021-2024 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <djwong@kernel.org>
6 #ifndef __XFS_SCRUB_ORPHANAGE_H__
7 #define __XFS_SCRUB_ORPHANAGE_H__
9 #ifdef CONFIG_XFS_ONLINE_REPAIR
10 int xrep_orphanage_create(struct xfs_scrub
*sc
);
13 * If we're doing a repair, ensure that the orphanage exists and attach it to
17 xrep_orphanage_try_create(
22 ASSERT(sc
->sm
->sm_flags
& XFS_SCRUB_IFLAG_REPAIR
);
24 error
= xrep_orphanage_create(sc
);
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.
41 int xrep_orphanage_iolock_two(struct xfs_scrub
*sc
);
43 void xrep_orphanage_ilock(struct xfs_scrub
*sc
, unsigned int ilock_flags
);
44 bool xrep_orphanage_ilock_nowait(struct xfs_scrub
*sc
,
45 unsigned int ilock_flags
);
46 void xrep_orphanage_iunlock(struct xfs_scrub
*sc
, unsigned int ilock_flags
);
48 void xrep_orphanage_rele(struct xfs_scrub
*sc
);
50 /* Information about a request to add a file to the orphanage. */
51 struct xrep_adoption
{
54 /* Name used for the adoption. */
55 struct xfs_name
*xname
;
57 /* Parent pointer context tracking */
58 struct xfs_parent_args ppargs
;
60 /* Block reservations for orphanage and child (if directory). */
61 unsigned int orphanage_blkres
;
62 unsigned int child_blkres
;
65 * Does the caller want us to bump the child link count? This is not
66 * needed when reattaching files that have become disconnected but have
67 * nlink > 1. It is necessary when changing the directory tree
70 bool bump_child_nlink
:1;
73 bool xrep_orphanage_can_adopt(struct xfs_scrub
*sc
);
75 int xrep_adoption_trans_alloc(struct xfs_scrub
*sc
,
76 struct xrep_adoption
*adopt
);
77 int xrep_adoption_compute_name(struct xrep_adoption
*adopt
,
78 struct xfs_name
*xname
);
79 int xrep_adoption_move(struct xrep_adoption
*adopt
);
80 int xrep_adoption_trans_roll(struct xrep_adoption
*adopt
);
82 struct xrep_adoption
{ /* empty */ };
83 # define xrep_orphanage_rele(sc) ((void)0)
84 #endif /* CONFIG_XFS_ONLINE_REPAIR */
86 #endif /* __XFS_SCRUB_ORPHANAGE_H__ */