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

Commit 579b62fa authored by Brian Foster's avatar Brian Foster Committed by Ben Myers
Browse files

xfs: add background scanning to clear eofblocks inodes



Create a new mount workqueue and delayed_work to enable background
scanning and freeing of eofblocks inodes. The scanner kicks in once
speculative preallocation occurs and stops requeueing itself when
no eofblocks inodes exist.

The scan interval is based on the new
'speculative_prealloc_lifetime' tunable (default to 5m). The
background scanner performs unfiltered, best effort scans (which
skips inodes under lock contention or with a dirty cache mapping).

Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 00ca79a0
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -21,7 +21,8 @@
/*
/*
 * Tunable XFS parameters.  xfs_params is required even when CONFIG_SYSCTL=n,
 * Tunable XFS parameters.  xfs_params is required even when CONFIG_SYSCTL=n,
 * other XFS code uses these values.  Times are measured in centisecs (i.e.
 * other XFS code uses these values.  Times are measured in centisecs (i.e.
 * 100ths of a second).
 * 100ths of a second) with the exception of eofb_timer, which is measured in
 * seconds.
 */
 */
xfs_param_t xfs_params = {
xfs_param_t xfs_params = {
			  /*	MIN		DFLT		MAX	*/
			  /*	MIN		DFLT		MAX	*/
@@ -40,4 +41,5 @@ xfs_param_t xfs_params = {
	.rotorstep	= {	1,		1,		255	},
	.rotorstep	= {	1,		1,		255	},
	.inherit_nodfrg	= {	0,		1,		1	},
	.inherit_nodfrg	= {	0,		1,		1	},
	.fstrm_timer	= {	1,		30*100,		3600*100},
	.fstrm_timer	= {	1,		30*100,		3600*100},
	.eofb_timer	= {	1,		300,		3600*24},
};
};
+29 −0
Original line number Original line Diff line number Diff line
@@ -615,6 +615,32 @@ restart:
	return last_error;
	return last_error;
}
}


/*
 * Background scanning to trim post-EOF preallocated space. This is queued
 * based on the 'background_prealloc_discard_period' tunable (5m by default).
 */
STATIC void
xfs_queue_eofblocks(
	struct xfs_mount *mp)
{
	rcu_read_lock();
	if (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_EOFBLOCKS_TAG))
		queue_delayed_work(mp->m_eofblocks_workqueue,
				   &mp->m_eofblocks_work,
				   msecs_to_jiffies(xfs_eofb_secs * 1000));
	rcu_read_unlock();
}

void
xfs_eofblocks_worker(
	struct work_struct *work)
{
	struct xfs_mount *mp = container_of(to_delayed_work(work),
				struct xfs_mount, m_eofblocks_work);
	xfs_icache_free_eofblocks(mp, NULL);
	xfs_queue_eofblocks(mp);
}

int
int
xfs_inode_ag_iterator(
xfs_inode_ag_iterator(
	struct xfs_mount	*mp,
	struct xfs_mount	*mp,
@@ -1273,6 +1299,9 @@ xfs_inode_set_eofblocks_tag(
				   XFS_ICI_EOFBLOCKS_TAG);
				   XFS_ICI_EOFBLOCKS_TAG);
		spin_unlock(&ip->i_mount->m_perag_lock);
		spin_unlock(&ip->i_mount->m_perag_lock);


		/* kick off background trimming */
		xfs_queue_eofblocks(ip->i_mount);

		trace_xfs_perag_set_eofblocks(ip->i_mount, pag->pag_agno,
		trace_xfs_perag_set_eofblocks(ip->i_mount, pag->pag_agno,
					      -1, _RET_IP_);
					      -1, _RET_IP_);
	}
	}
+1 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *);
int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *);
void xfs_eofblocks_worker(struct work_struct *);


int xfs_sync_inode_grab(struct xfs_inode *ip);
int xfs_sync_inode_grab(struct xfs_inode *ip);
int xfs_inode_ag_iterator(struct xfs_mount *mp,
int xfs_inode_ag_iterator(struct xfs_mount *mp,
+1 −0
Original line number Original line Diff line number Diff line
@@ -118,6 +118,7 @@
#define xfs_rotorstep		xfs_params.rotorstep.val
#define xfs_rotorstep		xfs_params.rotorstep.val
#define xfs_inherit_nodefrag	xfs_params.inherit_nodfrg.val
#define xfs_inherit_nodefrag	xfs_params.inherit_nodfrg.val
#define xfs_fstrm_centisecs	xfs_params.fstrm_timer.val
#define xfs_fstrm_centisecs	xfs_params.fstrm_timer.val
#define xfs_eofb_secs		xfs_params.eofb_timer.val


#define current_cpu()		(raw_smp_processor_id())
#define current_cpu()		(raw_smp_processor_id())
#define current_pid()		(current->pid)
#define current_pid()		(current->pid)
+2 −0
Original line number Original line Diff line number Diff line
@@ -1428,6 +1428,8 @@ xfs_unmountfs(
	__uint64_t		resblks;
	__uint64_t		resblks;
	int			error;
	int			error;


	cancel_delayed_work_sync(&mp->m_eofblocks_work);

	xfs_qm_unmount_quotas(mp);
	xfs_qm_unmount_quotas(mp);
	xfs_rtunmount_inodes(mp);
	xfs_rtunmount_inodes(mp);
	IRELE(mp->m_rootip);
	IRELE(mp->m_rootip);
Loading