mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
xfs: always free inline data before resetting inode fork during ifree
[ Upstream commit98c4f78dcd] 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 commit43518812d2("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@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
40ba283e26
commit
1eccdbd483
@@ -2421,6 +2421,24 @@ retry:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free any local-format buffers sitting around before we reset to
|
||||
* extents format.
|
||||
*/
|
||||
static inline void
|
||||
xfs_ifree_local_data(
|
||||
struct xfs_inode *ip,
|
||||
int whichfork)
|
||||
{
|
||||
struct xfs_ifork *ifp;
|
||||
|
||||
if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL)
|
||||
return;
|
||||
|
||||
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||
xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is called to return an inode to the inode free list.
|
||||
* The inode should already be truncated to 0 length and have
|
||||
@@ -2458,6 +2476,9 @@ xfs_ifree(
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
xfs_ifree_local_data(ip, XFS_DATA_FORK);
|
||||
xfs_ifree_local_data(ip, XFS_ATTR_FORK);
|
||||
|
||||
VFS_I(ip)->i_mode = 0; /* mark incore inode as free */
|
||||
ip->i_d.di_flags = 0;
|
||||
ip->i_d.di_dmevmask = 0;
|
||||
|
||||
Reference in New Issue
Block a user