On Fri, Jul 17, 2020 at 07:59:20AM -0400, Brian Foster wrote: > 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@xxxxxxxxxx> > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > --- > > v2: > - Update patch subject and commit log. Looks good. Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> -- Dave Chinner david@xxxxxxxxxxxxx