]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit - repair/phase6.c
xfs_repair: add support for validating dirent ftype field
authorDave Chinner <dchinner@redhat.com>
Mon, 3 Feb 2014 00:08:44 +0000 (11:08 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 3 Feb 2014 00:08:44 +0000 (11:08 +1100)
commitaaca101b1aeecb5edbcfb6aaa79a60a69ad41a65
tree5d4f771d249a7b8c6baa1fa0629b820b869ad875
parentca692f162d36c871c9c1b6169136b2c70503f2d8
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:

xfs_db> inode 64
xfs_db> a u3.bmx[0].startblock
xfs_db> p
....
du[3].inumber = 68
du[3].namelen = 11
du[3].name = "syscalltest"
du[3].filetype = 1
du[3].tag = 0x70
....
xfs_db> write du[3].filetype 5
du[3].filetype = 5
xfs_db> quit

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>
include/xfs_dir2.h
libxfs/xfs_dir2.c
repair/dino_chunks.c
repair/incore.h
repair/incore_ino.c
repair/phase6.c
repair/scan.c