]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
repair: use fs rootino for dummy parent value instead of zero
authorBrian Foster <bfoster@redhat.com>
Wed, 5 Aug 2020 18:02:39 +0000 (14:02 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 5 Aug 2020 18:02:39 +0000 (14:02 -0400)
commit993ca3ee0ad4ef5e08eda1eeffea86b776114d28
tree6f5854827346f12e97e852f6f8c485dcc666c6cb
parent1b0bfeb5e5ef99f2e5e325ef931514c3e86aeb4d
repair: use fs rootino for dummy parent value instead of zero

If a directory inode has an invalid parent ino on disk, repair
replaces the invalid value with a dummy value of zero in the buffer
and NULLFSINO in the in-core parent tracking. The zero value serves
no functional purpose as it is still an invalid value and the parent
must be repaired by phase 6 based on the in-core state before the
buffer can be written out. A consequence of using an invalid dummy
value is that phase 6 requires custom verifier infrastructure to
detect the invalid parent inode and temporarily replace it while the
core fork verifier runs. If we use a valid inode number as a dummy
value earlier in repair, this workaround can be removed.

An obvious choice for a valid dummy parent inode value is the
orphanage inode. However, the orphanage inode is not allocated until
much later in repair when the filesystem structure is established as
sound and placement of orphaned inodes is imminent. In this case, it
is too early to know for sure whether the associated inodes are
orphaned because a directory traversal later in repair can locate
references to the inode and repair the parent value based on the
structure of the directory tree.

Given all of this, escalate the preexisting workaround from the
custom verifier in phase 6 and set the root inode value as a dummy
parent for shortform directories with an invalid on-disk parent. The
in-core parent is still tracked as NULLFSINO and so forces repair to
either update the parent or orphan the inode before repair
completes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/dir2.c