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 3772328 : xrep_orphanage_try_create( 18 : struct xfs_scrub *sc) 19 : { 20 3772328 : int error; 21 : 22 3772328 : ASSERT(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR); 23 : 24 3772328 : error = xrep_orphanage_create(sc); 25 3772581 : 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 : int xrep_adoption_init(struct xfs_scrub *sc, struct xrep_adoption *adopt); 58 : int xrep_adoption_compute_name(struct xrep_adoption *adopt, 59 : unsigned char *namebuf); 60 : int xrep_adoption_prep(struct xrep_adoption *adopt); 61 : int xrep_adoption_commit(struct xrep_adoption *adopt); 62 : void xrep_adoption_cancel(struct xrep_adoption *adopt, int error); 63 : 64 : void xrep_orphanage_ilock(struct xfs_scrub *sc, unsigned int ilock_flags); 65 : bool xrep_orphanage_ilock_nowait(struct xfs_scrub *sc, 66 : unsigned int ilock_flags); 67 : void xrep_orphanage_iunlock(struct xfs_scrub *sc, unsigned int ilock_flags); 68 : 69 : void xrep_orphanage_rele(struct xfs_scrub *sc); 70 : #else 71 : struct xrep_adoption { /* empty */ }; 72 : # define xrep_orphanage_rele(sc) 73 : #endif /* CONFIG_XFS_ONLINE_REPAIR */ 74 : 75 : #endif /* __XFS_SCRUB_ORPHANAGE_H__ */