Lines Matching full:sc
41 struct xfs_scrub *sc, in xrep_tempfile_create() argument
45 .pip = sc->mp->m_rootip, in xrep_tempfile_create()
49 struct xfs_mount *mp = sc->mp; in xrep_tempfile_create()
66 ASSERT(sc->tp == NULL); in xrep_tempfile_create()
67 ASSERT(sc->tempip == NULL); in xrep_tempfile_create()
95 error = xfs_icreate(tp, ino, &args, &sc->tempip); in xrep_tempfile_create()
100 sc->tempip->i_diflags &= ~(XFS_DIFLAG_REALTIME | XFS_DIFLAG_RTINHERIT); in xrep_tempfile_create()
101 xfs_trans_log_inode(tp, sc->tempip, XFS_ILOG_CORE); in xrep_tempfile_create()
108 VFS_I(sc->tempip)->i_flags |= S_PRIVATE; in xrep_tempfile_create()
109 VFS_I(sc->tempip)->i_opflags &= ~IOP_XATTR; in xrep_tempfile_create()
112 error = xfs_dir_init(tp, sc->tempip, dp); in xrep_tempfile_create()
115 } else if (S_ISLNK(VFS_I(sc->tempip)->i_mode)) { in xrep_tempfile_create()
123 error = xfs_symlink_write_target(tp, sc->tempip, in xrep_tempfile_create()
124 sc->tempip->i_ino, ".", 1, 0, 0); in xrep_tempfile_create()
134 xfs_qm_vop_create_dqattach(tp, sc->tempip, udqp, gdqp, pdqp); in xrep_tempfile_create()
143 error = xfs_iunlink(tp, sc->tempip); in xrep_tempfile_create()
151 trace_xrep_tempfile_create(sc); in xrep_tempfile_create()
158 xfs_iunlock(sc->tempip, XFS_ILOCK_EXCL); in xrep_tempfile_create()
159 xfs_setup_iops(sc->tempip); in xrep_tempfile_create()
160 xfs_finish_inode_setup(sc->tempip); in xrep_tempfile_create()
162 sc->temp_ilock_flags = 0; in xrep_tempfile_create()
173 if (sc->tempip) { in xrep_tempfile_create()
174 xfs_iunlock(sc->tempip, XFS_ILOCK_EXCL); in xrep_tempfile_create()
175 xfs_finish_inode_setup(sc->tempip); in xrep_tempfile_create()
176 xchk_irele(sc, sc->tempip); in xrep_tempfile_create()
187 * Move sc->tempip from the regular directory tree to the metadata directory
188 * tree if sc->ip is part of the metadata directory tree and tempip has an
196 * the scrub setup functions grab sc->ip and create sc->tempip before we
202 struct xfs_scrub *sc) in xrep_tempfile_adjust_directory_tree() argument
206 if (!sc->tempip) in xrep_tempfile_adjust_directory_tree()
209 ASSERT(sc->tp == NULL); in xrep_tempfile_adjust_directory_tree()
210 ASSERT(!xfs_is_metadir_inode(sc->tempip)); in xrep_tempfile_adjust_directory_tree()
212 if (!sc->ip || !xfs_is_metadir_inode(sc->ip)) in xrep_tempfile_adjust_directory_tree()
214 if (!S_ISDIR(VFS_I(sc->tempip)->i_mode) && in xrep_tempfile_adjust_directory_tree()
215 !S_ISREG(VFS_I(sc->tempip)->i_mode)) in xrep_tempfile_adjust_directory_tree()
218 xfs_ilock(sc->tempip, XFS_IOLOCK_EXCL); in xrep_tempfile_adjust_directory_tree()
219 sc->temp_ilock_flags |= XFS_IOLOCK_EXCL; in xrep_tempfile_adjust_directory_tree()
221 error = xchk_trans_alloc(sc, 0); in xrep_tempfile_adjust_directory_tree()
225 xrep_tempfile_ilock(sc); in xrep_tempfile_adjust_directory_tree()
226 xfs_trans_ijoin(sc->tp, sc->tempip, 0); in xrep_tempfile_adjust_directory_tree()
229 xfs_trans_mod_dquot_byino(sc->tp, sc->tempip, XFS_TRANS_DQ_ICOUNT, -1L); in xrep_tempfile_adjust_directory_tree()
230 xfs_metafile_set_iflag(sc->tp, sc->tempip, XFS_METAFILE_UNKNOWN); in xrep_tempfile_adjust_directory_tree()
232 error = xrep_trans_commit(sc); in xrep_tempfile_adjust_directory_tree()
236 xfs_iflags_set(sc->tempip, XFS_IRECOVERY); in xrep_tempfile_adjust_directory_tree()
237 xfs_qm_dqdetach(sc->tempip); in xrep_tempfile_adjust_directory_tree()
239 xrep_tempfile_iunlock(sc); in xrep_tempfile_adjust_directory_tree()
241 xrep_tempfile_iounlock(sc); in xrep_tempfile_adjust_directory_tree()
251 struct xfs_scrub *sc) in xrep_tempfile_remove_metadir() argument
255 if (!sc->tempip || !xfs_is_metadir_inode(sc->tempip)) in xrep_tempfile_remove_metadir()
258 ASSERT(sc->tp == NULL); in xrep_tempfile_remove_metadir()
260 xfs_iflags_clear(sc->tempip, XFS_IRECOVERY); in xrep_tempfile_remove_metadir()
262 xfs_ilock(sc->tempip, XFS_IOLOCK_EXCL); in xrep_tempfile_remove_metadir()
263 sc->temp_ilock_flags |= XFS_IOLOCK_EXCL; in xrep_tempfile_remove_metadir()
265 error = xchk_trans_alloc(sc, 0); in xrep_tempfile_remove_metadir()
269 xrep_tempfile_ilock(sc); in xrep_tempfile_remove_metadir()
270 xfs_trans_ijoin(sc->tp, sc->tempip, 0); in xrep_tempfile_remove_metadir()
272 xfs_metafile_clear_iflag(sc->tp, sc->tempip); in xrep_tempfile_remove_metadir()
275 error = xfs_qm_dqattach_locked(sc->tempip, false); in xrep_tempfile_remove_metadir()
279 xfs_trans_mod_dquot_byino(sc->tp, sc->tempip, XFS_TRANS_DQ_ICOUNT, 1L); in xrep_tempfile_remove_metadir()
280 xfs_trans_mod_dquot_byino(sc->tp, sc->tempip, XFS_TRANS_DQ_BCOUNT, in xrep_tempfile_remove_metadir()
281 sc->tempip->i_nblocks); in xrep_tempfile_remove_metadir()
282 error = xrep_trans_commit(sc); in xrep_tempfile_remove_metadir()
286 xchk_trans_cancel(sc); in xrep_tempfile_remove_metadir()
288 xrep_tempfile_iunlock(sc); in xrep_tempfile_remove_metadir()
290 xrep_tempfile_iounlock(sc); in xrep_tempfile_remove_metadir()
297 struct xfs_scrub *sc) in xrep_tempfile_iolock_nowait() argument
299 if (xfs_ilock_nowait(sc->tempip, XFS_IOLOCK_EXCL)) { in xrep_tempfile_iolock_nowait()
300 sc->temp_ilock_flags |= XFS_IOLOCK_EXCL; in xrep_tempfile_iolock_nowait()
314 struct xfs_scrub *sc) in xrep_tempfile_iolock_polled() argument
318 while (!xrep_tempfile_iolock_nowait(sc)) { in xrep_tempfile_iolock_polled()
319 if (xchk_should_terminate(sc, &error)) in xrep_tempfile_iolock_polled()
330 struct xfs_scrub *sc) in xrep_tempfile_iounlock() argument
332 xfs_iunlock(sc->tempip, XFS_IOLOCK_EXCL); in xrep_tempfile_iounlock()
333 sc->temp_ilock_flags &= ~XFS_IOLOCK_EXCL; in xrep_tempfile_iounlock()
339 struct xfs_scrub *sc) in xrep_tempfile_ilock() argument
341 sc->temp_ilock_flags |= XFS_ILOCK_EXCL; in xrep_tempfile_ilock()
342 xfs_ilock(sc->tempip, XFS_ILOCK_EXCL); in xrep_tempfile_ilock()
348 struct xfs_scrub *sc) in xrep_tempfile_ilock_nowait() argument
350 if (xfs_ilock_nowait(sc->tempip, XFS_ILOCK_EXCL)) { in xrep_tempfile_ilock_nowait()
351 sc->temp_ilock_flags |= XFS_ILOCK_EXCL; in xrep_tempfile_ilock_nowait()
361 struct xfs_scrub *sc) in xrep_tempfile_iunlock() argument
363 xfs_iunlock(sc->tempip, XFS_ILOCK_EXCL); in xrep_tempfile_iunlock()
364 sc->temp_ilock_flags &= ~XFS_ILOCK_EXCL; in xrep_tempfile_iunlock()
373 struct xfs_scrub *sc) in xrep_tempfile_ilock_both() argument
375 xfs_lock_two_inodes(sc->ip, XFS_ILOCK_EXCL, sc->tempip, XFS_ILOCK_EXCL); in xrep_tempfile_ilock_both()
376 sc->ilock_flags |= XFS_ILOCK_EXCL; in xrep_tempfile_ilock_both()
377 sc->temp_ilock_flags |= XFS_ILOCK_EXCL; in xrep_tempfile_ilock_both()
383 struct xfs_scrub *sc) in xrep_tempfile_iunlock_both() argument
385 xrep_tempfile_iunlock(sc); in xrep_tempfile_iunlock_both()
386 xchk_iunlock(sc, XFS_ILOCK_EXCL); in xrep_tempfile_iunlock_both()
392 struct xfs_scrub *sc) in xrep_tempfile_rele() argument
394 if (!sc->tempip) in xrep_tempfile_rele()
397 if (sc->temp_ilock_flags) { in xrep_tempfile_rele()
398 xfs_iunlock(sc->tempip, sc->temp_ilock_flags); in xrep_tempfile_rele()
399 sc->temp_ilock_flags = 0; in xrep_tempfile_rele()
402 xrep_tempfile_remove_metadir(sc); in xrep_tempfile_rele()
403 xchk_irele(sc, sc->tempip); in xrep_tempfile_rele()
404 sc->tempip = NULL; in xrep_tempfile_rele()
414 struct xfs_scrub *sc, in xrep_tempfile_prealloc() argument
422 ASSERT(sc->tempip != NULL); in xrep_tempfile_prealloc()
423 ASSERT(!XFS_NOT_DQATTACHED(sc->mp, sc->tempip)); in xrep_tempfile_prealloc()
432 error = xfs_bmapi_read(sc->tempip, off, end - off, &map, &nmaps, in xrep_tempfile_prealloc()
456 error = xfs_bmapi_write(sc->tp, sc->tempip, off, end - off, in xrep_tempfile_prealloc()
464 trace_xrep_tempfile_prealloc(sc, XFS_DATA_FORK, &map); in xrep_tempfile_prealloc()
467 error = xfs_defer_finish(&sc->tp); in xrep_tempfile_prealloc()
481 struct xfs_scrub *sc, in xrep_tempfile_copyin() argument
488 struct xfs_mount *mp = sc->mp; in xrep_tempfile_copyin()
495 ASSERT(S_ISREG(VFS_I(sc->tempip)->i_mode)); in xrep_tempfile_copyin()
505 error = xfs_bmapi_read(sc->tempip, off, 1, &map, &nmaps, 0); in xrep_tempfile_copyin()
514 error = xfs_trans_get_buf(sc->tp, mp->m_ddev_targp, in xrep_tempfile_copyin()
520 trace_xrep_tempfile_copyin(sc, XFS_DATA_FORK, &map); in xrep_tempfile_copyin()
523 error = prep_fn(sc, bp, data); in xrep_tempfile_copyin()
525 xfs_trans_brelse(sc->tp, bp); in xrep_tempfile_copyin()
531 xfs_trans_brelse(sc->tp, bp); in xrep_tempfile_copyin()
568 struct xfs_scrub *sc, in xrep_tempfile_set_isize() argument
571 if (sc->tempip->i_disk_size == isize) in xrep_tempfile_set_isize()
574 sc->tempip->i_disk_size = isize; in xrep_tempfile_set_isize()
575 i_size_write(VFS_I(sc->tempip), isize); in xrep_tempfile_set_isize()
576 return xrep_tempfile_roll_trans(sc); in xrep_tempfile_set_isize()
587 struct xfs_scrub *sc) in xrep_tempfile_roll_trans() argument
591 xfs_trans_log_inode(sc->tp, sc->tempip, XFS_ILOG_CORE); in xrep_tempfile_roll_trans()
592 error = xrep_roll_trans(sc); in xrep_tempfile_roll_trans()
596 xfs_trans_ijoin(sc->tp, sc->tempip, 0); in xrep_tempfile_roll_trans()
607 struct xfs_scrub *sc, in xrep_tempexch_prep_request() argument
624 if (!xfs_ifork_ptr(sc->ip, whichfork) || in xrep_tempexch_prep_request()
625 !xfs_ifork_ptr(sc->tempip, whichfork)) { in xrep_tempexch_prep_request()
626 ASSERT(xfs_ifork_ptr(sc->ip, whichfork) != NULL); in xrep_tempexch_prep_request()
627 ASSERT(xfs_ifork_ptr(sc->tempip, whichfork) != NULL); in xrep_tempexch_prep_request()
632 req->ip1 = sc->tempip; in xrep_tempexch_prep_request()
633 req->ip2 = sc->ip; in xrep_tempexch_prep_request()
658 struct xfs_scrub *sc, in xrep_tempexch_estimate() argument
672 ifp = xfs_ifork_ptr(sc->ip, whichfork); in xrep_tempexch_estimate()
676 tifp = xfs_ifork_ptr(sc->tempip, whichfork); in xrep_tempexch_estimate()
694 req->ip1_bcount = sc->tempip->i_nblocks; in xrep_tempexch_estimate()
710 req->ip2_bcount = sc->ip->i_nblocks; in xrep_tempexch_estimate()
742 struct xfs_scrub *sc, in xrep_tempexch_reserve_quota() argument
745 struct xfs_trans *tp = sc->tp; in xrep_tempexch_reserve_quota()
800 struct xfs_scrub *sc, in xrep_tempexch_trans_reserve() argument
808 ASSERT(sc->tp != NULL); in xrep_tempexch_trans_reserve()
809 xfs_assert_ilocked(sc->ip, XFS_ILOCK_EXCL); in xrep_tempexch_trans_reserve()
810 xfs_assert_ilocked(sc->tempip, XFS_ILOCK_EXCL); in xrep_tempexch_trans_reserve()
812 error = xrep_tempexch_prep_request(sc, whichfork, off, len, tx); in xrep_tempexch_trans_reserve()
820 error = xfs_trans_reserve_more(sc->tp, tx->req.resblks, 0); in xrep_tempexch_trans_reserve()
824 return xrep_tempexch_reserve_quota(sc, tx); in xrep_tempexch_trans_reserve()
840 struct xfs_scrub *sc, in xrep_tempexch_trans_alloc() argument
847 ASSERT(sc->tp == NULL); in xrep_tempexch_trans_alloc()
848 ASSERT(xfs_has_exchange_range(sc->mp)); in xrep_tempexch_trans_alloc()
850 error = xrep_tempexch_prep_request(sc, whichfork, 0, XFS_MAX_FILEOFF, in xrep_tempexch_trans_alloc()
855 error = xrep_tempexch_estimate(sc, tx); in xrep_tempexch_trans_alloc()
859 if (xfs_has_lazysbcount(sc->mp)) in xrep_tempexch_trans_alloc()
862 error = xfs_trans_alloc(sc->mp, &M_RES(sc->mp)->tr_itruncate, in xrep_tempexch_trans_alloc()
863 tx->req.resblks, 0, flags, &sc->tp); in xrep_tempexch_trans_alloc()
867 sc->temp_ilock_flags |= XFS_ILOCK_EXCL; in xrep_tempexch_trans_alloc()
868 sc->ilock_flags |= XFS_ILOCK_EXCL; in xrep_tempexch_trans_alloc()
869 xfs_exchrange_ilock(sc->tp, sc->ip, sc->tempip); in xrep_tempexch_trans_alloc()
871 return xrep_tempexch_reserve_quota(sc, tx); in xrep_tempexch_trans_alloc()
881 struct xfs_scrub *sc, in xrep_tempexch_contents() argument
886 ASSERT(xfs_has_exchange_range(sc->mp)); in xrep_tempexch_contents()
888 xfs_exchange_mappings(sc->tp, &tx->req); in xrep_tempexch_contents()
889 error = xfs_defer_finish(&sc->tp); in xrep_tempexch_contents()
900 temp = i_size_read(VFS_I(sc->ip)); in xrep_tempexch_contents()
901 i_size_write(VFS_I(sc->ip), i_size_read(VFS_I(sc->tempip))); in xrep_tempexch_contents()
902 i_size_write(VFS_I(sc->tempip), temp); in xrep_tempexch_contents()
916 struct xfs_scrub *sc, in xrep_tempfile_copyout_local() argument
923 temp_ifp = xfs_ifork_ptr(sc->tempip, whichfork); in xrep_tempfile_copyout_local()
924 ifp = xfs_ifork_ptr(sc->ip, whichfork); in xrep_tempfile_copyout_local()
933 ASSERT(sc->tempip->i_disk_size <= in xrep_tempfile_copyout_local()
934 xfs_inode_data_fork_size(sc->ip)); in xrep_tempfile_copyout_local()
937 ASSERT(sc->tempip->i_forkoff >= sc->ip->i_forkoff); in xrep_tempfile_copyout_local()
944 /* Recreate @sc->ip's incore fork (ifp) with data from temp_ifp. */ in xrep_tempfile_copyout_local()
946 xfs_init_local_fork(sc->ip, whichfork, temp_ifp->if_data, in xrep_tempfile_copyout_local()
950 i_size_write(VFS_I(sc->ip), i_size_read(VFS_I(sc->tempip))); in xrep_tempfile_copyout_local()
951 sc->ip->i_disk_size = sc->tempip->i_disk_size; in xrep_tempfile_copyout_local()
955 xfs_trans_log_inode(sc->tp, sc->ip, ilog_flags); in xrep_tempfile_copyout_local()