Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6231848c authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: check for cow blocks before trying to clear them



There's no point in allocating a transaction and locking the inode in
preparation to clear cow blocks if there actually are any cow fork
extents.  Therefore, move the xfs_reflink_cancel_cow_range hunk to
xfs_inactive and check the cow ifp first.  This makes inode reclamation
run faster.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 3f883f5b
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -1872,6 +1872,7 @@ xfs_inactive(
	xfs_inode_t	*ip)
	xfs_inode_t	*ip)
{
{
	struct xfs_mount	*mp;
	struct xfs_mount	*mp;
	struct xfs_ifork	*cow_ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
	int			error;
	int			error;
	int			truncate = 0;
	int			truncate = 0;


@@ -1892,6 +1893,10 @@ xfs_inactive(
	if (mp->m_flags & XFS_MOUNT_RDONLY)
	if (mp->m_flags & XFS_MOUNT_RDONLY)
		return;
		return;


	/* Try to clean out the cow blocks if there are any. */
	if (xfs_is_reflink_inode(ip) && cow_ifp->if_bytes > 0)
		xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true);

	if (VFS_I(ip)->i_nlink != 0) {
	if (VFS_I(ip)->i_nlink != 0) {
		/*
		/*
		 * force is true because we are evicting an inode from the
		 * force is true because we are evicting an inode from the
+0 −9
Original line number Original line Diff line number Diff line
@@ -972,7 +972,6 @@ xfs_fs_destroy_inode(
	struct inode		*inode)
	struct inode		*inode)
{
{
	struct xfs_inode	*ip = XFS_I(inode);
	struct xfs_inode	*ip = XFS_I(inode);
	int			error;


	trace_xfs_destroy_inode(ip);
	trace_xfs_destroy_inode(ip);


@@ -980,14 +979,6 @@ xfs_fs_destroy_inode(
	XFS_STATS_INC(ip->i_mount, vn_rele);
	XFS_STATS_INC(ip->i_mount, vn_rele);
	XFS_STATS_INC(ip->i_mount, vn_remove);
	XFS_STATS_INC(ip->i_mount, vn_remove);


	if (xfs_is_reflink_inode(ip)) {
		error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true);
		if (error && !XFS_FORCED_SHUTDOWN(ip->i_mount))
			xfs_warn(ip->i_mount,
"Error %d while evicting CoW blocks for inode %llu.",
					error, ip->i_ino);
	}

	xfs_inactive(ip);
	xfs_inactive(ip);


	ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);
	ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);