xfs: simplify inode reclaim tagging interfaces
Inode radix tree tagging for reclaim passes a lot of unnecessary variables around. Over time the xfs-perag has grown a xfs_mount backpointer, and an internal agno so we don't need to pass other variables into the tagging functions to supply this information. Rework the functions to pass the minimal variable set required and simplify the internal logic and flow. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
parent
194293631d
commit
545c0889d2
|
@ -37,8 +37,7 @@
|
||||||
#include <linux/kthread.h>
|
#include <linux/kthread.h>
|
||||||
#include <linux/freezer.h>
|
#include <linux/freezer.h>
|
||||||
|
|
||||||
STATIC void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp,
|
STATIC void xfs_inode_clear_reclaim_tag(struct xfs_perag *pag, xfs_ino_t ino);
|
||||||
struct xfs_perag *pag, struct xfs_inode *ip);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and initialise an xfs_inode.
|
* Allocate and initialise an xfs_inode.
|
||||||
|
@ -271,7 +270,7 @@ xfs_iget_cache_hit(
|
||||||
*/
|
*/
|
||||||
ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS;
|
ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS;
|
||||||
ip->i_flags |= XFS_INEW;
|
ip->i_flags |= XFS_INEW;
|
||||||
__xfs_inode_clear_reclaim_tag(mp, pag, ip);
|
xfs_inode_clear_reclaim_tag(pag, ip->i_ino);
|
||||||
inode->i_state = I_NEW;
|
inode->i_state = I_NEW;
|
||||||
|
|
||||||
ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
|
ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
|
||||||
|
@ -768,30 +767,46 @@ xfs_reclaim_worker(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__xfs_inode_set_reclaim_tag(
|
xfs_perag_set_reclaim_tag(
|
||||||
struct xfs_perag *pag,
|
struct xfs_perag *pag)
|
||||||
struct xfs_inode *ip)
|
|
||||||
{
|
{
|
||||||
radix_tree_tag_set(&pag->pag_ici_root,
|
struct xfs_mount *mp = pag->pag_mount;
|
||||||
XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino),
|
|
||||||
|
ASSERT(spin_is_locked(&pag->pag_ici_lock));
|
||||||
|
if (pag->pag_ici_reclaimable++)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* propagate the reclaim tag up into the perag radix tree */
|
||||||
|
spin_lock(&mp->m_perag_lock);
|
||||||
|
radix_tree_tag_set(&mp->m_perag_tree, pag->pag_agno,
|
||||||
XFS_ICI_RECLAIM_TAG);
|
XFS_ICI_RECLAIM_TAG);
|
||||||
|
spin_unlock(&mp->m_perag_lock);
|
||||||
|
|
||||||
if (!pag->pag_ici_reclaimable) {
|
/* schedule periodic background inode reclaim */
|
||||||
/* propagate the reclaim tag up into the perag radix tree */
|
xfs_reclaim_work_queue(mp);
|
||||||
spin_lock(&ip->i_mount->m_perag_lock);
|
|
||||||
radix_tree_tag_set(&ip->i_mount->m_perag_tree, pag->pag_agno,
|
|
||||||
XFS_ICI_RECLAIM_TAG);
|
|
||||||
spin_unlock(&ip->i_mount->m_perag_lock);
|
|
||||||
|
|
||||||
/* schedule periodic background inode reclaim */
|
trace_xfs_perag_set_reclaim(mp, pag->pag_agno, -1, _RET_IP_);
|
||||||
xfs_reclaim_work_queue(ip->i_mount);
|
|
||||||
|
|
||||||
trace_xfs_perag_set_reclaim(ip->i_mount, pag->pag_agno,
|
|
||||||
-1, _RET_IP_);
|
|
||||||
}
|
|
||||||
pag->pag_ici_reclaimable++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xfs_perag_clear_reclaim_tag(
|
||||||
|
struct xfs_perag *pag)
|
||||||
|
{
|
||||||
|
struct xfs_mount *mp = pag->pag_mount;
|
||||||
|
|
||||||
|
ASSERT(spin_is_locked(&pag->pag_ici_lock));
|
||||||
|
if (--pag->pag_ici_reclaimable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* clear the reclaim tag from the perag radix tree */
|
||||||
|
spin_lock(&mp->m_perag_lock);
|
||||||
|
radix_tree_tag_clear(&mp->m_perag_tree, pag->pag_agno,
|
||||||
|
XFS_ICI_RECLAIM_TAG);
|
||||||
|
spin_unlock(&mp->m_perag_lock);
|
||||||
|
trace_xfs_perag_clear_reclaim(mp, pag->pag_agno, -1, _RET_IP_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We set the inode flag atomically with the radix tree tag.
|
* We set the inode flag atomically with the radix tree tag.
|
||||||
* Once we get tag lookups on the radix tree, this inode flag
|
* Once we get tag lookups on the radix tree, this inode flag
|
||||||
|
@ -799,47 +814,34 @@ __xfs_inode_set_reclaim_tag(
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xfs_inode_set_reclaim_tag(
|
xfs_inode_set_reclaim_tag(
|
||||||
xfs_inode_t *ip)
|
struct xfs_inode *ip)
|
||||||
{
|
{
|
||||||
struct xfs_mount *mp = ip->i_mount;
|
struct xfs_mount *mp = ip->i_mount;
|
||||||
struct xfs_perag *pag;
|
struct xfs_perag *pag;
|
||||||
|
|
||||||
pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
|
pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
|
||||||
spin_lock(&pag->pag_ici_lock);
|
spin_lock(&pag->pag_ici_lock);
|
||||||
spin_lock(&ip->i_flags_lock);
|
spin_lock(&ip->i_flags_lock);
|
||||||
__xfs_inode_set_reclaim_tag(pag, ip);
|
|
||||||
|
radix_tree_tag_set(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino),
|
||||||
|
XFS_ICI_RECLAIM_TAG);
|
||||||
|
xfs_perag_set_reclaim_tag(pag);
|
||||||
__xfs_iflags_set(ip, XFS_IRECLAIMABLE);
|
__xfs_iflags_set(ip, XFS_IRECLAIMABLE);
|
||||||
|
|
||||||
spin_unlock(&ip->i_flags_lock);
|
spin_unlock(&ip->i_flags_lock);
|
||||||
spin_unlock(&pag->pag_ici_lock);
|
spin_unlock(&pag->pag_ici_lock);
|
||||||
xfs_perag_put(pag);
|
xfs_perag_put(pag);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
__xfs_inode_clear_reclaim(
|
xfs_inode_clear_reclaim_tag(
|
||||||
xfs_perag_t *pag,
|
struct xfs_perag *pag,
|
||||||
xfs_inode_t *ip)
|
xfs_ino_t ino)
|
||||||
{
|
|
||||||
pag->pag_ici_reclaimable--;
|
|
||||||
if (!pag->pag_ici_reclaimable) {
|
|
||||||
/* clear the reclaim tag from the perag radix tree */
|
|
||||||
spin_lock(&ip->i_mount->m_perag_lock);
|
|
||||||
radix_tree_tag_clear(&ip->i_mount->m_perag_tree, pag->pag_agno,
|
|
||||||
XFS_ICI_RECLAIM_TAG);
|
|
||||||
spin_unlock(&ip->i_mount->m_perag_lock);
|
|
||||||
trace_xfs_perag_clear_reclaim(ip->i_mount, pag->pag_agno,
|
|
||||||
-1, _RET_IP_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC void
|
|
||||||
__xfs_inode_clear_reclaim_tag(
|
|
||||||
xfs_mount_t *mp,
|
|
||||||
xfs_perag_t *pag,
|
|
||||||
xfs_inode_t *ip)
|
|
||||||
{
|
{
|
||||||
radix_tree_tag_clear(&pag->pag_ici_root,
|
radix_tree_tag_clear(&pag->pag_ici_root,
|
||||||
XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG);
|
XFS_INO_TO_AGINO(pag->pag_mount, ino),
|
||||||
__xfs_inode_clear_reclaim(pag, ip);
|
XFS_ICI_RECLAIM_TAG);
|
||||||
|
xfs_perag_clear_reclaim_tag(pag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1030,7 +1032,7 @@ reclaim:
|
||||||
if (!radix_tree_delete(&pag->pag_ici_root,
|
if (!radix_tree_delete(&pag->pag_ici_root,
|
||||||
XFS_INO_TO_AGINO(ip->i_mount, ino)))
|
XFS_INO_TO_AGINO(ip->i_mount, ino)))
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
__xfs_inode_clear_reclaim(pag, ip);
|
xfs_perag_clear_reclaim_tag(pag);
|
||||||
spin_unlock(&pag->pag_ici_lock);
|
spin_unlock(&pag->pag_ici_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue