xfs: allow userspace to rebuild metadata structures

Add a new (superuser-only) flag to the online metadata repair ioctl to
force it to rebuild structures, even if they're not broken.  We will use
this to move metadata structures out of the way during a free space
defragmentation operation.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
index 7ac2b0a..5911508 100644
--- a/libxfs/xfs_fs.h
+++ b/libxfs/xfs_fs.h
@@ -791,9 +791,13 @@
 /* i: Don't mark inodes DONTCACHE at the end. */
 #define XFS_SCRUB_IFLAG_RETAIN_INODES	(1 << 9)
 
+/* i: Rebuild the data structure. */
+#define XFS_SCRUB_IFLAG_FORCE_REBUILD	(1 << 10)
+
 #define XFS_SCRUB_FLAGS_IN	(XFS_SCRUB_IFLAG_REPAIR | \
 				 XFS_SCRUB_IFLAG_FREEZE_OK | \
-				 XFS_SCRUB_IFLAG_RETAIN_INODES)
+				 XFS_SCRUB_IFLAG_RETAIN_INODES | \
+				 XFS_SCRUB_IFLAG_FORCE_REBUILD)
 #define XFS_SCRUB_FLAGS_OUT	(XFS_SCRUB_OFLAG_CORRUPT | \
 				 XFS_SCRUB_OFLAG_PREEN | \
 				 XFS_SCRUB_OFLAG_XFAIL | \
diff --git a/man/man2/ioctl_xfs_scrub_metadata.2 b/man/man2/ioctl_xfs_scrub_metadata.2
index 44298c0..5e9bbd2 100644
--- a/man/man2/ioctl_xfs_scrub_metadata.2
+++ b/man/man2/ioctl_xfs_scrub_metadata.2
@@ -236,6 +236,11 @@
 .B XFS_SCRUB_IFLAG_RETAIN_INODES
 Tag scrubbed inodes as DONTCACHE so that we don't purge the inode
 caches.
+.TP
+.B XFS_SCRUB_IFLAG_FORCE_REBUILD
+Force the kernel to rebuild the specified piece of metadata, even if it's
+healthy.
+This can only be specified by the system administrator.
 .RE
 .PP
 For metadata checkers that operate on inodes or inode metadata, the fields