xfs: always free inline data before resetting inode fork during ifree
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 22 Nov 2017 20:21:07 +0000 (12:21 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Feb 2018 16:05:38 +0000 (17:05 +0100)
commitb5bfda0f8e29c7070f19c0cac4005fd85f37a84e
treec6d5a610408c76cac221effd6ea39d5e24d73ad6
parent5c0b19bd8cffec6822c92af223814712bdde42bd
xfs: always free inline data before resetting inode fork during ifree

[ Upstream commit 98c4f78dcdd8cec112d1cbc5e9a792ee6e5ab7a6 ]

In xfs_ifree, we reset the data/attr forks to extents format without
bothering to free any inline data buffer that might still be around
after all the blocks have been truncated off the file.  Prior to commit
43518812d2 ("xfs: remove support for inlining data/extents into the
inode fork") nobody noticed because the leftover inline data after
truncation was small enough to fit inside the inline buffer inside the
fork itself.

However, now that we've removed the inline buffer, we /always/ have to
free the inline data buffer or else we leak them like crazy.  This test
was found by turning on kmemleak for generic/001 or generic/388.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/xfs_inode.c