Hi all, Here are a few patches cleaning up some problems with reflink. The first patch is the largest -- it reorganizes the remapping loop so that instead of running one transaction for each extent in the source file regardless of what's in the destination file, we look at both files to find the longest extent we can swap in one go, and run a transaction for just that piece. This fixes a problem of running out of block reservation when the filesystem is very fragmented. The second patch fixes some goofiness in the reflink prep function, and the third patch moves the "lock two inodes" code into xfs_inode.c since none of that is related to reflink. Mr. Torok: Could you try applying these patches to a recent kernel to see if they fix the fs crash problems you were seeing with duperemove, please? 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=reflink-cleanups --- fs/xfs/libxfs/xfs_bmap.h | 13 +- fs/xfs/xfs_file.c | 4 - fs/xfs/xfs_inode.c | 93 +++++++++++++ fs/xfs/xfs_inode.h | 3 fs/xfs/xfs_reflink.c | 325 +++++++++++++++++++--------------------------- fs/xfs/xfs_reflink.h | 2 fs/xfs/xfs_trace.h | 52 ------- fs/xfs/xfs_trans_dquot.c | 13 +- 8 files changed, 252 insertions(+), 253 deletions(-)