summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-07-19 15:29:12 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-07-23 12:08:01 -0400
commit032d91f9820f6d241dc5584c27a668cfd377aaf0 (patch)
treeaf9ed13b2a9e85cca186d9e38d71dda69b1f2119
parent1d8a748a8aa94a7da8f3d4fac1892037890d3cff (diff)
xfs: fix indentation and other whitespace problems in scrub/repair
Now that we've shortened everything, fix up all the indentation and whitespace problems. There are no functional changes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
-rw-r--r--fs/xfs/scrub/agheader.c172
-rw-r--r--fs/xfs/scrub/agheader_repair.c8
-rw-r--r--fs/xfs/scrub/alloc.c48
-rw-r--r--fs/xfs/scrub/attr.c20
-rw-r--r--fs/xfs/scrub/bmap.c150
-rw-r--r--fs/xfs/scrub/btree.c172
-rw-r--r--fs/xfs/scrub/btree.h25
-rw-r--r--fs/xfs/scrub/common.c158
-rw-r--r--fs/xfs/scrub/common.h23
-rw-r--r--fs/xfs/scrub/dabtree.c56
-rw-r--r--fs/xfs/scrub/dabtree.h21
-rw-r--r--fs/xfs/scrub/dir.c88
-rw-r--r--fs/xfs/scrub/ialloc.c58
-rw-r--r--fs/xfs/scrub/inode.c102
-rw-r--r--fs/xfs/scrub/parent.c60
-rw-r--r--fs/xfs/scrub/quota.c68
-rw-r--r--fs/xfs/scrub/refcount.c70
-rw-r--r--fs/xfs/scrub/repair.c148
-rw-r--r--fs/xfs/scrub/repair.h28
-rw-r--r--fs/xfs/scrub/rmap.c78
-rw-r--r--fs/xfs/scrub/rtbitmap.c38
-rw-r--r--fs/xfs/scrub/scrub.c8
-rw-r--r--fs/xfs/scrub/scrub.h62
-rw-r--r--fs/xfs/scrub/symlink.c10
-rw-r--r--fs/xfs/scrub/trace.c4
25 files changed, 832 insertions, 843 deletions
diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
index 14ba4189ae8f..3068a9382feb 100644
--- a/fs/xfs/scrub/agheader.c
+++ b/fs/xfs/scrub/agheader.c
@@ -30,13 +30,13 @@
30STATIC void 30STATIC void
31xchk_superblock_xref( 31xchk_superblock_xref(
32 struct xfs_scrub *sc, 32 struct xfs_scrub *sc,
33 struct xfs_buf *bp) 33 struct xfs_buf *bp)
34{ 34{
35 struct xfs_owner_info oinfo; 35 struct xfs_owner_info oinfo;
36 struct xfs_mount *mp = sc->mp; 36 struct xfs_mount *mp = sc->mp;
37 xfs_agnumber_t agno = sc->sm->sm_agno; 37 xfs_agnumber_t agno = sc->sm->sm_agno;
38 xfs_agblock_t agbno; 38 xfs_agblock_t agbno;
39 int error; 39 int error;
40 40
41 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 41 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
42 return; 42 return;
@@ -68,14 +68,14 @@ int
68xchk_superblock( 68xchk_superblock(
69 struct xfs_scrub *sc) 69 struct xfs_scrub *sc)
70{ 70{
71 struct xfs_mount *mp = sc->mp; 71 struct xfs_mount *mp = sc->mp;
72 struct xfs_buf *bp; 72 struct xfs_buf *bp;
73 struct xfs_dsb *sb; 73 struct xfs_dsb *sb;
74 xfs_agnumber_t agno; 74 xfs_agnumber_t agno;
75 uint32_t v2_ok; 75 uint32_t v2_ok;
76 __be32 features_mask; 76 __be32 features_mask;
77 int error; 77 int error;
78 __be16 vernum_mask; 78 __be16 vernum_mask;
79 79
80 agno = sc->sm->sm_agno; 80 agno = sc->sm->sm_agno;
81 if (agno == 0) 81 if (agno == 0)
@@ -367,9 +367,9 @@ static inline void
367xchk_agf_xref_freeblks( 367xchk_agf_xref_freeblks(
368 struct xfs_scrub *sc) 368 struct xfs_scrub *sc)
369{ 369{
370 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp); 370 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp);
371 xfs_extlen_t blocks = 0; 371 xfs_extlen_t blocks = 0;
372 int error; 372 int error;
373 373
374 if (!sc->sa.bno_cur) 374 if (!sc->sa.bno_cur)
375 return; 375 return;
@@ -387,11 +387,11 @@ static inline void
387xchk_agf_xref_cntbt( 387xchk_agf_xref_cntbt(
388 struct xfs_scrub *sc) 388 struct xfs_scrub *sc)
389{ 389{
390 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp); 390 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp);
391 xfs_agblock_t agbno; 391 xfs_agblock_t agbno;
392 xfs_extlen_t blocks; 392 xfs_extlen_t blocks;
393 int have; 393 int have;
394 int error; 394 int error;
395 395
396 if (!sc->sa.cnt_cur) 396 if (!sc->sa.cnt_cur)
397 return; 397 return;
@@ -419,11 +419,11 @@ STATIC void
419xchk_agf_xref_btreeblks( 419xchk_agf_xref_btreeblks(
420 struct xfs_scrub *sc) 420 struct xfs_scrub *sc)
421{ 421{
422 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp); 422 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp);
423 struct xfs_mount *mp = sc->mp; 423 struct xfs_mount *mp = sc->mp;
424 xfs_agblock_t blocks; 424 xfs_agblock_t blocks;
425 xfs_agblock_t btreeblks; 425 xfs_agblock_t btreeblks;
426 int error; 426 int error;
427 427
428 /* Check agf_rmap_blocks; set up for agf_btreeblks check */ 428 /* Check agf_rmap_blocks; set up for agf_btreeblks check */
429 if (sc->sa.rmap_cur) { 429 if (sc->sa.rmap_cur) {
@@ -465,9 +465,9 @@ static inline void
465xchk_agf_xref_refcblks( 465xchk_agf_xref_refcblks(
466 struct xfs_scrub *sc) 466 struct xfs_scrub *sc)
467{ 467{
468 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp); 468 struct xfs_agf *agf = XFS_BUF_TO_AGF(sc->sa.agf_bp);
469 xfs_agblock_t blocks; 469 xfs_agblock_t blocks;
470 int error; 470 int error;
471 471
472 if (!sc->sa.refc_cur) 472 if (!sc->sa.refc_cur)
473 return; 473 return;
@@ -484,10 +484,10 @@ STATIC void
484xchk_agf_xref( 484xchk_agf_xref(
485 struct xfs_scrub *sc) 485 struct xfs_scrub *sc)
486{ 486{
487 struct xfs_owner_info oinfo; 487 struct xfs_owner_info oinfo;
488 struct xfs_mount *mp = sc->mp; 488 struct xfs_mount *mp = sc->mp;
489 xfs_agblock_t agbno; 489 xfs_agblock_t agbno;
490 int error; 490 int error;
491 491
492 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 492 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
493 return; 493 return;
@@ -516,17 +516,17 @@ int
516xchk_agf( 516xchk_agf(
517 struct xfs_scrub *sc) 517 struct xfs_scrub *sc)
518{ 518{
519 struct xfs_mount *mp = sc->mp; 519 struct xfs_mount *mp = sc->mp;
520 struct xfs_agf *agf; 520 struct xfs_agf *agf;
521 xfs_agnumber_t agno; 521 xfs_agnumber_t agno;
522 xfs_agblock_t agbno; 522 xfs_agblock_t agbno;
523 xfs_agblock_t eoag; 523 xfs_agblock_t eoag;
524 xfs_agblock_t agfl_first; 524 xfs_agblock_t agfl_first;
525 xfs_agblock_t agfl_last; 525 xfs_agblock_t agfl_last;
526 xfs_agblock_t agfl_count; 526 xfs_agblock_t agfl_count;
527 xfs_agblock_t fl_count; 527 xfs_agblock_t fl_count;
528 int level; 528 int level;
529 int error = 0; 529 int error = 0;
530 530
531 agno = sc->sa.agno = sc->sm->sm_agno; 531 agno = sc->sa.agno = sc->sm->sm_agno;
532 error = xchk_ag_read_headers(sc, agno, &sc->sa.agi_bp, 532 error = xchk_ag_read_headers(sc, agno, &sc->sa.agi_bp,
@@ -598,10 +598,10 @@ out:
598/* AGFL */ 598/* AGFL */
599 599
600struct xchk_agfl_info { 600struct xchk_agfl_info {
601 struct xfs_owner_info oinfo; 601 struct xfs_owner_info oinfo;
602 unsigned int sz_entries; 602 unsigned int sz_entries;
603 unsigned int nr_entries; 603 unsigned int nr_entries;
604 xfs_agblock_t *entries; 604 xfs_agblock_t *entries;
605 struct xfs_scrub *sc; 605 struct xfs_scrub *sc;
606}; 606};
607 607
@@ -609,8 +609,8 @@ struct xchk_agfl_info {
609STATIC void 609STATIC void
610xchk_agfl_block_xref( 610xchk_agfl_block_xref(
611 struct xfs_scrub *sc, 611 struct xfs_scrub *sc,
612 xfs_agblock_t agbno, 612 xfs_agblock_t agbno,
613 struct xfs_owner_info *oinfo) 613 struct xfs_owner_info *oinfo)
614{ 614{
615 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 615 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
616 return; 616 return;
@@ -624,13 +624,13 @@ xchk_agfl_block_xref(
624/* Scrub an AGFL block. */ 624/* Scrub an AGFL block. */
625STATIC int 625STATIC int
626xchk_agfl_block( 626xchk_agfl_block(
627 struct xfs_mount *mp, 627 struct xfs_mount *mp,
628 xfs_agblock_t agbno, 628 xfs_agblock_t agbno,
629 void *priv) 629 void *priv)
630{ 630{
631 struct xchk_agfl_info *sai = priv; 631 struct xchk_agfl_info *sai = priv;
632 struct xfs_scrub *sc = sai->sc; 632 struct xfs_scrub *sc = sai->sc;
633 xfs_agnumber_t agno = sc->sa.agno; 633 xfs_agnumber_t agno = sc->sa.agno;
634 634
635 if (xfs_verify_agbno(mp, agno, agbno) && 635 if (xfs_verify_agbno(mp, agno, agbno) &&
636 sai->nr_entries < sai->sz_entries) 636 sai->nr_entries < sai->sz_entries)
@@ -662,10 +662,10 @@ STATIC void
662xchk_agfl_xref( 662xchk_agfl_xref(
663 struct xfs_scrub *sc) 663 struct xfs_scrub *sc)
664{ 664{
665 struct xfs_owner_info oinfo; 665 struct xfs_owner_info oinfo;
666 struct xfs_mount *mp = sc->mp; 666 struct xfs_mount *mp = sc->mp;
667 xfs_agblock_t agbno; 667 xfs_agblock_t agbno;
668 int error; 668 int error;
669 669
670 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 670 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
671 return; 671 return;
@@ -693,12 +693,12 @@ int
693xchk_agfl( 693xchk_agfl(
694 struct xfs_scrub *sc) 694 struct xfs_scrub *sc)
695{ 695{
696 struct xchk_agfl_info sai; 696 struct xchk_agfl_info sai;
697 struct xfs_agf *agf; 697 struct xfs_agf *agf;
698 xfs_agnumber_t agno; 698 xfs_agnumber_t agno;
699 unsigned int agflcount; 699 unsigned int agflcount;
700 unsigned int i; 700 unsigned int i;
701 int error; 701 int error;
702 702
703 agno = sc->sa.agno = sc->sm->sm_agno; 703 agno = sc->sa.agno = sc->sm->sm_agno;
704 error = xchk_ag_read_headers(sc, agno, &sc->sa.agi_bp, 704 error = xchk_ag_read_headers(sc, agno, &sc->sa.agi_bp,
@@ -770,10 +770,10 @@ static inline void
770xchk_agi_xref_icounts( 770xchk_agi_xref_icounts(
771 struct xfs_scrub *sc) 771 struct xfs_scrub *sc)
772{ 772{
773 struct xfs_agi *agi = XFS_BUF_TO_AGI(sc->sa.agi_bp); 773 struct xfs_agi *agi = XFS_BUF_TO_AGI(sc->sa.agi_bp);
774 xfs_agino_t icount; 774 xfs_agino_t icount;
775 xfs_agino_t freecount; 775 xfs_agino_t freecount;
776 int error; 776 int error;
777 777
778 if (!sc->sa.ino_cur) 778 if (!sc->sa.ino_cur)
779 return; 779 return;
@@ -791,10 +791,10 @@ STATIC void
791xchk_agi_xref( 791xchk_agi_xref(
792 struct xfs_scrub *sc) 792 struct xfs_scrub *sc)
793{ 793{
794 struct xfs_owner_info oinfo; 794 struct xfs_owner_info oinfo;
795 struct xfs_mount *mp = sc->mp; 795 struct xfs_mount *mp = sc->mp;
796 xfs_agblock_t agbno; 796 xfs_agblock_t agbno;
797 int error; 797 int error;
798 798
799 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 799 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
800 return; 800 return;
@@ -820,18 +820,18 @@ int
820xchk_agi( 820xchk_agi(
821 struct xfs_scrub *sc) 821 struct xfs_scrub *sc)
822{ 822{
823 struct xfs_mount *mp = sc->mp; 823 struct xfs_mount *mp = sc->mp;
824 struct xfs_agi *agi; 824 struct xfs_agi *agi;
825 xfs_agnumber_t agno; 825 xfs_agnumber_t agno;
826 xfs_agblock_t agbno; 826 xfs_agblock_t agbno;
827 xfs_agblock_t eoag; 827 xfs_agblock_t eoag;
828 xfs_agino_t agino; 828 xfs_agino_t agino;
829 xfs_agino_t first_agino; 829 xfs_agino_t first_agino;
830 xfs_agino_t last_agino; 830 xfs_agino_t last_agino;
831 xfs_agino_t icount; 831 xfs_agino_t icount;
832 int i; 832 int i;
833 int level; 833 int level;
834 int error = 0; 834 int error = 0;
835 835
836 agno = sc->sa.agno = sc->sm->sm_agno; 836 agno = sc->sa.agno = sc->sm->sm_agno;
837 error = xchk_ag_read_headers(sc, agno, &sc->sa.agi_bp, 837 error = xchk_ag_read_headers(sc, agno, &sc->sa.agi_bp,
diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
index 2457968482f8..1e96621ece3a 100644
--- a/fs/xfs/scrub/agheader_repair.c
+++ b/fs/xfs/scrub/agheader_repair.c
@@ -31,10 +31,10 @@ int
31xrep_superblock( 31xrep_superblock(
32 struct xfs_scrub *sc) 32 struct xfs_scrub *sc)
33{ 33{
34 struct xfs_mount *mp = sc->mp; 34 struct xfs_mount *mp = sc->mp;
35 struct xfs_buf *bp; 35 struct xfs_buf *bp;
36 xfs_agnumber_t agno; 36 xfs_agnumber_t agno;
37 int error; 37 int error;
38 38
39 /* Don't try to repair AG 0's sb; let xfs_repair deal with it. */ 39 /* Don't try to repair AG 0's sb; let xfs_repair deal with it. */
40 agno = sc->sm->sm_agno; 40 agno = sc->sm->sm_agno;
diff --git a/fs/xfs/scrub/alloc.c b/fs/xfs/scrub/alloc.c
index 653d80b3aa39..036b5c7021eb 100644
--- a/fs/xfs/scrub/alloc.c
+++ b/fs/xfs/scrub/alloc.c
@@ -30,7 +30,7 @@
30int 30int
31xchk_setup_ag_allocbt( 31xchk_setup_ag_allocbt(
32 struct xfs_scrub *sc, 32 struct xfs_scrub *sc,
33 struct xfs_inode *ip) 33 struct xfs_inode *ip)
34{ 34{
35 return xchk_setup_ag_btree(sc, ip, false); 35 return xchk_setup_ag_btree(sc, ip, false);
36} 36}
@@ -43,14 +43,14 @@ xchk_setup_ag_allocbt(
43STATIC void 43STATIC void
44xchk_allocbt_xref_other( 44xchk_allocbt_xref_other(
45 struct xfs_scrub *sc, 45 struct xfs_scrub *sc,
46 xfs_agblock_t agbno, 46 xfs_agblock_t agbno,
47 xfs_extlen_t len) 47 xfs_extlen_t len)
48{ 48{
49 struct xfs_btree_cur **pcur; 49 struct xfs_btree_cur **pcur;
50 xfs_agblock_t fbno; 50 xfs_agblock_t fbno;
51 xfs_extlen_t flen; 51 xfs_extlen_t flen;
52 int has_otherrec; 52 int has_otherrec;
53 int error; 53 int error;
54 54
55 if (sc->sm->sm_type == XFS_SCRUB_TYPE_BNOBT) 55 if (sc->sm->sm_type == XFS_SCRUB_TYPE_BNOBT)
56 pcur = &sc->sa.cnt_cur; 56 pcur = &sc->sa.cnt_cur;
@@ -83,8 +83,8 @@ xchk_allocbt_xref_other(
83STATIC void 83STATIC void
84xchk_allocbt_xref( 84xchk_allocbt_xref(
85 struct xfs_scrub *sc, 85 struct xfs_scrub *sc,
86 xfs_agblock_t agbno, 86 xfs_agblock_t agbno,
87 xfs_extlen_t len) 87 xfs_extlen_t len)
88{ 88{
89 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 89 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
90 return; 90 return;
@@ -98,14 +98,14 @@ xchk_allocbt_xref(
98/* Scrub a bnobt/cntbt record. */ 98/* Scrub a bnobt/cntbt record. */
99STATIC int 99STATIC int
100xchk_allocbt_rec( 100xchk_allocbt_rec(
101 struct xchk_btree *bs, 101 struct xchk_btree *bs,
102 union xfs_btree_rec *rec) 102 union xfs_btree_rec *rec)
103{ 103{
104 struct xfs_mount *mp = bs->cur->bc_mp; 104 struct xfs_mount *mp = bs->cur->bc_mp;
105 xfs_agnumber_t agno = bs->cur->bc_private.a.agno; 105 xfs_agnumber_t agno = bs->cur->bc_private.a.agno;
106 xfs_agblock_t bno; 106 xfs_agblock_t bno;
107 xfs_extlen_t len; 107 xfs_extlen_t len;
108 int error = 0; 108 int error = 0;
109 109
110 bno = be32_to_cpu(rec->alloc.ar_startblock); 110 bno = be32_to_cpu(rec->alloc.ar_startblock);
111 len = be32_to_cpu(rec->alloc.ar_blockcount); 111 len = be32_to_cpu(rec->alloc.ar_blockcount);
@@ -124,10 +124,10 @@ xchk_allocbt_rec(
124STATIC int 124STATIC int
125xchk_allocbt( 125xchk_allocbt(
126 struct xfs_scrub *sc, 126 struct xfs_scrub *sc,
127 xfs_btnum_t which) 127 xfs_btnum_t which)
128{ 128{
129 struct xfs_owner_info oinfo; 129 struct xfs_owner_info oinfo;
130 struct xfs_btree_cur *cur; 130 struct xfs_btree_cur *cur;
131 131
132 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG); 132 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
133 cur = which == XFS_BTNUM_BNO ? sc->sa.bno_cur : sc->sa.cnt_cur; 133 cur = which == XFS_BTNUM_BNO ? sc->sa.bno_cur : sc->sa.cnt_cur;
@@ -152,11 +152,11 @@ xchk_cntbt(
152void 152void
153xchk_xref_is_used_space( 153xchk_xref_is_used_space(
154 struct xfs_scrub *sc, 154 struct xfs_scrub *sc,
155 xfs_agblock_t agbno, 155 xfs_agblock_t agbno,
156 xfs_extlen_t len) 156 xfs_extlen_t len)
157{ 157{
158 bool is_freesp; 158 bool is_freesp;
159 int error; 159 int error;
160 160
161 if (!sc->sa.bno_cur || xchk_skip_xref(sc->sm)) 161 if (!sc->sa.bno_cur || xchk_skip_xref(sc->sm))
162 return; 162 return;
diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
index 6650fb3010b6..81d5e90547a1 100644
--- a/fs/xfs/scrub/attr.c
+++ b/fs/xfs/scrub/attr.c
@@ -34,9 +34,9 @@
34int 34int
35xchk_setup_xattr( 35xchk_setup_xattr(
36 struct xfs_scrub *sc, 36 struct xfs_scrub *sc,
37 struct xfs_inode *ip) 37 struct xfs_inode *ip)
38{ 38{
39 size_t sz; 39 size_t sz;
40 40
41 /* 41 /*
42 * Allocate the buffer without the inode lock held. We need enough 42 * Allocate the buffer without the inode lock held. We need enough
@@ -57,7 +57,7 @@ xchk_setup_xattr(
57 57
58struct xchk_xattr { 58struct xchk_xattr {
59 struct xfs_attr_list_context context; 59 struct xfs_attr_list_context context;
60 struct xfs_scrub *sc; 60 struct xfs_scrub *sc;
61}; 61};
62 62
63/* 63/*
@@ -128,12 +128,12 @@ fail_xref:
128STATIC bool 128STATIC bool
129xchk_xattr_set_map( 129xchk_xattr_set_map(
130 struct xfs_scrub *sc, 130 struct xfs_scrub *sc,
131 unsigned long *map, 131 unsigned long *map,
132 unsigned int start, 132 unsigned int start,
133 unsigned int len) 133 unsigned int len)
134{ 134{
135 unsigned int mapsize = sc->mp->m_attr_geo->blksize; 135 unsigned int mapsize = sc->mp->m_attr_geo->blksize;
136 bool ret = true; 136 bool ret = true;
137 137
138 if (start >= mapsize) 138 if (start >= mapsize)
139 return false; 139 return false;
@@ -155,7 +155,7 @@ xchk_xattr_set_map(
155 */ 155 */
156STATIC bool 156STATIC bool
157xchk_xattr_check_freemap( 157xchk_xattr_check_freemap(
158 struct xfs_scrub *sc, 158 struct xfs_scrub *sc,
159 unsigned long *map, 159 unsigned long *map,
160 struct xfs_attr3_icleaf_hdr *leafhdr) 160 struct xfs_attr3_icleaf_hdr *leafhdr)
161{ 161{
@@ -405,7 +405,7 @@ out:
405/* Scrub the extended attribute metadata. */ 405/* Scrub the extended attribute metadata. */
406int 406int
407xchk_xattr( 407xchk_xattr(
408 struct xfs_scrub *sc) 408 struct xfs_scrub *sc)
409{ 409{
410 struct xchk_xattr sx; 410 struct xchk_xattr sx;
411 struct attrlist_cursor_kern cursor = { 0 }; 411 struct attrlist_cursor_kern cursor = { 0 };
diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
index 0e5166232b15..e1d11f3223e3 100644
--- a/fs/xfs/scrub/bmap.c
+++ b/fs/xfs/scrub/bmap.c
@@ -35,9 +35,9 @@
35int 35int
36xchk_setup_inode_bmap( 36xchk_setup_inode_bmap(
37 struct xfs_scrub *sc, 37 struct xfs_scrub *sc,
38 struct xfs_inode *ip) 38 struct xfs_inode *ip)
39{ 39{
40 int error; 40 int error;
41 41
42 error = xchk_get_inode(sc, ip); 42 error = xchk_get_inode(sc, ip);
43 if (error) 43 if (error)
@@ -80,25 +80,25 @@ out:
80 80
81struct xchk_bmap_info { 81struct xchk_bmap_info {
82 struct xfs_scrub *sc; 82 struct xfs_scrub *sc;
83 xfs_fileoff_t lastoff; 83 xfs_fileoff_t lastoff;
84 bool is_rt; 84 bool is_rt;
85 bool is_shared; 85 bool is_shared;
86 int whichfork; 86 int whichfork;
87}; 87};
88 88
89/* Look for a corresponding rmap for this irec. */ 89/* Look for a corresponding rmap for this irec. */
90static inline bool 90static inline bool
91xchk_bmap_get_rmap( 91xchk_bmap_get_rmap(
92 struct xchk_bmap_info *info, 92 struct xchk_bmap_info *info,
93 struct xfs_bmbt_irec *irec, 93 struct xfs_bmbt_irec *irec,
94 xfs_agblock_t agbno, 94 xfs_agblock_t agbno,
95 uint64_t owner, 95 uint64_t owner,
96 struct xfs_rmap_irec *rmap) 96 struct xfs_rmap_irec *rmap)
97{ 97{
98 xfs_fileoff_t offset; 98 xfs_fileoff_t offset;
99 unsigned int rflags = 0; 99 unsigned int rflags = 0;
100 int has_rmap; 100 int has_rmap;
101 int error; 101 int error;
102 102
103 if (info->whichfork == XFS_ATTR_FORK) 103 if (info->whichfork == XFS_ATTR_FORK)
104 rflags |= XFS_RMAP_ATTR_FORK; 104 rflags |= XFS_RMAP_ATTR_FORK;
@@ -152,13 +152,13 @@ out:
152/* Make sure that we have rmapbt records for this extent. */ 152/* Make sure that we have rmapbt records for this extent. */
153STATIC void 153STATIC void
154xchk_bmap_xref_rmap( 154xchk_bmap_xref_rmap(
155 struct xchk_bmap_info *info, 155 struct xchk_bmap_info *info,
156 struct xfs_bmbt_irec *irec, 156 struct xfs_bmbt_irec *irec,
157 xfs_agblock_t agbno) 157 xfs_agblock_t agbno)
158{ 158{
159 struct xfs_rmap_irec rmap; 159 struct xfs_rmap_irec rmap;
160 unsigned long long rmap_end; 160 unsigned long long rmap_end;
161 uint64_t owner; 161 uint64_t owner;
162 162
163 if (!info->sc->sa.rmap_cur || xchk_skip_xref(info->sc->sm)) 163 if (!info->sc->sa.rmap_cur || xchk_skip_xref(info->sc->sm))
164 return; 164 return;
@@ -222,10 +222,10 @@ xchk_bmap_xref_rmap(
222/* Cross-reference a single rtdev extent record. */ 222/* Cross-reference a single rtdev extent record. */
223STATIC void 223STATIC void
224xchk_bmap_rt_extent_xref( 224xchk_bmap_rt_extent_xref(
225 struct xchk_bmap_info *info, 225 struct xchk_bmap_info *info,
226 struct xfs_inode *ip, 226 struct xfs_inode *ip,
227 struct xfs_btree_cur *cur, 227 struct xfs_btree_cur *cur,
228 struct xfs_bmbt_irec *irec) 228 struct xfs_bmbt_irec *irec)
229{ 229{
230 if (info->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 230 if (info->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
231 return; 231 return;
@@ -237,16 +237,16 @@ xchk_bmap_rt_extent_xref(
237/* Cross-reference a single datadev extent record. */ 237/* Cross-reference a single datadev extent record. */
238STATIC void 238STATIC void
239xchk_bmap_extent_xref( 239xchk_bmap_extent_xref(
240 struct xchk_bmap_info *info, 240 struct xchk_bmap_info *info,
241 struct xfs_inode *ip, 241 struct xfs_inode *ip,
242 struct xfs_btree_cur *cur, 242 struct xfs_btree_cur *cur,
243 struct xfs_bmbt_irec *irec) 243 struct xfs_bmbt_irec *irec)
244{ 244{
245 struct xfs_mount *mp = info->sc->mp; 245 struct xfs_mount *mp = info->sc->mp;
246 xfs_agnumber_t agno; 246 xfs_agnumber_t agno;
247 xfs_agblock_t agbno; 247 xfs_agblock_t agbno;
248 xfs_extlen_t len; 248 xfs_extlen_t len;
249 int error; 249 int error;
250 250
251 if (info->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 251 if (info->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
252 return; 252 return;
@@ -284,15 +284,15 @@ xchk_bmap_extent_xref(
284/* Scrub a single extent record. */ 284/* Scrub a single extent record. */
285STATIC int 285STATIC int
286xchk_bmap_extent( 286xchk_bmap_extent(
287 struct xfs_inode *ip, 287 struct xfs_inode *ip,
288 struct xfs_btree_cur *cur, 288 struct xfs_btree_cur *cur,
289 struct xchk_bmap_info *info, 289 struct xchk_bmap_info *info,
290 struct xfs_bmbt_irec *irec) 290 struct xfs_bmbt_irec *irec)
291{ 291{
292 struct xfs_mount *mp = info->sc->mp; 292 struct xfs_mount *mp = info->sc->mp;
293 struct xfs_buf *bp = NULL; 293 struct xfs_buf *bp = NULL;
294 xfs_filblks_t end; 294 xfs_filblks_t end;
295 int error = 0; 295 int error = 0;
296 296
297 if (cur) 297 if (cur)
298 xfs_btree_get_block(cur, 0, &bp); 298 xfs_btree_get_block(cur, 0, &bp);
@@ -357,16 +357,16 @@ xchk_bmap_extent(
357/* Scrub a bmbt record. */ 357/* Scrub a bmbt record. */
358STATIC int 358STATIC int
359xchk_bmapbt_rec( 359xchk_bmapbt_rec(
360 struct xchk_btree *bs, 360 struct xchk_btree *bs,
361 union xfs_btree_rec *rec) 361 union xfs_btree_rec *rec)
362{ 362{
363 struct xfs_bmbt_irec irec; 363 struct xfs_bmbt_irec irec;
364 struct xchk_bmap_info *info = bs->private; 364 struct xchk_bmap_info *info = bs->private;
365 struct xfs_inode *ip = bs->cur->bc_private.b.ip; 365 struct xfs_inode *ip = bs->cur->bc_private.b.ip;
366 struct xfs_buf *bp = NULL; 366 struct xfs_buf *bp = NULL;
367 struct xfs_btree_block *block; 367 struct xfs_btree_block *block;
368 uint64_t owner; 368 uint64_t owner;
369 int i; 369 int i;
370 370
371 /* 371 /*
372 * Check the owners of the btree blocks up to the level below 372 * Check the owners of the btree blocks up to the level below
@@ -392,14 +392,14 @@ xchk_bmapbt_rec(
392STATIC int 392STATIC int
393xchk_bmap_btree( 393xchk_bmap_btree(
394 struct xfs_scrub *sc, 394 struct xfs_scrub *sc,
395 int whichfork, 395 int whichfork,
396 struct xchk_bmap_info *info) 396 struct xchk_bmap_info *info)
397{ 397{
398 struct xfs_owner_info oinfo; 398 struct xfs_owner_info oinfo;
399 struct xfs_mount *mp = sc->mp; 399 struct xfs_mount *mp = sc->mp;
400 struct xfs_inode *ip = sc->ip; 400 struct xfs_inode *ip = sc->ip;
401 struct xfs_btree_cur *cur; 401 struct xfs_btree_cur *cur;
402 int error; 402 int error;
403 403
404 cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork); 404 cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork);
405 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); 405 xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork);
@@ -410,8 +410,8 @@ xchk_bmap_btree(
410 410
411struct xchk_bmap_check_rmap_info { 411struct xchk_bmap_check_rmap_info {
412 struct xfs_scrub *sc; 412 struct xfs_scrub *sc;
413 int whichfork; 413 int whichfork;
414 struct xfs_iext_cursor icur; 414 struct xfs_iext_cursor icur;
415}; 415};
416 416
417/* Can we find bmaps that fit this rmap? */ 417/* Can we find bmaps that fit this rmap? */
@@ -424,7 +424,7 @@ xchk_bmap_check_rmap(
424 struct xfs_bmbt_irec irec; 424 struct xfs_bmbt_irec irec;
425 struct xchk_bmap_check_rmap_info *sbcri = priv; 425 struct xchk_bmap_check_rmap_info *sbcri = priv;
426 struct xfs_ifork *ifp; 426 struct xfs_ifork *ifp;
427 struct xfs_scrub *sc = sbcri->sc; 427 struct xfs_scrub *sc = sbcri->sc;
428 bool have_map; 428 bool have_map;
429 429
430 /* Is this even the right fork? */ 430 /* Is this even the right fork? */
@@ -488,7 +488,7 @@ out:
488/* Make sure each rmap has a corresponding bmbt entry. */ 488/* Make sure each rmap has a corresponding bmbt entry. */
489STATIC int 489STATIC int
490xchk_bmap_check_ag_rmaps( 490xchk_bmap_check_ag_rmaps(
491 struct xfs_scrub *sc, 491 struct xfs_scrub *sc,
492 int whichfork, 492 int whichfork,
493 xfs_agnumber_t agno) 493 xfs_agnumber_t agno)
494{ 494{
@@ -523,11 +523,11 @@ out_agf:
523STATIC int 523STATIC int
524xchk_bmap_check_rmaps( 524xchk_bmap_check_rmaps(
525 struct xfs_scrub *sc, 525 struct xfs_scrub *sc,
526 int whichfork) 526 int whichfork)
527{ 527{
528 loff_t size; 528 loff_t size;
529 xfs_agnumber_t agno; 529 xfs_agnumber_t agno;
530 int error; 530 int error;
531 531
532 if (!xfs_sb_version_hasrmapbt(&sc->mp->m_sb) || 532 if (!xfs_sb_version_hasrmapbt(&sc->mp->m_sb) ||
533 whichfork == XFS_COW_FORK || 533 whichfork == XFS_COW_FORK ||
@@ -580,16 +580,16 @@ xchk_bmap_check_rmaps(
580STATIC int 580STATIC int
581xchk_bmap( 581xchk_bmap(
582 struct xfs_scrub *sc, 582 struct xfs_scrub *sc,
583 int whichfork) 583 int whichfork)
584{ 584{
585 struct xfs_bmbt_irec irec; 585 struct xfs_bmbt_irec irec;
586 struct xchk_bmap_info info = { NULL }; 586 struct xchk_bmap_info info = { NULL };
587 struct xfs_mount *mp = sc->mp; 587 struct xfs_mount *mp = sc->mp;
588 struct xfs_inode *ip = sc->ip; 588 struct xfs_inode *ip = sc->ip;
589 struct xfs_ifork *ifp; 589 struct xfs_ifork *ifp;
590 xfs_fileoff_t endoff; 590 xfs_fileoff_t endoff;
591 struct xfs_iext_cursor icur; 591 struct xfs_iext_cursor icur;
592 int error = 0; 592 int error = 0;
593 593
594 ifp = XFS_IFORK_PTR(ip, whichfork); 594 ifp = XFS_IFORK_PTR(ip, whichfork);
595 595
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index c4e1dce8c5b3..4ae959f7ad2c 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -31,11 +31,11 @@
31static bool 31static bool
32__xchk_btree_process_error( 32__xchk_btree_process_error(
33 struct xfs_scrub *sc, 33 struct xfs_scrub *sc,
34 struct xfs_btree_cur *cur, 34 struct xfs_btree_cur *cur,
35 int level, 35 int level,
36 int *error, 36 int *error,
37 __u32 errflag, 37 __u32 errflag,
38 void *ret_ip) 38 void *ret_ip)
39{ 39{
40 if (*error == 0) 40 if (*error == 0)
41 return true; 41 return true;
@@ -66,9 +66,9 @@ __xchk_btree_process_error(
66bool 66bool
67xchk_btree_process_error( 67xchk_btree_process_error(
68 struct xfs_scrub *sc, 68 struct xfs_scrub *sc,
69 struct xfs_btree_cur *cur, 69 struct xfs_btree_cur *cur,
70 int level, 70 int level,
71 int *error) 71 int *error)
72{ 72{
73 return __xchk_btree_process_error(sc, cur, level, error, 73 return __xchk_btree_process_error(sc, cur, level, error,
74 XFS_SCRUB_OFLAG_CORRUPT, __return_address); 74 XFS_SCRUB_OFLAG_CORRUPT, __return_address);
@@ -77,9 +77,9 @@ xchk_btree_process_error(
77bool 77bool
78xchk_btree_xref_process_error( 78xchk_btree_xref_process_error(
79 struct xfs_scrub *sc, 79 struct xfs_scrub *sc,
80 struct xfs_btree_cur *cur, 80 struct xfs_btree_cur *cur,
81 int level, 81 int level,
82 int *error) 82 int *error)
83{ 83{
84 return __xchk_btree_process_error(sc, cur, level, error, 84 return __xchk_btree_process_error(sc, cur, level, error,
85 XFS_SCRUB_OFLAG_XFAIL, __return_address); 85 XFS_SCRUB_OFLAG_XFAIL, __return_address);
@@ -89,10 +89,10 @@ xchk_btree_xref_process_error(
89static void 89static void
90__xchk_btree_set_corrupt( 90__xchk_btree_set_corrupt(
91 struct xfs_scrub *sc, 91 struct xfs_scrub *sc,
92 struct xfs_btree_cur *cur, 92 struct xfs_btree_cur *cur,
93 int level, 93 int level,
94 __u32 errflag, 94 __u32 errflag,
95 void *ret_ip) 95 void *ret_ip)
96{ 96{
97 sc->sm->sm_flags |= errflag; 97 sc->sm->sm_flags |= errflag;
98 98
@@ -107,8 +107,8 @@ __xchk_btree_set_corrupt(
107void 107void
108xchk_btree_set_corrupt( 108xchk_btree_set_corrupt(
109 struct xfs_scrub *sc, 109 struct xfs_scrub *sc,
110 struct xfs_btree_cur *cur, 110 struct xfs_btree_cur *cur,
111 int level) 111 int level)
112{ 112{
113 __xchk_btree_set_corrupt(sc, cur, level, XFS_SCRUB_OFLAG_CORRUPT, 113 __xchk_btree_set_corrupt(sc, cur, level, XFS_SCRUB_OFLAG_CORRUPT,
114 __return_address); 114 __return_address);
@@ -117,8 +117,8 @@ xchk_btree_set_corrupt(
117void 117void
118xchk_btree_xref_set_corrupt( 118xchk_btree_xref_set_corrupt(
119 struct xfs_scrub *sc, 119 struct xfs_scrub *sc,
120 struct xfs_btree_cur *cur, 120 struct xfs_btree_cur *cur,
121 int level) 121 int level)
122{ 122{
123 __xchk_btree_set_corrupt(sc, cur, level, XFS_SCRUB_OFLAG_XCORRUPT, 123 __xchk_btree_set_corrupt(sc, cur, level, XFS_SCRUB_OFLAG_XCORRUPT,
124 __return_address); 124 __return_address);
@@ -225,11 +225,11 @@ xchk_btree_key(
225 */ 225 */
226static bool 226static bool
227xchk_btree_ptr_ok( 227xchk_btree_ptr_ok(
228 struct xchk_btree *bs, 228 struct xchk_btree *bs,
229 int level, 229 int level,
230 union xfs_btree_ptr *ptr) 230 union xfs_btree_ptr *ptr)
231{ 231{
232 bool res; 232 bool res;
233 233
234 /* A btree rooted in an inode has no block pointer to the root. */ 234 /* A btree rooted in an inode has no block pointer to the root. */
235 if ((bs->cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && 235 if ((bs->cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) &&
@@ -250,18 +250,18 @@ xchk_btree_ptr_ok(
250/* Check that a btree block's sibling matches what we expect it. */ 250/* Check that a btree block's sibling matches what we expect it. */
251STATIC int 251STATIC int
252xchk_btree_block_check_sibling( 252xchk_btree_block_check_sibling(
253 struct xchk_btree *bs, 253 struct xchk_btree *bs,
254 int level, 254 int level,
255 int direction, 255 int direction,
256 union xfs_btree_ptr *sibling) 256 union xfs_btree_ptr *sibling)
257{ 257{
258 struct xfs_btree_cur *cur = bs->cur; 258 struct xfs_btree_cur *cur = bs->cur;
259 struct xfs_btree_block *pblock; 259 struct xfs_btree_block *pblock;
260 struct xfs_buf *pbp; 260 struct xfs_buf *pbp;
261 struct xfs_btree_cur *ncur = NULL; 261 struct xfs_btree_cur *ncur = NULL;
262 union xfs_btree_ptr *pp; 262 union xfs_btree_ptr *pp;
263 int success; 263 int success;
264 int error; 264 int error;
265 265
266 error = xfs_btree_dup_cursor(cur, &ncur); 266 error = xfs_btree_dup_cursor(cur, &ncur);
267 if (!xchk_btree_process_error(bs->sc, cur, level + 1, &error) || 267 if (!xchk_btree_process_error(bs->sc, cur, level + 1, &error) ||
@@ -313,14 +313,14 @@ out:
313/* Check the siblings of a btree block. */ 313/* Check the siblings of a btree block. */
314STATIC int 314STATIC int
315xchk_btree_block_check_siblings( 315xchk_btree_block_check_siblings(
316 struct xchk_btree *bs, 316 struct xchk_btree *bs,
317 struct xfs_btree_block *block) 317 struct xfs_btree_block *block)
318{ 318{
319 struct xfs_btree_cur *cur = bs->cur; 319 struct xfs_btree_cur *cur = bs->cur;
320 union xfs_btree_ptr leftsib; 320 union xfs_btree_ptr leftsib;
321 union xfs_btree_ptr rightsib; 321 union xfs_btree_ptr rightsib;
322 int level; 322 int level;
323 int error = 0; 323 int error = 0;
324 324
325 xfs_btree_get_sibling(cur, block, &leftsib, XFS_BB_LEFTSIB); 325 xfs_btree_get_sibling(cur, block, &leftsib, XFS_BB_LEFTSIB);
326 xfs_btree_get_sibling(cur, block, &rightsib, XFS_BB_RIGHTSIB); 326 xfs_btree_get_sibling(cur, block, &rightsib, XFS_BB_RIGHTSIB);
@@ -361,15 +361,15 @@ struct check_owner {
361 */ 361 */
362STATIC int 362STATIC int
363xchk_btree_check_block_owner( 363xchk_btree_check_block_owner(
364 struct xchk_btree *bs, 364 struct xchk_btree *bs,
365 int level, 365 int level,
366 xfs_daddr_t daddr) 366 xfs_daddr_t daddr)
367{ 367{
368 xfs_agnumber_t agno; 368 xfs_agnumber_t agno;
369 xfs_agblock_t agbno; 369 xfs_agblock_t agbno;
370 xfs_btnum_t btnum; 370 xfs_btnum_t btnum;
371 bool init_sa; 371 bool init_sa;
372 int error = 0; 372 int error = 0;
373 373
374 if (!bs->cur) 374 if (!bs->cur)
375 return 0; 375 return 0;
@@ -408,12 +408,12 @@ xchk_btree_check_block_owner(
408/* Check the owner of a btree block. */ 408/* Check the owner of a btree block. */
409STATIC int 409STATIC int
410xchk_btree_check_owner( 410xchk_btree_check_owner(
411 struct xchk_btree *bs, 411 struct xchk_btree *bs,
412 int level, 412 int level,
413 struct xfs_buf *bp) 413 struct xfs_buf *bp)
414{ 414{
415 struct xfs_btree_cur *cur = bs->cur; 415 struct xfs_btree_cur *cur = bs->cur;
416 struct check_owner *co; 416 struct check_owner *co;
417 417
418 if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && bp == NULL) 418 if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && bp == NULL)
419 return 0; 419 return 0;
@@ -484,14 +484,14 @@ xchk_btree_check_minrecs(
484 */ 484 */
485STATIC int 485STATIC int
486xchk_btree_get_block( 486xchk_btree_get_block(
487 struct xchk_btree *bs, 487 struct xchk_btree *bs,
488 int level, 488 int level,
489 union xfs_btree_ptr *pp, 489 union xfs_btree_ptr *pp,
490 struct xfs_btree_block **pblock, 490 struct xfs_btree_block **pblock,
491 struct xfs_buf **pbp) 491 struct xfs_buf **pbp)
492{ 492{
493 void *failed_at; 493 xfs_failaddr_t failed_at;
494 int error; 494 int error;
495 495
496 *pblock = NULL; 496 *pblock = NULL;
497 *pbp = NULL; 497 *pbp = NULL;
@@ -538,17 +538,17 @@ xchk_btree_get_block(
538 */ 538 */
539STATIC void 539STATIC void
540xchk_btree_block_keys( 540xchk_btree_block_keys(
541 struct xchk_btree *bs, 541 struct xchk_btree *bs,
542 int level, 542 int level,
543 struct xfs_btree_block *block) 543 struct xfs_btree_block *block)
544{ 544{
545 union xfs_btree_key block_keys; 545 union xfs_btree_key block_keys;
546 struct xfs_btree_cur *cur = bs->cur; 546 struct xfs_btree_cur *cur = bs->cur;
547 union xfs_btree_key *high_bk; 547 union xfs_btree_key *high_bk;
548 union xfs_btree_key *parent_keys; 548 union xfs_btree_key *parent_keys;
549 union xfs_btree_key *high_pk; 549 union xfs_btree_key *high_pk;
550 struct xfs_btree_block *parent_block; 550 struct xfs_btree_block *parent_block;
551 struct xfs_buf *bp; 551 struct xfs_buf *bp;
552 552
553 if (level >= cur->bc_nlevels - 1) 553 if (level >= cur->bc_nlevels - 1)
554 return; 554 return;
@@ -584,22 +584,22 @@ xchk_btree_block_keys(
584int 584int
585xchk_btree( 585xchk_btree(
586 struct xfs_scrub *sc, 586 struct xfs_scrub *sc,
587 struct xfs_btree_cur *cur, 587 struct xfs_btree_cur *cur,
588 xchk_btree_rec_fn scrub_fn, 588 xchk_btree_rec_fn scrub_fn,
589 struct xfs_owner_info *oinfo, 589 struct xfs_owner_info *oinfo,
590 void *private) 590 void *private)
591{ 591{
592 struct xchk_btree bs = { NULL }; 592 struct xchk_btree bs = { NULL };
593 union xfs_btree_ptr ptr; 593 union xfs_btree_ptr ptr;
594 union xfs_btree_ptr *pp; 594 union xfs_btree_ptr *pp;
595 union xfs_btree_rec *recp; 595 union xfs_btree_rec *recp;
596 struct xfs_btree_block *block; 596 struct xfs_btree_block *block;
597 int level; 597 int level;
598 struct xfs_buf *bp; 598 struct xfs_buf *bp;
599 struct check_owner *co; 599 struct check_owner *co;
600 struct check_owner *n; 600 struct check_owner *n;
601 int i; 601 int i;
602 int error = 0; 602 int error = 0;
603 603
604 /* Initialize scrub state */ 604 /* Initialize scrub state */
605 bs.cur = cur; 605 bs.cur = cur;
diff --git a/fs/xfs/scrub/btree.h b/fs/xfs/scrub/btree.h
index a0b74b515b9b..aada763cd006 100644
--- a/fs/xfs/scrub/btree.h
+++ b/fs/xfs/scrub/btree.h
@@ -14,8 +14,7 @@ bool xchk_btree_process_error(struct xfs_scrub *sc,
14 14
15/* Check for btree xref operation errors. */ 15/* Check for btree xref operation errors. */
16bool xchk_btree_xref_process_error(struct xfs_scrub *sc, 16bool xchk_btree_xref_process_error(struct xfs_scrub *sc,
17 struct xfs_btree_cur *cur, int level, 17 struct xfs_btree_cur *cur, int level, int *error);
18 int *error);
19 18
20/* Check for btree corruption. */ 19/* Check for btree corruption. */
21void xchk_btree_set_corrupt(struct xfs_scrub *sc, 20void xchk_btree_set_corrupt(struct xfs_scrub *sc,
@@ -33,20 +32,20 @@ typedef int (*xchk_btree_rec_fn)(
33struct xchk_btree { 32struct xchk_btree {
34 /* caller-provided scrub state */ 33 /* caller-provided scrub state */
35 struct xfs_scrub *sc; 34 struct xfs_scrub *sc;
36 struct xfs_btree_cur *cur; 35 struct xfs_btree_cur *cur;
37 xchk_btree_rec_fn scrub_rec; 36 xchk_btree_rec_fn scrub_rec;
38 struct xfs_owner_info *oinfo; 37 struct xfs_owner_info *oinfo;
39 void *private; 38 void *private;
40 39
41 /* internal scrub state */ 40 /* internal scrub state */
42 union xfs_btree_rec lastrec; 41 union xfs_btree_rec lastrec;
43 bool firstrec; 42 bool firstrec;
44 union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS]; 43 union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS];
45 bool firstkey[XFS_BTREE_MAXLEVELS]; 44 bool firstkey[XFS_BTREE_MAXLEVELS];
46 struct list_head to_check; 45 struct list_head to_check;
47}; 46};
48int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur, 47int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
49 xchk_btree_rec_fn scrub_fn, 48 xchk_btree_rec_fn scrub_fn, struct xfs_owner_info *oinfo,
50 struct xfs_owner_info *oinfo, void *private); 49 void *private);
51 50
52#endif /* __XFS_SCRUB_BTREE_H__ */ 51#endif /* __XFS_SCRUB_BTREE_H__ */
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index ed9195116556..baac08304a5a 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -70,11 +70,11 @@
70static bool 70static bool
71__xchk_process_error( 71__xchk_process_error(
72 struct xfs_scrub *sc, 72 struct xfs_scrub *sc,
73 xfs_agnumber_t agno, 73 xfs_agnumber_t agno,
74 xfs_agblock_t bno, 74 xfs_agblock_t bno,
75 int *error, 75 int *error,
76 __u32 errflag, 76 __u32 errflag,
77 void *ret_ip) 77 void *ret_ip)
78{ 78{
79 switch (*error) { 79 switch (*error) {
80 case 0: 80 case 0:
@@ -100,9 +100,9 @@ __xchk_process_error(
100bool 100bool
101xchk_process_error( 101xchk_process_error(
102 struct xfs_scrub *sc, 102 struct xfs_scrub *sc,
103 xfs_agnumber_t agno, 103 xfs_agnumber_t agno,
104 xfs_agblock_t bno, 104 xfs_agblock_t bno,
105 int *error) 105 int *error)
106{ 106{
107 return __xchk_process_error(sc, agno, bno, error, 107 return __xchk_process_error(sc, agno, bno, error,
108 XFS_SCRUB_OFLAG_CORRUPT, __return_address); 108 XFS_SCRUB_OFLAG_CORRUPT, __return_address);
@@ -111,9 +111,9 @@ xchk_process_error(
111bool 111bool
112xchk_xref_process_error( 112xchk_xref_process_error(
113 struct xfs_scrub *sc, 113 struct xfs_scrub *sc,
114 xfs_agnumber_t agno, 114 xfs_agnumber_t agno,
115 xfs_agblock_t bno, 115 xfs_agblock_t bno,
116 int *error) 116 int *error)
117{ 117{
118 return __xchk_process_error(sc, agno, bno, error, 118 return __xchk_process_error(sc, agno, bno, error,
119 XFS_SCRUB_OFLAG_XFAIL, __return_address); 119 XFS_SCRUB_OFLAG_XFAIL, __return_address);
@@ -123,11 +123,11 @@ xchk_xref_process_error(
123static bool 123static bool
124__xchk_fblock_process_error( 124__xchk_fblock_process_error(
125 struct xfs_scrub *sc, 125 struct xfs_scrub *sc,
126 int whichfork, 126 int whichfork,
127 xfs_fileoff_t offset, 127 xfs_fileoff_t offset,
128 int *error, 128 int *error,
129 __u32 errflag, 129 __u32 errflag,
130 void *ret_ip) 130 void *ret_ip)
131{ 131{
132 switch (*error) { 132 switch (*error) {
133 case 0: 133 case 0:
@@ -153,9 +153,9 @@ __xchk_fblock_process_error(
153bool 153bool
154xchk_fblock_process_error( 154xchk_fblock_process_error(
155 struct xfs_scrub *sc, 155 struct xfs_scrub *sc,
156 int whichfork, 156 int whichfork,
157 xfs_fileoff_t offset, 157 xfs_fileoff_t offset,
158 int *error) 158 int *error)
159{ 159{
160 return __xchk_fblock_process_error(sc, whichfork, offset, error, 160 return __xchk_fblock_process_error(sc, whichfork, offset, error,
161 XFS_SCRUB_OFLAG_CORRUPT, __return_address); 161 XFS_SCRUB_OFLAG_CORRUPT, __return_address);
@@ -164,9 +164,9 @@ xchk_fblock_process_error(
164bool 164bool
165xchk_fblock_xref_process_error( 165xchk_fblock_xref_process_error(
166 struct xfs_scrub *sc, 166 struct xfs_scrub *sc,
167 int whichfork, 167 int whichfork,
168 xfs_fileoff_t offset, 168 xfs_fileoff_t offset,
169 int *error) 169 int *error)
170{ 170{
171 return __xchk_fblock_process_error(sc, whichfork, offset, error, 171 return __xchk_fblock_process_error(sc, whichfork, offset, error,
172 XFS_SCRUB_OFLAG_XFAIL, __return_address); 172 XFS_SCRUB_OFLAG_XFAIL, __return_address);
@@ -188,7 +188,7 @@ xchk_fblock_xref_process_error(
188void 188void
189xchk_block_set_preen( 189xchk_block_set_preen(
190 struct xfs_scrub *sc, 190 struct xfs_scrub *sc,
191 struct xfs_buf *bp) 191 struct xfs_buf *bp)
192{ 192{
193 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN; 193 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
194 trace_xchk_block_preen(sc, bp->b_bn, __return_address); 194 trace_xchk_block_preen(sc, bp->b_bn, __return_address);
@@ -202,7 +202,7 @@ xchk_block_set_preen(
202void 202void
203xchk_ino_set_preen( 203xchk_ino_set_preen(
204 struct xfs_scrub *sc, 204 struct xfs_scrub *sc,
205 xfs_ino_t ino) 205 xfs_ino_t ino)
206{ 206{
207 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN; 207 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
208 trace_xchk_ino_preen(sc, ino, __return_address); 208 trace_xchk_ino_preen(sc, ino, __return_address);
@@ -212,7 +212,7 @@ xchk_ino_set_preen(
212void 212void
213xchk_block_set_corrupt( 213xchk_block_set_corrupt(
214 struct xfs_scrub *sc, 214 struct xfs_scrub *sc,
215 struct xfs_buf *bp) 215 struct xfs_buf *bp)
216{ 216{
217 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; 217 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
218 trace_xchk_block_error(sc, bp->b_bn, __return_address); 218 trace_xchk_block_error(sc, bp->b_bn, __return_address);
@@ -222,7 +222,7 @@ xchk_block_set_corrupt(
222void 222void
223xchk_block_xref_set_corrupt( 223xchk_block_xref_set_corrupt(
224 struct xfs_scrub *sc, 224 struct xfs_scrub *sc,
225 struct xfs_buf *bp) 225 struct xfs_buf *bp)
226{ 226{
227 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; 227 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
228 trace_xchk_block_error(sc, bp->b_bn, __return_address); 228 trace_xchk_block_error(sc, bp->b_bn, __return_address);
@@ -236,7 +236,7 @@ xchk_block_xref_set_corrupt(
236void 236void
237xchk_ino_set_corrupt( 237xchk_ino_set_corrupt(
238 struct xfs_scrub *sc, 238 struct xfs_scrub *sc,
239 xfs_ino_t ino) 239 xfs_ino_t ino)
240{ 240{
241 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; 241 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
242 trace_xchk_ino_error(sc, ino, __return_address); 242 trace_xchk_ino_error(sc, ino, __return_address);
@@ -246,7 +246,7 @@ xchk_ino_set_corrupt(
246void 246void
247xchk_ino_xref_set_corrupt( 247xchk_ino_xref_set_corrupt(
248 struct xfs_scrub *sc, 248 struct xfs_scrub *sc,
249 xfs_ino_t ino) 249 xfs_ino_t ino)
250{ 250{
251 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; 251 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
252 trace_xchk_ino_error(sc, ino, __return_address); 252 trace_xchk_ino_error(sc, ino, __return_address);
@@ -256,8 +256,8 @@ xchk_ino_xref_set_corrupt(
256void 256void
257xchk_fblock_set_corrupt( 257xchk_fblock_set_corrupt(
258 struct xfs_scrub *sc, 258 struct xfs_scrub *sc,
259 int whichfork, 259 int whichfork,
260 xfs_fileoff_t offset) 260 xfs_fileoff_t offset)
261{ 261{
262 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; 262 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
263 trace_xchk_fblock_error(sc, whichfork, offset, __return_address); 263 trace_xchk_fblock_error(sc, whichfork, offset, __return_address);
@@ -267,8 +267,8 @@ xchk_fblock_set_corrupt(
267void 267void
268xchk_fblock_xref_set_corrupt( 268xchk_fblock_xref_set_corrupt(
269 struct xfs_scrub *sc, 269 struct xfs_scrub *sc,
270 int whichfork, 270 int whichfork,
271 xfs_fileoff_t offset) 271 xfs_fileoff_t offset)
272{ 272{
273 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; 273 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
274 trace_xchk_fblock_error(sc, whichfork, offset, __return_address); 274 trace_xchk_fblock_error(sc, whichfork, offset, __return_address);
@@ -281,7 +281,7 @@ xchk_fblock_xref_set_corrupt(
281void 281void
282xchk_ino_set_warning( 282xchk_ino_set_warning(
283 struct xfs_scrub *sc, 283 struct xfs_scrub *sc,
284 xfs_ino_t ino) 284 xfs_ino_t ino)
285{ 285{
286 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING; 286 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
287 trace_xchk_ino_warning(sc, ino, __return_address); 287 trace_xchk_ino_warning(sc, ino, __return_address);
@@ -291,8 +291,8 @@ xchk_ino_set_warning(
291void 291void
292xchk_fblock_set_warning( 292xchk_fblock_set_warning(
293 struct xfs_scrub *sc, 293 struct xfs_scrub *sc,
294 int whichfork, 294 int whichfork,
295 xfs_fileoff_t offset) 295 xfs_fileoff_t offset)
296{ 296{
297 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING; 297 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
298 trace_xchk_fblock_warning(sc, whichfork, offset, __return_address); 298 trace_xchk_fblock_warning(sc, whichfork, offset, __return_address);
@@ -319,13 +319,13 @@ struct xchk_rmap_ownedby_info {
319 319
320STATIC int 320STATIC int
321xchk_count_rmap_ownedby_irec( 321xchk_count_rmap_ownedby_irec(
322 struct xfs_btree_cur *cur, 322 struct xfs_btree_cur *cur,
323 struct xfs_rmap_irec *rec, 323 struct xfs_rmap_irec *rec,
324 void *priv) 324 void *priv)
325{ 325{
326 struct xchk_rmap_ownedby_info *sroi = priv; 326 struct xchk_rmap_ownedby_info *sroi = priv;
327 bool irec_attr; 327 bool irec_attr;
328 bool oinfo_attr; 328 bool oinfo_attr;
329 329
330 irec_attr = rec->rm_flags & XFS_RMAP_ATTR_FORK; 330 irec_attr = rec->rm_flags & XFS_RMAP_ATTR_FORK;
331 oinfo_attr = sroi->oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK; 331 oinfo_attr = sroi->oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK;
@@ -346,11 +346,11 @@ xchk_count_rmap_ownedby_irec(
346int 346int
347xchk_count_rmap_ownedby_ag( 347xchk_count_rmap_ownedby_ag(
348 struct xfs_scrub *sc, 348 struct xfs_scrub *sc,
349 struct xfs_btree_cur *cur, 349 struct xfs_btree_cur *cur,
350 struct xfs_owner_info *oinfo, 350 struct xfs_owner_info *oinfo,
351 xfs_filblks_t *blocks) 351 xfs_filblks_t *blocks)
352{ 352{
353 struct xchk_rmap_ownedby_info sroi; 353 struct xchk_rmap_ownedby_info sroi;
354 354
355 sroi.oinfo = oinfo; 355 sroi.oinfo = oinfo;
356 *blocks = 0; 356 *blocks = 0;
@@ -372,7 +372,7 @@ xchk_count_rmap_ownedby_ag(
372static inline bool 372static inline bool
373want_ag_read_header_failure( 373want_ag_read_header_failure(
374 struct xfs_scrub *sc, 374 struct xfs_scrub *sc,
375 unsigned int type) 375 unsigned int type)
376{ 376{
377 /* Return all AG header read failures when scanning btrees. */ 377 /* Return all AG header read failures when scanning btrees. */
378 if (sc->sm->sm_type != XFS_SCRUB_TYPE_AGF && 378 if (sc->sm->sm_type != XFS_SCRUB_TYPE_AGF &&
@@ -399,13 +399,13 @@ want_ag_read_header_failure(
399int 399int
400xchk_ag_read_headers( 400xchk_ag_read_headers(
401 struct xfs_scrub *sc, 401 struct xfs_scrub *sc,
402 xfs_agnumber_t agno, 402 xfs_agnumber_t agno,
403 struct xfs_buf **agi, 403 struct xfs_buf **agi,
404 struct xfs_buf **agf, 404 struct xfs_buf **agf,
405 struct xfs_buf **agfl) 405 struct xfs_buf **agfl)
406{ 406{
407 struct xfs_mount *mp = sc->mp; 407 struct xfs_mount *mp = sc->mp;
408 int error; 408 int error;
409 409
410 error = xfs_ialloc_read_agi(mp, sc->tp, agno, agi); 410 error = xfs_ialloc_read_agi(mp, sc->tp, agno, agi);
411 if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGI)) 411 if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGI))
@@ -455,8 +455,8 @@ xchk_ag_btcur_init(
455 struct xfs_scrub *sc, 455 struct xfs_scrub *sc,
456 struct xchk_ag *sa) 456 struct xchk_ag *sa)
457{ 457{
458 struct xfs_mount *mp = sc->mp; 458 struct xfs_mount *mp = sc->mp;
459 xfs_agnumber_t agno = sa->agno; 459 xfs_agnumber_t agno = sa->agno;
460 460
461 if (sa->agf_bp) { 461 if (sa->agf_bp) {
462 /* Set up a bnobt cursor for cross-referencing. */ 462 /* Set up a bnobt cursor for cross-referencing. */
@@ -545,10 +545,10 @@ xchk_ag_free(
545int 545int
546xchk_ag_init( 546xchk_ag_init(
547 struct xfs_scrub *sc, 547 struct xfs_scrub *sc,
548 xfs_agnumber_t agno, 548 xfs_agnumber_t agno,
549 struct xchk_ag *sa) 549 struct xchk_ag *sa)
550{ 550{
551 int error; 551 int error;
552 552
553 sa->agno = agno; 553 sa->agno = agno;
554 error = xchk_ag_read_headers(sc, agno, &sa->agi_bp, 554 error = xchk_ag_read_headers(sc, agno, &sa->agi_bp,
@@ -566,7 +566,7 @@ xchk_ag_init(
566void 566void
567xchk_perag_get( 567xchk_perag_get(
568 struct xfs_mount *mp, 568 struct xfs_mount *mp,
569 struct xchk_ag *sa) 569 struct xchk_ag *sa)
570{ 570{
571 if (!sa->pag) 571 if (!sa->pag)
572 sa->pag = xfs_perag_get(mp, sa->agno); 572 sa->pag = xfs_perag_get(mp, sa->agno);
@@ -587,7 +587,7 @@ xchk_perag_get(
587int 587int
588xchk_trans_alloc( 588xchk_trans_alloc(
589 struct xfs_scrub *sc, 589 struct xfs_scrub *sc,
590 uint resblks) 590 uint resblks)
591{ 591{
592 if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) 592 if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)
593 return xfs_trans_alloc(sc->mp, &M_RES(sc->mp)->tr_itruncate, 593 return xfs_trans_alloc(sc->mp, &M_RES(sc->mp)->tr_itruncate,
@@ -600,9 +600,9 @@ xchk_trans_alloc(
600int 600int
601xchk_setup_fs( 601xchk_setup_fs(
602 struct xfs_scrub *sc, 602 struct xfs_scrub *sc,
603 struct xfs_inode *ip) 603 struct xfs_inode *ip)
604{ 604{
605 uint resblks; 605 uint resblks;
606 606
607 resblks = xrep_calc_ag_resblks(sc); 607 resblks = xrep_calc_ag_resblks(sc);
608 return xchk_trans_alloc(sc, resblks); 608 return xchk_trans_alloc(sc, resblks);
@@ -612,11 +612,11 @@ xchk_setup_fs(
612int 612int
613xchk_setup_ag_btree( 613xchk_setup_ag_btree(
614 struct xfs_scrub *sc, 614 struct xfs_scrub *sc,
615 struct xfs_inode *ip, 615 struct xfs_inode *ip,
616 bool force_log) 616 bool force_log)
617{ 617{
618 struct xfs_mount *mp = sc->mp; 618 struct xfs_mount *mp = sc->mp;
619 int error; 619 int error;
620 620
621 /* 621 /*
622 * If the caller asks us to checkpont the log, do so. This 622 * If the caller asks us to checkpont the log, do so. This
@@ -659,12 +659,12 @@ xchk_checkpoint_log(
659int 659int
660xchk_get_inode( 660xchk_get_inode(
661 struct xfs_scrub *sc, 661 struct xfs_scrub *sc,
662 struct xfs_inode *ip_in) 662 struct xfs_inode *ip_in)
663{ 663{
664 struct xfs_imap imap; 664 struct xfs_imap imap;
665 struct xfs_mount *mp = sc->mp; 665 struct xfs_mount *mp = sc->mp;
666 struct xfs_inode *ip = NULL; 666 struct xfs_inode *ip = NULL;
667 int error; 667 int error;
668 668
669 /* We want to scan the inode we already had opened. */ 669 /* We want to scan the inode we already had opened. */
670 if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) { 670 if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) {
@@ -723,10 +723,10 @@ xchk_get_inode(
723int 723int
724xchk_setup_inode_contents( 724xchk_setup_inode_contents(
725 struct xfs_scrub *sc, 725 struct xfs_scrub *sc,
726 struct xfs_inode *ip, 726 struct xfs_inode *ip,
727 unsigned int resblks) 727 unsigned int resblks)
728{ 728{
729 int error; 729 int error;
730 730
731 error = xchk_get_inode(sc, ip); 731 error = xchk_get_inode(sc, ip);
732 if (error) 732 if (error)
@@ -754,8 +754,8 @@ out:
754bool 754bool
755xchk_should_check_xref( 755xchk_should_check_xref(
756 struct xfs_scrub *sc, 756 struct xfs_scrub *sc,
757 int *error, 757 int *error,
758 struct xfs_btree_cur **curpp) 758 struct xfs_btree_cur **curpp)
759{ 759{
760 /* No point in xref if we already know we're corrupt. */ 760 /* No point in xref if we already know we're corrupt. */
761 if (xchk_skip_xref(sc->sm)) 761 if (xchk_skip_xref(sc->sm))
@@ -789,9 +789,9 @@ xchk_should_check_xref(
789void 789void
790xchk_buffer_recheck( 790xchk_buffer_recheck(
791 struct xfs_scrub *sc, 791 struct xfs_scrub *sc,
792 struct xfs_buf *bp) 792 struct xfs_buf *bp)
793{ 793{
794 xfs_failaddr_t fa; 794 xfs_failaddr_t fa;
795 795
796 if (bp->b_ops == NULL) { 796 if (bp->b_ops == NULL) {
797 xchk_block_set_corrupt(sc, bp); 797 xchk_block_set_corrupt(sc, bp);
@@ -816,9 +816,9 @@ int
816xchk_metadata_inode_forks( 816xchk_metadata_inode_forks(
817 struct xfs_scrub *sc) 817 struct xfs_scrub *sc)
818{ 818{
819 __u32 smtype; 819 __u32 smtype;
820 bool shared; 820 bool shared;
821 int error; 821 int error;
822 822
823 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 823 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
824 return 0; 824 return 0;
diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h
index c321230d32dc..2d4324d12f9a 100644
--- a/fs/xfs/scrub/common.h
+++ b/fs/xfs/scrub/common.h
@@ -108,24 +108,21 @@ xchk_setup_quota(struct xfs_scrub *sc, struct xfs_inode *ip)
108 108
109void xchk_ag_free(struct xfs_scrub *sc, struct xchk_ag *sa); 109void xchk_ag_free(struct xfs_scrub *sc, struct xchk_ag *sa);
110int xchk_ag_init(struct xfs_scrub *sc, xfs_agnumber_t agno, 110int xchk_ag_init(struct xfs_scrub *sc, xfs_agnumber_t agno,
111 struct xchk_ag *sa); 111 struct xchk_ag *sa);
112void xchk_perag_get(struct xfs_mount *mp, struct xchk_ag *sa); 112void xchk_perag_get(struct xfs_mount *mp, struct xchk_ag *sa);
113int xchk_ag_read_headers(struct xfs_scrub *sc, xfs_agnumber_t agno, 113int xchk_ag_read_headers(struct xfs_scrub *sc, xfs_agnumber_t agno,
114 struct xfs_buf **agi, struct xfs_buf **agf, 114 struct xfs_buf **agi, struct xfs_buf **agf,
115 struct xfs_buf **agfl); 115 struct xfs_buf **agfl);
116void xchk_ag_btcur_free(struct xchk_ag *sa); 116void xchk_ag_btcur_free(struct xchk_ag *sa);
117int xchk_ag_btcur_init(struct xfs_scrub *sc, 117int xchk_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);
118 struct xchk_ag *sa); 118int xchk_count_rmap_ownedby_ag(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
119int xchk_count_rmap_ownedby_ag(struct xfs_scrub *sc, 119 struct xfs_owner_info *oinfo, xfs_filblks_t *blocks);
120 struct xfs_btree_cur *cur,
121 struct xfs_owner_info *oinfo,
122 xfs_filblks_t *blocks);
123 120
124int xchk_setup_ag_btree(struct xfs_scrub *sc, 121int xchk_setup_ag_btree(struct xfs_scrub *sc, struct xfs_inode *ip,
125 struct xfs_inode *ip, bool force_log); 122 bool force_log);
126int xchk_get_inode(struct xfs_scrub *sc, struct xfs_inode *ip_in); 123int xchk_get_inode(struct xfs_scrub *sc, struct xfs_inode *ip_in);
127int xchk_setup_inode_contents(struct xfs_scrub *sc, 124int xchk_setup_inode_contents(struct xfs_scrub *sc, struct xfs_inode *ip,
128 struct xfs_inode *ip, unsigned int resblks); 125 unsigned int resblks);
129void xchk_buffer_recheck(struct xfs_scrub *sc, struct xfs_buf *bp); 126void xchk_buffer_recheck(struct xfs_scrub *sc, struct xfs_buf *bp);
130 127
131/* 128/*
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index 7fc12d540ea6..f1260b4bfdee 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -36,9 +36,9 @@
36 */ 36 */
37bool 37bool
38xchk_da_process_error( 38xchk_da_process_error(
39 struct xchk_da_btree *ds, 39 struct xchk_da_btree *ds,
40 int level, 40 int level,
41 int *error) 41 int *error)
42{ 42{
43 struct xfs_scrub *sc = ds->sc; 43 struct xfs_scrub *sc = ds->sc;
44 44
@@ -72,8 +72,8 @@ xchk_da_process_error(
72 */ 72 */
73void 73void
74xchk_da_set_corrupt( 74xchk_da_set_corrupt(
75 struct xchk_da_btree *ds, 75 struct xchk_da_btree *ds,
76 int level) 76 int level)
77{ 77{
78 struct xfs_scrub *sc = ds->sc; 78 struct xfs_scrub *sc = ds->sc;
79 79
@@ -88,13 +88,13 @@ xchk_da_set_corrupt(
88/* Find an entry at a certain level in a da btree. */ 88/* Find an entry at a certain level in a da btree. */
89STATIC void * 89STATIC void *
90xchk_da_btree_entry( 90xchk_da_btree_entry(
91 struct xchk_da_btree *ds, 91 struct xchk_da_btree *ds,
92 int level, 92 int level,
93 int rec) 93 int rec)
94{ 94{
95 char *ents; 95 char *ents;
96 struct xfs_da_state_blk *blk; 96 struct xfs_da_state_blk *blk;
97 void *baddr; 97 void *baddr;
98 98
99 /* Dispatch the entry finding function. */ 99 /* Dispatch the entry finding function. */
100 blk = &ds->state->path.blk[level]; 100 blk = &ds->state->path.blk[level];
@@ -158,9 +158,9 @@ xchk_da_btree_hash(
158 */ 158 */
159STATIC bool 159STATIC bool
160xchk_da_btree_ptr_ok( 160xchk_da_btree_ptr_ok(
161 struct xchk_da_btree *ds, 161 struct xchk_da_btree *ds,
162 int level, 162 int level,
163 xfs_dablk_t blkno) 163 xfs_dablk_t blkno)
164{ 164{
165 if (blkno < ds->lowest || (ds->highest != 0 && blkno >= ds->highest)) { 165 if (blkno < ds->lowest || (ds->highest != 0 && blkno >= ds->highest)) {
166 xchk_da_set_corrupt(ds, level); 166 xchk_da_set_corrupt(ds, level);
@@ -246,13 +246,13 @@ static const struct xfs_buf_ops xchk_da_btree_buf_ops = {
246/* Check a block's sibling. */ 246/* Check a block's sibling. */
247STATIC int 247STATIC int
248xchk_da_btree_block_check_sibling( 248xchk_da_btree_block_check_sibling(
249 struct xchk_da_btree *ds, 249 struct xchk_da_btree *ds,
250 int level, 250 int level,
251 int direction, 251 int direction,
252 xfs_dablk_t sibling) 252 xfs_dablk_t sibling)
253{ 253{
254 int retval; 254 int retval;
255 int error; 255 int error;
256 256
257 memcpy(&ds->state->altpath, &ds->state->path, 257 memcpy(&ds->state->altpath, &ds->state->path,
258 sizeof(ds->state->altpath)); 258 sizeof(ds->state->altpath));
@@ -294,13 +294,13 @@ out:
294/* Check a block's sibling pointers. */ 294/* Check a block's sibling pointers. */
295STATIC int 295STATIC int
296xchk_da_btree_block_check_siblings( 296xchk_da_btree_block_check_siblings(
297 struct xchk_da_btree *ds, 297 struct xchk_da_btree *ds,
298 int level, 298 int level,
299 struct xfs_da_blkinfo *hdr) 299 struct xfs_da_blkinfo *hdr)
300{ 300{
301 xfs_dablk_t forw; 301 xfs_dablk_t forw;
302 xfs_dablk_t back; 302 xfs_dablk_t back;
303 int error = 0; 303 int error = 0;
304 304
305 forw = be32_to_cpu(hdr->forw); 305 forw = be32_to_cpu(hdr->forw);
306 back = be32_to_cpu(hdr->back); 306 back = be32_to_cpu(hdr->back);
@@ -474,9 +474,9 @@ out_nobuf:
474/* Visit all nodes and leaves of a da btree. */ 474/* Visit all nodes and leaves of a da btree. */
475int 475int
476xchk_da_btree( 476xchk_da_btree(
477 struct xfs_scrub *sc, 477 struct xfs_scrub *sc,
478 int whichfork, 478 int whichfork,
479 xchk_da_btree_rec_fn scrub_fn, 479 xchk_da_btree_rec_fn scrub_fn,
480 void *private) 480 void *private)
481{ 481{
482 struct xchk_da_btree ds = {}; 482 struct xchk_da_btree ds = {};
diff --git a/fs/xfs/scrub/dabtree.h b/fs/xfs/scrub/dabtree.h
index a15c03389e8f..cb3f0003245b 100644
--- a/fs/xfs/scrub/dabtree.h
+++ b/fs/xfs/scrub/dabtree.h
@@ -9,12 +9,12 @@
9/* dir/attr btree */ 9/* dir/attr btree */
10 10
11struct xchk_da_btree { 11struct xchk_da_btree {
12 struct xfs_da_args dargs; 12 struct xfs_da_args dargs;
13 xfs_dahash_t hashes[XFS_DA_NODE_MAXDEPTH]; 13 xfs_dahash_t hashes[XFS_DA_NODE_MAXDEPTH];
14 int maxrecs[XFS_DA_NODE_MAXDEPTH]; 14 int maxrecs[XFS_DA_NODE_MAXDEPTH];
15 struct xfs_da_state *state; 15 struct xfs_da_state *state;
16 struct xfs_scrub *sc; 16 struct xfs_scrub *sc;
17 void *private; 17 void *private;
18 18
19 /* 19 /*
20 * Lowest and highest directory block address in which we expect 20 * Lowest and highest directory block address in which we expect
@@ -22,10 +22,10 @@ struct xchk_da_btree {
22 * (presumably) means between LEAF_OFFSET and FREE_OFFSET; for 22 * (presumably) means between LEAF_OFFSET and FREE_OFFSET; for
23 * attributes there is no limit. 23 * attributes there is no limit.
24 */ 24 */
25 xfs_dablk_t lowest; 25 xfs_dablk_t lowest;
26 xfs_dablk_t highest; 26 xfs_dablk_t highest;
27 27
28 int tree_level; 28 int tree_level;
29}; 29};
30 30
31typedef int (*xchk_da_btree_rec_fn)(struct xchk_da_btree *ds, 31typedef int (*xchk_da_btree_rec_fn)(struct xchk_da_btree *ds,
@@ -37,9 +37,8 @@ bool xchk_da_process_error(struct xchk_da_btree *ds, int level, int *error);
37/* Check for da btree corruption. */ 37/* Check for da btree corruption. */
38void xchk_da_set_corrupt(struct xchk_da_btree *ds, int level); 38void xchk_da_set_corrupt(struct xchk_da_btree *ds, int level);
39 39
40int xchk_da_btree_hash(struct xchk_da_btree *ds, int level, 40int xchk_da_btree_hash(struct xchk_da_btree *ds, int level, __be32 *hashp);
41 __be32 *hashp);
42int xchk_da_btree(struct xfs_scrub *sc, int whichfork, 41int xchk_da_btree(struct xfs_scrub *sc, int whichfork,
43 xchk_da_btree_rec_fn scrub_fn, void *private); 42 xchk_da_btree_rec_fn scrub_fn, void *private);
44 43
45#endif /* __XFS_SCRUB_DABTREE_H__ */ 44#endif /* __XFS_SCRUB_DABTREE_H__ */
diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
index 194a3ef69a9f..f58709052b03 100644
--- a/fs/xfs/scrub/dir.c
+++ b/fs/xfs/scrub/dir.c
@@ -33,7 +33,7 @@
33int 33int
34xchk_setup_directory( 34xchk_setup_directory(
35 struct xfs_scrub *sc, 35 struct xfs_scrub *sc,
36 struct xfs_inode *ip) 36 struct xfs_inode *ip)
37{ 37{
38 return xchk_setup_inode_contents(sc, ip, 0); 38 return xchk_setup_inode_contents(sc, ip, 0);
39} 39}
@@ -44,7 +44,7 @@ xchk_setup_directory(
44 44
45struct xchk_dir_ctx { 45struct xchk_dir_ctx {
46 /* VFS fill-directory iterator */ 46 /* VFS fill-directory iterator */
47 struct dir_context dir_iter; 47 struct dir_context dir_iter;
48 48
49 struct xfs_scrub *sc; 49 struct xfs_scrub *sc;
50}; 50};
@@ -52,15 +52,15 @@ struct xchk_dir_ctx {
52/* Check that an inode's mode matches a given DT_ type. */ 52/* Check that an inode's mode matches a given DT_ type. */
53STATIC int 53STATIC int
54xchk_dir_check_ftype( 54xchk_dir_check_ftype(
55 struct xchk_dir_ctx *sdc, 55 struct xchk_dir_ctx *sdc,
56 xfs_fileoff_t offset, 56 xfs_fileoff_t offset,
57 xfs_ino_t inum, 57 xfs_ino_t inum,
58 int dtype) 58 int dtype)
59{ 59{
60 struct xfs_mount *mp = sdc->sc->mp; 60 struct xfs_mount *mp = sdc->sc->mp;
61 struct xfs_inode *ip; 61 struct xfs_inode *ip;
62 int ino_dtype; 62 int ino_dtype;
63 int error = 0; 63 int error = 0;
64 64
65 if (!xfs_sb_version_hasftype(&mp->m_sb)) { 65 if (!xfs_sb_version_hasftype(&mp->m_sb)) {
66 if (dtype != DT_UNKNOWN && dtype != DT_DIR) 66 if (dtype != DT_UNKNOWN && dtype != DT_DIR)
@@ -102,20 +102,20 @@ out:
102 */ 102 */
103STATIC int 103STATIC int
104xchk_dir_actor( 104xchk_dir_actor(
105 struct dir_context *dir_iter, 105 struct dir_context *dir_iter,
106 const char *name, 106 const char *name,
107 int namelen, 107 int namelen,
108 loff_t pos, 108 loff_t pos,
109 u64 ino, 109 u64 ino,
110 unsigned type) 110 unsigned type)
111{ 111{
112 struct xfs_mount *mp; 112 struct xfs_mount *mp;
113 struct xfs_inode *ip; 113 struct xfs_inode *ip;
114 struct xchk_dir_ctx *sdc; 114 struct xchk_dir_ctx *sdc;
115 struct xfs_name xname; 115 struct xfs_name xname;
116 xfs_ino_t lookup_ino; 116 xfs_ino_t lookup_ino;
117 xfs_dablk_t offset; 117 xfs_dablk_t offset;
118 int error = 0; 118 int error = 0;
119 119
120 sdc = container_of(dir_iter, struct xchk_dir_ctx, dir_iter); 120 sdc = container_of(dir_iter, struct xchk_dir_ctx, dir_iter);
121 ip = sdc->sc->ip; 121 ip = sdc->sc->ip;
@@ -289,7 +289,7 @@ out:
289 */ 289 */
290STATIC void 290STATIC void
291xchk_directory_check_free_entry( 291xchk_directory_check_free_entry(
292 struct xfs_scrub *sc, 292 struct xfs_scrub *sc,
293 xfs_dablk_t lblk, 293 xfs_dablk_t lblk,
294 struct xfs_dir2_data_free *bf, 294 struct xfs_dir2_data_free *bf,
295 struct xfs_dir2_data_unused *dup) 295 struct xfs_dir2_data_unused *dup)
@@ -314,7 +314,7 @@ xchk_directory_check_free_entry(
314/* Check free space info in a directory data block. */ 314/* Check free space info in a directory data block. */
315STATIC int 315STATIC int
316xchk_directory_data_bestfree( 316xchk_directory_data_bestfree(
317 struct xfs_scrub *sc, 317 struct xfs_scrub *sc,
318 xfs_dablk_t lblk, 318 xfs_dablk_t lblk,
319 bool is_block) 319 bool is_block)
320{ 320{
@@ -455,7 +455,7 @@ out:
455 */ 455 */
456STATIC void 456STATIC void
457xchk_directory_check_freesp( 457xchk_directory_check_freesp(
458 struct xfs_scrub *sc, 458 struct xfs_scrub *sc,
459 xfs_dablk_t lblk, 459 xfs_dablk_t lblk,
460 struct xfs_buf *dbp, 460 struct xfs_buf *dbp,
461 unsigned int len) 461 unsigned int len)
@@ -474,7 +474,7 @@ xchk_directory_check_freesp(
474/* Check free space info in a directory leaf1 block. */ 474/* Check free space info in a directory leaf1 block. */
475STATIC int 475STATIC int
476xchk_directory_leaf1_bestfree( 476xchk_directory_leaf1_bestfree(
477 struct xfs_scrub *sc, 477 struct xfs_scrub *sc,
478 struct xfs_da_args *args, 478 struct xfs_da_args *args,
479 xfs_dablk_t lblk) 479 xfs_dablk_t lblk)
480{ 480{
@@ -572,7 +572,7 @@ out:
572/* Check free space info in a directory freespace block. */ 572/* Check free space info in a directory freespace block. */
573STATIC int 573STATIC int
574xchk_directory_free_bestfree( 574xchk_directory_free_bestfree(
575 struct xfs_scrub *sc, 575 struct xfs_scrub *sc,
576 struct xfs_da_args *args, 576 struct xfs_da_args *args,
577 xfs_dablk_t lblk) 577 xfs_dablk_t lblk)
578{ 578{
@@ -628,18 +628,18 @@ STATIC int
628xchk_directory_blocks( 628xchk_directory_blocks(
629 struct xfs_scrub *sc) 629 struct xfs_scrub *sc)
630{ 630{
631 struct xfs_bmbt_irec got; 631 struct xfs_bmbt_irec got;
632 struct xfs_da_args args; 632 struct xfs_da_args args;
633 struct xfs_ifork *ifp; 633 struct xfs_ifork *ifp;
634 struct xfs_mount *mp = sc->mp; 634 struct xfs_mount *mp = sc->mp;
635 xfs_fileoff_t leaf_lblk; 635 xfs_fileoff_t leaf_lblk;
636 xfs_fileoff_t free_lblk; 636 xfs_fileoff_t free_lblk;
637 xfs_fileoff_t lblk; 637 xfs_fileoff_t lblk;
638 struct xfs_iext_cursor icur; 638 struct xfs_iext_cursor icur;
639 xfs_dablk_t dabno; 639 xfs_dablk_t dabno;
640 bool found; 640 bool found;
641 int is_block = 0; 641 int is_block = 0;
642 int error; 642 int error;
643 643
644 /* Ignore local format directories. */ 644 /* Ignore local format directories. */
645 if (sc->ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS && 645 if (sc->ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS &&
@@ -772,14 +772,14 @@ int
772xchk_directory( 772xchk_directory(
773 struct xfs_scrub *sc) 773 struct xfs_scrub *sc)
774{ 774{
775 struct xchk_dir_ctx sdc = { 775 struct xchk_dir_ctx sdc = {
776 .dir_iter.actor = xchk_dir_actor, 776 .dir_iter.actor = xchk_dir_actor,
777 .dir_iter.pos = 0, 777 .dir_iter.pos = 0,
778 .sc = sc, 778 .sc = sc,
779 }; 779 };
780 size_t bufsize; 780 size_t bufsize;
781 loff_t oldpos; 781 loff_t oldpos;
782 int error = 0; 782 int error = 0;
783 783
784 if (!S_ISDIR(VFS_I(sc->ip)->i_mode)) 784 if (!S_ISDIR(VFS_I(sc->ip)->i_mode))
785 return -ENOENT; 785 return -ENOENT;
diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
index 6df8eba9f52b..224dba937492 100644
--- a/fs/xfs/scrub/ialloc.c
+++ b/fs/xfs/scrub/ialloc.c
@@ -37,7 +37,7 @@
37int 37int
38xchk_setup_ag_iallocbt( 38xchk_setup_ag_iallocbt(
39 struct xfs_scrub *sc, 39 struct xfs_scrub *sc,
40 struct xfs_inode *ip) 40 struct xfs_inode *ip)
41{ 41{
42 return xchk_setup_ag_btree(sc, ip, sc->try_harder); 42 return xchk_setup_ag_btree(sc, ip, sc->try_harder);
43} 43}
@@ -51,7 +51,7 @@ xchk_setup_ag_iallocbt(
51 */ 51 */
52static inline void 52static inline void
53xchk_iallocbt_chunk_xref_other( 53xchk_iallocbt_chunk_xref_other(
54 struct xfs_scrub *sc, 54 struct xfs_scrub *sc,
55 struct xfs_inobt_rec_incore *irec, 55 struct xfs_inobt_rec_incore *irec,
56 xfs_agino_t agino) 56 xfs_agino_t agino)
57{ 57{
@@ -76,7 +76,7 @@ xchk_iallocbt_chunk_xref_other(
76/* Cross-reference with the other btrees. */ 76/* Cross-reference with the other btrees. */
77STATIC void 77STATIC void
78xchk_iallocbt_chunk_xref( 78xchk_iallocbt_chunk_xref(
79 struct xfs_scrub *sc, 79 struct xfs_scrub *sc,
80 struct xfs_inobt_rec_incore *irec, 80 struct xfs_inobt_rec_incore *irec,
81 xfs_agino_t agino, 81 xfs_agino_t agino,
82 xfs_agblock_t agbno, 82 xfs_agblock_t agbno,
@@ -364,13 +364,13 @@ out:
364STATIC void 364STATIC void
365xchk_iallocbt_xref_rmap_btreeblks( 365xchk_iallocbt_xref_rmap_btreeblks(
366 struct xfs_scrub *sc, 366 struct xfs_scrub *sc,
367 int which) 367 int which)
368{ 368{
369 struct xfs_owner_info oinfo; 369 struct xfs_owner_info oinfo;
370 xfs_filblks_t blocks; 370 xfs_filblks_t blocks;
371 xfs_extlen_t inobt_blocks = 0; 371 xfs_extlen_t inobt_blocks = 0;
372 xfs_extlen_t finobt_blocks = 0; 372 xfs_extlen_t finobt_blocks = 0;
373 int error; 373 int error;
374 374
375 if (!sc->sa.ino_cur || !sc->sa.rmap_cur || 375 if (!sc->sa.ino_cur || !sc->sa.rmap_cur ||
376 (xfs_sb_version_hasfinobt(&sc->mp->m_sb) && !sc->sa.fino_cur) || 376 (xfs_sb_version_hasfinobt(&sc->mp->m_sb) && !sc->sa.fino_cur) ||
@@ -404,12 +404,12 @@ xchk_iallocbt_xref_rmap_btreeblks(
404STATIC void 404STATIC void
405xchk_iallocbt_xref_rmap_inodes( 405xchk_iallocbt_xref_rmap_inodes(
406 struct xfs_scrub *sc, 406 struct xfs_scrub *sc,
407 int which, 407 int which,
408 xfs_filblks_t inode_blocks) 408 xfs_filblks_t inode_blocks)
409{ 409{
410 struct xfs_owner_info oinfo; 410 struct xfs_owner_info oinfo;
411 xfs_filblks_t blocks; 411 xfs_filblks_t blocks;
412 int error; 412 int error;
413 413
414 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) 414 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
415 return; 415 return;
@@ -428,12 +428,12 @@ xchk_iallocbt_xref_rmap_inodes(
428STATIC int 428STATIC int
429xchk_iallocbt( 429xchk_iallocbt(
430 struct xfs_scrub *sc, 430 struct xfs_scrub *sc,
431 xfs_btnum_t which) 431 xfs_btnum_t which)
432{ 432{
433 struct xfs_btree_cur *cur; 433 struct xfs_btree_cur *cur;
434 struct xfs_owner_info oinfo; 434 struct xfs_owner_info oinfo;
435 xfs_filblks_t inode_blocks = 0; 435 xfs_filblks_t inode_blocks = 0;
436 int error; 436 int error;
437 437
438 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT); 438 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT);
439 cur = which == XFS_BTNUM_INO ? sc->sa.ino_cur : sc->sa.fino_cur; 439 cur = which == XFS_BTNUM_INO ? sc->sa.ino_cur : sc->sa.fino_cur;
@@ -475,13 +475,13 @@ xchk_finobt(
475static inline void 475static inline void
476xchk_xref_inode_check( 476xchk_xref_inode_check(
477 struct xfs_scrub *sc, 477 struct xfs_scrub *sc,
478 xfs_agblock_t agbno, 478 xfs_agblock_t agbno,
479 xfs_extlen_t len, 479 xfs_extlen_t len,
480 struct xfs_btree_cur **icur, 480 struct xfs_btree_cur **icur,
481 bool should_have_inodes) 481 bool should_have_inodes)
482{ 482{
483 bool has_inodes; 483 bool has_inodes;
484 int error; 484 int error;
485 485
486 if (!(*icur) || xchk_skip_xref(sc->sm)) 486 if (!(*icur) || xchk_skip_xref(sc->sm))
487 return; 487 return;
@@ -497,8 +497,8 @@ xchk_xref_inode_check(
497void 497void
498xchk_xref_is_not_inode_chunk( 498xchk_xref_is_not_inode_chunk(
499 struct xfs_scrub *sc, 499 struct xfs_scrub *sc,
500 xfs_agblock_t agbno, 500 xfs_agblock_t agbno,
501 xfs_extlen_t len) 501 xfs_extlen_t len)
502{ 502{
503 xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, false); 503 xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, false);
504 xchk_xref_inode_check(sc, agbno, len, &sc->sa.fino_cur, false); 504 xchk_xref_inode_check(sc, agbno, len, &sc->sa.fino_cur, false);
@@ -508,8 +508,8 @@ xchk_xref_is_not_inode_chunk(
508void 508void
509xchk_xref_is_inode_chunk( 509xchk_xref_is_inode_chunk(
510 struct xfs_scrub *sc, 510 struct xfs_scrub *sc,
511 xfs_agblock_t agbno, 511 xfs_agblock_t agbno,
512 xfs_extlen_t len) 512 xfs_extlen_t len)
513{ 513{
514 xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, true); 514 xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, true);
515} 515}
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index 6cc027983c13..5b3b177c0fc9 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -39,9 +39,9 @@
39int 39int
40xchk_setup_inode( 40xchk_setup_inode(
41 struct xfs_scrub *sc, 41 struct xfs_scrub *sc,
42 struct xfs_inode *ip) 42 struct xfs_inode *ip)
43{ 43{
44 int error; 44 int error;
45 45
46 /* 46 /*
47 * Try to get the inode. If the verifiers fail, we try again 47 * Try to get the inode. If the verifiers fail, we try again
@@ -78,12 +78,12 @@ out:
78STATIC void 78STATIC void
79xchk_inode_extsize( 79xchk_inode_extsize(
80 struct xfs_scrub *sc, 80 struct xfs_scrub *sc,
81 struct xfs_dinode *dip, 81 struct xfs_dinode *dip,
82 xfs_ino_t ino, 82 xfs_ino_t ino,
83 uint16_t mode, 83 uint16_t mode,
84 uint16_t flags) 84 uint16_t flags)
85{ 85{
86 xfs_failaddr_t fa; 86 xfs_failaddr_t fa;
87 87
88 fa = xfs_inode_validate_extsize(sc->mp, be32_to_cpu(dip->di_extsize), 88 fa = xfs_inode_validate_extsize(sc->mp, be32_to_cpu(dip->di_extsize),
89 mode, flags); 89 mode, flags);
@@ -100,13 +100,13 @@ xchk_inode_extsize(
100STATIC void 100STATIC void
101xchk_inode_cowextsize( 101xchk_inode_cowextsize(
102 struct xfs_scrub *sc, 102 struct xfs_scrub *sc,
103 struct xfs_dinode *dip, 103 struct xfs_dinode *dip,
104 xfs_ino_t ino, 104 xfs_ino_t ino,
105 uint16_t mode, 105 uint16_t mode,
106 uint16_t flags, 106 uint16_t flags,
107 uint64_t flags2) 107 uint64_t flags2)
108{ 108{
109 xfs_failaddr_t fa; 109 xfs_failaddr_t fa;
110 110
111 fa = xfs_inode_validate_cowextsize(sc->mp, 111 fa = xfs_inode_validate_cowextsize(sc->mp,
112 be32_to_cpu(dip->di_cowextsize), mode, flags, 112 be32_to_cpu(dip->di_cowextsize), mode, flags,
@@ -119,12 +119,12 @@ xchk_inode_cowextsize(
119STATIC void 119STATIC void
120xchk_inode_flags( 120xchk_inode_flags(
121 struct xfs_scrub *sc, 121 struct xfs_scrub *sc,
122 struct xfs_dinode *dip, 122 struct xfs_dinode *dip,
123 xfs_ino_t ino, 123 xfs_ino_t ino,
124 uint16_t mode, 124 uint16_t mode,
125 uint16_t flags) 125 uint16_t flags)
126{ 126{
127 struct xfs_mount *mp = sc->mp; 127 struct xfs_mount *mp = sc->mp;
128 128
129 if (flags & ~XFS_DIFLAG_ANY) 129 if (flags & ~XFS_DIFLAG_ANY)
130 goto bad; 130 goto bad;
@@ -164,13 +164,13 @@ bad:
164STATIC void 164STATIC void
165xchk_inode_flags2( 165xchk_inode_flags2(
166 struct xfs_scrub *sc, 166 struct xfs_scrub *sc,
167 struct xfs_dinode *dip, 167 struct xfs_dinode *dip,
168 xfs_ino_t ino, 168 xfs_ino_t ino,
169 uint16_t mode, 169 uint16_t mode,
170 uint16_t flags, 170 uint16_t flags,
171 uint64_t flags2) 171 uint64_t flags2)
172{ 172{
173 struct xfs_mount *mp = sc->mp; 173 struct xfs_mount *mp = sc->mp;
174 174
175 if (flags2 & ~XFS_DIFLAG2_ANY) 175 if (flags2 & ~XFS_DIFLAG2_ANY)
176 goto bad; 176 goto bad;
@@ -207,16 +207,16 @@ bad:
207STATIC void 207STATIC void
208xchk_dinode( 208xchk_dinode(
209 struct xfs_scrub *sc, 209 struct xfs_scrub *sc,
210 struct xfs_dinode *dip, 210 struct xfs_dinode *dip,
211 xfs_ino_t ino) 211 xfs_ino_t ino)
212{ 212{
213 struct xfs_mount *mp = sc->mp; 213 struct xfs_mount *mp = sc->mp;
214 size_t fork_recs; 214 size_t fork_recs;
215 unsigned long long isize; 215 unsigned long long isize;
216 uint64_t flags2; 216 uint64_t flags2;
217 uint32_t nextents; 217 uint32_t nextents;
218 uint16_t flags; 218 uint16_t flags;
219 uint16_t mode; 219 uint16_t mode;
220 220
221 flags = be16_to_cpu(dip->di_flags); 221 flags = be16_to_cpu(dip->di_flags);
222 if (dip->di_version >= 3) 222 if (dip->di_version >= 3)
@@ -426,7 +426,7 @@ xchk_dinode(
426 */ 426 */
427static void 427static void
428xchk_inode_xref_finobt( 428xchk_inode_xref_finobt(
429 struct xfs_scrub *sc, 429 struct xfs_scrub *sc,
430 xfs_ino_t ino) 430 xfs_ino_t ino)
431{ 431{
432 struct xfs_inobt_rec_incore rec; 432 struct xfs_inobt_rec_incore rec;
@@ -470,12 +470,12 @@ xchk_inode_xref_finobt(
470STATIC void 470STATIC void
471xchk_inode_xref_bmap( 471xchk_inode_xref_bmap(
472 struct xfs_scrub *sc, 472 struct xfs_scrub *sc,
473 struct xfs_dinode *dip) 473 struct xfs_dinode *dip)
474{ 474{
475 xfs_extnum_t nextents; 475 xfs_extnum_t nextents;
476 xfs_filblks_t count; 476 xfs_filblks_t count;
477 xfs_filblks_t acount; 477 xfs_filblks_t acount;
478 int error; 478 int error;
479 479
480 if (xchk_skip_xref(sc->sm)) 480 if (xchk_skip_xref(sc->sm))
481 return; 481 return;
@@ -504,13 +504,13 @@ xchk_inode_xref_bmap(
504STATIC void 504STATIC void
505xchk_inode_xref( 505xchk_inode_xref(
506 struct xfs_scrub *sc, 506 struct xfs_scrub *sc,
507 xfs_ino_t ino, 507 xfs_ino_t ino,
508 struct xfs_dinode *dip) 508 struct xfs_dinode *dip)
509{ 509{
510 struct xfs_owner_info oinfo; 510 struct xfs_owner_info oinfo;
511 xfs_agnumber_t agno; 511 xfs_agnumber_t agno;
512 xfs_agblock_t agbno; 512 xfs_agblock_t agbno;
513 int error; 513 int error;
514 514
515 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 515 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
516 return; 516 return;
@@ -541,11 +541,11 @@ xchk_inode_xref(
541static void 541static void
542xchk_inode_check_reflink_iflag( 542xchk_inode_check_reflink_iflag(
543 struct xfs_scrub *sc, 543 struct xfs_scrub *sc,
544 xfs_ino_t ino) 544 xfs_ino_t ino)
545{ 545{
546 struct xfs_mount *mp = sc->mp; 546 struct xfs_mount *mp = sc->mp;
547 bool has_shared; 547 bool has_shared;
548 int error; 548 int error;
549 549
550 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 550 if (!xfs_sb_version_hasreflink(&mp->m_sb))
551 return; 551 return;
@@ -566,8 +566,8 @@ int
566xchk_inode( 566xchk_inode(
567 struct xfs_scrub *sc) 567 struct xfs_scrub *sc)
568{ 568{
569 struct xfs_dinode di; 569 struct xfs_dinode di;
570 int error = 0; 570 int error = 0;
571 571
572 /* 572 /*
573 * If sc->ip is NULL, that means that the setup function called 573 * If sc->ip is NULL, that means that the setup function called
diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c
index 808459ad0c35..aacb0284c48a 100644
--- a/fs/xfs/scrub/parent.c
+++ b/fs/xfs/scrub/parent.c
@@ -29,7 +29,7 @@
29int 29int
30xchk_setup_parent( 30xchk_setup_parent(
31 struct xfs_scrub *sc, 31 struct xfs_scrub *sc,
32 struct xfs_inode *ip) 32 struct xfs_inode *ip)
33{ 33{
34 return xchk_setup_inode_contents(sc, ip, 0); 34 return xchk_setup_inode_contents(sc, ip, 0);
35} 35}
@@ -39,22 +39,22 @@ xchk_setup_parent(
39/* Look for an entry in a parent pointing to this inode. */ 39/* Look for an entry in a parent pointing to this inode. */
40 40
41struct xchk_parent_ctx { 41struct xchk_parent_ctx {
42 struct dir_context dc; 42 struct dir_context dc;
43 xfs_ino_t ino; 43 xfs_ino_t ino;
44 xfs_nlink_t nlink; 44 xfs_nlink_t nlink;
45}; 45};
46 46
47/* Look for a single entry in a directory pointing to an inode. */ 47/* Look for a single entry in a directory pointing to an inode. */
48STATIC int 48STATIC int
49xchk_parent_actor( 49xchk_parent_actor(
50 struct dir_context *dc, 50 struct dir_context *dc,
51 const char *name, 51 const char *name,
52 int namelen, 52 int namelen,
53 loff_t pos, 53 loff_t pos,
54 u64 ino, 54 u64 ino,
55 unsigned type) 55 unsigned type)
56{ 56{
57 struct xchk_parent_ctx *spc; 57 struct xchk_parent_ctx *spc;
58 58
59 spc = container_of(dc, struct xchk_parent_ctx, dc); 59 spc = container_of(dc, struct xchk_parent_ctx, dc);
60 if (spc->ino == ino) 60 if (spc->ino == ino)
@@ -66,19 +66,19 @@ xchk_parent_actor(
66STATIC int 66STATIC int
67xchk_parent_count_parent_dentries( 67xchk_parent_count_parent_dentries(
68 struct xfs_scrub *sc, 68 struct xfs_scrub *sc,
69 struct xfs_inode *parent, 69 struct xfs_inode *parent,
70 xfs_nlink_t *nlink) 70 xfs_nlink_t *nlink)
71{ 71{
72 struct xchk_parent_ctx spc = { 72 struct xchk_parent_ctx spc = {
73 .dc.actor = xchk_parent_actor, 73 .dc.actor = xchk_parent_actor,
74 .dc.pos = 0, 74 .dc.pos = 0,
75 .ino = sc->ip->i_ino, 75 .ino = sc->ip->i_ino,
76 .nlink = 0, 76 .nlink = 0,
77 }; 77 };
78 size_t bufsize; 78 size_t bufsize;
79 loff_t oldpos; 79 loff_t oldpos;
80 uint lock_mode; 80 uint lock_mode;
81 int error = 0; 81 int error = 0;
82 82
83 /* 83 /*
84 * If there are any blocks, read-ahead block 0 as we're almost 84 * If there are any blocks, read-ahead block 0 as we're almost
@@ -122,14 +122,14 @@ out:
122STATIC int 122STATIC int
123xchk_parent_validate( 123xchk_parent_validate(
124 struct xfs_scrub *sc, 124 struct xfs_scrub *sc,
125 xfs_ino_t dnum, 125 xfs_ino_t dnum,
126 bool *try_again) 126 bool *try_again)
127{ 127{
128 struct xfs_mount *mp = sc->mp; 128 struct xfs_mount *mp = sc->mp;
129 struct xfs_inode *dp = NULL; 129 struct xfs_inode *dp = NULL;
130 xfs_nlink_t expected_nlink; 130 xfs_nlink_t expected_nlink;
131 xfs_nlink_t nlink; 131 xfs_nlink_t nlink;
132 int error = 0; 132 int error = 0;
133 133
134 *try_again = false; 134 *try_again = false;
135 135
@@ -257,11 +257,11 @@ int
257xchk_parent( 257xchk_parent(
258 struct xfs_scrub *sc) 258 struct xfs_scrub *sc)
259{ 259{
260 struct xfs_mount *mp = sc->mp; 260 struct xfs_mount *mp = sc->mp;
261 xfs_ino_t dnum; 261 xfs_ino_t dnum;
262 bool try_again; 262 bool try_again;
263 int tries = 0; 263 int tries = 0;
264 int error = 0; 264 int error = 0;
265 265
266 /* 266 /*
267 * If we're a directory, check that the '..' link points up to 267 * If we're a directory, check that the '..' link points up to
diff --git a/fs/xfs/scrub/quota.c b/fs/xfs/scrub/quota.c
index 309ebeecfa5d..782d582d3edd 100644
--- a/fs/xfs/scrub/quota.c
+++ b/fs/xfs/scrub/quota.c
@@ -49,10 +49,10 @@ xchk_quota_to_dqtype(
49int 49int
50xchk_setup_quota( 50xchk_setup_quota(
51 struct xfs_scrub *sc, 51 struct xfs_scrub *sc,
52 struct xfs_inode *ip) 52 struct xfs_inode *ip)
53{ 53{
54 uint dqtype; 54 uint dqtype;
55 int error; 55 int error;
56 56
57 if (!XFS_IS_QUOTA_RUNNING(sc->mp) || !XFS_IS_QUOTA_ON(sc->mp)) 57 if (!XFS_IS_QUOTA_RUNNING(sc->mp) || !XFS_IS_QUOTA_ON(sc->mp))
58 return -ENOENT; 58 return -ENOENT;
@@ -77,33 +77,33 @@ xchk_setup_quota(
77 77
78struct xchk_quota_info { 78struct xchk_quota_info {
79 struct xfs_scrub *sc; 79 struct xfs_scrub *sc;
80 xfs_dqid_t last_id; 80 xfs_dqid_t last_id;
81}; 81};
82 82
83/* Scrub the fields in an individual quota item. */ 83/* Scrub the fields in an individual quota item. */
84STATIC int 84STATIC int
85xchk_quota_item( 85xchk_quota_item(
86 struct xfs_dquot *dq, 86 struct xfs_dquot *dq,
87 uint dqtype, 87 uint dqtype,
88 void *priv) 88 void *priv)
89{ 89{
90 struct xchk_quota_info *sqi = priv; 90 struct xchk_quota_info *sqi = priv;
91 struct xfs_scrub *sc = sqi->sc; 91 struct xfs_scrub *sc = sqi->sc;
92 struct xfs_mount *mp = sc->mp; 92 struct xfs_mount *mp = sc->mp;
93 struct xfs_disk_dquot *d = &dq->q_core; 93 struct xfs_disk_dquot *d = &dq->q_core;
94 struct xfs_quotainfo *qi = mp->m_quotainfo; 94 struct xfs_quotainfo *qi = mp->m_quotainfo;
95 xfs_fileoff_t offset; 95 xfs_fileoff_t offset;
96 unsigned long long bsoft; 96 unsigned long long bsoft;
97 unsigned long long isoft; 97 unsigned long long isoft;
98 unsigned long long rsoft; 98 unsigned long long rsoft;
99 unsigned long long bhard; 99 unsigned long long bhard;
100 unsigned long long ihard; 100 unsigned long long ihard;
101 unsigned long long rhard; 101 unsigned long long rhard;
102 unsigned long long bcount; 102 unsigned long long bcount;
103 unsigned long long icount; 103 unsigned long long icount;
104 unsigned long long rcount; 104 unsigned long long rcount;
105 xfs_ino_t fs_icount; 105 xfs_ino_t fs_icount;
106 xfs_dqid_t id = be32_to_cpu(d->d_id); 106 xfs_dqid_t id = be32_to_cpu(d->d_id);
107 107
108 /* 108 /*
109 * Except for the root dquot, the actual dquot we got must either have 109 * Except for the root dquot, the actual dquot we got must either have
@@ -197,12 +197,12 @@ STATIC int
197xchk_quota_data_fork( 197xchk_quota_data_fork(
198 struct xfs_scrub *sc) 198 struct xfs_scrub *sc)
199{ 199{
200 struct xfs_bmbt_irec irec = { 0 }; 200 struct xfs_bmbt_irec irec = { 0 };
201 struct xfs_iext_cursor icur; 201 struct xfs_iext_cursor icur;
202 struct xfs_quotainfo *qi = sc->mp->m_quotainfo; 202 struct xfs_quotainfo *qi = sc->mp->m_quotainfo;
203 struct xfs_ifork *ifp; 203 struct xfs_ifork *ifp;
204 xfs_fileoff_t max_dqid_off; 204 xfs_fileoff_t max_dqid_off;
205 int error = 0; 205 int error = 0;
206 206
207 /* Invoke the fork scrubber. */ 207 /* Invoke the fork scrubber. */
208 error = xchk_metadata_inode_forks(sc); 208 error = xchk_metadata_inode_forks(sc);
@@ -236,11 +236,11 @@ int
236xchk_quota( 236xchk_quota(
237 struct xfs_scrub *sc) 237 struct xfs_scrub *sc)
238{ 238{
239 struct xchk_quota_info sqi; 239 struct xchk_quota_info sqi;
240 struct xfs_mount *mp = sc->mp; 240 struct xfs_mount *mp = sc->mp;
241 struct xfs_quotainfo *qi = mp->m_quotainfo; 241 struct xfs_quotainfo *qi = mp->m_quotainfo;
242 uint dqtype; 242 uint dqtype;
243 int error = 0; 243 int error = 0;
244 244
245 dqtype = xchk_quota_to_dqtype(sc); 245 dqtype = xchk_quota_to_dqtype(sc);
246 246
diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
index c1162d408987..e8c82b026083 100644
--- a/fs/xfs/scrub/refcount.c
+++ b/fs/xfs/scrub/refcount.c
@@ -30,7 +30,7 @@
30int 30int
31xchk_setup_ag_refcountbt( 31xchk_setup_ag_refcountbt(
32 struct xfs_scrub *sc, 32 struct xfs_scrub *sc,
33 struct xfs_inode *ip) 33 struct xfs_inode *ip)
34{ 34{
35 return xchk_setup_ag_btree(sc, ip, false); 35 return xchk_setup_ag_btree(sc, ip, false);
36} 36}
@@ -74,21 +74,21 @@ xchk_setup_ag_refcountbt(
74 * should always hold true. If not, the refcount is incorrect. 74 * should always hold true. If not, the refcount is incorrect.
75 */ 75 */
76struct xchk_refcnt_frag { 76struct xchk_refcnt_frag {
77 struct list_head list; 77 struct list_head list;
78 struct xfs_rmap_irec rm; 78 struct xfs_rmap_irec rm;
79}; 79};
80 80
81struct xchk_refcnt_check { 81struct xchk_refcnt_check {
82 struct xfs_scrub *sc; 82 struct xfs_scrub *sc;
83 struct list_head fragments; 83 struct list_head fragments;
84 84
85 /* refcount extent we're examining */ 85 /* refcount extent we're examining */
86 xfs_agblock_t bno; 86 xfs_agblock_t bno;
87 xfs_extlen_t len; 87 xfs_extlen_t len;
88 xfs_nlink_t refcount; 88 xfs_nlink_t refcount;
89 89
90 /* number of owners seen */ 90 /* number of owners seen */
91 xfs_nlink_t seen; 91 xfs_nlink_t seen;
92}; 92};
93 93
94/* 94/*
@@ -278,7 +278,7 @@ done:
278/* Use the rmap entries covering this extent to verify the refcount. */ 278/* Use the rmap entries covering this extent to verify the refcount. */
279STATIC void 279STATIC void
280xchk_refcountbt_xref_rmap( 280xchk_refcountbt_xref_rmap(
281 struct xfs_scrub *sc, 281 struct xfs_scrub *sc,
282 xfs_agblock_t bno, 282 xfs_agblock_t bno,
283 xfs_extlen_t len, 283 xfs_extlen_t len,
284 xfs_nlink_t refcount) 284 xfs_nlink_t refcount)
@@ -326,9 +326,9 @@ out_free:
326STATIC void 326STATIC void
327xchk_refcountbt_xref( 327xchk_refcountbt_xref(
328 struct xfs_scrub *sc, 328 struct xfs_scrub *sc,
329 xfs_agblock_t agbno, 329 xfs_agblock_t agbno,
330 xfs_extlen_t len, 330 xfs_extlen_t len,
331 xfs_nlink_t refcount) 331 xfs_nlink_t refcount)
332{ 332{
333 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 333 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
334 return; 334 return;
@@ -341,17 +341,17 @@ xchk_refcountbt_xref(
341/* Scrub a refcountbt record. */ 341/* Scrub a refcountbt record. */
342STATIC int 342STATIC int
343xchk_refcountbt_rec( 343xchk_refcountbt_rec(
344 struct xchk_btree *bs, 344 struct xchk_btree *bs,
345 union xfs_btree_rec *rec) 345 union xfs_btree_rec *rec)
346{ 346{
347 struct xfs_mount *mp = bs->cur->bc_mp; 347 struct xfs_mount *mp = bs->cur->bc_mp;
348 xfs_agblock_t *cow_blocks = bs->private; 348 xfs_agblock_t *cow_blocks = bs->private;
349 xfs_agnumber_t agno = bs->cur->bc_private.a.agno; 349 xfs_agnumber_t agno = bs->cur->bc_private.a.agno;
350 xfs_agblock_t bno; 350 xfs_agblock_t bno;
351 xfs_extlen_t len; 351 xfs_extlen_t len;
352 xfs_nlink_t refcount; 352 xfs_nlink_t refcount;
353 bool has_cowflag; 353 bool has_cowflag;
354 int error = 0; 354 int error = 0;
355 355
356 bno = be32_to_cpu(rec->refc.rc_startblock); 356 bno = be32_to_cpu(rec->refc.rc_startblock);
357 len = be32_to_cpu(rec->refc.rc_blockcount); 357 len = be32_to_cpu(rec->refc.rc_blockcount);
@@ -383,12 +383,12 @@ xchk_refcountbt_rec(
383STATIC void 383STATIC void
384xchk_refcount_xref_rmap( 384xchk_refcount_xref_rmap(
385 struct xfs_scrub *sc, 385 struct xfs_scrub *sc,
386 struct xfs_owner_info *oinfo, 386 struct xfs_owner_info *oinfo,
387 xfs_filblks_t cow_blocks) 387 xfs_filblks_t cow_blocks)
388{ 388{
389 xfs_extlen_t refcbt_blocks = 0; 389 xfs_extlen_t refcbt_blocks = 0;
390 xfs_filblks_t blocks; 390 xfs_filblks_t blocks;
391 int error; 391 int error;
392 392
393 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) 393 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
394 return; 394 return;
@@ -419,9 +419,9 @@ int
419xchk_refcountbt( 419xchk_refcountbt(
420 struct xfs_scrub *sc) 420 struct xfs_scrub *sc)
421{ 421{
422 struct xfs_owner_info oinfo; 422 struct xfs_owner_info oinfo;
423 xfs_agblock_t cow_blocks = 0; 423 xfs_agblock_t cow_blocks = 0;
424 int error; 424 int error;
425 425
426 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_REFC); 426 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_REFC);
427 error = xchk_btree(sc, sc->sa.refc_cur, xchk_refcountbt_rec, 427 error = xchk_btree(sc, sc->sa.refc_cur, xchk_refcountbt_rec,
@@ -437,7 +437,7 @@ xchk_refcountbt(
437/* xref check that a cow staging extent is marked in the refcountbt. */ 437/* xref check that a cow staging extent is marked in the refcountbt. */
438void 438void
439xchk_xref_is_cow_staging( 439xchk_xref_is_cow_staging(
440 struct xfs_scrub *sc, 440 struct xfs_scrub *sc,
441 xfs_agblock_t agbno, 441 xfs_agblock_t agbno,
442 xfs_extlen_t len) 442 xfs_extlen_t len)
443{ 443{
@@ -484,11 +484,11 @@ xchk_xref_is_cow_staging(
484void 484void
485xchk_xref_is_not_shared( 485xchk_xref_is_not_shared(
486 struct xfs_scrub *sc, 486 struct xfs_scrub *sc,
487 xfs_agblock_t agbno, 487 xfs_agblock_t agbno,
488 xfs_extlen_t len) 488 xfs_extlen_t len)
489{ 489{
490 bool shared; 490 bool shared;
491 int error; 491 int error;
492 492
493 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm)) 493 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm))
494 return; 494 return;
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 29debd5649ac..5de1cac424ec 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -42,11 +42,11 @@
42 */ 42 */
43int 43int
44xrep_attempt( 44xrep_attempt(
45 struct xfs_inode *ip, 45 struct xfs_inode *ip,
46 struct xfs_scrub *sc, 46 struct xfs_scrub *sc,
47 bool *fixed) 47 bool *fixed)
48{ 48{
49 int error = 0; 49 int error = 0;
50 50
51 trace_xrep_attempt(ip, sc->sm, error); 51 trace_xrep_attempt(ip, sc->sm, error);
52 52
@@ -94,7 +94,7 @@ xrep_attempt(
94 */ 94 */
95void 95void
96xrep_failure( 96xrep_failure(
97 struct xfs_mount *mp) 97 struct xfs_mount *mp)
98{ 98{
99 xfs_alert_ratelimited(mp, 99 xfs_alert_ratelimited(mp,
100"Corruption not fixed during online repair. Unmount and run xfs_repair."); 100"Corruption not fixed during online repair. Unmount and run xfs_repair.");
@@ -108,7 +108,7 @@ int
108xrep_probe( 108xrep_probe(
109 struct xfs_scrub *sc) 109 struct xfs_scrub *sc)
110{ 110{
111 int error = 0; 111 int error = 0;
112 112
113 if (xchk_should_terminate(sc, &error)) 113 if (xchk_should_terminate(sc, &error))
114 return error; 114 return error;
@@ -124,7 +124,7 @@ int
124xrep_roll_ag_trans( 124xrep_roll_ag_trans(
125 struct xfs_scrub *sc) 125 struct xfs_scrub *sc)
126{ 126{
127 int error; 127 int error;
128 128
129 /* Keep the AG header buffers locked so we can keep going. */ 129 /* Keep the AG header buffers locked so we can keep going. */
130 xfs_trans_bhold(sc->tp, sc->sa.agi_bp); 130 xfs_trans_bhold(sc->tp, sc->sa.agi_bp);
@@ -163,9 +163,9 @@ out_release:
163 */ 163 */
164bool 164bool
165xrep_ag_has_space( 165xrep_ag_has_space(
166 struct xfs_perag *pag, 166 struct xfs_perag *pag,
167 xfs_extlen_t nr_blocks, 167 xfs_extlen_t nr_blocks,
168 enum xfs_ag_resv_type type) 168 enum xfs_ag_resv_type type)
169{ 169{
170 return !xfs_ag_resv_critical(pag, XFS_AG_RESV_RMAPBT) && 170 return !xfs_ag_resv_critical(pag, XFS_AG_RESV_RMAPBT) &&
171 !xfs_ag_resv_critical(pag, XFS_AG_RESV_METADATA) && 171 !xfs_ag_resv_critical(pag, XFS_AG_RESV_METADATA) &&
@@ -179,7 +179,7 @@ xrep_ag_has_space(
179 */ 179 */
180xfs_extlen_t 180xfs_extlen_t
181xrep_calc_ag_resblks( 181xrep_calc_ag_resblks(
182 struct xfs_scrub *sc) 182 struct xfs_scrub *sc)
183{ 183{
184 struct xfs_mount *mp = sc->mp; 184 struct xfs_mount *mp = sc->mp;
185 struct xfs_scrub_metadata *sm = sc->sm; 185 struct xfs_scrub_metadata *sm = sc->sm;
@@ -280,13 +280,13 @@ xrep_calc_ag_resblks(
280int 280int
281xrep_alloc_ag_block( 281xrep_alloc_ag_block(
282 struct xfs_scrub *sc, 282 struct xfs_scrub *sc,
283 struct xfs_owner_info *oinfo, 283 struct xfs_owner_info *oinfo,
284 xfs_fsblock_t *fsbno, 284 xfs_fsblock_t *fsbno,
285 enum xfs_ag_resv_type resv) 285 enum xfs_ag_resv_type resv)
286{ 286{
287 struct xfs_alloc_arg args = {0}; 287 struct xfs_alloc_arg args = {0};
288 xfs_agblock_t bno; 288 xfs_agblock_t bno;
289 int error; 289 int error;
290 290
291 switch (resv) { 291 switch (resv) {
292 case XFS_AG_RESV_AGFL: 292 case XFS_AG_RESV_AGFL:
@@ -330,7 +330,7 @@ xrep_alloc_ag_block(
330/* Initialize a new AG btree root block with zero entries. */ 330/* Initialize a new AG btree root block with zero entries. */
331int 331int
332xrep_init_btblock( 332xrep_init_btblock(
333 struct xfs_scrub *sc, 333 struct xfs_scrub *sc,
334 xfs_fsblock_t fsb, 334 xfs_fsblock_t fsb,
335 struct xfs_buf **bpp, 335 struct xfs_buf **bpp,
336 xfs_btnum_t btnum, 336 xfs_btnum_t btnum,
@@ -386,11 +386,11 @@ xrep_init_btblock(
386int 386int
387xrep_collect_btree_extent( 387xrep_collect_btree_extent(
388 struct xfs_scrub *sc, 388 struct xfs_scrub *sc,
389 struct xrep_extent_list *exlist, 389 struct xrep_extent_list *exlist,
390 xfs_fsblock_t fsbno, 390 xfs_fsblock_t fsbno,
391 xfs_extlen_t len) 391 xfs_extlen_t len)
392{ 392{
393 struct xrep_extent *rex; 393 struct xrep_extent *rex;
394 394
395 trace_xrep_collect_btree_extent(sc->mp, 395 trace_xrep_collect_btree_extent(sc->mp,
396 XFS_FSB_TO_AGNO(sc->mp, fsbno), 396 XFS_FSB_TO_AGNO(sc->mp, fsbno),
@@ -416,10 +416,10 @@ xrep_collect_btree_extent(
416void 416void
417xrep_cancel_btree_extents( 417xrep_cancel_btree_extents(
418 struct xfs_scrub *sc, 418 struct xfs_scrub *sc,
419 struct xrep_extent_list *exlist) 419 struct xrep_extent_list *exlist)
420{ 420{
421 struct xrep_extent *rex; 421 struct xrep_extent *rex;
422 struct xrep_extent *n; 422 struct xrep_extent *n;
423 423
424 for_each_xrep_extent_safe(rex, n, exlist) { 424 for_each_xrep_extent_safe(rex, n, exlist) {
425 list_del(&rex->list); 425 list_del(&rex->list);
@@ -430,12 +430,12 @@ xrep_cancel_btree_extents(
430/* Compare two btree extents. */ 430/* Compare two btree extents. */
431static int 431static int
432xrep_btree_extent_cmp( 432xrep_btree_extent_cmp(
433 void *priv, 433 void *priv,
434 struct list_head *a, 434 struct list_head *a,
435 struct list_head *b) 435 struct list_head *b)
436{ 436{
437 struct xrep_extent *ap; 437 struct xrep_extent *ap;
438 struct xrep_extent *bp; 438 struct xrep_extent *bp;
439 439
440 ap = container_of(a, struct xrep_extent, list); 440 ap = container_of(a, struct xrep_extent, list);
441 bp = container_of(b, struct xrep_extent, list); 441 bp = container_of(b, struct xrep_extent, list);
@@ -464,17 +464,17 @@ xrep_btree_extent_cmp(
464int 464int
465xrep_subtract_extents( 465xrep_subtract_extents(
466 struct xfs_scrub *sc, 466 struct xfs_scrub *sc,
467 struct xrep_extent_list *exlist, 467 struct xrep_extent_list *exlist,
468 struct xrep_extent_list *sublist) 468 struct xrep_extent_list *sublist)
469{ 469{
470 struct list_head *lp; 470 struct list_head *lp;
471 struct xrep_extent *ex; 471 struct xrep_extent *ex;
472 struct xrep_extent *newex; 472 struct xrep_extent *newex;
473 struct xrep_extent *subex; 473 struct xrep_extent *subex;
474 xfs_fsblock_t sub_fsb; 474 xfs_fsblock_t sub_fsb;
475 xfs_extlen_t sub_len; 475 xfs_extlen_t sub_len;
476 int state; 476 int state;
477 int error = 0; 477 int error = 0;
478 478
479 if (list_empty(&exlist->list) || list_empty(&sublist->list)) 479 if (list_empty(&exlist->list) || list_empty(&sublist->list))
480 return 0; 480 return 0;
@@ -621,13 +621,13 @@ out:
621int 621int
622xrep_invalidate_blocks( 622xrep_invalidate_blocks(
623 struct xfs_scrub *sc, 623 struct xfs_scrub *sc,
624 struct xrep_extent_list *exlist) 624 struct xrep_extent_list *exlist)
625{ 625{
626 struct xrep_extent *rex; 626 struct xrep_extent *rex;
627 struct xrep_extent *n; 627 struct xrep_extent *n;
628 struct xfs_buf *bp; 628 struct xfs_buf *bp;
629 xfs_fsblock_t fsbno; 629 xfs_fsblock_t fsbno;
630 xfs_agblock_t i; 630 xfs_agblock_t i;
631 631
632 /* 632 /*
633 * For each block in each extent, see if there's an incore buffer for 633 * For each block in each extent, see if there's an incore buffer for
@@ -659,9 +659,9 @@ xrep_invalidate_blocks(
659int 659int
660xrep_fix_freelist( 660xrep_fix_freelist(
661 struct xfs_scrub *sc, 661 struct xfs_scrub *sc,
662 bool can_shrink) 662 bool can_shrink)
663{ 663{
664 struct xfs_alloc_arg args = {0}; 664 struct xfs_alloc_arg args = {0};
665 665
666 args.mp = sc->mp; 666 args.mp = sc->mp;
667 args.tp = sc->tp; 667 args.tp = sc->tp;
@@ -679,10 +679,10 @@ xrep_fix_freelist(
679STATIC int 679STATIC int
680xrep_put_freelist( 680xrep_put_freelist(
681 struct xfs_scrub *sc, 681 struct xfs_scrub *sc,
682 xfs_agblock_t agbno) 682 xfs_agblock_t agbno)
683{ 683{
684 struct xfs_owner_info oinfo; 684 struct xfs_owner_info oinfo;
685 int error; 685 int error;
686 686
687 /* Make sure there's space on the freelist. */ 687 /* Make sure there's space on the freelist. */
688 error = xrep_fix_freelist(sc, true); 688 error = xrep_fix_freelist(sc, true);
@@ -715,16 +715,16 @@ xrep_put_freelist(
715STATIC int 715STATIC int
716xrep_dispose_btree_block( 716xrep_dispose_btree_block(
717 struct xfs_scrub *sc, 717 struct xfs_scrub *sc,
718 xfs_fsblock_t fsbno, 718 xfs_fsblock_t fsbno,
719 struct xfs_owner_info *oinfo, 719 struct xfs_owner_info *oinfo,
720 enum xfs_ag_resv_type resv) 720 enum xfs_ag_resv_type resv)
721{ 721{
722 struct xfs_btree_cur *cur; 722 struct xfs_btree_cur *cur;
723 struct xfs_buf *agf_bp = NULL; 723 struct xfs_buf *agf_bp = NULL;
724 xfs_agnumber_t agno; 724 xfs_agnumber_t agno;
725 xfs_agblock_t agbno; 725 xfs_agblock_t agbno;
726 bool has_other_rmap; 726 bool has_other_rmap;
727 int error; 727 int error;
728 728
729 agno = XFS_FSB_TO_AGNO(sc->mp, fsbno); 729 agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
730 agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno); 730 agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
@@ -789,13 +789,13 @@ out_free:
789int 789int
790xrep_reap_btree_extents( 790xrep_reap_btree_extents(
791 struct xfs_scrub *sc, 791 struct xfs_scrub *sc,
792 struct xrep_extent_list *exlist, 792 struct xrep_extent_list *exlist,
793 struct xfs_owner_info *oinfo, 793 struct xfs_owner_info *oinfo,
794 enum xfs_ag_resv_type type) 794 enum xfs_ag_resv_type type)
795{ 795{
796 struct xrep_extent *rex; 796 struct xrep_extent *rex;
797 struct xrep_extent *n; 797 struct xrep_extent *n;
798 int error = 0; 798 int error = 0;
799 799
800 ASSERT(xfs_sb_version_hasrmapbt(&sc->mp->m_sb)); 800 ASSERT(xfs_sb_version_hasrmapbt(&sc->mp->m_sb));
801 801
@@ -851,7 +851,7 @@ out:
851 */ 851 */
852 852
853struct xrep_findroot { 853struct xrep_findroot {
854 struct xfs_scrub *sc; 854 struct xfs_scrub *sc;
855 struct xfs_buf *agfl_bp; 855 struct xfs_buf *agfl_bp;
856 struct xfs_agf *agf; 856 struct xfs_agf *agf;
857 struct xrep_find_ag_btree *btree_info; 857 struct xrep_find_ag_btree *btree_info;
@@ -860,11 +860,11 @@ struct xrep_findroot {
860/* See if our block is in the AGFL. */ 860/* See if our block is in the AGFL. */
861STATIC int 861STATIC int
862xrep_findroot_agfl_walk( 862xrep_findroot_agfl_walk(
863 struct xfs_mount *mp, 863 struct xfs_mount *mp,
864 xfs_agblock_t bno, 864 xfs_agblock_t bno,
865 void *priv) 865 void *priv)
866{ 866{
867 xfs_agblock_t *agbno = priv; 867 xfs_agblock_t *agbno = priv;
868 868
869 return (*agbno == bno) ? XFS_BTREE_QUERY_RANGE_ABORT : 0; 869 return (*agbno == bno) ? XFS_BTREE_QUERY_RANGE_ABORT : 0;
870} 870}
@@ -981,7 +981,7 @@ xrep_findroot_rmap(
981/* Find the roots of the per-AG btrees described in btree_info. */ 981/* Find the roots of the per-AG btrees described in btree_info. */
982int 982int
983xrep_find_ag_btree_roots( 983xrep_find_ag_btree_roots(
984 struct xfs_scrub *sc, 984 struct xfs_scrub *sc,
985 struct xfs_buf *agf_bp, 985 struct xfs_buf *agf_bp,
986 struct xrep_find_ag_btree *btree_info, 986 struct xrep_find_ag_btree *btree_info,
987 struct xfs_buf *agfl_bp) 987 struct xfs_buf *agfl_bp)
@@ -1017,9 +1017,9 @@ xrep_find_ag_btree_roots(
1017void 1017void
1018xrep_force_quotacheck( 1018xrep_force_quotacheck(
1019 struct xfs_scrub *sc, 1019 struct xfs_scrub *sc,
1020 uint dqtype) 1020 uint dqtype)
1021{ 1021{
1022 uint flag; 1022 uint flag;
1023 1023
1024 flag = xfs_quota_chkd_flag(dqtype); 1024 flag = xfs_quota_chkd_flag(dqtype);
1025 if (!(flag & sc->mp->m_qflags)) 1025 if (!(flag & sc->mp->m_qflags))
@@ -1046,7 +1046,7 @@ int
1046xrep_ino_dqattach( 1046xrep_ino_dqattach(
1047 struct xfs_scrub *sc) 1047 struct xfs_scrub *sc)
1048{ 1048{
1049 int error; 1049 int error;
1050 1050
1051 error = xfs_qm_dqattach_locked(sc->ip, false); 1051 error = xfs_qm_dqattach_locked(sc->ip, false);
1052 switch (error) { 1052 switch (error) {
diff --git a/fs/xfs/scrub/repair.h b/fs/xfs/scrub/repair.h
index 677f4b73b5ec..91355f6b0087 100644
--- a/fs/xfs/scrub/repair.h
+++ b/fs/xfs/scrub/repair.h
@@ -15,33 +15,31 @@ static inline int xrep_notsupported(struct xfs_scrub *sc)
15 15
16/* Repair helpers */ 16/* Repair helpers */
17 17
18int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, 18int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, bool *fixed);
19 bool *fixed);
20void xrep_failure(struct xfs_mount *mp); 19void xrep_failure(struct xfs_mount *mp);
21int xrep_roll_ag_trans(struct xfs_scrub *sc); 20int xrep_roll_ag_trans(struct xfs_scrub *sc);
22bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks, 21bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
23 enum xfs_ag_resv_type type); 22 enum xfs_ag_resv_type type);
24xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc); 23xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
25int xrep_alloc_ag_block(struct xfs_scrub *sc, 24int xrep_alloc_ag_block(struct xfs_scrub *sc, struct xfs_owner_info *oinfo,
26 struct xfs_owner_info *oinfo, xfs_fsblock_t *fsbno, 25 xfs_fsblock_t *fsbno, enum xfs_ag_resv_type resv);
27 enum xfs_ag_resv_type resv);
28int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb, 26int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
29 struct xfs_buf **bpp, xfs_btnum_t btnum, 27 struct xfs_buf **bpp, xfs_btnum_t btnum,
30 const struct xfs_buf_ops *ops); 28 const struct xfs_buf_ops *ops);
31 29
32struct xrep_extent { 30struct xrep_extent {
33 struct list_head list; 31 struct list_head list;
34 xfs_fsblock_t fsbno; 32 xfs_fsblock_t fsbno;
35 xfs_extlen_t len; 33 xfs_extlen_t len;
36}; 34};
37 35
38struct xrep_extent_list { 36struct xrep_extent_list {
39 struct list_head list; 37 struct list_head list;
40}; 38};
41 39
42static inline void 40static inline void
43xrep_init_extent_list( 41xrep_init_extent_list(
44 struct xrep_extent_list *exlist) 42 struct xrep_extent_list *exlist)
45{ 43{
46 INIT_LIST_HEAD(&exlist->list); 44 INIT_LIST_HEAD(&exlist->list);
47} 45}
@@ -78,10 +76,8 @@ struct xrep_find_ag_btree {
78 unsigned int height; 76 unsigned int height;
79}; 77};
80 78
81int xrep_find_ag_btree_roots(struct xfs_scrub *sc, 79int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
82 struct xfs_buf *agf_bp, 80 struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
83 struct xrep_find_ag_btree *btree_info,
84 struct xfs_buf *agfl_bp);
85void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype); 81void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype);
86int xrep_ino_dqattach(struct xfs_scrub *sc); 82int xrep_ino_dqattach(struct xfs_scrub *sc);
87 83
@@ -93,9 +89,9 @@ int xrep_superblock(struct xfs_scrub *sc);
93#else 89#else
94 90
95static inline int xrep_attempt( 91static inline int xrep_attempt(
96 struct xfs_inode *ip, 92 struct xfs_inode *ip,
97 struct xfs_scrub *sc, 93 struct xfs_scrub *sc,
98 bool *fixed) 94 bool *fixed)
99{ 95{
100 return -EOPNOTSUPP; 96 return -EOPNOTSUPP;
101} 97}
diff --git a/fs/xfs/scrub/rmap.c b/fs/xfs/scrub/rmap.c
index dc9c91a706ff..5e293c129813 100644
--- a/fs/xfs/scrub/rmap.c
+++ b/fs/xfs/scrub/rmap.c
@@ -31,7 +31,7 @@
31int 31int
32xchk_setup_ag_rmapbt( 32xchk_setup_ag_rmapbt(
33 struct xfs_scrub *sc, 33 struct xfs_scrub *sc,
34 struct xfs_inode *ip) 34 struct xfs_inode *ip)
35{ 35{
36 return xchk_setup_ag_btree(sc, ip, false); 36 return xchk_setup_ag_btree(sc, ip, false);
37} 37}
@@ -42,15 +42,15 @@ xchk_setup_ag_rmapbt(
42STATIC void 42STATIC void
43xchk_rmapbt_xref_refc( 43xchk_rmapbt_xref_refc(
44 struct xfs_scrub *sc, 44 struct xfs_scrub *sc,
45 struct xfs_rmap_irec *irec) 45 struct xfs_rmap_irec *irec)
46{ 46{
47 xfs_agblock_t fbno; 47 xfs_agblock_t fbno;
48 xfs_extlen_t flen; 48 xfs_extlen_t flen;
49 bool non_inode; 49 bool non_inode;
50 bool is_bmbt; 50 bool is_bmbt;
51 bool is_attr; 51 bool is_attr;
52 bool is_unwritten; 52 bool is_unwritten;
53 int error; 53 int error;
54 54
55 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm)) 55 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm))
56 return; 56 return;
@@ -73,10 +73,10 @@ xchk_rmapbt_xref_refc(
73STATIC void 73STATIC void
74xchk_rmapbt_xref( 74xchk_rmapbt_xref(
75 struct xfs_scrub *sc, 75 struct xfs_scrub *sc,
76 struct xfs_rmap_irec *irec) 76 struct xfs_rmap_irec *irec)
77{ 77{
78 xfs_agblock_t agbno = irec->rm_startblock; 78 xfs_agblock_t agbno = irec->rm_startblock;
79 xfs_extlen_t len = irec->rm_blockcount; 79 xfs_extlen_t len = irec->rm_blockcount;
80 80
81 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 81 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
82 return; 82 return;
@@ -96,17 +96,17 @@ xchk_rmapbt_xref(
96/* Scrub an rmapbt record. */ 96/* Scrub an rmapbt record. */
97STATIC int 97STATIC int
98xchk_rmapbt_rec( 98xchk_rmapbt_rec(
99 struct xchk_btree *bs, 99 struct xchk_btree *bs,
100 union xfs_btree_rec *rec) 100 union xfs_btree_rec *rec)
101{ 101{
102 struct xfs_mount *mp = bs->cur->bc_mp; 102 struct xfs_mount *mp = bs->cur->bc_mp;
103 struct xfs_rmap_irec irec; 103 struct xfs_rmap_irec irec;
104 xfs_agnumber_t agno = bs->cur->bc_private.a.agno; 104 xfs_agnumber_t agno = bs->cur->bc_private.a.agno;
105 bool non_inode; 105 bool non_inode;
106 bool is_unwritten; 106 bool is_unwritten;
107 bool is_bmbt; 107 bool is_bmbt;
108 bool is_attr; 108 bool is_attr;
109 int error; 109 int error;
110 110
111 error = xfs_rmap_btrec_to_irec(rec, &irec); 111 error = xfs_rmap_btrec_to_irec(rec, &irec);
112 if (!xchk_btree_process_error(bs->sc, bs->cur, 0, &error)) 112 if (!xchk_btree_process_error(bs->sc, bs->cur, 0, &error))
@@ -174,7 +174,7 @@ int
174xchk_rmapbt( 174xchk_rmapbt(
175 struct xfs_scrub *sc) 175 struct xfs_scrub *sc)
176{ 176{
177 struct xfs_owner_info oinfo; 177 struct xfs_owner_info oinfo;
178 178
179 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG); 179 xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
180 return xchk_btree(sc, sc->sa.rmap_cur, xchk_rmapbt_rec, 180 return xchk_btree(sc, sc->sa.rmap_cur, xchk_rmapbt_rec,
@@ -185,13 +185,13 @@ xchk_rmapbt(
185static inline void 185static inline void
186xchk_xref_check_owner( 186xchk_xref_check_owner(
187 struct xfs_scrub *sc, 187 struct xfs_scrub *sc,
188 xfs_agblock_t bno, 188 xfs_agblock_t bno,
189 xfs_extlen_t len, 189 xfs_extlen_t len,
190 struct xfs_owner_info *oinfo, 190 struct xfs_owner_info *oinfo,
191 bool should_have_rmap) 191 bool should_have_rmap)
192{ 192{
193 bool has_rmap; 193 bool has_rmap;
194 int error; 194 int error;
195 195
196 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) 196 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
197 return; 197 return;
@@ -208,9 +208,9 @@ xchk_xref_check_owner(
208void 208void
209xchk_xref_is_owned_by( 209xchk_xref_is_owned_by(
210 struct xfs_scrub *sc, 210 struct xfs_scrub *sc,
211 xfs_agblock_t bno, 211 xfs_agblock_t bno,
212 xfs_extlen_t len, 212 xfs_extlen_t len,
213 struct xfs_owner_info *oinfo) 213 struct xfs_owner_info *oinfo)
214{ 214{
215 xchk_xref_check_owner(sc, bno, len, oinfo, true); 215 xchk_xref_check_owner(sc, bno, len, oinfo, true);
216} 216}
@@ -219,9 +219,9 @@ xchk_xref_is_owned_by(
219void 219void
220xchk_xref_is_not_owned_by( 220xchk_xref_is_not_owned_by(
221 struct xfs_scrub *sc, 221 struct xfs_scrub *sc,
222 xfs_agblock_t bno, 222 xfs_agblock_t bno,
223 xfs_extlen_t len, 223 xfs_extlen_t len,
224 struct xfs_owner_info *oinfo) 224 struct xfs_owner_info *oinfo)
225{ 225{
226 xchk_xref_check_owner(sc, bno, len, oinfo, false); 226 xchk_xref_check_owner(sc, bno, len, oinfo, false);
227} 227}
@@ -230,11 +230,11 @@ xchk_xref_is_not_owned_by(
230void 230void
231xchk_xref_has_no_owner( 231xchk_xref_has_no_owner(
232 struct xfs_scrub *sc, 232 struct xfs_scrub *sc,
233 xfs_agblock_t bno, 233 xfs_agblock_t bno,
234 xfs_extlen_t len) 234 xfs_extlen_t len)
235{ 235{
236 bool has_rmap; 236 bool has_rmap;
237 int error; 237 int error;
238 238
239 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) 239 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
240 return; 240 return;
diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c
index 653a809bba34..665d4bbb17cc 100644
--- a/fs/xfs/scrub/rtbitmap.c
+++ b/fs/xfs/scrub/rtbitmap.c
@@ -27,9 +27,9 @@
27int 27int
28xchk_setup_rt( 28xchk_setup_rt(
29 struct xfs_scrub *sc, 29 struct xfs_scrub *sc,
30 struct xfs_inode *ip) 30 struct xfs_inode *ip)
31{ 31{
32 int error; 32 int error;
33 33
34 error = xchk_setup_fs(sc, ip); 34 error = xchk_setup_fs(sc, ip);
35 if (error) 35 if (error)
@@ -47,13 +47,13 @@ xchk_setup_rt(
47/* Scrub a free extent record from the realtime bitmap. */ 47/* Scrub a free extent record from the realtime bitmap. */
48STATIC int 48STATIC int
49xchk_rtbitmap_rec( 49xchk_rtbitmap_rec(
50 struct xfs_trans *tp, 50 struct xfs_trans *tp,
51 struct xfs_rtalloc_rec *rec, 51 struct xfs_rtalloc_rec *rec,
52 void *priv) 52 void *priv)
53{ 53{
54 struct xfs_scrub *sc = priv; 54 struct xfs_scrub *sc = priv;
55 xfs_rtblock_t startblock; 55 xfs_rtblock_t startblock;
56 xfs_rtblock_t blockcount; 56 xfs_rtblock_t blockcount;
57 57
58 startblock = rec->ar_startext * tp->t_mountp->m_sb.sb_rextsize; 58 startblock = rec->ar_startext * tp->t_mountp->m_sb.sb_rextsize;
59 blockcount = rec->ar_extcount * tp->t_mountp->m_sb.sb_rextsize; 59 blockcount = rec->ar_extcount * tp->t_mountp->m_sb.sb_rextsize;
@@ -70,7 +70,7 @@ int
70xchk_rtbitmap( 70xchk_rtbitmap(
71 struct xfs_scrub *sc) 71 struct xfs_scrub *sc)
72{ 72{
73 int error; 73 int error;
74 74
75 /* Invoke the fork scrubber. */ 75 /* Invoke the fork scrubber. */
76 error = xchk_metadata_inode_forks(sc); 76 error = xchk_metadata_inode_forks(sc);
@@ -90,10 +90,10 @@ int
90xchk_rtsummary( 90xchk_rtsummary(
91 struct xfs_scrub *sc) 91 struct xfs_scrub *sc)
92{ 92{
93 struct xfs_inode *rsumip = sc->mp->m_rsumip; 93 struct xfs_inode *rsumip = sc->mp->m_rsumip;
94 struct xfs_inode *old_ip = sc->ip; 94 struct xfs_inode *old_ip = sc->ip;
95 uint old_ilock_flags = sc->ilock_flags; 95 uint old_ilock_flags = sc->ilock_flags;
96 int error = 0; 96 int error = 0;
97 97
98 /* 98 /*
99 * We ILOCK'd the rt bitmap ip in the setup routine, now lock the 99 * We ILOCK'd the rt bitmap ip in the setup routine, now lock the
@@ -126,14 +126,14 @@ out:
126void 126void
127xchk_xref_is_used_rt_space( 127xchk_xref_is_used_rt_space(
128 struct xfs_scrub *sc, 128 struct xfs_scrub *sc,
129 xfs_rtblock_t fsbno, 129 xfs_rtblock_t fsbno,
130 xfs_extlen_t len) 130 xfs_extlen_t len)
131{ 131{
132 xfs_rtblock_t startext; 132 xfs_rtblock_t startext;
133 xfs_rtblock_t endext; 133 xfs_rtblock_t endext;
134 xfs_rtblock_t extcount; 134 xfs_rtblock_t extcount;
135 bool is_free; 135 bool is_free;
136 int error; 136 int error;
137 137
138 if (xchk_skip_xref(sc->sm)) 138 if (xchk_skip_xref(sc->sm))
139 return; 139 return;
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index b3c6420ccae5..5956b8073e2f 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -153,7 +153,7 @@ static int
153xchk_probe( 153xchk_probe(
154 struct xfs_scrub *sc) 154 struct xfs_scrub *sc)
155{ 155{
156 int error = 0; 156 int error = 0;
157 157
158 if (xchk_should_terminate(sc, &error)) 158 if (xchk_should_terminate(sc, &error))
159 return error; 159 return error;
@@ -167,8 +167,8 @@ xchk_probe(
167STATIC int 167STATIC int
168xchk_teardown( 168xchk_teardown(
169 struct xfs_scrub *sc, 169 struct xfs_scrub *sc,
170 struct xfs_inode *ip_in, 170 struct xfs_inode *ip_in,
171 int error) 171 int error)
172{ 172{
173 xchk_ag_free(sc, &sc->sa); 173 xchk_ag_free(sc, &sc->sa);
174 if (sc->tp) { 174 if (sc->tp) {
@@ -479,7 +479,7 @@ xfs_scrub_metadata(
479 struct xfs_inode *ip, 479 struct xfs_inode *ip,
480 struct xfs_scrub_metadata *sm) 480 struct xfs_scrub_metadata *sm)
481{ 481{
482 struct xfs_scrub sc; 482 struct xfs_scrub sc;
483 struct xfs_mount *mp = ip->i_mount; 483 struct xfs_mount *mp = ip->i_mount;
484 bool try_harder = false; 484 bool try_harder = false;
485 bool already_fixed = false; 485 bool already_fixed = false;
diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h
index 47c75d2f28da..af323b229c4b 100644
--- a/fs/xfs/scrub/scrub.h
+++ b/fs/xfs/scrub/scrub.h
@@ -36,21 +36,21 @@ struct xchk_meta_ops {
36 36
37/* Buffer pointers and btree cursors for an entire AG. */ 37/* Buffer pointers and btree cursors for an entire AG. */
38struct xchk_ag { 38struct xchk_ag {
39 xfs_agnumber_t agno; 39 xfs_agnumber_t agno;
40 struct xfs_perag *pag; 40 struct xfs_perag *pag;
41 41
42 /* AG btree roots */ 42 /* AG btree roots */
43 struct xfs_buf *agf_bp; 43 struct xfs_buf *agf_bp;
44 struct xfs_buf *agfl_bp; 44 struct xfs_buf *agfl_bp;
45 struct xfs_buf *agi_bp; 45 struct xfs_buf *agi_bp;
46 46
47 /* AG btrees */ 47 /* AG btrees */
48 struct xfs_btree_cur *bno_cur; 48 struct xfs_btree_cur *bno_cur;
49 struct xfs_btree_cur *cnt_cur; 49 struct xfs_btree_cur *cnt_cur;
50 struct xfs_btree_cur *ino_cur; 50 struct xfs_btree_cur *ino_cur;
51 struct xfs_btree_cur *fino_cur; 51 struct xfs_btree_cur *fino_cur;
52 struct xfs_btree_cur *rmap_cur; 52 struct xfs_btree_cur *rmap_cur;
53 struct xfs_btree_cur *refc_cur; 53 struct xfs_btree_cur *refc_cur;
54}; 54};
55 55
56struct xfs_scrub { 56struct xfs_scrub {
@@ -66,7 +66,7 @@ struct xfs_scrub {
66 bool has_quotaofflock; 66 bool has_quotaofflock;
67 67
68 /* State tracking for single-AG operations. */ 68 /* State tracking for single-AG operations. */
69 struct xchk_ag sa; 69 struct xchk_ag sa;
70}; 70};
71 71
72/* Metadata scrubbers */ 72/* Metadata scrubbers */
@@ -115,27 +115,25 @@ xchk_quota(struct xfs_scrub *sc)
115#endif 115#endif
116 116
117/* cross-referencing helpers */ 117/* cross-referencing helpers */
118void xchk_xref_is_used_space(struct xfs_scrub *sc, 118void xchk_xref_is_used_space(struct xfs_scrub *sc, xfs_agblock_t agbno,
119 xfs_agblock_t agbno, xfs_extlen_t len); 119 xfs_extlen_t len);
120void xchk_xref_is_not_inode_chunk(struct xfs_scrub *sc, 120void xchk_xref_is_not_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
121 xfs_agblock_t agbno, xfs_extlen_t len); 121 xfs_extlen_t len);
122void xchk_xref_is_inode_chunk(struct xfs_scrub *sc, 122void xchk_xref_is_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
123 xfs_agblock_t agbno, xfs_extlen_t len); 123 xfs_extlen_t len);
124void xchk_xref_is_owned_by(struct xfs_scrub *sc, 124void xchk_xref_is_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
125 xfs_agblock_t agbno, xfs_extlen_t len, 125 xfs_extlen_t len, struct xfs_owner_info *oinfo);
126 struct xfs_owner_info *oinfo); 126void xchk_xref_is_not_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
127void xchk_xref_is_not_owned_by(struct xfs_scrub *sc, 127 xfs_extlen_t len, struct xfs_owner_info *oinfo);
128 xfs_agblock_t agbno, xfs_extlen_t len, 128void xchk_xref_has_no_owner(struct xfs_scrub *sc, xfs_agblock_t agbno,
129 struct xfs_owner_info *oinfo); 129 xfs_extlen_t len);
130void xchk_xref_has_no_owner(struct xfs_scrub *sc, 130void xchk_xref_is_cow_staging(struct xfs_scrub *sc, xfs_agblock_t bno,
131 xfs_agblock_t agbno, xfs_extlen_t len); 131 xfs_extlen_t len);
132void xchk_xref_is_cow_staging(struct xfs_scrub *sc, 132void xchk_xref_is_not_shared(struct xfs_scrub *sc, xfs_agblock_t bno,
133 xfs_agblock_t bno, xfs_extlen_t len); 133 xfs_extlen_t len);
134void xchk_xref_is_not_shared(struct xfs_scrub *sc,
135 xfs_agblock_t bno, xfs_extlen_t len);
136#ifdef CONFIG_XFS_RT 134#ifdef CONFIG_XFS_RT
137void xchk_xref_is_used_rt_space(struct xfs_scrub *sc, 135void xchk_xref_is_used_rt_space(struct xfs_scrub *sc, xfs_rtblock_t rtbno,
138 xfs_rtblock_t rtbno, xfs_extlen_t len); 136 xfs_extlen_t len);
139#else 137#else
140# define xchk_xref_is_used_rt_space(sc, rtbno, len) do { } while (0) 138# define xchk_xref_is_used_rt_space(sc, rtbno, len) do { } while (0)
141#endif 139#endif
diff --git a/fs/xfs/scrub/symlink.c b/fs/xfs/scrub/symlink.c
index 56c6347e9482..f7ebaa946999 100644
--- a/fs/xfs/scrub/symlink.c
+++ b/fs/xfs/scrub/symlink.c
@@ -27,7 +27,7 @@
27int 27int
28xchk_setup_symlink( 28xchk_setup_symlink(
29 struct xfs_scrub *sc, 29 struct xfs_scrub *sc,
30 struct xfs_inode *ip) 30 struct xfs_inode *ip)
31{ 31{
32 /* Allocate the buffer without the inode lock held. */ 32 /* Allocate the buffer without the inode lock held. */
33 sc->buf = kmem_zalloc_large(XFS_SYMLINK_MAXLEN + 1, KM_SLEEP); 33 sc->buf = kmem_zalloc_large(XFS_SYMLINK_MAXLEN + 1, KM_SLEEP);
@@ -43,10 +43,10 @@ int
43xchk_symlink( 43xchk_symlink(
44 struct xfs_scrub *sc) 44 struct xfs_scrub *sc)
45{ 45{
46 struct xfs_inode *ip = sc->ip; 46 struct xfs_inode *ip = sc->ip;
47 struct xfs_ifork *ifp; 47 struct xfs_ifork *ifp;
48 loff_t len; 48 loff_t len;
49 int error = 0; 49 int error = 0;
50 50
51 if (!S_ISLNK(VFS_I(ip)->i_mode)) 51 if (!S_ISLNK(VFS_I(ip)->i_mode))
52 return -ENOENT; 52 return -ENOENT;
diff --git a/fs/xfs/scrub/trace.c b/fs/xfs/scrub/trace.c
index 1ef1202a1e45..96feaf8dcdec 100644
--- a/fs/xfs/scrub/trace.c
+++ b/fs/xfs/scrub/trace.c
@@ -23,8 +23,8 @@
23/* Figure out which block the btree cursor was pointing to. */ 23/* Figure out which block the btree cursor was pointing to. */
24static inline xfs_fsblock_t 24static inline xfs_fsblock_t
25xchk_btree_cur_fsbno( 25xchk_btree_cur_fsbno(
26 struct xfs_btree_cur *cur, 26 struct xfs_btree_cur *cur,
27 int level) 27 int level)
28{ 28{
29 if (level < cur->bc_nlevels && cur->bc_bufs[level]) 29 if (level < cur->bc_nlevels && cur->bc_bufs[level])
30 return XFS_DADDR_TO_FSB(cur->bc_mp, cur->bc_bufs[level]->b_bn); 30 return XFS_DADDR_TO_FSB(cur->bc_mp, cur->bc_bufs[level]->b_bn);