Lines Matching full:sc

51 	struct xfs_scrub	*sc,  in xrep_chown_orphanage()  argument
55 struct xfs_mount *mp = sc->mp; in xrep_chown_orphanage()
120 /* Create the orphanage directory, and set sc->orphanage to it. */
123 struct xfs_scrub *sc) in xrep_orphanage_create() argument
125 struct xfs_mount *mp = sc->mp; in xrep_orphanage_create()
127 struct inode *root_inode = VFS_I(sc->mp->m_rootip); in xrep_orphanage_create()
134 sc->orphanage = NULL; in xrep_orphanage_create()
138 ASSERT(sc->tp == NULL); in xrep_orphanage_create()
139 ASSERT(sc->orphanage == NULL); in xrep_orphanage_create()
195 error = xrep_chown_orphanage(sc, XFS_I(orphanage_inode)); in xrep_orphanage_create()
200 sc->orphanage = XFS_I(orphanage_inode); in xrep_orphanage_create()
201 sc->orphanage_ilock_flags = 0; in xrep_orphanage_create()
206 inode_unlock(VFS_I(sc->mp->m_rootip)); in xrep_orphanage_create()
215 struct xfs_scrub *sc, in xrep_orphanage_ilock() argument
218 sc->orphanage_ilock_flags |= ilock_flags; in xrep_orphanage_ilock()
219 xfs_ilock(sc->orphanage, ilock_flags); in xrep_orphanage_ilock()
224 struct xfs_scrub *sc, in xrep_orphanage_ilock_nowait() argument
227 if (xfs_ilock_nowait(sc->orphanage, ilock_flags)) { in xrep_orphanage_ilock_nowait()
228 sc->orphanage_ilock_flags |= ilock_flags; in xrep_orphanage_ilock_nowait()
237 struct xfs_scrub *sc, in xrep_orphanage_iunlock() argument
240 xfs_iunlock(sc->orphanage, ilock_flags); in xrep_orphanage_iunlock()
241 sc->orphanage_ilock_flags &= ~ilock_flags; in xrep_orphanage_iunlock()
244 /* Grab the IOLOCK of the orphanage and sc->ip. */
247 struct xfs_scrub *sc) in xrep_orphanage_iolock_two() argument
252 if (xchk_should_terminate(sc, &error)) in xrep_orphanage_iolock_two()
260 if (xrep_orphanage_ilock_nowait(sc, XFS_IOLOCK_EXCL)) { in xrep_orphanage_iolock_two()
261 if (xchk_ilock_nowait(sc, XFS_IOLOCK_EXCL)) in xrep_orphanage_iolock_two()
263 xrep_orphanage_iunlock(sc, XFS_IOLOCK_EXCL); in xrep_orphanage_iolock_two()
274 struct xfs_scrub *sc) in xrep_orphanage_rele() argument
276 if (!sc->orphanage) in xrep_orphanage_rele()
279 if (sc->orphanage_ilock_flags) in xrep_orphanage_rele()
280 xfs_iunlock(sc->orphanage, sc->orphanage_ilock_flags); in xrep_orphanage_rele()
282 xchk_irele(sc, sc->orphanage); in xrep_orphanage_rele()
283 sc->orphanage = NULL; in xrep_orphanage_rele()
288 /* Can the orphanage adopt @sc->ip? */
291 struct xfs_scrub *sc) in xrep_orphanage_can_adopt() argument
293 ASSERT(sc->ip != NULL); in xrep_orphanage_can_adopt()
295 if (!sc->orphanage) in xrep_orphanage_can_adopt()
297 if (sc->ip == sc->orphanage) in xrep_orphanage_can_adopt()
299 if (xchk_inode_is_sb_rooted(sc->ip)) in xrep_orphanage_can_adopt()
301 if (xfs_is_internal_inode(sc->ip)) in xrep_orphanage_can_adopt()
310 * adoption, take ILOCK_EXCL of the orphanage and sc->ip, joins them to the
312 * IOLOCK of the orphanage and sc->ip.
316 struct xfs_scrub *sc, in xrep_adoption_trans_alloc() argument
319 struct xfs_mount *mp = sc->mp; in xrep_adoption_trans_alloc()
323 ASSERT(sc->tp == NULL); in xrep_adoption_trans_alloc()
324 ASSERT(sc->ip != NULL); in xrep_adoption_trans_alloc()
325 ASSERT(sc->orphanage != NULL); in xrep_adoption_trans_alloc()
326 ASSERT(sc->ilock_flags & XFS_IOLOCK_EXCL); in xrep_adoption_trans_alloc()
327 ASSERT(sc->orphanage_ilock_flags & XFS_IOLOCK_EXCL); in xrep_adoption_trans_alloc()
328 ASSERT(!(sc->ilock_flags & (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL))); in xrep_adoption_trans_alloc()
329 ASSERT(!(sc->orphanage_ilock_flags & in xrep_adoption_trans_alloc()
333 adopt->sc = sc; in xrep_adoption_trans_alloc()
335 if (S_ISDIR(VFS_I(sc->ip)->i_mode)) in xrep_adoption_trans_alloc()
349 &sc->tp); in xrep_adoption_trans_alloc()
353 xfs_lock_two_inodes(sc->orphanage, XFS_ILOCK_EXCL, in xrep_adoption_trans_alloc()
354 sc->ip, XFS_ILOCK_EXCL); in xrep_adoption_trans_alloc()
355 sc->ilock_flags |= XFS_ILOCK_EXCL; in xrep_adoption_trans_alloc()
356 sc->orphanage_ilock_flags |= XFS_ILOCK_EXCL; in xrep_adoption_trans_alloc()
358 xfs_trans_ijoin(sc->tp, sc->orphanage, 0); in xrep_adoption_trans_alloc()
359 xfs_trans_ijoin(sc->tp, sc->ip, 0); in xrep_adoption_trans_alloc()
367 error = xfs_trans_reserve_quota_nblks(sc->tp, sc->orphanage, in xrep_adoption_trans_alloc()
378 error = xfs_trans_reserve_quota_nblks(sc->tp, sc->ip, in xrep_adoption_trans_alloc()
386 xchk_trans_cancel(sc); in xrep_adoption_trans_alloc()
387 xrep_orphanage_iunlock(sc, XFS_ILOCK_EXCL); in xrep_adoption_trans_alloc()
388 xchk_iunlock(sc, XFS_ILOCK_EXCL); in xrep_adoption_trans_alloc()
394 * orphanage. Caller must hold ILOCKs of sc->ip and the orphanage and must not
402 struct xfs_scrub *sc = adopt->sc; in xrep_adoption_compute_name() local
409 xname->len = snprintf(namebuf, MAXNAMELEN, "%llu", sc->ip->i_ino); in xrep_adoption_compute_name()
410 xname->type = xfs_mode_to_ftype(VFS_I(sc->ip)->i_mode); in xrep_adoption_compute_name()
413 error = xchk_dir_lookup(sc, sc->orphanage, xname, &ino); in xrep_adoption_compute_name()
416 sc->ip->i_ino, ++incr); in xrep_adoption_compute_name()
417 error = xchk_dir_lookup(sc, sc->orphanage, xname, &ino); in xrep_adoption_compute_name()
440 struct xfs_scrub *sc = adopt->sc; in xrep_adoption_check_dcache() local
444 d_orphanage = d_find_alias(VFS_I(sc->orphanage)); in xrep_adoption_check_dcache()
450 trace_xrep_adoption_check_child(sc->mp, d_child); in xrep_adoption_check_dcache()
477 struct xfs_scrub *sc = adopt->sc; in xrep_adoption_zap_dcache() local
481 d_orphanage = d_find_alias(VFS_I(sc->orphanage)); in xrep_adoption_zap_dcache()
487 trace_xrep_adoption_invalidate_child(sc->mp, d_child); in xrep_adoption_zap_dcache()
498 while ((d_child = d_find_alias(VFS_I(sc->ip))) != NULL) { in xrep_adoption_zap_dcache()
499 trace_xrep_adoption_invalidate_child(sc->mp, d_child); in xrep_adoption_zap_dcache()
529 struct xfs_scrub *sc = adopt->sc; in xrep_adoption_move() local
530 bool isdir = S_ISDIR(VFS_I(sc->ip)->i_mode); in xrep_adoption_move()
533 trace_xrep_adoption_reparent(sc->orphanage, adopt->xname, in xrep_adoption_move()
534 sc->ip->i_ino); in xrep_adoption_move()
545 if (!xfs_inode_has_attr_fork(sc->ip) && xfs_has_parent(sc->mp)) { in xrep_adoption_move()
548 error = xfs_bmap_add_attrfork(sc->tp, sc->ip, sf_size, true); in xrep_adoption_move()
554 error = xfs_dir_createname(sc->tp, sc->orphanage, adopt->xname, in xrep_adoption_move()
555 sc->ip->i_ino, adopt->orphanage_blkres); in xrep_adoption_move()
563 xfs_trans_ichgtime(sc->tp, sc->orphanage, in xrep_adoption_move()
566 xfs_bumplink(sc->tp, sc->orphanage); in xrep_adoption_move()
567 xfs_trans_log_inode(sc->tp, sc->orphanage, XFS_ILOG_CORE); in xrep_adoption_move()
571 xfs_bumplink(sc->tp, sc->ip); in xrep_adoption_move()
572 xfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE); in xrep_adoption_move()
577 error = xfs_dir_replace(sc->tp, sc->ip, &xfs_name_dotdot, in xrep_adoption_move()
578 sc->orphanage->i_ino, adopt->child_blkres); in xrep_adoption_move()
584 if (xfs_has_parent(sc->mp)) { in xrep_adoption_move()
585 error = xfs_parent_addname(sc->tp, &adopt->ppargs, in xrep_adoption_move()
586 sc->orphanage, adopt->xname, sc->ip); in xrep_adoption_move()
596 xfs_dir_update_hook(sc->orphanage, sc->ip, 1, adopt->xname); in xrep_adoption_move()
617 struct xfs_scrub *sc = adopt->sc; in xrep_adoption_trans_roll() local
620 trace_xrep_adoption_trans_roll(sc->orphanage, sc->ip, in xrep_adoption_trans_roll()
621 !!(sc->tp->t_flags & XFS_TRANS_DIRTY)); in xrep_adoption_trans_roll()
624 error = xrep_defer_finish(sc); in xrep_adoption_trans_roll()
629 return xfs_trans_roll(&sc->tp); in xrep_adoption_trans_roll()