Lines Matching +full:non +full:- +full:live

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2021-2024 Oracle. All Rights Reserved.
35 * Live Inode Link Count Repair
38 * Use the live inode link count information that we collected to replace the
39 * nlink values of the incore inodes. A scrub->repair cycle should have left
40 * the live data and hooks active, so this is safe so long as we make sure the
63 if (obs->parents != 0) in xrep_nlinks_is_orphaned()
65 if (xchk_inode_is_dirtree_root(ip) || ip == sc->orphanage) in xrep_nlinks_is_orphaned()
78 pag = xfs_perag_get(sc->mp, XFS_INO_TO_AGNO(sc->mp, sc->ip->i_ino)); in xrep_nlinks_iunlink_remove()
79 error = xfs_iunlink_remove(sc->tp, pag, sc->ip); in xrep_nlinks_iunlink_remove()
86 * and resources in a certain order, it's possible that this will be a no-op.
93 struct xfs_scrub *sc = xnc->sc; in xrep_nlinks_repair_inode()
94 struct xfs_mount *mp = sc->mp; in xrep_nlinks_repair_inode()
95 struct xfs_inode *ip = sc->ip; in xrep_nlinks_repair_inode()
104 * they're correct for non-directories, and the directory repair code in xrep_nlinks_repair_inode()
120 error = xrep_adoption_trans_alloc(sc, &xnc->adoption); in xrep_nlinks_repair_inode()
137 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_link, 0, 0, 0, in xrep_nlinks_repair_inode()
138 &sc->tp); in xrep_nlinks_repair_inode()
145 xfs_trans_ijoin(sc->tp, ip, 0); in xrep_nlinks_repair_inode()
148 mutex_lock(&xnc->lock); in xrep_nlinks_repair_inode()
150 if (xchk_iscan_aborted(&xnc->collect_iscan)) { in xrep_nlinks_repair_inode()
151 error = -ECANCELED; in xrep_nlinks_repair_inode()
155 error = xfarray_load_sparse(xnc->nlinks, ip->i_ino, &obs); in xrep_nlinks_repair_inode()
163 mutex_unlock(&xnc->lock); in xrep_nlinks_repair_inode()
166 actual_nlink = VFS_I(ip)->i_nlink; in xrep_nlinks_repair_inode()
169 * Non-directories cannot have directories pointing up to them. in xrep_nlinks_repair_inode()
175 * store. This is a never-ending and stupid battle; both tools missed in xrep_nlinks_repair_inode()
178 if (!S_ISDIR(VFS_I(ip)->i_mode) && obs.children != 0) { in xrep_nlinks_repair_inode()
191 error = xrep_adoption_compute_name(&xnc->adoption, &xnc->xname); in xrep_nlinks_repair_inode()
200 error = xrep_adoption_move(&xnc->adoption); in xrep_nlinks_repair_inode()
205 * Re-read the link counts since the reparenting will have in xrep_nlinks_repair_inode()
208 mutex_lock(&xnc->lock); in xrep_nlinks_repair_inode()
209 error = xfarray_load_sparse(xnc->nlinks, ip->i_ino, &obs); in xrep_nlinks_repair_inode()
210 mutex_unlock(&xnc->lock); in xrep_nlinks_repair_inode()
215 actual_nlink = VFS_I(ip)->i_nlink; in xrep_nlinks_repair_inode()
235 error = xfs_iunlink(sc->tp, ip); in xrep_nlinks_repair_inode()
255 xfs_trans_log_inode(sc->tp, ip, XFS_ILOG_CORE); in xrep_nlinks_repair_inode()
261 mutex_unlock(&xnc->lock); in xrep_nlinks_repair_inode()
286 error = xchk_iscan_iter(&xnc->compare_iscan, ipp); in xrep_nlinks_iter()
287 } while (error == -EBUSY); in xrep_nlinks_iter()
297 struct xchk_nlink_ctrs *xnc = sc->buf; in xrep_nlinks()
308 if (!xfs_has_ftype(sc->mp)) in xrep_nlinks()
309 return -EOPNOTSUPP; in xrep_nlinks()
314 * seconds -- even if repair misses a few inodes, we still try to fix in xrep_nlinks()
317 xchk_iscan_start(sc, 30000, 100, &xnc->compare_iscan); in xrep_nlinks()
318 ASSERT(sc->ip == NULL); in xrep_nlinks()
320 while ((error = xrep_nlinks_iter(xnc, &sc->ip)) == 1) { in xrep_nlinks()
328 xchk_iscan_mark_visited(&xnc->compare_iscan, sc->ip); in xrep_nlinks()
329 xchk_irele(sc, sc->ip); in xrep_nlinks()
330 sc->ip = NULL; in xrep_nlinks()
347 xchk_iscan_iter_finish(&xnc->compare_iscan); in xrep_nlinks()
348 xchk_iscan_teardown(&xnc->compare_iscan); in xrep_nlinks()