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

Commit 5017e97d authored by Dave Chinner's avatar Dave Chinner Committed by Alex Elder
Browse files

xfs: rename xfs_get_perag



xfs_get_perag is really getting the perag that an inode belongs to
based on it's inode number. Convert the use of this function to just
get the perag from a provided ag number.  Use this new function to
obtain the per-ag structure when traversing the per AG inode trees
for sync and reclaim.

Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent c9c12971
Loading
Loading
Loading
Loading
+13 −9
Original line number Original line Diff line number Diff line
@@ -90,14 +90,13 @@ xfs_inode_ag_lookup(
STATIC int
STATIC int
xfs_inode_ag_walk(
xfs_inode_ag_walk(
	struct xfs_mount	*mp,
	struct xfs_mount	*mp,
	xfs_agnumber_t		ag,
	struct xfs_perag	*pag,
	int			(*execute)(struct xfs_inode *ip,
	int			(*execute)(struct xfs_inode *ip,
					   struct xfs_perag *pag, int flags),
					   struct xfs_perag *pag, int flags),
	int			flags,
	int			flags,
	int			tag,
	int			tag,
	int			exclusive)
	int			exclusive)
{
{
	struct xfs_perag	*pag = &mp->m_perag[ag];
	uint32_t		first_index;
	uint32_t		first_index;
	int			last_error = 0;
	int			last_error = 0;
	int			skipped;
	int			skipped;
@@ -141,8 +140,6 @@ restart:
		delay(1);
		delay(1);
		goto restart;
		goto restart;
	}
	}

	xfs_put_perag(mp, pag);
	return last_error;
	return last_error;
}
}


@@ -160,10 +157,16 @@ xfs_inode_ag_iterator(
	xfs_agnumber_t		ag;
	xfs_agnumber_t		ag;


	for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) {
	for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) {
		if (!mp->m_perag[ag].pag_ici_init)
		struct xfs_perag	*pag;

		pag = xfs_perag_get(mp, ag);
		if (!pag->pag_ici_init) {
			xfs_perag_put(pag);
			continue;
			continue;
		error = xfs_inode_ag_walk(mp, ag, execute, flags, tag,
		}
		error = xfs_inode_ag_walk(mp, pag, execute, flags, tag,
						exclusive);
						exclusive);
		xfs_perag_put(pag);
		if (error) {
		if (error) {
			last_error = error;
			last_error = error;
			if (error == EFSCORRUPTED)
			if (error == EFSCORRUPTED)
@@ -690,16 +693,17 @@ void
xfs_inode_set_reclaim_tag(
xfs_inode_set_reclaim_tag(
	xfs_inode_t	*ip)
	xfs_inode_t	*ip)
{
{
	xfs_mount_t	*mp = ip->i_mount;
	struct xfs_mount *mp = ip->i_mount;
	xfs_perag_t	*pag = xfs_get_perag(mp, ip->i_ino);
	struct xfs_perag *pag;


	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
	read_lock(&pag->pag_ici_lock);
	read_lock(&pag->pag_ici_lock);
	spin_lock(&ip->i_flags_lock);
	spin_lock(&ip->i_flags_lock);
	__xfs_inode_set_reclaim_tag(pag, ip);
	__xfs_inode_set_reclaim_tag(pag, ip);
	__xfs_iflags_set(ip, XFS_IRECLAIMABLE);
	__xfs_iflags_set(ip, XFS_IRECLAIMABLE);
	spin_unlock(&ip->i_flags_lock);
	spin_unlock(&ip->i_flags_lock);
	read_unlock(&pag->pag_ici_lock);
	read_unlock(&pag->pag_ici_lock);
	xfs_put_perag(mp, pag);
	xfs_perag_put(pag);
}
}


void
void
+5 −5
Original line number Original line Diff line number Diff line
@@ -374,7 +374,7 @@ xfs_iget(
		return EINVAL;
		return EINVAL;


	/* get the perag structure and ensure that it's inode capable */
	/* get the perag structure and ensure that it's inode capable */
	pag = xfs_get_perag(mp, ino);
	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ino));
	if (!pag->pagi_inodeok)
	if (!pag->pagi_inodeok)
		return EINVAL;
		return EINVAL;
	ASSERT(pag->pag_ici_init);
	ASSERT(pag->pag_ici_init);
@@ -398,7 +398,7 @@ again:
		if (error)
		if (error)
			goto out_error_or_again;
			goto out_error_or_again;
	}
	}
	xfs_put_perag(mp, pag);
	xfs_perag_put(pag);


	*ipp = ip;
	*ipp = ip;


@@ -417,7 +417,7 @@ out_error_or_again:
		delay(1);
		delay(1);
		goto again;
		goto again;
	}
	}
	xfs_put_perag(mp, pag);
	xfs_perag_put(pag);
	return error;
	return error;
}
}


@@ -488,12 +488,12 @@ xfs_ireclaim(
	 * added to the tree assert that it's been there before to catch
	 * added to the tree assert that it's been there before to catch
	 * problems with the inode life time early on.
	 * problems with the inode life time early on.
	 */
	 */
	pag = xfs_get_perag(mp, ip->i_ino);
	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
	write_lock(&pag->pag_ici_lock);
	write_lock(&pag->pag_ici_lock);
	if (!radix_tree_delete(&pag->pag_ici_root, agino))
	if (!radix_tree_delete(&pag->pag_ici_root, agino))
		ASSERT(0);
		ASSERT(0);
	write_unlock(&pag->pag_ici_lock);
	write_unlock(&pag->pag_ici_lock);
	xfs_put_perag(mp, pag);
	xfs_perag_put(pag);


	/*
	/*
	 * Here we do an (almost) spurious inode lock in order to coordinate
	 * Here we do an (almost) spurious inode lock in order to coordinate
+5 −3
Original line number Original line Diff line number Diff line
@@ -1946,8 +1946,9 @@ xfs_ifree_cluster(
	xfs_inode_t		*ip, **ip_found;
	xfs_inode_t		*ip, **ip_found;
	xfs_inode_log_item_t	*iip;
	xfs_inode_log_item_t	*iip;
	xfs_log_item_t		*lip;
	xfs_log_item_t		*lip;
	xfs_perag_t		*pag = xfs_get_perag(mp, inum);
	struct xfs_perag	*pag;


	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum));
	if (mp->m_sb.sb_blocksize >= XFS_INODE_CLUSTER_SIZE(mp)) {
	if (mp->m_sb.sb_blocksize >= XFS_INODE_CLUSTER_SIZE(mp)) {
		blks_per_cluster = 1;
		blks_per_cluster = 1;
		ninodes = mp->m_sb.sb_inopblock;
		ninodes = mp->m_sb.sb_inopblock;
@@ -2088,7 +2089,7 @@ xfs_ifree_cluster(
	}
	}


	kmem_free(ip_found);
	kmem_free(ip_found);
	xfs_put_perag(mp, pag);
	xfs_perag_put(pag);
}
}


/*
/*
@@ -2675,7 +2676,7 @@ xfs_iflush_cluster(
	xfs_buf_t	*bp)
	xfs_buf_t	*bp)
{
{
	xfs_mount_t		*mp = ip->i_mount;
	xfs_mount_t		*mp = ip->i_mount;
	xfs_perag_t		*pag = xfs_get_perag(mp, ip->i_ino);
	struct xfs_perag	*pag;
	unsigned long		first_index, mask;
	unsigned long		first_index, mask;
	unsigned long		inodes_per_cluster;
	unsigned long		inodes_per_cluster;
	int			ilist_size;
	int			ilist_size;
@@ -2686,6 +2687,7 @@ xfs_iflush_cluster(
	int			bufwasdelwri;
	int			bufwasdelwri;
	int			i;
	int			i;


	pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
	ASSERT(pag->pagi_inodeok);
	ASSERT(pag->pagi_inodeok);
	ASSERT(pag->pag_ici_init);
	ASSERT(pag->pag_ici_init);


+4 −4
Original line number Original line Diff line number Diff line
@@ -386,14 +386,14 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
/*
/*
 * perag get/put wrappers for eventual ref counting
 * perag get/put wrappers for eventual ref counting
 */
 */
static inline xfs_perag_t *
static inline struct xfs_perag *
xfs_get_perag(struct xfs_mount *mp, xfs_ino_t ino)
xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno)
{
{
	return &mp->m_perag[XFS_INO_TO_AGNO(mp, ino)];
	return &mp->m_perag[agno];
}
}


static inline void
static inline void
xfs_put_perag(struct xfs_mount *mp, xfs_perag_t *pag)
xfs_perag_put(struct xfs_perag *pag)
{
{
	/* nothing to see here, move along */
	/* nothing to see here, move along */
}
}