Hi all, These patches contain experimental code to enable userspace to defragment the free space in a filesystem. Two purposes are imagined for this functionality: clearing space at the end of a filesystem before shrinking it, and clearing free space in anticipation of making a large allocation. The first patch adds a new fallocate mode that allows userspace to allocate free space from the filesystem into a file. The goal here is to allow the filesystem shrink process to prevent allocation from a certain part of the filesystem while a free space defragmenter evacuates all the files from the doomed part of the filesystem. The second patch amends the online repair system to allow the sysadmin to forcibly rebuild metadata structures, even if they're not corrupt. Without adding an ioctl to move metadata btree blocks, this is the only way to dislodge metadata. 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 kernel git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=defrag-freespace xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=defrag-freespace fstests git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=defrag-freespace --- fs/open.c | 5 + fs/xfs/libxfs/xfs_alloc.c | 88 ++++++++++++ fs/xfs/libxfs/xfs_alloc.h | 4 + fs/xfs/libxfs/xfs_bmap.c | 150 ++++++++++++++++++++ fs/xfs/libxfs/xfs_bmap.h | 3 fs/xfs/xfs_bmap_util.c | 315 ++++++++++++++++++++++++++++++++++++++++++- fs/xfs/xfs_bmap_util.h | 7 + fs/xfs/xfs_file.c | 39 +++++ fs/xfs/xfs_rtalloc.c | 49 +++++++ fs/xfs/xfs_rtalloc.h | 12 ++ fs/xfs/xfs_trace.h | 72 +++++++++- include/linux/falloc.h | 3 include/uapi/linux/falloc.h | 8 + 13 files changed, 742 insertions(+), 13 deletions(-)