|
34 | 34 | #include "xfs_quota.h" |
35 | 35 | #include "xfs_exchmaps.h" |
36 | 36 | #include "xfs_rtbitmap.h" |
| 37 | +#include "xfs_rtgroup.h" |
37 | 38 | #include "scrub/scrub.h" |
38 | 39 | #include "scrub/common.h" |
39 | 40 | #include "scrub/trace.h" |
@@ -121,6 +122,17 @@ xchk_process_error( |
121 | 122 | XFS_SCRUB_OFLAG_CORRUPT, __return_address); |
122 | 123 | } |
123 | 124 |
|
| 125 | +bool |
| 126 | +xchk_process_rt_error( |
| 127 | + struct xfs_scrub *sc, |
| 128 | + xfs_rgnumber_t rgno, |
| 129 | + xfs_rgblock_t rgbno, |
| 130 | + int *error) |
| 131 | +{ |
| 132 | + return __xchk_process_error(sc, rgno, rgbno, error, |
| 133 | + XFS_SCRUB_OFLAG_CORRUPT, __return_address); |
| 134 | +} |
| 135 | + |
124 | 136 | bool |
125 | 137 | xchk_xref_process_error( |
126 | 138 | struct xfs_scrub *sc, |
@@ -684,6 +696,72 @@ xchk_ag_init( |
684 | 696 | return 0; |
685 | 697 | } |
686 | 698 |
|
| 699 | +#ifdef CONFIG_XFS_RT |
| 700 | +/* |
| 701 | + * For scrubbing a realtime group, grab all the in-core resources we'll need to |
| 702 | + * check the metadata, which means taking the ILOCK of the realtime group's |
| 703 | + * metadata inodes. Callers must not join these inodes to the transaction with |
| 704 | + * non-zero lockflags or concurrency problems will result. The @rtglock_flags |
| 705 | + * argument takes XFS_RTGLOCK_* flags. |
| 706 | + */ |
| 707 | +int |
| 708 | +xchk_rtgroup_init( |
| 709 | + struct xfs_scrub *sc, |
| 710 | + xfs_rgnumber_t rgno, |
| 711 | + struct xchk_rt *sr) |
| 712 | +{ |
| 713 | + ASSERT(sr->rtg == NULL); |
| 714 | + ASSERT(sr->rtlock_flags == 0); |
| 715 | + |
| 716 | + sr->rtg = xfs_rtgroup_get(sc->mp, rgno); |
| 717 | + if (!sr->rtg) |
| 718 | + return -ENOENT; |
| 719 | + return 0; |
| 720 | +} |
| 721 | + |
| 722 | +void |
| 723 | +xchk_rtgroup_lock( |
| 724 | + struct xchk_rt *sr, |
| 725 | + unsigned int rtglock_flags) |
| 726 | +{ |
| 727 | + xfs_rtgroup_lock(sr->rtg, rtglock_flags); |
| 728 | + sr->rtlock_flags = rtglock_flags; |
| 729 | +} |
| 730 | + |
| 731 | +/* |
| 732 | + * Unlock the realtime group. This must be done /after/ committing (or |
| 733 | + * cancelling) the scrub transaction. |
| 734 | + */ |
| 735 | +static void |
| 736 | +xchk_rtgroup_unlock( |
| 737 | + struct xchk_rt *sr) |
| 738 | +{ |
| 739 | + ASSERT(sr->rtg != NULL); |
| 740 | + |
| 741 | + if (sr->rtlock_flags) { |
| 742 | + xfs_rtgroup_unlock(sr->rtg, sr->rtlock_flags); |
| 743 | + sr->rtlock_flags = 0; |
| 744 | + } |
| 745 | +} |
| 746 | + |
| 747 | +/* |
| 748 | + * Unlock the realtime group and release its resources. This must be done |
| 749 | + * /after/ committing (or cancelling) the scrub transaction. |
| 750 | + */ |
| 751 | +void |
| 752 | +xchk_rtgroup_free( |
| 753 | + struct xfs_scrub *sc, |
| 754 | + struct xchk_rt *sr) |
| 755 | +{ |
| 756 | + ASSERT(sr->rtg != NULL); |
| 757 | + |
| 758 | + xchk_rtgroup_unlock(sr); |
| 759 | + |
| 760 | + xfs_rtgroup_put(sr->rtg); |
| 761 | + sr->rtg = NULL; |
| 762 | +} |
| 763 | +#endif /* CONFIG_XFS_RT */ |
| 764 | + |
687 | 765 | /* Per-scrubber setup functions */ |
688 | 766 |
|
689 | 767 | void |
|
0 commit comments