Hi all, Alex Lyakas observed that xfs_repair can accidentally trash the root directory on a filesystem. Specifically, if one formats a V4 filesystem without sparse inodes but with sunit/swidth set and then mounts that filesystem with a different sunit/swidth, the kernel will update the values in the superblock. This causes xfs_repair's sb_rootino estimation to differ from the actual root directory, and it discards the actual root directory even though there's nothing wrong with it. Therefore, hoist the logic that computes the root inode location into libxfs so that the kernel will avoid the sb update if the proposed sunit/swidth changes would alter the sb_rootino estimation; and then teach xfs_repair to retain the root directory even if the estimation doesn't add up, as long as sb_rootino points to a directory whose '..' entry points to itself. v4 rebases on the latest for-next and adds in a few things that Eric and I discussed during the review of v3. If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below. This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome. --D xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=repair-find-rootdir fstests git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=repair-find-rootdir