xfs_repair: add support for validating dirent ftype field
Add code to track the filetype of an inode from phase 3 when all the
inodes are scanned throught to phase 6 when the directory structure
is validated and corrected.
Add code to phase 6 shortform and long form directory entry
validation to read the ftype from the dirent, lookup the inode
record and check they are the same. If they aren't and we are in
no-modify mode, issue a warning such as:
Phase 6 - check inode connectivity...
- traversing filesystem ...
would fix ftype mismatch (5/1) in directory/child inode 64/68
- traversal finished ...
- moving disconnected inodes to lost+found ...
If we are fixing the problem:
Phase 6 - check inode connectivity...
- resetting contents of realtime bitmap and summary inodes
- traversing filesystem ...
fixing ftype mismatch (5/1) in directory/child inode 64/68
- traversal finished ...
- moving disconnected inodes to lost+found ...
Note that this is from a leaf form directory entry that was
intentionally corrupted with xfs_db like so:
Shortform directory entry repair was tested in a similar fashion.
Further, track the ftype in the directory hash table that is build,
so if the directory is rebuild from scratch it has the necessary
ftype information to rebuild the directory correctly. Further, if we
detect a ftype mismatch, update the entry in the hash so that later
directory errors that lead to it being rebuilt use the corrected
ftype field, not the bad one.
Note that this code pulls in some kernel side code that is currently
in kernel private locations (xfs_mode_to_ftype table), so there'll
be some kernel/userspace sync work needed to bring these back into
line.
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>