Lines Matching full:rd

172 	struct xrep_dir		*rd = sc->buf;  in xrep_dir_teardown()  local
174 xrep_findparent_scan_teardown(&rd->pscan); in xrep_dir_teardown()
175 xfblob_destroy(rd->dir_names); in xrep_dir_teardown()
176 xfarray_destroy(rd->dir_entries); in xrep_dir_teardown()
184 struct xrep_dir *rd; in xrep_setup_directory() local
197 rd = kvzalloc(sizeof(struct xrep_dir), XCHK_GFP_FLAGS); in xrep_setup_directory()
198 if (!rd) in xrep_setup_directory()
200 rd->sc = sc; in xrep_setup_directory()
201 rd->xname.name = rd->namebuf; in xrep_setup_directory()
202 sc->buf = rd; in xrep_setup_directory()
213 struct xrep_dir *rd) in xrep_dir_lookup_parent() argument
215 struct xfs_scrub *sc = rd->sc; in xrep_dir_lookup_parent()
238 struct xrep_dir *rd) in xrep_dir_dcache_parent() argument
240 struct xfs_scrub *sc = rd->sc; in xrep_dir_dcache_parent()
258 struct xrep_dir *rd) in xrep_dir_find_parent() argument
262 ino = xrep_findparent_self_reference(rd->sc); in xrep_dir_find_parent()
264 xrep_findparent_scan_finish_early(&rd->pscan, ino); in xrep_dir_find_parent()
268 ino = xrep_dir_dcache_parent(rd); in xrep_dir_find_parent()
270 xrep_findparent_scan_finish_early(&rd->pscan, ino); in xrep_dir_find_parent()
274 ino = xrep_dir_lookup_parent(rd); in xrep_dir_find_parent()
276 xrep_findparent_scan_finish_early(&rd->pscan, ino); in xrep_dir_find_parent()
286 return xrep_findparent_scan(&rd->pscan); in xrep_dir_find_parent()
295 struct xrep_dir *rd, in xrep_dir_want_salvage() argument
300 struct xfs_mount *mp = rd->sc->mp; in xrep_dir_want_salvage()
303 if (ino == rd->sc->ip->i_ino) in xrep_dir_want_salvage()
325 struct xrep_dir *rd, in xrep_dir_stash_createname() argument
337 trace_xrep_dir_stash_createname(rd->sc->tempip, name, ino); in xrep_dir_stash_createname()
339 error = xfblob_storename(rd->dir_names, &dirent.name_cookie, name); in xrep_dir_stash_createname()
343 return xfarray_append(rd->dir_entries, &dirent); in xrep_dir_stash_createname()
352 struct xrep_dir *rd, in xrep_dir_stash_removename() argument
364 trace_xrep_dir_stash_removename(rd->sc->tempip, name, ino); in xrep_dir_stash_removename()
366 error = xfblob_storename(rd->dir_names, &dirent.name_cookie, name); in xrep_dir_stash_removename()
370 return xfarray_append(rd->dir_entries, &dirent); in xrep_dir_stash_removename()
376 struct xrep_dir *rd, in xrep_dir_salvage_entry() argument
384 struct xfs_scrub *sc = rd->sc; in xrep_dir_salvage_entry()
419 if (xfs_is_metadir_inode(ip) != xfs_is_metadir_inode(rd->sc->ip)) { in xrep_dir_salvage_entry()
427 return xrep_dir_stash_createname(rd, &xname, ino); in xrep_dir_salvage_entry()
433 struct xrep_dir *rd, in xrep_dir_salvage_sf_entry() argument
439 ino = xfs_dir2_sf_get_ino(rd->sc->mp, sfp, sfep); in xrep_dir_salvage_sf_entry()
440 if (!xrep_dir_want_salvage(rd, sfep->name, sfep->namelen, ino)) in xrep_dir_salvage_sf_entry()
443 return xrep_dir_salvage_entry(rd, sfep->name, sfep->namelen, ino); in xrep_dir_salvage_sf_entry()
449 struct xrep_dir *rd, in xrep_dir_salvage_data_entry() argument
455 if (!xrep_dir_want_salvage(rd, dep->name, dep->namelen, ino)) in xrep_dir_salvage_data_entry()
458 return xrep_dir_salvage_entry(rd, dep->name, dep->namelen, ino); in xrep_dir_salvage_data_entry()
464 struct xrep_dir *rd, in xrep_dir_recover_data() argument
467 struct xfs_da_geometry *geo = rd->sc->mp->m_dir_geo; in xrep_dir_recover_data()
484 if (xchk_should_terminate(rd->sc, &error)) in xrep_dir_recover_data()
494 offset += xfs_dir2_data_entsize(rd->sc->mp, dep->namelen); in xrep_dir_recover_data()
499 error = xrep_dir_salvage_data_entry(rd, dep); in xrep_dir_recover_data()
511 struct xrep_dir *rd) in xrep_dir_recover_sf() argument
521 ifp = xfs_ifork_ptr(rd->sc->ip, XFS_DATA_FORK); in xrep_dir_recover_sf()
526 trace_xrep_dir_salvaged_parent(rd->sc->ip, ino); in xrep_dir_recover_sf()
530 if (xchk_should_terminate(rd->sc, &error)) in xrep_dir_recover_sf()
533 next = xfs_dir2_sf_nextentry(rd->sc->mp, hdr, sfep); in xrep_dir_recover_sf()
538 error = xrep_dir_salvage_sf_entry(rd, hdr, sfep); in xrep_dir_recover_sf()
558 struct xrep_dir *rd, in xrep_dir_guess_format() argument
561 struct xfs_inode *dp = rd->sc->ip; in xrep_dir_guess_format()
562 struct xfs_mount *mp = rd->sc->mp; in xrep_dir_guess_format()
588 error = xfs_bmap_last_before(rd->sc->tp, dp, &last, XFS_DATA_FORK); in xrep_dir_guess_format()
600 struct xrep_dir *rd, in xrep_dir_recover_dirblock() argument
613 error = xfs_da_read_buf(rd->sc->tp, rd->sc->ip, dabno, in xrep_dir_recover_dirblock()
621 trace_xrep_dir_recover_dirblock(rd->sc->ip, dabno, in xrep_dir_recover_dirblock()
643 if (xfs_dir3_block_header_check(bp, rd->sc->ip->i_ino) != NULL) in xrep_dir_recover_dirblock()
650 if (xfs_dir3_data_header_check(bp, rd->sc->ip->i_ino) != NULL) in xrep_dir_recover_dirblock()
658 error = xrep_dir_recover_data(rd, bp); in xrep_dir_recover_dirblock()
662 xfs_trans_brelse(rd->sc->tp, bp); in xrep_dir_recover_dirblock()
668 struct xrep_dir *rd, in xrep_dir_init_args() argument
672 memset(&rd->args, 0, sizeof(struct xfs_da_args)); in xrep_dir_init_args()
673 rd->args.geo = rd->sc->mp->m_dir_geo; in xrep_dir_init_args()
674 rd->args.whichfork = XFS_DATA_FORK; in xrep_dir_init_args()
675 rd->args.owner = rd->sc->ip->i_ino; in xrep_dir_init_args()
676 rd->args.trans = rd->sc->tp; in xrep_dir_init_args()
677 rd->args.dp = dp; in xrep_dir_init_args()
680 rd->args.name = name->name; in xrep_dir_init_args()
681 rd->args.namelen = name->len; in xrep_dir_init_args()
682 rd->args.filetype = name->type; in xrep_dir_init_args()
683 rd->args.hashval = xfs_dir2_hashname(rd->sc->mp, name); in xrep_dir_init_args()
689 struct xrep_dir *rd, in xrep_dir_replay_createname() argument
694 struct xfs_scrub *sc = rd->sc; in xrep_dir_replay_createname()
695 struct xfs_inode *dp = rd->sc->tempip; in xrep_dir_replay_createname()
706 xrep_dir_init_args(rd, dp, name); in xrep_dir_replay_createname()
707 rd->args.inumber = inum; in xrep_dir_replay_createname()
708 rd->args.total = total; in xrep_dir_replay_createname()
709 rd->args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; in xrep_dir_replay_createname()
710 return xfs_dir_createname_args(&rd->args); in xrep_dir_replay_createname()
716 struct xrep_dir *rd, in xrep_dir_replay_removename() argument
720 struct xfs_inode *dp = rd->args.dp; in xrep_dir_replay_removename()
724 xrep_dir_init_args(rd, dp, name); in xrep_dir_replay_removename()
725 rd->args.op_flags = 0; in xrep_dir_replay_removename()
726 rd->args.total = total; in xrep_dir_replay_removename()
729 return xfs_dir_removename_args(&rd->args); in xrep_dir_replay_removename()
739 struct xrep_dir *rd, in xrep_dir_replay_update() argument
743 struct xfs_mount *mp = rd->sc->mp; in xrep_dir_replay_update()
751 error = xchk_trans_alloc(rd->sc, resblks); in xrep_dir_replay_update()
756 xrep_tempfile_ilock(rd->sc); in xrep_dir_replay_update()
757 xfs_trans_ijoin(rd->sc->tp, rd->sc->tempip, 0); in xrep_dir_replay_update()
768 error = xchk_dir_lookup(rd->sc, rd->sc->tempip, xname, &ino); in xrep_dir_replay_update()
775 error = xrep_dir_replay_createname(rd, xname, dirent->ino, in xrep_dir_replay_update()
781 rd->subdirs++; in xrep_dir_replay_update()
782 rd->dirents++; in xrep_dir_replay_update()
792 error = xchk_dir_lookup(rd->sc, rd->sc->tempip, xname, &ino); in xrep_dir_replay_update()
804 error = xrep_dir_replay_removename(rd, xname, resblks); in xrep_dir_replay_update()
809 rd->subdirs--; in xrep_dir_replay_update()
810 rd->dirents--; in xrep_dir_replay_update()
819 error = xrep_trans_commit(rd->sc); in xrep_dir_replay_update()
823 xrep_tempfile_iunlock(rd->sc); in xrep_dir_replay_update()
826 xchk_trans_cancel(rd->sc); in xrep_dir_replay_update()
827 xrep_tempfile_iunlock(rd->sc); in xrep_dir_replay_update()
841 struct xrep_dir *rd) in xrep_dir_replay_updates() argument
847 mutex_lock(&rd->pscan.lock); in xrep_dir_replay_updates()
848 foreach_xfarray_idx(rd->dir_entries, array_cur) { in xrep_dir_replay_updates()
851 error = xfarray_load(rd->dir_entries, array_cur, &dirent); in xrep_dir_replay_updates()
855 error = xfblob_loadname(rd->dir_names, dirent.name_cookie, in xrep_dir_replay_updates()
856 &rd->xname, dirent.namelen); in xrep_dir_replay_updates()
859 rd->xname.type = dirent.ftype; in xrep_dir_replay_updates()
860 mutex_unlock(&rd->pscan.lock); in xrep_dir_replay_updates()
862 error = xrep_dir_replay_update(rd, &rd->xname, &dirent); in xrep_dir_replay_updates()
865 mutex_lock(&rd->pscan.lock); in xrep_dir_replay_updates()
869 xfarray_truncate(rd->dir_entries); in xrep_dir_replay_updates()
870 xfblob_truncate(rd->dir_names); in xrep_dir_replay_updates()
871 mutex_unlock(&rd->pscan.lock); in xrep_dir_replay_updates()
874 mutex_unlock(&rd->pscan.lock); in xrep_dir_replay_updates()
885 struct xrep_dir *rd) in xrep_dir_flush_stashed() argument
908 error = xrep_trans_commit(rd->sc); in xrep_dir_flush_stashed()
911 xchk_iunlock(rd->sc, XFS_ILOCK_EXCL); in xrep_dir_flush_stashed()
919 error = xrep_tempfile_iolock_polled(rd->sc); in xrep_dir_flush_stashed()
924 error = xrep_dir_replay_updates(rd); in xrep_dir_flush_stashed()
925 xrep_tempfile_iounlock(rd->sc); in xrep_dir_flush_stashed()
932 error = xchk_trans_alloc(rd->sc, 0); in xrep_dir_flush_stashed()
935 xchk_ilock(rd->sc, XFS_ILOCK_EXCL); in xrep_dir_flush_stashed()
942 struct xrep_dir *rd) in xrep_dir_want_flush_stashed() argument
946 bytes = xfarray_bytes(rd->dir_entries) + xfblob_bytes(rd->dir_names); in xrep_dir_want_flush_stashed()
953 struct xrep_dir *rd) in xrep_dir_recover() argument
956 struct xfs_scrub *sc = rd->sc; in xrep_dir_recover()
964 xrep_dir_guess_format(rd, &magic_guess); in xrep_dir_recover()
983 if (xchk_should_terminate(rd->sc, &error)) in xrep_dir_recover()
986 error = xrep_dir_recover_dirblock(rd, in xrep_dir_recover()
992 if (xrep_dir_want_flush_stashed(rd)) { in xrep_dir_recover()
993 error = xrep_dir_flush_stashed(rd); in xrep_dir_recover()
1009 struct xrep_dir *rd) in xrep_dir_find_entries() argument
1011 struct xfs_inode *dp = rd->sc->ip; in xrep_dir_find_entries()
1019 error = xrep_dir_recover_sf(rd); in xrep_dir_find_entries()
1021 error = xfs_iread_extents(rd->sc->tp, dp, XFS_DATA_FORK); in xrep_dir_find_entries()
1025 error = xrep_dir_recover(rd); in xrep_dir_find_entries()
1030 return xrep_dir_flush_stashed(rd); in xrep_dir_find_entries()
1036 struct xrep_dir *rd) in xrep_dir_salvage_entries() argument
1038 struct xfs_scrub *sc = rd->sc; in xrep_dir_salvage_entries()
1048 error = xrep_dir_find_parent(rd); in xrep_dir_salvage_entries()
1058 error = xrep_dir_find_entries(rd); in xrep_dir_salvage_entries()
1109 struct xrep_dir *rd = priv; in xrep_dir_scan_pptr() local
1128 mutex_lock(&rd->pscan.lock); in xrep_dir_scan_pptr()
1129 error = xrep_dir_stash_createname(rd, &xname, ip->i_ino); in xrep_dir_scan_pptr()
1130 mutex_unlock(&rd->pscan.lock); in xrep_dir_scan_pptr()
1147 struct xrep_dir *rd = priv; in xrep_dir_scan_dirent() local
1150 if (ino != rd->sc->ip->i_ino) in xrep_dir_scan_dirent()
1154 if (!xfs_verify_dir_ino(rd->sc->mp, ino)) in xrep_dir_scan_dirent()
1169 xrep_findparent_scan_found(&rd->pscan, dp->i_ino); in xrep_dir_scan_dirent()
1179 struct xrep_dir *rd, in xrep_dir_want_scan() argument
1182 return ip != rd->sc->ip && !xrep_is_tempfile(ip); in xrep_dir_want_scan()
1193 struct xrep_dir *rd, in xrep_dir_scan_ilock() argument
1199 if (!xrep_dir_want_scan(rd, ip)) in xrep_dir_scan_ilock()
1221 struct xrep_dir *rd, in xrep_dir_scan_file() argument
1227 lock_mode = xrep_dir_scan_ilock(rd, ip); in xrep_dir_scan_file()
1229 if (!xrep_dir_want_scan(rd, ip)) in xrep_dir_scan_file()
1241 error = xchk_xattr_walk(rd->sc, ip, xrep_dir_scan_pptr, NULL, rd); in xrep_dir_scan_file()
1255 error = xchk_dir_walk(rd->sc, ip, xrep_dir_scan_dirent, rd); in xrep_dir_scan_file()
1261 xchk_iscan_mark_visited(&rd->pscan.iscan, ip); in xrep_dir_scan_file()
1272 struct xrep_dir *rd) in xrep_dir_scan_dirtree() argument
1274 struct xfs_scrub *sc = rd->sc; in xrep_dir_scan_dirtree()
1280 xrep_findparent_scan_found(&rd->pscan, sc->ip->i_ino); in xrep_dir_scan_dirtree()
1294 while ((error = xchk_iscan_iter(&rd->pscan.iscan, &ip)) == 1) { in xrep_dir_scan_dirtree()
1297 error = xrep_dir_scan_file(rd, ip); in xrep_dir_scan_dirtree()
1303 mutex_lock(&rd->pscan.lock); in xrep_dir_scan_dirtree()
1304 flush = xrep_dir_want_flush_stashed(rd); in xrep_dir_scan_dirtree()
1305 mutex_unlock(&rd->pscan.lock); in xrep_dir_scan_dirtree()
1313 error = xrep_dir_replay_updates(rd); in xrep_dir_scan_dirtree()
1324 xchk_iscan_iter_finish(&rd->pscan.iscan); in xrep_dir_scan_dirtree()
1341 xchk_trans_cancel(rd->sc); in xrep_dir_scan_dirtree()
1356 struct xrep_dir *rd; in xrep_dir_live_update() local
1360 rd = container_of(nb, struct xrep_dir, pscan.dhook.dirent_hook.nb); in xrep_dir_live_update()
1361 sc = rd->sc; in xrep_dir_live_update()
1369 xchk_iscan_want_live_update(&rd->pscan.iscan, p->ip->i_ino)) { in xrep_dir_live_update()
1370 mutex_lock(&rd->pscan.lock); in xrep_dir_live_update()
1372 error = xrep_dir_stash_createname(rd, p->name, in xrep_dir_live_update()
1375 error = xrep_dir_stash_removename(rd, p->name, in xrep_dir_live_update()
1377 mutex_unlock(&rd->pscan.lock); in xrep_dir_live_update()
1388 xchk_iscan_want_live_update(&rd->pscan.iscan, p->dp->i_ino)) { in xrep_dir_live_update()
1394 xrep_findparent_scan_found(&rd->pscan, p->dp->i_ino); in xrep_dir_live_update()
1398 rd->pscan.parent_ino); in xrep_dir_live_update()
1400 xrep_findparent_scan_found(&rd->pscan, NULLFSINO); in xrep_dir_live_update()
1406 xchk_iscan_abort(&rd->pscan.iscan); in xrep_dir_live_update()
1417 struct xrep_dir *rd, in xrep_dir_reset_fork() argument
1420 struct xfs_scrub *sc = rd->sc; in xrep_dir_reset_fork()
1439 xrep_dir_init_args(rd, sc->tempip, NULL); in xrep_dir_reset_fork()
1440 return xfs_dir2_sf_create(&rd->args, parent_ino); in xrep_dir_reset_fork()
1511 struct xrep_dir *rd, in xrep_dir_replace() argument
1517 struct xfs_scrub *sc = rd->sc; in xrep_dir_replace()
1526 xrep_dir_init_args(rd, dp, name); in xrep_dir_replace()
1527 rd->args.inumber = inum; in xrep_dir_replace()
1528 rd->args.total = total; in xrep_dir_replace()
1529 return xfs_dir_replace_args(&rd->args); in xrep_dir_replace()
1538 struct xrep_dir *rd) in xrep_dir_set_nlink() argument
1540 struct xfs_scrub *sc = rd->sc; in xrep_dir_set_nlink()
1544 rd->subdirs + 2, in xrep_dir_set_nlink()
1562 if (rd->dirents == 0) { in xrep_dir_set_nlink()
1563 rd->needs_adoption = false; in xrep_dir_set_nlink()
1599 struct xrep_dir *rd) in xrep_dir_finalize_tempdir() argument
1601 struct xfs_scrub *sc = rd->sc; in xrep_dir_finalize_tempdir()
1605 return xrep_tempexch_trans_alloc(sc, XFS_DATA_FORK, &rd->tx); in xrep_dir_finalize_tempdir()
1614 error = xrep_dir_replay_updates(rd); in xrep_dir_finalize_tempdir()
1618 error = xrep_tempexch_trans_alloc(sc, XFS_DATA_FORK, &rd->tx); in xrep_dir_finalize_tempdir()
1622 if (xfarray_length(rd->dir_entries) == 0) in xrep_dir_finalize_tempdir()
1634 struct xrep_dir *rd) in xrep_dir_swap() argument
1636 struct xfs_scrub *sc = rd->sc; in xrep_dir_swap()
1648 if (rd->pscan.parent_ino == NULLFSINO) { in xrep_dir_swap()
1649 rd->needs_adoption = true; in xrep_dir_swap()
1650 rd->pscan.parent_ino = rd->sc->mp->m_sb.sb_rootino; in xrep_dir_swap()
1661 error = xchk_dir_lookup(sc, rd->sc->tempip, &xfs_name_dotdot, &ino); in xrep_dir_swap()
1665 if (rd->pscan.parent_ino != ino) { in xrep_dir_swap()
1666 error = xrep_dir_replace(rd, rd->sc->tempip, &xfs_name_dotdot, in xrep_dir_swap()
1667 rd->pscan.parent_ino, rd->tx.req.resblks); in xrep_dir_swap()
1688 return xrep_dir_set_nlink(rd); in xrep_dir_swap()
1695 error = xrep_tempfile_roll_trans(rd->sc); in xrep_dir_swap()
1708 error = xrep_dir_set_nlink(rd); in xrep_dir_swap()
1712 return xrep_tempexch_contents(sc, &rd->tx); in xrep_dir_swap()
1721 struct xrep_dir *rd) in xrep_dir_rebuild_tree() argument
1723 struct xfs_scrub *sc = rd->sc; in xrep_dir_rebuild_tree()
1726 trace_xrep_dir_rebuild_tree(sc->ip, rd->pscan.parent_ino); in xrep_dir_rebuild_tree()
1733 error = xrep_tempfile_iolock_polled(rd->sc); in xrep_dir_rebuild_tree()
1742 error = xrep_dir_finalize_tempdir(rd); in xrep_dir_rebuild_tree()
1746 if (xchk_iscan_aborted(&rd->pscan.iscan)) in xrep_dir_rebuild_tree()
1754 error = xrep_dir_swap(rd); in xrep_dir_rebuild_tree()
1763 error = xrep_dir_reset_fork(rd, sc->mp->m_rootip->i_ino); in xrep_dir_rebuild_tree()
1784 struct xrep_dir *rd) in xrep_dir_setup_scan() argument
1786 struct xfs_scrub *sc = rd->sc; in xrep_dir_setup_scan()
1793 &rd->dir_entries); in xrep_dir_setup_scan()
1799 error = xfblob_create(descr, &rd->dir_names); in xrep_dir_setup_scan()
1805 error = __xrep_findparent_scan_start(sc, &rd->pscan, in xrep_dir_setup_scan()
1808 error = xrep_findparent_scan_start(sc, &rd->pscan); in xrep_dir_setup_scan()
1815 xfblob_destroy(rd->dir_names); in xrep_dir_setup_scan()
1816 rd->dir_names = NULL; in xrep_dir_setup_scan()
1818 xfarray_destroy(rd->dir_entries); in xrep_dir_setup_scan()
1819 rd->dir_entries = NULL; in xrep_dir_setup_scan()
1833 struct xrep_dir *rd) in xrep_dir_move_to_orphanage() argument
1835 struct xfs_scrub *sc = rd->sc; in xrep_dir_move_to_orphanage()
1867 error = xrep_adoption_trans_alloc(sc, &rd->adoption); in xrep_dir_move_to_orphanage()
1871 error = xrep_adoption_compute_name(&rd->adoption, &rd->xname); in xrep_dir_move_to_orphanage()
1890 error = xrep_adoption_move(&rd->adoption); in xrep_dir_move_to_orphanage()
1899 error = xrep_adoption_trans_roll(&rd->adoption); in xrep_dir_move_to_orphanage()
1923 struct xrep_dir *rd = sc->buf; in xrep_directory() local
1933 error = xrep_dir_setup_scan(rd); in xrep_directory()
1938 error = xrep_dir_scan_dirtree(rd); in xrep_directory()
1940 error = xrep_dir_salvage_entries(rd); in xrep_directory()
1948 error = xrep_dir_rebuild_tree(rd); in xrep_directory()
1952 if (rd->needs_adoption) { in xrep_directory()
1953 if (!xrep_orphanage_can_adopt(rd->sc)) in xrep_directory()
1956 error = xrep_dir_move_to_orphanage(rd); in xrep_directory()