2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "err_protos.h"
30 #include "attr_repair.h"
37 * gettext lookups for translations of strings use mutexes internally to
38 * the library. Hence when we come through here doing parallel scans in
39 * multiple AGs, then all do concurrent text conversions and serialise
40 * on the translation string lookups. Let's avoid doing repeated lookups
41 * by making them static variables and only assigning the translation
44 static char *forkname_data
;
45 static char *forkname_attr
;
46 static char *ftype_real_time
;
47 static char *ftype_regular
;
50 dinode_bmbt_translation_init(void)
52 forkname_data
= _("data");
53 forkname_attr
= _("attr");
54 ftype_real_time
= _("real-time");
55 ftype_regular
= _("regular");
59 get_forkname(int whichfork
)
62 if (whichfork
== XFS_DATA_FORK
)
68 * inode clearing routines
72 clear_dinode_attr(xfs_mount_t
*mp
, xfs_dinode_t
*dino
, xfs_ino_t ino_num
)
74 ASSERT(dino
->di_forkoff
!= 0);
78 _("clearing inode %" PRIu64
" attributes\n"), ino_num
);
81 _("would have cleared inode %" PRIu64
" attributes\n"), ino_num
);
83 if (be16_to_cpu(dino
->di_anextents
) != 0) {
86 dino
->di_anextents
= cpu_to_be16(0);
89 if (dino
->di_aformat
!= XFS_DINODE_FMT_EXTENTS
) {
92 dino
->di_aformat
= XFS_DINODE_FMT_EXTENTS
;
95 /* get rid of the fork by clearing forkoff */
97 /* Originally, when the attr repair code was added, the fork was cleared
98 * by turning it into shortform status. This meant clearing the
99 * hdr.totsize/count fields and also changing aformat to LOCAL
100 * (vs EXTENTS). Over various fixes, the aformat and forkoff have
101 * been updated to not show an attribute fork at all, however.
102 * It could be possible that resetting totsize/count are not needed,
103 * but just to be safe, leave it in for now.
107 xfs_attr_shortform_t
*asf
= (xfs_attr_shortform_t
*)
108 XFS_DFORK_APTR(dino
);
109 asf
->hdr
.totsize
= cpu_to_be16(sizeof(xfs_attr_sf_hdr_t
));
111 dino
->di_forkoff
= 0; /* got to do this after asf is set */
115 * always returns 1 since the fork gets zapped
121 clear_dinode_core(struct xfs_mount
*mp
, xfs_dinode_t
*dinoc
, xfs_ino_t ino_num
)
126 #define __dirty_no_modify_ret(dirty) \
127 ({ (dirty) = 1; if (no_modify) return 1; })
129 if (be16_to_cpu(dinoc
->di_magic
) != XFS_DINODE_MAGIC
) {
130 __dirty_no_modify_ret(dirty
);
131 dinoc
->di_magic
= cpu_to_be16(XFS_DINODE_MAGIC
);
134 if (!libxfs_dinode_good_version(mp
, dinoc
->di_version
)) {
135 __dirty_no_modify_ret(dirty
);
136 if (xfs_sb_version_hascrc(&mp
->m_sb
))
137 dinoc
->di_version
= 3;
139 dinoc
->di_version
= 2;
142 if (be16_to_cpu(dinoc
->di_mode
) != 0) {
143 __dirty_no_modify_ret(dirty
);
147 if (be16_to_cpu(dinoc
->di_flags
) != 0) {
148 __dirty_no_modify_ret(dirty
);
152 if (be32_to_cpu(dinoc
->di_dmevmask
) != 0) {
153 __dirty_no_modify_ret(dirty
);
154 dinoc
->di_dmevmask
= 0;
157 if (dinoc
->di_forkoff
!= 0) {
158 __dirty_no_modify_ret(dirty
);
159 dinoc
->di_forkoff
= 0;
162 if (dinoc
->di_format
!= XFS_DINODE_FMT_EXTENTS
) {
163 __dirty_no_modify_ret(dirty
);
164 dinoc
->di_format
= XFS_DINODE_FMT_EXTENTS
;
167 if (dinoc
->di_aformat
!= XFS_DINODE_FMT_EXTENTS
) {
168 __dirty_no_modify_ret(dirty
);
169 dinoc
->di_aformat
= XFS_DINODE_FMT_EXTENTS
;
172 if (be64_to_cpu(dinoc
->di_size
) != 0) {
173 __dirty_no_modify_ret(dirty
);
177 if (be64_to_cpu(dinoc
->di_nblocks
) != 0) {
178 __dirty_no_modify_ret(dirty
);
179 dinoc
->di_nblocks
= 0;
182 if (be16_to_cpu(dinoc
->di_onlink
) != 0) {
183 __dirty_no_modify_ret(dirty
);
184 dinoc
->di_onlink
= 0;
187 if (be32_to_cpu(dinoc
->di_nextents
) != 0) {
188 __dirty_no_modify_ret(dirty
);
189 dinoc
->di_nextents
= 0;
192 if (be16_to_cpu(dinoc
->di_anextents
) != 0) {
193 __dirty_no_modify_ret(dirty
);
194 dinoc
->di_anextents
= 0;
197 if (dinoc
->di_version
> 1 &&
198 be32_to_cpu(dinoc
->di_nlink
) != 0) {
199 __dirty_no_modify_ret(dirty
);
203 /* we are done for version 1/2 inodes */
204 if (dinoc
->di_version
< 3)
207 if (be64_to_cpu(dinoc
->di_ino
) != ino_num
) {
208 __dirty_no_modify_ret(dirty
);
209 dinoc
->di_ino
= cpu_to_be64(ino_num
);
212 if (platform_uuid_compare(&dinoc
->di_uuid
, &mp
->m_sb
.sb_meta_uuid
)) {
213 __dirty_no_modify_ret(dirty
);
214 platform_uuid_copy(&dinoc
->di_uuid
, &mp
->m_sb
.sb_meta_uuid
);
217 for (i
= 0; i
< sizeof(dinoc
->di_pad2
)/sizeof(dinoc
->di_pad2
[0]); i
++) {
218 if (dinoc
->di_pad2
[i
] != 0) {
219 __dirty_no_modify_ret(dirty
);
220 memset(dinoc
->di_pad2
, 0, sizeof(dinoc
->di_pad2
));
225 if (be64_to_cpu(dinoc
->di_flags2
) != 0) {
226 __dirty_no_modify_ret(dirty
);
227 dinoc
->di_flags2
= 0;
230 if (be64_to_cpu(dinoc
->di_lsn
) != 0) {
231 __dirty_no_modify_ret(dirty
);
235 if (be64_to_cpu(dinoc
->di_changecount
) != 0) {
236 __dirty_no_modify_ret(dirty
);
237 dinoc
->di_changecount
= 0;
244 clear_dinode_unlinked(xfs_mount_t
*mp
, xfs_dinode_t
*dino
)
247 if (be32_to_cpu(dino
->di_next_unlinked
) != NULLAGINO
) {
249 dino
->di_next_unlinked
= cpu_to_be32(NULLAGINO
);
257 * this clears the unlinked list too so it should not be called
258 * until after the agi unlinked lists are walked in phase 3.
259 * returns > zero if the inode has been altered while being cleared
262 clear_dinode(xfs_mount_t
*mp
, xfs_dinode_t
*dino
, xfs_ino_t ino_num
)
266 dirty
= clear_dinode_core(mp
, dino
, ino_num
);
267 dirty
+= clear_dinode_unlinked(mp
, dino
);
269 /* and clear the forks */
271 if (dirty
&& !no_modify
)
272 memset(XFS_DFORK_DPTR(dino
), 0,
273 XFS_LITINO(mp
, dino
->di_version
));
280 * misc. inode-related utility routines
284 * verify_ag_bno is heavily used. In the common case, it
285 * performs just two number of compares
286 * Returns 1 for bad ag/bno pair or 0 if it's valid.
289 verify_ag_bno(xfs_sb_t
*sbp
,
293 if (agno
< (sbp
->sb_agcount
- 1))
294 return (agbno
>= sbp
->sb_agblocks
);
295 if (agno
== (sbp
->sb_agcount
- 1))
296 return (agbno
>= (sbp
->sb_dblocks
-
297 ((xfs_rfsblock_t
)(sbp
->sb_agcount
- 1) *
303 * returns 0 if inode number is valid, 1 if bogus
306 verify_inum(xfs_mount_t
*mp
,
312 xfs_sb_t
*sbp
= &mp
->m_sb
;;
314 /* range check ag #, ag block. range-checking offset is pointless */
316 agno
= XFS_INO_TO_AGNO(mp
, ino
);
317 agino
= XFS_INO_TO_AGINO(mp
, ino
);
318 agbno
= XFS_AGINO_TO_AGBNO(mp
, agino
);
322 if (ino
== 0 || ino
== NULLFSINO
)
325 if (ino
!= XFS_AGINO_TO_INO(mp
, agno
, agino
))
328 return verify_ag_bno(sbp
, agno
, agbno
);
332 * have a separate routine to ensure that we don't accidentally
333 * lose illegally set bits in the agino by turning it into an FSINO
334 * to feed to the above routine
337 verify_aginum(xfs_mount_t
*mp
,
342 xfs_sb_t
*sbp
= &mp
->m_sb
;;
344 /* range check ag #, ag block. range-checking offset is pointless */
346 if (agino
== 0 || agino
== NULLAGINO
)
350 * agino's can't be too close to NULLAGINO because the min blocksize
351 * is 9 bits and at most 1 bit of that gets used for the inode offset
352 * so if the agino gets shifted by the # of offset bits and compared
353 * to the legal agbno values, a bogus agino will be too large. there
354 * will be extra bits set at the top that shouldn't be set.
356 agbno
= XFS_AGINO_TO_AGBNO(mp
, agino
);
360 return verify_ag_bno(sbp
, agno
, agbno
);
364 * return 1 if block number is good, 0 if out of range
367 verify_dfsbno(xfs_mount_t
*mp
,
372 xfs_sb_t
*sbp
= &mp
->m_sb
;;
374 /* range check ag #, ag block. range-checking offset is pointless */
376 agno
= XFS_FSB_TO_AGNO(mp
, fsbno
);
377 agbno
= XFS_FSB_TO_AGBNO(mp
, fsbno
);
379 return verify_ag_bno(sbp
, agno
, agbno
) == 0;
382 #define XR_DFSBNORANGE_VALID 0
383 #define XR_DFSBNORANGE_BADSTART 1
384 #define XR_DFSBNORANGE_BADEND 2
385 #define XR_DFSBNORANGE_OVERFLOW 3
388 verify_dfsbno_range(xfs_mount_t
*mp
,
394 xfs_sb_t
*sbp
= &mp
->m_sb
;;
396 /* the start and end blocks better be in the same allocation group */
397 agno
= XFS_FSB_TO_AGNO(mp
, fsbno
);
398 if (agno
!= XFS_FSB_TO_AGNO(mp
, fsbno
+ count
- 1)) {
399 return XR_DFSBNORANGE_OVERFLOW
;
402 agbno
= XFS_FSB_TO_AGBNO(mp
, fsbno
);
403 if (verify_ag_bno(sbp
, agno
, agbno
)) {
404 return XR_DFSBNORANGE_BADSTART
;
407 agbno
= XFS_FSB_TO_AGBNO(mp
, fsbno
+ count
- 1);
408 if (verify_ag_bno(sbp
, agno
, agbno
)) {
409 return XR_DFSBNORANGE_BADEND
;
412 return (XR_DFSBNORANGE_VALID
);
416 verify_agbno(xfs_mount_t
*mp
,
420 xfs_sb_t
*sbp
= &mp
->m_sb
;;
422 /* range check ag #, ag block. range-checking offset is pointless */
423 return verify_ag_bno(sbp
, agno
, agbno
) == 0;
429 xfs_bmbt_irec_t
*irec
,
437 int pwe
; /* partially-written extent */
440 * check numeric validity of the extent
442 if (irec
->br_startblock
>= mp
->m_sb
.sb_rblocks
) {
444 _("inode %" PRIu64
" - bad rt extent start block number %" PRIu64
", offset %" PRIu64
"\n"),
450 if (irec
->br_startblock
+ irec
->br_blockcount
- 1 >= mp
->m_sb
.sb_rblocks
) {
452 _("inode %" PRIu64
" - bad rt extent last block number %" PRIu64
", offset %" PRIu64
"\n"),
454 irec
->br_startblock
+ irec
->br_blockcount
- 1,
458 if (irec
->br_startblock
+ irec
->br_blockcount
- 1 < irec
->br_startblock
) {
460 _("inode %" PRIu64
" - bad rt extent overflows - start %" PRIu64
", "
461 "end %" PRIu64
", offset %" PRIu64
"\n"),
464 irec
->br_startblock
+ irec
->br_blockcount
- 1,
470 * verify that the blocks listed in the record
471 * are multiples of an extent
473 if (xfs_sb_version_hasextflgbit(&mp
->m_sb
) == 0 &&
474 (irec
->br_startblock
% mp
->m_sb
.sb_rextsize
!= 0 ||
475 irec
->br_blockcount
% mp
->m_sb
.sb_rextsize
!= 0)) {
477 _("malformed rt inode extent [%" PRIu64
" %" PRIu64
"] (fs rtext size = %u)\n"),
480 mp
->m_sb
.sb_rextsize
);
485 * set the appropriate number of extents
486 * this iterates block by block, this can be optimised using extents
488 for (b
= irec
->br_startblock
; b
< irec
->br_startblock
+
489 irec
->br_blockcount
; b
+= mp
->m_sb
.sb_rextsize
) {
490 ext
= (xfs_rtblock_t
) b
/ mp
->m_sb
.sb_rextsize
;
491 pwe
= xfs_sb_version_hasextflgbit(&mp
->m_sb
) &&
492 irec
->br_state
== XFS_EXT_UNWRITTEN
&&
493 (b
% mp
->m_sb
.sb_rextsize
!= 0);
495 if (check_dups
== 1) {
496 if (search_rt_dup_extent(mp
, ext
) && !pwe
) {
498 _("data fork in rt ino %" PRIu64
" claims dup rt extent,"
499 "off - %" PRIu64
", start - %" PRIu64
", count %" PRIu64
"\n"),
503 irec
->br_blockcount
);
509 state
= get_rtbmap(ext
);
513 set_rtbmap(ext
, XR_E_INUSE
);
517 _("bad state in rt block map %" PRIu64
"\n"),
523 _("data fork in rt inode %" PRIu64
" found metadata block %" PRIu64
" in rt bmap\n"),
529 set_rtbmap(ext
, XR_E_MULT
);
531 _("data fork in rt inode %" PRIu64
" claims used rt block %" PRIu64
"\n"),
537 _("illegal state %d in rt block map %" PRIu64
"\n"),
543 * bump up the block counter
545 *tot
+= irec
->br_blockcount
;
551 * return 1 if inode should be cleared, 0 otherwise
552 * if check_dups should be set to 1, that implies that
553 * the primary purpose of this call is to see if the
554 * file overlaps with any duplicate extents (in the
555 * duplicate extent list).
558 process_bmbt_reclist_int(
566 xfs_fileoff_t
*first_key
,
567 xfs_fileoff_t
*last_key
,
571 xfs_bmbt_irec_t irec
;
572 xfs_filblks_t cp
= 0; /* prev count */
573 xfs_fsblock_t sp
= 0; /* prev start */
574 xfs_fileoff_t op
= 0; /* prev offset */
577 char *forkname
= get_forkname(whichfork
);
584 xfs_agnumber_t locked_agno
= -1;
587 if (type
== XR_INO_RTDATA
)
588 ftype
= ftype_real_time
;
590 ftype
= ftype_regular
;
592 for (i
= 0; i
< *numrecs
; i
++) {
593 libxfs_bmbt_disk_get_all((rp
+i
), &irec
);
595 *last_key
= *first_key
= irec
.br_startoff
;
597 *last_key
= irec
.br_startoff
;
598 if (i
> 0 && op
+ cp
> irec
.br_startoff
) {
600 _("bmap rec out of order, inode %" PRIu64
" entry %d "
601 "[o s c] [%" PRIu64
" %" PRIu64
" %" PRIu64
"], "
602 "%d [%" PRIu64
" %" PRIu64
" %" PRIu64
"]\n"),
603 ino
, i
, irec
.br_startoff
, irec
.br_startblock
,
604 irec
.br_blockcount
, i
- 1, op
, sp
, cp
);
607 op
= irec
.br_startoff
;
608 cp
= irec
.br_blockcount
;
609 sp
= irec
.br_startblock
;
612 * check numeric validity of the extent
614 if (irec
.br_blockcount
== 0) {
616 _("zero length extent (off = %" PRIu64
", fsbno = %" PRIu64
") in ino %" PRIu64
"\n"),
623 if (type
== XR_INO_RTDATA
&& whichfork
== XFS_DATA_FORK
) {
625 * realtime bitmaps don't use AG locks, so returning
626 * immediately is fine for this code path.
628 if (process_rt_rec(mp
, &irec
, ino
, tot
, check_dups
))
631 * skip rest of loop processing since that'irec.br_startblock
632 * all for regular file forks and attr forks
638 * regular file data fork or attribute fork
640 switch (verify_dfsbno_range(mp
, irec
.br_startblock
,
641 irec
.br_blockcount
)) {
642 case XR_DFSBNORANGE_VALID
:
645 case XR_DFSBNORANGE_BADSTART
:
647 _("inode %" PRIu64
" - bad extent starting block number %" PRIu64
", offset %" PRIu64
"\n"),
653 case XR_DFSBNORANGE_BADEND
:
655 _("inode %" PRIu64
" - bad extent last block number %" PRIu64
", offset %" PRIu64
"\n"),
657 irec
.br_startblock
+ irec
.br_blockcount
- 1,
661 case XR_DFSBNORANGE_OVERFLOW
:
663 _("inode %" PRIu64
" - bad extent overflows - start %" PRIu64
", "
664 "end %" PRIu64
", offset %" PRIu64
"\n"),
667 irec
.br_startblock
+ irec
.br_blockcount
- 1,
671 /* Ensure this extent does not extend beyond the max offset */
672 if (irec
.br_startoff
+ irec
.br_blockcount
- 1 >
673 fs_max_file_offset
) {
675 _("inode %" PRIu64
" - extent exceeds max offset - start %" PRIu64
", "
676 "count %" PRIu64
", physical block %" PRIu64
"\n"),
677 ino
, irec
.br_startoff
, irec
.br_blockcount
,
682 if (blkmapp
&& *blkmapp
) {
684 error2
= blkmap_set_ext(blkmapp
, irec
.br_startoff
,
685 irec
.br_startblock
, irec
.br_blockcount
);
688 * we don't want to clear the inode due to an
689 * internal bmap tracking error, but if we've
690 * run out of memory then we simply can't
691 * validate that the filesystem is consistent.
692 * Hence just abort at this point with an ENOMEM
696 _("Fatal error: inode %" PRIu64
" - blkmap_set_ext(): %s\n"
697 "\t%s fork, off - %" PRIu64
", start - %" PRIu64
", cnt %" PRIu64
"\n"),
698 ino
, strerror(error2
), forkname
,
699 irec
.br_startoff
, irec
.br_startblock
,
705 * Profiling shows that the following loop takes the
706 * most time in all of xfs_repair.
708 agno
= XFS_FSB_TO_AGNO(mp
, irec
.br_startblock
);
709 agbno
= XFS_FSB_TO_AGBNO(mp
, irec
.br_startblock
);
710 ebno
= agbno
+ irec
.br_blockcount
;
711 if (agno
!= locked_agno
) {
712 if (locked_agno
!= -1)
713 pthread_mutex_unlock(&ag_locks
[locked_agno
].lock
);
714 pthread_mutex_lock(&ag_locks
[agno
].lock
);
720 * if we're just checking the bmap for dups,
721 * return if we find one, otherwise, continue
722 * checking each entry without setting the
725 if (search_dup_extent(agno
, agbno
, ebno
)) {
727 _("%s fork in ino %" PRIu64
" claims dup extent, "
728 "off - %" PRIu64
", start - %" PRIu64
", cnt %" PRIu64
"\n"),
729 forkname
, ino
, irec
.br_startoff
,
734 *tot
+= irec
.br_blockcount
;
738 for (b
= irec
.br_startblock
;
740 b
+= blen
, agbno
+= blen
) {
741 state
= get_bmap_ext(agno
, agbno
, ebno
, &blen
);
746 _("%s fork in ino %" PRIu64
" claims free block %" PRIu64
"\n"),
747 forkname
, ino
, (__uint64_t
) b
);
748 /* fall through ... */
749 case XR_E_INUSE1
: /* seen by rmap */
751 set_bmap_ext(agno
, agbno
, blen
, XR_E_INUSE
);
755 do_error(_("bad state in block map %" PRIu64
"\n"), b
);
760 do_warn(_("rmap claims metadata use!\n"));
766 _("%s fork in inode %" PRIu64
" claims metadata block %" PRIu64
"\n"),
772 set_bmap_ext(agno
, agbno
, blen
, XR_E_MULT
);
774 _("%s fork in %s inode %" PRIu64
" claims used block %" PRIu64
"\n"),
775 forkname
, ftype
, ino
, b
);
780 _("illegal state %d in block map %" PRIu64
"\n"),
784 if (collect_rmaps
) { /* && !check_dups */
785 error
= rmap_add_rec(mp
, ino
, whichfork
, &irec
);
788 _("couldn't add reverse mapping\n")
791 *tot
+= irec
.br_blockcount
;
795 if (locked_agno
!= -1)
796 pthread_mutex_unlock(&ag_locks
[locked_agno
].lock
);
799 ASSERT(i
< *numrecs
);
800 do_warn(_("correcting nextents for inode %" PRIu64
"\n"), ino
);
808 * return 1 if inode should be cleared, 0 otherwise, sets block bitmap
812 process_bmbt_reclist(
820 xfs_fileoff_t
*first_key
,
821 xfs_fileoff_t
*last_key
,
824 return process_bmbt_reclist_int(mp
, rp
, numrecs
, type
, ino
, tot
,
825 blkmapp
, first_key
, last_key
, 0, whichfork
);
829 * return 1 if inode should be cleared, 0 otherwise, does not set
842 xfs_fileoff_t first_key
= 0;
843 xfs_fileoff_t last_key
= 0;
845 return process_bmbt_reclist_int(mp
, rp
, numrecs
, type
, ino
, tot
,
846 NULL
, &first_key
, &last_key
, 1, whichfork
);
850 * these two are meant for routines that read and work with inodes
851 * one at a time where the inodes may be in any order (like walking
852 * the unlinked lists to look for inodes). the caller is responsible
853 * for writing/releasing the buffer.
856 get_agino_buf(xfs_mount_t
*mp
,
861 ino_tree_node_t
*irec
;
865 if ((irec
= find_inode_rec(mp
, agno
, agino
)) == NULL
)
868 size
= MAX(1, XFS_FSB_TO_BB(mp
,
869 mp
->m_inode_cluster_size
>> mp
->m_sb
.sb_blocklog
));
870 bp
= libxfs_readbuf(mp
->m_dev
, XFS_AGB_TO_DADDR(mp
, agno
,
871 XFS_AGINO_TO_AGBNO(mp
, irec
->ino_startnum
)), size
, 0,
874 do_warn(_("cannot read inode (%u/%u), disk block %" PRIu64
"\n"),
875 agno
, irec
->ino_startnum
,
876 XFS_AGB_TO_DADDR(mp
, agno
,
877 XFS_AGINO_TO_AGBNO(mp
, irec
->ino_startnum
)));
881 *dipp
= xfs_make_iptr(mp
, bp
, agino
-
882 XFS_OFFBNO_TO_AGINO(mp
, XFS_AGINO_TO_AGBNO(mp
,
890 * higher level inode processing stuff starts here:
891 * first, one utility routine for each type of inode
895 * return 1 if inode should be cleared, 0 otherwise
911 xfs_bmdr_block_t
*dib
;
912 xfs_fileoff_t last_key
;
913 xfs_fileoff_t first_key
= 0;
916 xfs_bmbt_key_t
*pkey
;
917 char *forkname
= get_forkname(whichfork
);
921 bmap_cursor_t cursor
;
924 dib
= (xfs_bmdr_block_t
*)XFS_DFORK_PTR(dip
, whichfork
);
925 lino
= XFS_AGINO_TO_INO(mp
, agno
, ino
);
929 magic
= xfs_sb_version_hascrc(&mp
->m_sb
) ? XFS_BMAP_CRC_MAGIC
932 level
= be16_to_cpu(dib
->bb_level
);
933 numrecs
= be16_to_cpu(dib
->bb_numrecs
);
935 if ((level
== 0) || (level
> XFS_BM_MAXLEVELS(mp
, whichfork
))) {
937 * XXX - if we were going to fix up the inode,
938 * we'd try to treat the fork as an interior
939 * node and see if we could get an accurate
940 * level value from one of the blocks pointed
941 * to by the pointers in the fork. For now
942 * though, we just bail (and blow out the inode).
945 _("bad level %d in inode %" PRIu64
" bmap btree root block\n"),
946 level
, XFS_AGINO_TO_INO(mp
, agno
, ino
));
951 _("bad numrecs 0 in inode %" PRIu64
" bmap btree root block\n"),
952 XFS_AGINO_TO_INO(mp
, agno
, ino
));
956 * use bmdr/dfork_dsize since the root block is in the data fork
958 if (XFS_BMDR_SPACE_CALC(numrecs
) > XFS_DFORK_SIZE(dip
, mp
, whichfork
)) {
960 _("indicated size of %s btree root (%d bytes) greater than space in "
961 "inode %" PRIu64
" %s fork\n"),
962 forkname
, XFS_BMDR_SPACE_CALC(numrecs
), lino
, forkname
);
966 init_bm_cursor(&cursor
, level
+ 1);
968 pp
= XFS_BMDR_PTR_ADDR(dib
, 1,
969 libxfs_bmdr_maxrecs(XFS_DFORK_SIZE(dip
, mp
, whichfork
), 0));
970 pkey
= XFS_BMDR_KEY_ADDR(dib
, 1);
971 last_key
= NULLFILEOFF
;
973 for (i
= 0; i
< numrecs
; i
++) {
975 * XXX - if we were going to do more to fix up the inode
976 * btree, we'd do it right here. For now, if there's a
977 * problem, we'll bail out and presumably clear the inode.
979 if (!verify_dfsbno(mp
, get_unaligned_be64(&pp
[i
]))) {
981 _("bad bmap btree ptr 0x%" PRIx64
" in ino %" PRIu64
"\n"),
982 get_unaligned_be64(&pp
[i
]), lino
);
986 if (scan_lbtree(get_unaligned_be64(&pp
[i
]), level
, scan_bmapbt
,
987 type
, whichfork
, lino
, tot
, nex
, blkmapp
,
988 &cursor
, 1, check_dups
, magic
,
992 * fix key (offset) mismatches between the keys in root
993 * block records and the first key of each child block.
994 * fixes cases where entries have been shifted between
995 * blocks but the parent hasn't been updated
997 if (!check_dups
&& cursor
.level
[level
-1].first_key
!=
998 get_unaligned_be64(&pkey
[i
].br_startoff
)) {
1001 _("correcting key in bmbt root (was %" PRIu64
", now %" PRIu64
") in inode "
1002 "%" PRIu64
" %s fork\n"),
1003 get_unaligned_be64(&pkey
[i
].br_startoff
),
1004 cursor
.level
[level
-1].first_key
,
1005 XFS_AGINO_TO_INO(mp
, agno
, ino
),
1009 cursor
.level
[level
-1].first_key
,
1010 &pkey
[i
].br_startoff
);
1013 _("bad key in bmbt root (is %" PRIu64
", would reset to %" PRIu64
") in inode "
1014 "%" PRIu64
" %s fork\n"),
1015 get_unaligned_be64(&pkey
[i
].br_startoff
),
1016 cursor
.level
[level
-1].first_key
,
1017 XFS_AGINO_TO_INO(mp
, agno
, ino
),
1022 * make sure that keys are in ascending order. blow out
1023 * inode if the ordering doesn't hold
1025 if (check_dups
== 0) {
1026 if (last_key
!= NULLFILEOFF
&& last_key
>=
1027 cursor
.level
[level
-1].first_key
) {
1029 _("out of order bmbt root key %" PRIu64
" in inode %" PRIu64
" %s fork\n"),
1031 XFS_AGINO_TO_INO(mp
, agno
, ino
),
1035 last_key
= cursor
.level
[level
-1].first_key
;
1039 * Ideally if all the extents are ok (perhaps after further
1040 * checks below?) we'd just move this back into extents format.
1041 * But for now clear it, as the kernel will choke on this
1043 if (*nex
<= XFS_DFORK_SIZE(dip
, mp
, whichfork
) /
1044 sizeof(xfs_bmbt_rec_t
)) {
1046 _("extent count for ino %" PRIu64
" %s fork too low (%" PRIu64
") for file format\n"),
1047 lino
, forkname
, *nex
);
1051 * Check that the last child block's forward sibling pointer
1054 if (check_dups
== 0 &&
1055 cursor
.level
[0].right_fsbno
!= NULLFSBLOCK
) {
1057 _("bad fwd (right) sibling pointer (saw %" PRIu64
" should be NULLFSBLOCK)\n"),
1058 cursor
.level
[0].right_fsbno
);
1060 _("\tin inode %" PRIu64
" (%s fork) bmap btree block %" PRIu64
"\n"),
1061 XFS_AGINO_TO_INO(mp
, agno
, ino
), forkname
,
1062 cursor
.level
[0].fsbno
);
1070 * return 1 if inode should be cleared, 0 otherwise
1075 xfs_agnumber_t agno
,
1080 xfs_rfsblock_t
*tot
,
1088 xfs_fileoff_t first_key
;
1089 xfs_fileoff_t last_key
;
1093 lino
= XFS_AGINO_TO_INO(mp
, agno
, ino
);
1094 rp
= (xfs_bmbt_rec_t
*)XFS_DFORK_PTR(dip
, whichfork
);
1096 numrecs
= XFS_DFORK_NEXTENTS(dip
, whichfork
);
1099 * We've already decided on the maximum number of extents on the inode,
1100 * and numrecs may be corrupt. Hence make sure we only allow numrecs to
1101 * be in the range of valid on-disk numbers, which is:
1102 * 0 < numrecs < 2^31 - 1
1108 * XXX - if we were going to fix up the btree record,
1109 * we'd do it right here. For now, if there's a problem,
1110 * we'll bail out and presumably clear the inode.
1112 if (check_dups
== 0)
1113 ret
= process_bmbt_reclist(mp
, rp
, &numrecs
, type
, lino
,
1114 tot
, blkmapp
, &first_key
, &last_key
,
1117 ret
= scan_bmbt_reclist(mp
, rp
, &numrecs
, type
, lino
, tot
,
1125 * return 1 if inode should be cleared, 0 otherwise
1130 xfs_agnumber_t agno
,
1135 xfs_attr_shortform_t
*asf
;
1138 lino
= XFS_AGINO_TO_INO(mp
, agno
, ino
);
1139 if (whichfork
== XFS_DATA_FORK
&& be64_to_cpu(dip
->di_size
) >
1140 XFS_DFORK_DSIZE(dip
, mp
)) {
1142 _("local inode %" PRIu64
" data fork is too large (size = %lld, max = %d)\n"),
1143 lino
, (unsigned long long) be64_to_cpu(dip
->di_size
),
1144 XFS_DFORK_DSIZE(dip
, mp
));
1146 } else if (whichfork
== XFS_ATTR_FORK
) {
1147 asf
= (xfs_attr_shortform_t
*)XFS_DFORK_APTR(dip
);
1148 if (be16_to_cpu(asf
->hdr
.totsize
) > XFS_DFORK_ASIZE(dip
, mp
)) {
1150 _("local inode %" PRIu64
" attr fork too large (size %d, max = %d)\n"),
1151 lino
, be16_to_cpu(asf
->hdr
.totsize
),
1152 XFS_DFORK_ASIZE(dip
, mp
));
1155 if (be16_to_cpu(asf
->hdr
.totsize
) < sizeof(xfs_attr_sf_hdr_t
)) {
1157 _("local inode %" PRIu64
" attr too small (size = %d, min size = %zd)\n"),
1158 lino
, be16_to_cpu(asf
->hdr
.totsize
),
1159 sizeof(xfs_attr_sf_hdr_t
));
1168 process_symlink_extlist(xfs_mount_t
*mp
, xfs_ino_t lino
, xfs_dinode_t
*dino
)
1170 xfs_fileoff_t expected_offset
;
1172 xfs_bmbt_irec_t irec
;
1177 if (be64_to_cpu(dino
->di_size
) <= XFS_DFORK_DSIZE(dino
, mp
)) {
1178 if (dino
->di_format
== XFS_DINODE_FMT_LOCAL
)
1181 _("mismatch between format (%d) and size (%" PRId64
") in symlink ino %" PRIu64
"\n"),
1183 (__int64_t
)be64_to_cpu(dino
->di_size
), lino
);
1186 if (dino
->di_format
== XFS_DINODE_FMT_LOCAL
) {
1188 _("mismatch between format (%d) and size (%" PRId64
") in symlink inode %" PRIu64
"\n"),
1190 (__int64_t
)be64_to_cpu(dino
->di_size
), lino
);
1194 rp
= (xfs_bmbt_rec_t
*)XFS_DFORK_DPTR(dino
);
1195 numrecs
= be32_to_cpu(dino
->di_nextents
);
1198 * the max # of extents in a symlink inode is equal to the
1199 * number of max # of blocks required to store the symlink
1201 if (numrecs
> max_symlink_blocks
) {
1203 _("bad number of extents (%d) in symlink %" PRIu64
" data fork\n"),
1208 max_blocks
= max_symlink_blocks
;
1209 expected_offset
= 0;
1211 for (i
= 0; i
< numrecs
; i
++) {
1212 libxfs_bmbt_disk_get_all((rp
+i
), &irec
);
1213 if (irec
.br_startoff
!= expected_offset
) {
1215 _("bad extent #%d offset (%" PRIu64
") in symlink %" PRIu64
" data fork\n"),
1216 i
, irec
.br_startoff
, lino
);
1219 if (irec
.br_blockcount
== 0 || irec
.br_blockcount
> max_blocks
) {
1221 _("bad extent #%d count (%" PRIu64
") in symlink %" PRIu64
" data fork\n"),
1222 i
, irec
.br_blockcount
, lino
);
1226 max_blocks
-= irec
.br_blockcount
;
1227 expected_offset
+= irec
.br_blockcount
;
1234 * takes a name and length and returns 1 if the name contains
1235 * a \0, returns 0 otherwise
1238 null_check(char *name
, int length
)
1242 ASSERT(length
< MAXPATHLEN
);
1244 for (i
= 0; i
< length
; i
++, name
++) {
1253 process_symlink_remote(
1254 struct xfs_mount
*mp
,
1256 struct xfs_dinode
*dino
,
1257 struct blkmap
*blkmap
,
1260 xfs_fsblock_t fsbno
;
1268 pathlen
= be64_to_cpu(dino
->di_size
);
1271 while (pathlen
> 0) {
1276 fsbno
= blkmap_get(blkmap
, i
);
1277 if (fsbno
== NULLFSBLOCK
) {
1279 _("cannot read inode %" PRIu64
", file block %d, NULL disk block\n"),
1285 * There's a symlink header for each contiguous extent. If
1286 * there are contiguous blocks, read them in one go.
1288 while (blk_cnt
<= max_symlink_blocks
) {
1289 if (blkmap_get(blkmap
, i
+ 1) != fsbno
+ 1)
1295 byte_cnt
= XFS_FSB_TO_B(mp
, blk_cnt
);
1297 bp
= libxfs_readbuf(mp
->m_dev
, XFS_FSB_TO_DADDR(mp
, fsbno
),
1298 BTOBB(byte_cnt
), 0, &xfs_symlink_buf_ops
);
1301 _("cannot read inode %" PRIu64
", file block %d, disk block %" PRIu64
"\n"),
1305 if (bp
->b_error
== -EFSBADCRC
) {
1307 _("Bad symlink buffer CRC, block %" PRIu64
", inode %" PRIu64
".\n"
1308 "Correcting CRC, but symlink may be bad.\n"), fsbno
, lino
);
1312 byte_cnt
= XFS_SYMLINK_BUF_SPACE(mp
, byte_cnt
);
1313 byte_cnt
= MIN(pathlen
, byte_cnt
);
1316 if (xfs_sb_version_hascrc(&mp
->m_sb
)) {
1317 if (!libxfs_symlink_hdr_ok(lino
, offset
,
1320 _("bad symlink header ino %" PRIu64
", file block %d, disk block %" PRIu64
"\n"),
1325 src
+= sizeof(struct xfs_dsymlink_hdr
);
1328 memmove(dst
+ offset
, src
, byte_cnt
);
1330 pathlen
-= byte_cnt
;
1334 if (badcrc
&& !no_modify
)
1335 libxfs_writebuf(bp
, 0);
1343 * like usual, returns 0 if everything's ok and 1 if something's
1354 char data
[MAXPATHLEN
];
1357 * check size against kernel symlink limits. we know
1358 * size is consistent with inode storage format -- e.g.
1359 * the inode is structurally ok so we don't have to check
1362 if (be64_to_cpu(dino
->di_size
) >= MAXPATHLEN
) {
1363 do_warn(_("symlink in inode %" PRIu64
" too long (%llu chars)\n"),
1364 lino
, (unsigned long long) be64_to_cpu(dino
->di_size
));
1369 * have to check symlink component by component.
1370 * get symlink contents into data area
1373 if (be64_to_cpu(dino
->di_size
) <= XFS_DFORK_DSIZE(dino
, mp
)) {
1375 * local symlink, just copy the symlink out of the
1376 * inode into the data area
1378 memmove(symlink
, XFS_DFORK_DPTR(dino
),
1379 be64_to_cpu(dino
->di_size
));
1383 error
= process_symlink_remote(mp
, lino
, dino
, blkmap
, symlink
);
1388 data
[be64_to_cpu(dino
->di_size
)] = '\0';
1393 if (null_check(symlink
, be64_to_cpu(dino
->di_size
))) {
1395 _("found illegal null character in symlink inode %" PRIu64
"\n"),
1404 * called to process the set of misc inode special inode types
1405 * that have no associated data storage (fifos, pipes, devices, etc.).
1408 process_misc_ino_types(xfs_mount_t
*mp
,
1414 * disallow mountpoint inodes until such time as the
1415 * kernel actually allows them to be created (will
1416 * probably require a superblock version rev, sigh).
1418 if (type
== XR_INO_MOUNTPOINT
) {
1420 _("inode %" PRIu64
" has bad inode type (IFMNT)\n"), lino
);
1425 * must also have a zero size
1427 if (be64_to_cpu(dino
->di_size
) != 0) {
1431 _("size of character device inode %" PRIu64
" != 0 (%" PRId64
" bytes)\n"), lino
,
1432 (__int64_t
)be64_to_cpu(dino
->di_size
));
1436 _("size of block device inode %" PRIu64
" != 0 (%" PRId64
" bytes)\n"), lino
,
1437 (__int64_t
)be64_to_cpu(dino
->di_size
));
1441 _("size of socket inode %" PRIu64
" != 0 (%" PRId64
" bytes)\n"), lino
,
1442 (__int64_t
)be64_to_cpu(dino
->di_size
));
1446 _("size of fifo inode %" PRIu64
" != 0 (%" PRId64
" bytes)\n"), lino
,
1447 (__int64_t
)be64_to_cpu(dino
->di_size
));
1450 do_warn(_("Internal error - process_misc_ino_types, "
1451 "illegal type %d\n"), type
);
1462 process_misc_ino_types_blocks(xfs_rfsblock_t totblocks
, xfs_ino_t lino
, int type
)
1465 * you can not enforce all misc types have zero data fork blocks
1466 * by checking dino->di_nblocks because atotblocks (attribute
1467 * blocks) are part of nblocks. We must check this later when atotblocks
1468 * has been calculated or by doing a simple check that anExtents == 0.
1469 * We must also guarantee that totblocks is 0. Thus nblocks checking
1470 * will be done later in process_dinode_int for misc types.
1473 if (totblocks
!= 0) {
1477 _("size of character device inode %" PRIu64
" != 0 (%" PRIu64
" blocks)\n"),
1482 _("size of block device inode %" PRIu64
" != 0 (%" PRIu64
" blocks)\n"),
1487 _("size of socket inode %" PRIu64
" != 0 (%" PRIu64
" blocks)\n"),
1492 _("size of fifo inode %" PRIu64
" != 0 (%" PRIu64
" blocks)\n"),
1507 return be16_to_cpu(dino
->di_mode
) & S_IFMT
;
1515 int mode
= be16_to_cpu(dino
->di_mode
);
1517 ASSERT((new_fmt
& ~S_IFMT
) == 0);
1521 dino
->di_mode
= cpu_to_be16(mode
);
1525 check_dinode_mode_format(
1526 xfs_dinode_t
*dinoc
)
1528 if (dinoc
->di_format
>= XFS_DINODE_FMT_UUID
)
1529 return -1; /* FMT_UUID is not used */
1531 switch (dinode_fmt(dinoc
)) {
1536 return (dinoc
->di_format
!= XFS_DINODE_FMT_DEV
) ? -1 : 0;
1539 return (dinoc
->di_format
< XFS_DINODE_FMT_LOCAL
||
1540 dinoc
->di_format
> XFS_DINODE_FMT_BTREE
) ? -1 : 0;
1543 return (dinoc
->di_format
< XFS_DINODE_FMT_EXTENTS
||
1544 dinoc
->di_format
> XFS_DINODE_FMT_BTREE
) ? -1 : 0;
1547 return (dinoc
->di_format
< XFS_DINODE_FMT_LOCAL
||
1548 dinoc
->di_format
> XFS_DINODE_FMT_EXTENTS
) ? -1 : 0;
1552 return 0; /* invalid modes are checked elsewhere */
1556 * If inode is a superblock inode, does type check to make sure is it valid.
1557 * Returns 0 if it's valid, non-zero if it needs to be cleared.
1561 process_check_sb_inodes(
1563 xfs_dinode_t
*dinoc
,
1568 if (lino
== mp
->m_sb
.sb_rootino
) {
1569 if (*type
!= XR_INO_DIR
) {
1570 do_warn(_("root inode %" PRIu64
" has bad type 0x%x\n"),
1571 lino
, dinode_fmt(dinoc
));
1574 do_warn(_("resetting to directory\n"));
1575 change_dinode_fmt(dinoc
, S_IFDIR
);
1578 do_warn(_("would reset to directory\n"));
1582 if (lino
== mp
->m_sb
.sb_uquotino
) {
1583 if (*type
!= XR_INO_DATA
) {
1584 do_warn(_("user quota inode %" PRIu64
" has bad type 0x%x\n"),
1585 lino
, dinode_fmt(dinoc
));
1586 mp
->m_sb
.sb_uquotino
= NULLFSINO
;
1591 if (lino
== mp
->m_sb
.sb_gquotino
) {
1592 if (*type
!= XR_INO_DATA
) {
1593 do_warn(_("group quota inode %" PRIu64
" has bad type 0x%x\n"),
1594 lino
, dinode_fmt(dinoc
));
1595 mp
->m_sb
.sb_gquotino
= NULLFSINO
;
1600 if (lino
== mp
->m_sb
.sb_pquotino
) {
1601 if (*type
!= XR_INO_DATA
) {
1602 do_warn(_("project quota inode %" PRIu64
" has bad type 0x%x\n"),
1603 lino
, dinode_fmt(dinoc
));
1604 mp
->m_sb
.sb_pquotino
= NULLFSINO
;
1609 if (lino
== mp
->m_sb
.sb_rsumino
) {
1610 if (*type
!= XR_INO_RTSUM
) {
1612 _("realtime summary inode %" PRIu64
" has bad type 0x%x, "),
1613 lino
, dinode_fmt(dinoc
));
1615 do_warn(_("resetting to regular file\n"));
1616 change_dinode_fmt(dinoc
, S_IFREG
);
1619 do_warn(_("would reset to regular file\n"));
1622 if (mp
->m_sb
.sb_rblocks
== 0 && dinoc
->di_nextents
!= 0) {
1624 _("bad # of extents (%u) for realtime summary inode %" PRIu64
"\n"),
1625 be32_to_cpu(dinoc
->di_nextents
), lino
);
1630 if (lino
== mp
->m_sb
.sb_rbmino
) {
1631 if (*type
!= XR_INO_RTBITMAP
) {
1633 _("realtime bitmap inode %" PRIu64
" has bad type 0x%x, "),
1634 lino
, dinode_fmt(dinoc
));
1636 do_warn(_("resetting to regular file\n"));
1637 change_dinode_fmt(dinoc
, S_IFREG
);
1640 do_warn(_("would reset to regular file\n"));
1643 if (mp
->m_sb
.sb_rblocks
== 0 && dinoc
->di_nextents
!= 0) {
1645 _("bad # of extents (%u) for realtime bitmap inode %" PRIu64
"\n"),
1646 be32_to_cpu(dinoc
->di_nextents
), lino
);
1655 * general size/consistency checks:
1657 * if the size <= size of the data fork, directories must be
1658 * local inodes unlike regular files which would be extent inodes.
1659 * all the other mentioned types have to have a zero size value.
1661 * if the size and format don't match, get out now rather than
1662 * risk trying to process a non-existent extents or btree
1666 process_check_inode_sizes(
1672 xfs_fsize_t size
= be64_to_cpu(dino
->di_size
);
1677 if (size
<= XFS_DFORK_DSIZE(dino
, mp
) &&
1678 dino
->di_format
!= XFS_DINODE_FMT_LOCAL
) {
1680 _("mismatch between format (%d) and size (%" PRId64
") in directory ino %" PRIu64
"\n"),
1681 dino
->di_format
, size
, lino
);
1684 if (size
> XFS_DIR2_LEAF_OFFSET
) {
1686 _("directory inode %" PRIu64
" has bad size %" PRId64
"\n"),
1692 case XR_INO_SYMLINK
:
1693 if (process_symlink_extlist(mp
, lino
, dino
)) {
1694 do_warn(_("bad data fork in symlink %" PRIu64
"\n"), lino
);
1699 case XR_INO_CHRDEV
: /* fall through to FIFO case ... */
1700 case XR_INO_BLKDEV
: /* fall through to FIFO case ... */
1701 case XR_INO_SOCK
: /* fall through to FIFO case ... */
1702 case XR_INO_MOUNTPOINT
: /* fall through to FIFO case ... */
1704 if (process_misc_ino_types(mp
, dino
, lino
, type
))
1710 * if we have no realtime blocks, any inode claiming
1711 * to be a real-time file is bogus
1713 if (mp
->m_sb
.sb_rblocks
== 0) {
1715 _("found inode %" PRIu64
" claiming to be a real-time file\n"), lino
);
1720 case XR_INO_RTBITMAP
:
1721 if (size
!= (__int64_t
)mp
->m_sb
.sb_rbmblocks
*
1722 mp
->m_sb
.sb_blocksize
) {
1724 _("realtime bitmap inode %" PRIu64
" has bad size %" PRId64
" (should be %" PRIu64
")\n"),
1726 (__int64_t
) mp
->m_sb
.sb_rbmblocks
*
1727 mp
->m_sb
.sb_blocksize
);
1733 if (size
!= mp
->m_rsumsize
) {
1735 _("realtime summary inode %" PRIu64
" has bad size %" PRId64
" (should be %d)\n"),
1736 lino
, size
, mp
->m_rsumsize
);
1748 * check for illegal values of forkoff
1751 process_check_inode_forkoff(
1756 if (dino
->di_forkoff
== 0)
1759 switch (dino
->di_format
) {
1760 case XFS_DINODE_FMT_DEV
:
1761 if (dino
->di_forkoff
!= (roundup(sizeof(xfs_dev_t
), 8) >> 3)) {
1763 _("bad attr fork offset %d in dev inode %" PRIu64
", should be %d\n"),
1764 dino
->di_forkoff
, lino
,
1765 (int)(roundup(sizeof(xfs_dev_t
), 8) >> 3));
1769 case XFS_DINODE_FMT_LOCAL
: /* fall through ... */
1770 case XFS_DINODE_FMT_EXTENTS
: /* fall through ... */
1771 case XFS_DINODE_FMT_BTREE
:
1772 if (dino
->di_forkoff
>=
1773 (XFS_LITINO(mp
, dino
->di_version
) >> 3)) {
1775 _("bad attr fork offset %d in inode %" PRIu64
", max=%d\n"),
1776 dino
->di_forkoff
, lino
,
1777 XFS_LITINO(mp
, dino
->di_version
) >> 3);
1782 do_error(_("unexpected inode format %d\n"), dino
->di_format
);
1789 * Updates the inodes block and extent counts if they are wrong
1792 process_inode_blocks_and_extents(
1794 xfs_rfsblock_t nblocks
,
1795 __uint64_t nextents
,
1796 __uint64_t anextents
,
1800 if (nblocks
!= be64_to_cpu(dino
->di_nblocks
)) {
1803 _("correcting nblocks for inode %" PRIu64
", was %llu - counted %" PRIu64
"\n"), lino
,
1804 (unsigned long long) be64_to_cpu(dino
->di_nblocks
),
1806 dino
->di_nblocks
= cpu_to_be64(nblocks
);
1810 _("bad nblocks %llu for inode %" PRIu64
", would reset to %" PRIu64
"\n"),
1811 (unsigned long long) be64_to_cpu(dino
->di_nblocks
),
1816 if (nextents
> MAXEXTNUM
) {
1818 _("too many data fork extents (%" PRIu64
") in inode %" PRIu64
"\n"),
1822 if (nextents
!= be32_to_cpu(dino
->di_nextents
)) {
1825 _("correcting nextents for inode %" PRIu64
", was %d - counted %" PRIu64
"\n"),
1827 be32_to_cpu(dino
->di_nextents
),
1829 dino
->di_nextents
= cpu_to_be32(nextents
);
1833 _("bad nextents %d for inode %" PRIu64
", would reset to %" PRIu64
"\n"),
1834 be32_to_cpu(dino
->di_nextents
),
1839 if (anextents
> MAXAEXTNUM
) {
1841 _("too many attr fork extents (%" PRIu64
") in inode %" PRIu64
"\n"),
1845 if (anextents
!= be16_to_cpu(dino
->di_anextents
)) {
1848 _("correcting anextents for inode %" PRIu64
", was %d - counted %" PRIu64
"\n"),
1850 be16_to_cpu(dino
->di_anextents
), anextents
);
1851 dino
->di_anextents
= cpu_to_be16(anextents
);
1855 _("bad anextents %d for inode %" PRIu64
", would reset to %" PRIu64
"\n"),
1856 be16_to_cpu(dino
->di_anextents
),
1862 * We are comparing different units here, but that's fine given that
1863 * an extent has to have at least a block in it.
1865 if (nblocks
< nextents
+ anextents
) {
1867 _("nblocks (%" PRIu64
") smaller than nextents for inode %" PRIu64
"\n"), nblocks
, lino
);
1875 * check data fork -- if it's bad, clear the inode
1878 process_inode_data_fork(
1880 xfs_agnumber_t agno
,
1885 xfs_rfsblock_t
*totblocks
,
1886 __uint64_t
*nextents
,
1890 xfs_ino_t lino
= XFS_AGINO_TO_INO(mp
, agno
, ino
);
1895 * extent count on disk is only valid for positive values. The kernel
1896 * uses negative values in memory. hence if we see negative numbers
1899 nex
= be32_to_cpu(dino
->di_nextents
);
1905 if (*nextents
> be64_to_cpu(dino
->di_nblocks
))
1909 if (dino
->di_format
!= XFS_DINODE_FMT_LOCAL
&& type
!= XR_INO_RTDATA
)
1910 *dblkmap
= blkmap_alloc(*nextents
, XFS_DATA_FORK
);
1913 switch (dino
->di_format
) {
1914 case XFS_DINODE_FMT_LOCAL
:
1915 err
= process_lclinode(mp
, agno
, ino
, dino
, XFS_DATA_FORK
);
1918 case XFS_DINODE_FMT_EXTENTS
:
1919 err
= process_exinode(mp
, agno
, ino
, dino
, type
, dirty
,
1920 totblocks
, nextents
, dblkmap
, XFS_DATA_FORK
,
1923 case XFS_DINODE_FMT_BTREE
:
1924 err
= process_btinode(mp
, agno
, ino
, dino
, type
, dirty
,
1925 totblocks
, nextents
, dblkmap
, XFS_DATA_FORK
,
1928 case XFS_DINODE_FMT_DEV
: /* fall through */
1932 do_error(_("unknown format %d, ino %" PRIu64
" (mode = %d)\n"),
1933 dino
->di_format
, lino
, be16_to_cpu(dino
->di_mode
));
1937 do_warn(_("bad data fork in inode %" PRIu64
"\n"), lino
);
1939 *dirty
+= clear_dinode(mp
, dino
, lino
);
1947 * if check_dups was non-zero, we have to
1948 * re-process data fork to set bitmap since the
1949 * bitmap wasn't set the first time through
1951 switch (dino
->di_format
) {
1952 case XFS_DINODE_FMT_LOCAL
:
1953 err
= process_lclinode(mp
, agno
, ino
, dino
,
1956 case XFS_DINODE_FMT_EXTENTS
:
1957 err
= process_exinode(mp
, agno
, ino
, dino
, type
,
1958 dirty
, totblocks
, nextents
, dblkmap
,
1961 case XFS_DINODE_FMT_BTREE
:
1962 err
= process_btinode(mp
, agno
, ino
, dino
, type
,
1963 dirty
, totblocks
, nextents
, dblkmap
,
1966 case XFS_DINODE_FMT_DEV
: /* fall through */
1970 do_error(_("unknown format %d, ino %" PRIu64
" (mode = %d)\n"),
1971 dino
->di_format
, lino
,
1972 be16_to_cpu(dino
->di_mode
));
1975 if (no_modify
&& err
!= 0)
1984 * Process extended attribute fork in inode
1987 process_inode_attr_fork(
1989 xfs_agnumber_t agno
,
1994 xfs_rfsblock_t
*atotblocks
,
1995 __uint64_t
*anextents
,
1997 int extra_attr_check
,
2000 xfs_ino_t lino
= XFS_AGINO_TO_INO(mp
, agno
, ino
);
2001 blkmap_t
*ablkmap
= NULL
;
2005 if (!XFS_DFORK_Q(dino
)) {
2007 if (dino
->di_aformat
!= XFS_DINODE_FMT_EXTENTS
) {
2008 do_warn(_("bad attribute format %d in inode %" PRIu64
", "),
2009 dino
->di_aformat
, lino
);
2011 do_warn(_("resetting value\n"));
2012 dino
->di_aformat
= XFS_DINODE_FMT_EXTENTS
;
2015 do_warn(_("would reset value\n"));
2020 *anextents
= be16_to_cpu(dino
->di_anextents
);
2021 if (*anextents
> be64_to_cpu(dino
->di_nblocks
))
2024 switch (dino
->di_aformat
) {
2025 case XFS_DINODE_FMT_LOCAL
:
2028 err
= process_lclinode(mp
, agno
, ino
, dino
, XFS_ATTR_FORK
);
2030 case XFS_DINODE_FMT_EXTENTS
:
2031 ablkmap
= blkmap_alloc(*anextents
, XFS_ATTR_FORK
);
2033 err
= process_exinode(mp
, agno
, ino
, dino
, type
, dirty
,
2034 atotblocks
, anextents
, &ablkmap
,
2035 XFS_ATTR_FORK
, check_dups
);
2037 case XFS_DINODE_FMT_BTREE
:
2038 ablkmap
= blkmap_alloc(*anextents
, XFS_ATTR_FORK
);
2040 err
= process_btinode(mp
, agno
, ino
, dino
, type
, dirty
,
2041 atotblocks
, anextents
, &ablkmap
,
2042 XFS_ATTR_FORK
, check_dups
);
2045 do_warn(_("illegal attribute format %d, ino %" PRIu64
"\n"),
2046 dino
->di_aformat
, lino
);
2053 * clear the attribute fork if necessary. we can't
2054 * clear the inode because we've already put the
2055 * inode space info into the blockmap.
2057 * XXX - put the inode onto the "move it" list and
2058 * log the the attribute scrubbing
2060 do_warn(_("bad attribute fork in inode %" PRIu64
), lino
);
2063 if (delete_attr_ok
) {
2064 do_warn(_(", clearing attr fork\n"));
2065 *dirty
+= clear_dinode_attr(mp
, dino
, lino
);
2066 dino
->di_aformat
= XFS_DINODE_FMT_LOCAL
;
2069 *dirty
+= clear_dinode(mp
, dino
, lino
);
2073 do_warn(_(", would clear attr fork\n"));
2078 blkmap_free(ablkmap
);
2081 return delete_attr_ok
? 0 : 1;
2085 switch (dino
->di_aformat
) {
2086 case XFS_DINODE_FMT_LOCAL
:
2087 err
= process_lclinode(mp
, agno
, ino
, dino
,
2090 case XFS_DINODE_FMT_EXTENTS
:
2091 err
= process_exinode(mp
, agno
, ino
, dino
,
2092 type
, dirty
, atotblocks
, anextents
,
2093 &ablkmap
, XFS_ATTR_FORK
, 0);
2095 case XFS_DINODE_FMT_BTREE
:
2096 err
= process_btinode(mp
, agno
, ino
, dino
,
2097 type
, dirty
, atotblocks
, anextents
,
2098 &ablkmap
, XFS_ATTR_FORK
, 0);
2101 do_error(_("illegal attribute fmt %d, ino %" PRIu64
"\n"),
2102 dino
->di_aformat
, lino
);
2105 if (no_modify
&& err
!= 0) {
2106 blkmap_free(ablkmap
);
2114 * do attribute semantic-based consistency checks now
2117 /* get this only in phase 3, not in both phase 3 and 4 */
2118 if (extra_attr_check
&&
2119 process_attributes(mp
, lino
, dino
, ablkmap
, &repair
)) {
2121 _("problem with attribute contents in inode %" PRIu64
"\n"),
2124 /* clear attributes if not done already */
2126 *dirty
+= clear_dinode_attr(mp
, dino
, lino
);
2127 dino
->di_aformat
= XFS_DINODE_FMT_LOCAL
;
2129 do_warn(_("would clear attr fork\n"));
2135 *dirty
= 1; /* it's been repaired */
2138 blkmap_free(ablkmap
);
2143 * check nlinks feature, if it's a version 1 inode,
2144 * just leave nlinks alone. even if it's set wrong,
2145 * it'll be reset when read in.
2149 process_check_inode_nlink_version(
2156 * if it's a version 2 inode, it should have a zero
2157 * onlink field, so clear it.
2159 if (dino
->di_version
> 1 && dino
->di_onlink
!= 0) {
2162 _("clearing obsolete nlink field in version 2 inode %" PRIu64
", was %d, now 0\n"),
2163 lino
, be16_to_cpu(dino
->di_onlink
));
2164 dino
->di_onlink
= 0;
2168 _("would clear obsolete nlink field in version 2 inode %" PRIu64
", currently %d\n"),
2169 lino
, be16_to_cpu(dino
->di_onlink
));
2176 * returns 0 if the inode is ok, 1 if the inode is corrupt
2177 * check_dups can be set to 1 *only* when called by the
2178 * first pass of the duplicate block checking of phase 4.
2179 * *dirty is set > 0 if the dinode has been altered and
2180 * needs to be written out.
2182 * for detailed, info, look at process_dinode() comments.
2185 process_dinode_int(xfs_mount_t
*mp
,
2187 xfs_agnumber_t agno
,
2189 int was_free
, /* 1 if inode is currently free */
2190 int *dirty
, /* out == > 0 if inode is now dirty */
2191 int *used
, /* out == 1 if inode is in use */
2192 int verify_mode
, /* 1 == verify but don't modify inode */
2193 int uncertain
, /* 1 == inode is uncertain */
2194 int ino_discovery
, /* 1 == check dirs for unknown inodes */
2195 int check_dups
, /* 1 == check if inode claims
2196 * duplicate blocks */
2197 int extra_attr_check
, /* 1 == do attribute format and value checks */
2198 int *isa_dir
, /* out == 1 if inode is a directory */
2199 xfs_ino_t
*parent
) /* out -- parent if ino is a dir */
2201 xfs_rfsblock_t totblocks
= 0;
2202 xfs_rfsblock_t atotblocks
= 0;
2206 __uint64_t nextents
;
2207 __uint64_t anextents
;
2209 const int is_free
= 0;
2210 const int is_used
= 1;
2211 blkmap_t
*dblkmap
= NULL
;
2213 *dirty
= *isa_dir
= 0;
2215 type
= XR_INO_UNKNOWN
;
2217 lino
= XFS_AGINO_TO_INO(mp
, agno
, ino
);
2218 di_mode
= be16_to_cpu(dino
->di_mode
);
2221 * if in verify mode, don't modify the inode.
2223 * if correcting, reset stuff that has known values
2225 * if in uncertain mode, be silent on errors since we're
2226 * trying to find out if these are inodes as opposed
2227 * to assuming that they are. Just return the appropriate
2228 * return code in that case.
2230 * If uncertain is set, verify_mode MUST be set.
2232 ASSERT(uncertain
== 0 || verify_mode
!= 0);
2235 * This is the only valid point to check the CRC; after this we may have
2236 * made changes which invalidate it, and the CRC is only updated again
2237 * when it gets written out.
2239 * Of course if we make any modifications after this, the inode gets
2240 * rewritten, and the CRC is updated automagically.
2242 if (xfs_sb_version_hascrc(&mp
->m_sb
) &&
2243 !libxfs_verify_cksum((char *)dino
, mp
->m_sb
.sb_inodesize
,
2244 XFS_DINODE_CRC_OFF
)) {
2247 do_warn(_("bad CRC for inode %" PRIu64
"%c"),
2248 lino
, verify_mode
? '\n' : ',');
2251 do_warn(_(" will rewrite\n"));
2254 do_warn(_(" would rewrite\n"));
2258 if (be16_to_cpu(dino
->di_magic
) != XFS_DINODE_MAGIC
) {
2261 do_warn(_("bad magic number 0x%x on inode %" PRIu64
"%c"),
2262 be16_to_cpu(dino
->di_magic
), lino
,
2263 verify_mode
? '\n' : ',');
2266 do_warn(_(" resetting magic number\n"));
2267 dino
->di_magic
= cpu_to_be16(XFS_DINODE_MAGIC
);
2270 do_warn(_(" would reset magic number\n"));
2274 if (!libxfs_dinode_good_version(mp
, dino
->di_version
)) {
2277 do_warn(_("bad version number 0x%x on inode %" PRIu64
"%c"),
2278 (__s8
)dino
->di_version
, lino
,
2279 verify_mode
? '\n' : ',');
2282 do_warn(_(" resetting version number\n"));
2284 xfs_sb_version_hascrc(&mp
->m_sb
) ? 3 : 2;
2287 do_warn(_(" would reset version number\n"));
2292 * We don't bother checking the CRC here - we cannot guarantee that when
2293 * we are called here that the inode has not already been modified in
2294 * memory and hence invalidated the CRC.
2296 if (xfs_sb_version_hascrc(&mp
->m_sb
)) {
2297 if (be64_to_cpu(dino
->di_ino
) != lino
) {
2300 _("inode identifier %llu mismatch on inode %" PRIu64
"\n"),
2301 be64_to_cpu(dino
->di_ino
), lino
);
2306 if (platform_uuid_compare(&dino
->di_uuid
,
2307 &mp
->m_sb
.sb_meta_uuid
)) {
2310 _("UUID mismatch on inode %" PRIu64
"\n"), lino
);
2318 * blow out of here if the inode size is < 0
2320 if ((xfs_fsize_t
)be64_to_cpu(dino
->di_size
) < 0) {
2323 _("bad (negative) size %" PRId64
" on inode %" PRIu64
"\n"),
2324 (__int64_t
)be64_to_cpu(dino
->di_size
),
2332 * if not in verify mode, check to sii if the inode and imap
2333 * agree that the inode is free
2335 if (!verify_mode
&& di_mode
== 0) {
2337 * was_free value is not meaningful if we're in verify mode
2341 * easy case, inode free -- inode and map agree, clear
2342 * it just in case to ensure that format, etc. are
2346 *dirty
+= clear_dinode(mp
, dino
, lino
);
2351 * the inode looks free but the map says it's in use.
2352 * clear the inode just to be safe and mark the inode
2356 _("imap claims a free inode %" PRIu64
" is in use, "), lino
);
2358 do_warn(_("correcting imap and clearing inode\n"));
2359 *dirty
+= clear_dinode(mp
, dino
, lino
);
2362 do_warn(_("would correct imap and clear inode\n"));
2368 * because of the lack of any write ordering guarantee, it's
2369 * possible that the core got updated but the forks didn't.
2370 * so rather than be ambitious (and probably incorrect),
2371 * if there's an inconsistency, we get conservative and
2372 * just pitch the file. blow off checking formats of
2373 * free inodes since technically any format is legal
2374 * as we reset the inode when we re-use it.
2376 if (di_mode
!= 0 && check_dinode_mode_format(dino
) != 0) {
2379 _("bad inode format in inode %" PRIu64
"\n"), lino
);
2386 * check that we only have valid flags set, and those that are set make
2389 if (dino
->di_flags
) {
2390 uint16_t flags
= be16_to_cpu(dino
->di_flags
);
2392 if (flags
& ~XFS_DIFLAG_ANY
) {
2395 _("Bad flags set in inode %" PRIu64
"\n"),
2398 flags
&= XFS_DIFLAG_ANY
;
2401 if (flags
& (XFS_DIFLAG_REALTIME
| XFS_DIFLAG_RTINHERIT
)) {
2402 /* need an rt-dev! */
2406 _("inode %" PRIu64
" has RT flag set but there is no RT device\n"),
2409 flags
&= ~(XFS_DIFLAG_REALTIME
|
2410 XFS_DIFLAG_RTINHERIT
);
2413 if (flags
& XFS_DIFLAG_NEWRTBM
) {
2414 /* must be a rt bitmap inode */
2415 if (lino
!= mp
->m_sb
.sb_rbmino
) {
2418 _("inode %" PRIu64
" not rt bitmap\n"),
2421 flags
&= ~XFS_DIFLAG_NEWRTBM
;
2424 if (flags
& (XFS_DIFLAG_RTINHERIT
|
2425 XFS_DIFLAG_EXTSZINHERIT
|
2426 XFS_DIFLAG_PROJINHERIT
|
2427 XFS_DIFLAG_NOSYMLINKS
)) {
2428 /* must be a directory */
2429 if (di_mode
&& !S_ISDIR(di_mode
)) {
2432 _("directory flags set on non-directory inode %" PRIu64
"\n" ),
2435 flags
&= ~(XFS_DIFLAG_RTINHERIT
|
2436 XFS_DIFLAG_EXTSZINHERIT
|
2437 XFS_DIFLAG_PROJINHERIT
|
2438 XFS_DIFLAG_NOSYMLINKS
);
2441 if (flags
& (XFS_DIFLAG_REALTIME
| FS_XFLAG_EXTSIZE
)) {
2442 /* must be a file */
2443 if (di_mode
&& !S_ISREG(di_mode
)) {
2446 _("file flags set on non-file inode %" PRIu64
"\n"),
2449 flags
&= ~(XFS_DIFLAG_REALTIME
|
2453 if (!verify_mode
&& flags
!= be16_to_cpu(dino
->di_flags
)) {
2455 do_warn(_("fixing bad flags.\n"));
2456 dino
->di_flags
= cpu_to_be16(flags
);
2459 do_warn(_("would fix bad flags.\n"));
2467 * clear the next unlinked field if necessary on a good
2468 * inode only during phase 4 -- when checking for inodes
2469 * referencing duplicate blocks. then it's safe because
2470 * we've done the inode discovery and have found all the inodes
2471 * we're going to find. check_dups is set to 1 only during
2474 if (check_dups
&& !no_modify
)
2475 *dirty
+= clear_dinode_unlinked(mp
, dino
);
2477 /* set type and map type info */
2479 switch (di_mode
& S_IFMT
) {
2485 if (be16_to_cpu(dino
->di_flags
) & XFS_DIFLAG_REALTIME
)
2486 type
= XR_INO_RTDATA
;
2487 else if (lino
== mp
->m_sb
.sb_rbmino
)
2488 type
= XR_INO_RTBITMAP
;
2489 else if (lino
== mp
->m_sb
.sb_rsumino
)
2490 type
= XR_INO_RTSUM
;
2495 type
= XR_INO_SYMLINK
;
2498 type
= XR_INO_CHRDEV
;
2501 type
= XR_INO_BLKDEV
;
2510 do_warn(_("bad inode type %#o inode %" PRIu64
"\n"),
2511 di_mode
& S_IFMT
, lino
);
2516 * type checks for superblock inodes
2518 if (process_check_sb_inodes(mp
, dino
, lino
, &type
, dirty
) != 0)
2522 * only regular files with REALTIME or EXTSIZE flags set can have
2523 * extsize set, or directories with EXTSZINHERIT.
2525 if (be32_to_cpu(dino
->di_extsize
) != 0) {
2526 if ((type
== XR_INO_RTDATA
) ||
2527 (type
== XR_INO_DIR
&& (be16_to_cpu(dino
->di_flags
) &
2528 XFS_DIFLAG_EXTSZINHERIT
)) ||
2529 (type
== XR_INO_DATA
&& (be16_to_cpu(dino
->di_flags
) &
2530 XFS_DIFLAG_EXTSIZE
))) {
2534 _("bad non-zero extent size %u for non-realtime/extsize inode %" PRIu64
", "),
2535 be32_to_cpu(dino
->di_extsize
), lino
);
2537 do_warn(_("resetting to zero\n"));
2538 dino
->di_extsize
= 0;
2541 do_warn(_("would reset to zero\n"));
2546 * general size/consistency checks:
2548 if (process_check_inode_sizes(mp
, dino
, lino
, type
) != 0)
2552 * check for illegal values of forkoff
2554 if (process_check_inode_forkoff(mp
, dino
, lino
) != 0)
2558 * check data fork -- if it's bad, clear the inode
2560 if (process_inode_data_fork(mp
, agno
, ino
, dino
, type
, dirty
,
2561 &totblocks
, &nextents
, &dblkmap
, check_dups
) != 0)
2565 * check attribute fork if necessary. attributes are
2566 * always stored in the regular filesystem.
2568 if (process_inode_attr_fork(mp
, agno
, ino
, dino
, type
, dirty
,
2569 &atotblocks
, &anextents
, check_dups
, extra_attr_check
,
2574 * enforce totblocks is 0 for misc types
2576 if (process_misc_ino_types_blocks(totblocks
, lino
, type
))
2580 * correct space counters if required
2582 if (process_inode_blocks_and_extents(dino
, totblocks
+ atotblocks
,
2583 nextents
, anextents
, lino
, dirty
) != 0)
2587 * do any semantic type-based checking here
2591 if (process_dir2(mp
, lino
, dino
, ino_discovery
,
2592 dirty
, "", parent
, dblkmap
)) {
2594 _("problem with directory contents in inode %" PRIu64
"\n"),
2599 case XR_INO_SYMLINK
:
2600 if (process_symlink(mp
, lino
, dino
, dblkmap
) != 0) {
2602 _("problem with symbolic link in inode %" PRIu64
"\n"),
2611 blkmap_free(dblkmap
);
2614 * check nlinks feature, if it's a version 1 inode,
2615 * just leave nlinks alone. even if it's set wrong,
2616 * it'll be reset when read in.
2618 *dirty
+= process_check_inode_nlink_version(dino
, lino
);
2624 *dirty
+= clear_dinode(mp
, dino
, lino
);
2630 blkmap_free(dblkmap
);
2635 * returns 1 if inode is used, 0 if free.
2636 * performs any necessary salvaging actions.
2637 * note that we leave the generation count alone
2638 * because nothing we could set it to would be
2639 * guaranteed to be correct so the best guess for
2640 * the correct value is just to leave it alone.
2642 * The trick is detecting empty files. For those,
2643 * the core and the forks should all be in the "empty"
2644 * or zero-length state -- a zero or possibly minimum length
2645 * (in the case of dirs) extent list -- although inline directories
2646 * and symlinks might be handled differently. So it should be
2647 * possible to sanity check them against each other.
2649 * If the forks are an empty extent list though, then forget it.
2650 * The file is toast anyway since we can't recover its storage.
2654 * mp -- mount structure
2655 * dino -- pointer to on-disk inode structure
2656 * agno/ino -- inode numbers
2657 * free -- whether the map thinks the inode is free (1 == free)
2658 * ino_discovery -- whether we should examine directory
2659 * contents to discover new inodes
2660 * check_dups -- whether we should check to see if the
2661 * inode references duplicate blocks
2662 * if so, we compare the inode's claimed
2663 * blocks against the contents of the
2664 * duplicate extent list but we don't
2665 * set the bitmap. If not, we set the
2666 * bitmap and try and detect multiply
2667 * claimed blocks using the bitmap.
2669 * dirty -- whether we changed the inode (1 == yes)
2670 * used -- 1 if the inode is used, 0 if free. In no modify
2671 * mode, whether the inode should be used or free
2672 * isa_dir -- 1 if the inode is a directory, 0 if not. In
2673 * no modify mode, if the inode would be a dir or not.
2675 * Return value -- 0 if the inode is good, 1 if it is/was corrupt
2682 xfs_agnumber_t agno
,
2689 int extra_attr_check
,
2693 const int verify_mode
= 0;
2694 const int uncertain
= 0;
2696 #ifdef XR_INODE_TRACE
2697 fprintf(stderr
, _("processing inode %d/%d\n"), agno
, ino
);
2699 return process_dinode_int(mp
, dino
, agno
, ino
, was_free
, dirty
, used
,
2700 verify_mode
, uncertain
, ino_discovery
,
2701 check_dups
, extra_attr_check
, isa_dir
, parent
);
2705 * a more cursory check, check inode core, *DON'T* check forks
2706 * this basically just verifies whether the inode is an inode
2707 * and whether or not it has been totally trashed. returns 0
2708 * if the inode passes the cursory sanity check, 1 otherwise.
2714 xfs_agnumber_t agno
,
2721 const int verify_mode
= 1;
2722 const int check_dups
= 0;
2723 const int ino_discovery
= 0;
2724 const int uncertain
= 0;
2726 return process_dinode_int(mp
, dino
, agno
, ino
, 0, &dirty
, &used
,
2727 verify_mode
, uncertain
, ino_discovery
,
2728 check_dups
, 0, &isa_dir
, &parent
);
2732 * like above only for inode on the uncertain list. it sets
2733 * the uncertain flag which makes process_dinode_int quieter.
2734 * returns 0 if the inode passes the cursory sanity check, 1 otherwise.
2737 verify_uncertain_dinode(
2740 xfs_agnumber_t agno
,
2747 const int verify_mode
= 1;
2748 const int check_dups
= 0;
2749 const int ino_discovery
= 0;
2750 const int uncertain
= 1;
2752 return process_dinode_int(mp
, dino
, agno
, ino
, 0, &dirty
, &used
,
2753 verify_mode
, uncertain
, ino_discovery
,
2754 check_dups
, 0, &isa_dir
, &parent
);