This source file includes following definitions.
- __xchk_process_error
- xchk_process_error
- xchk_xref_process_error
- __xchk_fblock_process_error
- xchk_fblock_process_error
- xchk_fblock_xref_process_error
- xchk_block_set_preen
- xchk_ino_set_preen
- xchk_set_corrupt
- xchk_block_set_corrupt
- xchk_block_xref_set_corrupt
- xchk_ino_set_corrupt
- xchk_ino_xref_set_corrupt
- xchk_fblock_set_corrupt
- xchk_fblock_xref_set_corrupt
- xchk_ino_set_warning
- xchk_fblock_set_warning
- xchk_set_incomplete
- xchk_count_rmap_ownedby_irec
- xchk_count_rmap_ownedby_ag
- want_ag_read_header_failure
- xchk_ag_read_headers
- xchk_ag_btcur_free
- xchk_ag_btcur_init
- xchk_ag_free
- xchk_ag_init
- xchk_perag_get
- xchk_trans_alloc
- xchk_setup_fs
- xchk_setup_ag_btree
- xchk_checkpoint_log
- xchk_get_inode
- xchk_setup_inode_contents
- xchk_should_check_xref
- xchk_buffer_recheck
- xchk_metadata_inode_forks
- xchk_ilock_inverted
- xchk_stop_reaping
- xchk_start_reaping
1
2
3
4
5
6 #include "xfs.h"
7 #include "xfs_fs.h"
8 #include "xfs_shared.h"
9 #include "xfs_format.h"
10 #include "xfs_trans_resv.h"
11 #include "xfs_mount.h"
12 #include "xfs_btree.h"
13 #include "xfs_log_format.h"
14 #include "xfs_trans.h"
15 #include "xfs_sb.h"
16 #include "xfs_inode.h"
17 #include "xfs_icache.h"
18 #include "xfs_alloc.h"
19 #include "xfs_alloc_btree.h"
20 #include "xfs_ialloc.h"
21 #include "xfs_ialloc_btree.h"
22 #include "xfs_refcount_btree.h"
23 #include "xfs_rmap.h"
24 #include "xfs_rmap_btree.h"
25 #include "xfs_log.h"
26 #include "xfs_trans_priv.h"
27 #include "xfs_attr.h"
28 #include "xfs_reflink.h"
29 #include "scrub/scrub.h"
30 #include "scrub/common.h"
31 #include "scrub/trace.h"
32 #include "scrub/repair.h"
33 #include "scrub/health.h"
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 static bool
64 __xchk_process_error(
65 struct xfs_scrub *sc,
66 xfs_agnumber_t agno,
67 xfs_agblock_t bno,
68 int *error,
69 __u32 errflag,
70 void *ret_ip)
71 {
72 switch (*error) {
73 case 0:
74 return true;
75 case -EDEADLOCK:
76
77 trace_xchk_deadlock_retry(sc->ip, sc->sm, *error);
78 break;
79 case -EFSBADCRC:
80 case -EFSCORRUPTED:
81
82 sc->sm->sm_flags |= errflag;
83 *error = 0;
84
85 default:
86 trace_xchk_op_error(sc, agno, bno, *error,
87 ret_ip);
88 break;
89 }
90 return false;
91 }
92
93 bool
94 xchk_process_error(
95 struct xfs_scrub *sc,
96 xfs_agnumber_t agno,
97 xfs_agblock_t bno,
98 int *error)
99 {
100 return __xchk_process_error(sc, agno, bno, error,
101 XFS_SCRUB_OFLAG_CORRUPT, __return_address);
102 }
103
104 bool
105 xchk_xref_process_error(
106 struct xfs_scrub *sc,
107 xfs_agnumber_t agno,
108 xfs_agblock_t bno,
109 int *error)
110 {
111 return __xchk_process_error(sc, agno, bno, error,
112 XFS_SCRUB_OFLAG_XFAIL, __return_address);
113 }
114
115
116 static bool
117 __xchk_fblock_process_error(
118 struct xfs_scrub *sc,
119 int whichfork,
120 xfs_fileoff_t offset,
121 int *error,
122 __u32 errflag,
123 void *ret_ip)
124 {
125 switch (*error) {
126 case 0:
127 return true;
128 case -EDEADLOCK:
129
130 trace_xchk_deadlock_retry(sc->ip, sc->sm, *error);
131 break;
132 case -EFSBADCRC:
133 case -EFSCORRUPTED:
134
135 sc->sm->sm_flags |= errflag;
136 *error = 0;
137
138 default:
139 trace_xchk_file_op_error(sc, whichfork, offset, *error,
140 ret_ip);
141 break;
142 }
143 return false;
144 }
145
146 bool
147 xchk_fblock_process_error(
148 struct xfs_scrub *sc,
149 int whichfork,
150 xfs_fileoff_t offset,
151 int *error)
152 {
153 return __xchk_fblock_process_error(sc, whichfork, offset, error,
154 XFS_SCRUB_OFLAG_CORRUPT, __return_address);
155 }
156
157 bool
158 xchk_fblock_xref_process_error(
159 struct xfs_scrub *sc,
160 int whichfork,
161 xfs_fileoff_t offset,
162 int *error)
163 {
164 return __xchk_fblock_process_error(sc, whichfork, offset, error,
165 XFS_SCRUB_OFLAG_XFAIL, __return_address);
166 }
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181 void
182 xchk_block_set_preen(
183 struct xfs_scrub *sc,
184 struct xfs_buf *bp)
185 {
186 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
187 trace_xchk_block_preen(sc, bp->b_bn, __return_address);
188 }
189
190
191
192
193
194
195 void
196 xchk_ino_set_preen(
197 struct xfs_scrub *sc,
198 xfs_ino_t ino)
199 {
200 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
201 trace_xchk_ino_preen(sc, ino, __return_address);
202 }
203
204
205 void
206 xchk_set_corrupt(
207 struct xfs_scrub *sc)
208 {
209 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
210 trace_xchk_fs_error(sc, 0, __return_address);
211 }
212
213
214 void
215 xchk_block_set_corrupt(
216 struct xfs_scrub *sc,
217 struct xfs_buf *bp)
218 {
219 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
220 trace_xchk_block_error(sc, bp->b_bn, __return_address);
221 }
222
223
224 void
225 xchk_block_xref_set_corrupt(
226 struct xfs_scrub *sc,
227 struct xfs_buf *bp)
228 {
229 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
230 trace_xchk_block_error(sc, bp->b_bn, __return_address);
231 }
232
233
234
235
236
237
238 void
239 xchk_ino_set_corrupt(
240 struct xfs_scrub *sc,
241 xfs_ino_t ino)
242 {
243 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
244 trace_xchk_ino_error(sc, ino, __return_address);
245 }
246
247
248 void
249 xchk_ino_xref_set_corrupt(
250 struct xfs_scrub *sc,
251 xfs_ino_t ino)
252 {
253 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
254 trace_xchk_ino_error(sc, ino, __return_address);
255 }
256
257
258 void
259 xchk_fblock_set_corrupt(
260 struct xfs_scrub *sc,
261 int whichfork,
262 xfs_fileoff_t offset)
263 {
264 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
265 trace_xchk_fblock_error(sc, whichfork, offset, __return_address);
266 }
267
268
269 void
270 xchk_fblock_xref_set_corrupt(
271 struct xfs_scrub *sc,
272 int whichfork,
273 xfs_fileoff_t offset)
274 {
275 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT;
276 trace_xchk_fblock_error(sc, whichfork, offset, __return_address);
277 }
278
279
280
281
282
283 void
284 xchk_ino_set_warning(
285 struct xfs_scrub *sc,
286 xfs_ino_t ino)
287 {
288 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
289 trace_xchk_ino_warning(sc, ino, __return_address);
290 }
291
292
293 void
294 xchk_fblock_set_warning(
295 struct xfs_scrub *sc,
296 int whichfork,
297 xfs_fileoff_t offset)
298 {
299 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
300 trace_xchk_fblock_warning(sc, whichfork, offset, __return_address);
301 }
302
303
304 void
305 xchk_set_incomplete(
306 struct xfs_scrub *sc)
307 {
308 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_INCOMPLETE;
309 trace_xchk_incomplete(sc, __return_address);
310 }
311
312
313
314
315
316
317 struct xchk_rmap_ownedby_info {
318 const struct xfs_owner_info *oinfo;
319 xfs_filblks_t *blocks;
320 };
321
322 STATIC int
323 xchk_count_rmap_ownedby_irec(
324 struct xfs_btree_cur *cur,
325 struct xfs_rmap_irec *rec,
326 void *priv)
327 {
328 struct xchk_rmap_ownedby_info *sroi = priv;
329 bool irec_attr;
330 bool oinfo_attr;
331
332 irec_attr = rec->rm_flags & XFS_RMAP_ATTR_FORK;
333 oinfo_attr = sroi->oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK;
334
335 if (rec->rm_owner != sroi->oinfo->oi_owner)
336 return 0;
337
338 if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || irec_attr == oinfo_attr)
339 (*sroi->blocks) += rec->rm_blockcount;
340
341 return 0;
342 }
343
344
345
346
347
348 int
349 xchk_count_rmap_ownedby_ag(
350 struct xfs_scrub *sc,
351 struct xfs_btree_cur *cur,
352 const struct xfs_owner_info *oinfo,
353 xfs_filblks_t *blocks)
354 {
355 struct xchk_rmap_ownedby_info sroi = {
356 .oinfo = oinfo,
357 .blocks = blocks,
358 };
359
360 *blocks = 0;
361 return xfs_rmap_query_all(cur, xchk_count_rmap_ownedby_irec,
362 &sroi);
363 }
364
365
366
367
368
369
370
371
372
373
374 static inline bool
375 want_ag_read_header_failure(
376 struct xfs_scrub *sc,
377 unsigned int type)
378 {
379
380 if (sc->sm->sm_type != XFS_SCRUB_TYPE_AGF &&
381 sc->sm->sm_type != XFS_SCRUB_TYPE_AGFL &&
382 sc->sm->sm_type != XFS_SCRUB_TYPE_AGI)
383 return true;
384
385
386
387
388
389 if (sc->sm->sm_type == type)
390 return true;
391 return false;
392 }
393
394
395
396
397
398
399
400
401 int
402 xchk_ag_read_headers(
403 struct xfs_scrub *sc,
404 xfs_agnumber_t agno,
405 struct xfs_buf **agi,
406 struct xfs_buf **agf,
407 struct xfs_buf **agfl)
408 {
409 struct xfs_mount *mp = sc->mp;
410 int error;
411
412 error = xfs_ialloc_read_agi(mp, sc->tp, agno, agi);
413 if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGI))
414 goto out;
415
416 error = xfs_alloc_read_agf(mp, sc->tp, agno, 0, agf);
417 if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGF))
418 goto out;
419
420 error = xfs_alloc_read_agfl(mp, sc->tp, agno, agfl);
421 if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGFL))
422 goto out;
423 error = 0;
424 out:
425 return error;
426 }
427
428
429 void
430 xchk_ag_btcur_free(
431 struct xchk_ag *sa)
432 {
433 if (sa->refc_cur)
434 xfs_btree_del_cursor(sa->refc_cur, XFS_BTREE_ERROR);
435 if (sa->rmap_cur)
436 xfs_btree_del_cursor(sa->rmap_cur, XFS_BTREE_ERROR);
437 if (sa->fino_cur)
438 xfs_btree_del_cursor(sa->fino_cur, XFS_BTREE_ERROR);
439 if (sa->ino_cur)
440 xfs_btree_del_cursor(sa->ino_cur, XFS_BTREE_ERROR);
441 if (sa->cnt_cur)
442 xfs_btree_del_cursor(sa->cnt_cur, XFS_BTREE_ERROR);
443 if (sa->bno_cur)
444 xfs_btree_del_cursor(sa->bno_cur, XFS_BTREE_ERROR);
445
446 sa->refc_cur = NULL;
447 sa->rmap_cur = NULL;
448 sa->fino_cur = NULL;
449 sa->ino_cur = NULL;
450 sa->bno_cur = NULL;
451 sa->cnt_cur = NULL;
452 }
453
454
455 int
456 xchk_ag_btcur_init(
457 struct xfs_scrub *sc,
458 struct xchk_ag *sa)
459 {
460 struct xfs_mount *mp = sc->mp;
461 xfs_agnumber_t agno = sa->agno;
462
463 xchk_perag_get(sc->mp, sa);
464 if (sa->agf_bp &&
465 xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_BNO)) {
466
467 sa->bno_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp,
468 agno, XFS_BTNUM_BNO);
469 if (!sa->bno_cur)
470 goto err;
471 }
472
473 if (sa->agf_bp &&
474 xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_CNT)) {
475
476 sa->cnt_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp,
477 agno, XFS_BTNUM_CNT);
478 if (!sa->cnt_cur)
479 goto err;
480 }
481
482
483 if (sa->agi_bp &&
484 xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_INO)) {
485 sa->ino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp,
486 agno, XFS_BTNUM_INO);
487 if (!sa->ino_cur)
488 goto err;
489 }
490
491
492 if (sa->agi_bp && xfs_sb_version_hasfinobt(&mp->m_sb) &&
493 xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_FINO)) {
494 sa->fino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp,
495 agno, XFS_BTNUM_FINO);
496 if (!sa->fino_cur)
497 goto err;
498 }
499
500
501 if (sa->agf_bp && xfs_sb_version_hasrmapbt(&mp->m_sb) &&
502 xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) {
503 sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp,
504 agno);
505 if (!sa->rmap_cur)
506 goto err;
507 }
508
509
510 if (sa->agf_bp && xfs_sb_version_hasreflink(&mp->m_sb) &&
511 xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_REFC)) {
512 sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp,
513 sa->agf_bp, agno);
514 if (!sa->refc_cur)
515 goto err;
516 }
517
518 return 0;
519 err:
520 return -ENOMEM;
521 }
522
523
524 void
525 xchk_ag_free(
526 struct xfs_scrub *sc,
527 struct xchk_ag *sa)
528 {
529 xchk_ag_btcur_free(sa);
530 if (sa->agfl_bp) {
531 xfs_trans_brelse(sc->tp, sa->agfl_bp);
532 sa->agfl_bp = NULL;
533 }
534 if (sa->agf_bp) {
535 xfs_trans_brelse(sc->tp, sa->agf_bp);
536 sa->agf_bp = NULL;
537 }
538 if (sa->agi_bp) {
539 xfs_trans_brelse(sc->tp, sa->agi_bp);
540 sa->agi_bp = NULL;
541 }
542 if (sa->pag) {
543 xfs_perag_put(sa->pag);
544 sa->pag = NULL;
545 }
546 sa->agno = NULLAGNUMBER;
547 }
548
549
550
551
552
553
554
555
556 int
557 xchk_ag_init(
558 struct xfs_scrub *sc,
559 xfs_agnumber_t agno,
560 struct xchk_ag *sa)
561 {
562 int error;
563
564 sa->agno = agno;
565 error = xchk_ag_read_headers(sc, agno, &sa->agi_bp,
566 &sa->agf_bp, &sa->agfl_bp);
567 if (error)
568 return error;
569
570 return xchk_ag_btcur_init(sc, sa);
571 }
572
573
574
575
576
577 void
578 xchk_perag_get(
579 struct xfs_mount *mp,
580 struct xchk_ag *sa)
581 {
582 if (!sa->pag)
583 sa->pag = xfs_perag_get(mp, sa->agno);
584 }
585
586
587
588
589
590
591
592
593
594
595
596
597
598 int
599 xchk_trans_alloc(
600 struct xfs_scrub *sc,
601 uint resblks)
602 {
603 if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)
604 return xfs_trans_alloc(sc->mp, &M_RES(sc->mp)->tr_itruncate,
605 resblks, 0, 0, &sc->tp);
606
607 return xfs_trans_alloc_empty(sc->mp, &sc->tp);
608 }
609
610
611 int
612 xchk_setup_fs(
613 struct xfs_scrub *sc,
614 struct xfs_inode *ip)
615 {
616 uint resblks;
617
618 resblks = xrep_calc_ag_resblks(sc);
619 return xchk_trans_alloc(sc, resblks);
620 }
621
622
623 int
624 xchk_setup_ag_btree(
625 struct xfs_scrub *sc,
626 struct xfs_inode *ip,
627 bool force_log)
628 {
629 struct xfs_mount *mp = sc->mp;
630 int error;
631
632
633
634
635
636
637
638 if (force_log) {
639 error = xchk_checkpoint_log(mp);
640 if (error)
641 return error;
642 }
643
644 error = xchk_setup_fs(sc, ip);
645 if (error)
646 return error;
647
648 return xchk_ag_init(sc, sc->sm->sm_agno, &sc->sa);
649 }
650
651
652 int
653 xchk_checkpoint_log(
654 struct xfs_mount *mp)
655 {
656 int error;
657
658 error = xfs_log_force(mp, XFS_LOG_SYNC);
659 if (error)
660 return error;
661 xfs_ail_push_all_sync(mp->m_ail);
662 return 0;
663 }
664
665
666
667
668
669
670 int
671 xchk_get_inode(
672 struct xfs_scrub *sc,
673 struct xfs_inode *ip_in)
674 {
675 struct xfs_imap imap;
676 struct xfs_mount *mp = sc->mp;
677 struct xfs_inode *ip = NULL;
678 int error;
679
680
681 if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) {
682 sc->ip = ip_in;
683 return 0;
684 }
685
686
687 if (xfs_internal_inum(mp, sc->sm->sm_ino))
688 return -ENOENT;
689 error = xfs_iget(mp, NULL, sc->sm->sm_ino,
690 XFS_IGET_UNTRUSTED | XFS_IGET_DONTCACHE, 0, &ip);
691 switch (error) {
692 case -ENOENT:
693
694 return error;
695 case 0:
696
697 break;
698 case -EINVAL:
699
700
701
702
703
704
705
706
707
708
709
710
711 error = xfs_imap(sc->mp, sc->tp, sc->sm->sm_ino, &imap,
712 XFS_IGET_UNTRUSTED | XFS_IGET_DONTCACHE);
713 if (error)
714 return -ENOENT;
715 error = -EFSCORRUPTED;
716
717 default:
718 trace_xchk_op_error(sc,
719 XFS_INO_TO_AGNO(mp, sc->sm->sm_ino),
720 XFS_INO_TO_AGBNO(mp, sc->sm->sm_ino),
721 error, __return_address);
722 return error;
723 }
724 if (VFS_I(ip)->i_generation != sc->sm->sm_gen) {
725 xfs_irele(ip);
726 return -ENOENT;
727 }
728
729 sc->ip = ip;
730 return 0;
731 }
732
733
734 int
735 xchk_setup_inode_contents(
736 struct xfs_scrub *sc,
737 struct xfs_inode *ip,
738 unsigned int resblks)
739 {
740 int error;
741
742 error = xchk_get_inode(sc, ip);
743 if (error)
744 return error;
745
746
747 sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL;
748 xfs_ilock(sc->ip, sc->ilock_flags);
749 error = xchk_trans_alloc(sc, resblks);
750 if (error)
751 goto out;
752 sc->ilock_flags |= XFS_ILOCK_EXCL;
753 xfs_ilock(sc->ip, XFS_ILOCK_EXCL);
754
755 out:
756
757 return error;
758 }
759
760
761
762
763
764
765 bool
766 xchk_should_check_xref(
767 struct xfs_scrub *sc,
768 int *error,
769 struct xfs_btree_cur **curpp)
770 {
771
772 if (xchk_skip_xref(sc->sm))
773 return false;
774
775 if (*error == 0)
776 return true;
777
778 if (curpp) {
779
780 if (!*curpp)
781 return false;
782
783
784 xfs_btree_del_cursor(*curpp, XFS_BTREE_ERROR);
785 *curpp = NULL;
786 }
787
788 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XFAIL;
789 trace_xchk_xref_error(sc, *error, __return_address);
790
791
792
793
794
795 *error = 0;
796 return false;
797 }
798
799
800 void
801 xchk_buffer_recheck(
802 struct xfs_scrub *sc,
803 struct xfs_buf *bp)
804 {
805 xfs_failaddr_t fa;
806
807 if (bp->b_ops == NULL) {
808 xchk_block_set_corrupt(sc, bp);
809 return;
810 }
811 if (bp->b_ops->verify_struct == NULL) {
812 xchk_set_incomplete(sc);
813 return;
814 }
815 fa = bp->b_ops->verify_struct(bp);
816 if (!fa)
817 return;
818 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
819 trace_xchk_block_error(sc, bp->b_bn, fa);
820 }
821
822
823
824
825
826 int
827 xchk_metadata_inode_forks(
828 struct xfs_scrub *sc)
829 {
830 __u32 smtype;
831 bool shared;
832 int error;
833
834 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
835 return 0;
836
837
838 if (sc->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
839 xchk_ino_set_corrupt(sc, sc->ip->i_ino);
840 return 0;
841 }
842
843
844 if (xfs_is_reflink_inode(sc->ip)) {
845 xchk_ino_set_corrupt(sc, sc->ip->i_ino);
846 return 0;
847 }
848
849
850 if (xfs_inode_hasattr(sc->ip)) {
851 xchk_ino_set_corrupt(sc, sc->ip->i_ino);
852 return 0;
853 }
854
855
856 smtype = sc->sm->sm_type;
857 sc->sm->sm_type = XFS_SCRUB_TYPE_BMBTD;
858 error = xchk_bmap_data(sc);
859 sc->sm->sm_type = smtype;
860 if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
861 return error;
862
863
864 if (xfs_sb_version_hasreflink(&sc->mp->m_sb)) {
865 error = xfs_reflink_inode_has_shared_extents(sc->tp, sc->ip,
866 &shared);
867 if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, 0,
868 &error))
869 return error;
870 if (shared)
871 xchk_ino_set_corrupt(sc, sc->ip->i_ino);
872 }
873
874 return error;
875 }
876
877
878
879
880
881
882
883
884 int
885 xchk_ilock_inverted(
886 struct xfs_inode *ip,
887 uint lock_mode)
888 {
889 int i;
890
891 for (i = 0; i < 20; i++) {
892 if (xfs_ilock_nowait(ip, lock_mode))
893 return 0;
894 delay(1);
895 }
896 return -EDEADLOCK;
897 }
898
899
900 void
901 xchk_stop_reaping(
902 struct xfs_scrub *sc)
903 {
904 sc->flags |= XCHK_REAPING_DISABLED;
905 xfs_stop_block_reaping(sc->mp);
906 }
907
908
909 void
910 xchk_start_reaping(
911 struct xfs_scrub *sc)
912 {
913 xfs_start_block_reaping(sc->mp);
914 sc->flags &= ~XCHK_REAPING_DISABLED;
915 }