Commit fe588ed3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

xfs: use generic inode iterator in xfs_qm_dqrele_all_inodes

Use xfs_inode_ag_iterator instead of opencoding the inode walk in the
quota code.  Mark xfs_inode_ag_iterator and xfs_sync_inode_valid non-static
to allow using them from the quota code.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJosef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed-by: default avatarEric Sandeen <sandeen@sandeen.net>
parent 75f3cb13
...@@ -141,7 +141,7 @@ xfs_inode_ag_walk( ...@@ -141,7 +141,7 @@ xfs_inode_ag_walk(
return last_error; return last_error;
} }
STATIC int int
xfs_inode_ag_iterator( xfs_inode_ag_iterator(
struct xfs_mount *mp, struct xfs_mount *mp,
int (*execute)(struct xfs_inode *ip, int (*execute)(struct xfs_inode *ip,
...@@ -167,7 +167,7 @@ xfs_inode_ag_iterator( ...@@ -167,7 +167,7 @@ xfs_inode_ag_iterator(
} }
/* must be called with pag_ici_lock held and releases it */ /* must be called with pag_ici_lock held and releases it */
STATIC int int
xfs_sync_inode_valid( xfs_sync_inode_valid(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_perag *pag) struct xfs_perag *pag)
......
...@@ -54,4 +54,10 @@ void xfs_inode_set_reclaim_tag(struct xfs_inode *ip); ...@@ -54,4 +54,10 @@ void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
void xfs_inode_clear_reclaim_tag(struct xfs_inode *ip); void xfs_inode_clear_reclaim_tag(struct xfs_inode *ip);
void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, struct xfs_perag *pag, void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, struct xfs_perag *pag,
struct xfs_inode *ip); struct xfs_inode *ip);
int xfs_sync_inode_valid(struct xfs_inode *ip, struct xfs_perag *pag);
int xfs_inode_ag_iterator(struct xfs_mount *mp,
int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, int flags),
int flags, int tag);
#endif #endif
...@@ -847,105 +847,55 @@ xfs_qm_export_flags( ...@@ -847,105 +847,55 @@ xfs_qm_export_flags(
} }
/* STATIC int
* Release all the dquots on the inodes in an AG. xfs_dqrele_inode(
*/ struct xfs_inode *ip,
STATIC void struct xfs_perag *pag,
xfs_qm_dqrele_inodes_ag( int flags)
xfs_mount_t *mp,
int ag,
uint flags)
{ {
xfs_inode_t *ip = NULL; int error;
xfs_perag_t *pag = &mp->m_perag[ag];
int first_index = 0;
int nr_found;
do {
/*
* use a gang lookup to find the next inode in the tree
* as the tree is sparse and a gang lookup walks to find
* the number of objects requested.
*/
read_lock(&pag->pag_ici_lock);
nr_found = radix_tree_gang_lookup(&pag->pag_ici_root,
(void**)&ip, first_index, 1);
if (!nr_found) {
read_unlock(&pag->pag_ici_lock);
break;
}
/*
* Update the index for the next lookup. Catch overflows
* into the next AG range which can occur if we have inodes
* in the last block of the AG and we are currently
* pointing to the last inode.
*/
first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);
if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) {
read_unlock(&pag->pag_ici_lock);
break;
}
/* skip quota inodes */ /* skip quota inodes */
if (ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) { if (ip == XFS_QI_UQIP(ip->i_mount) || ip == XFS_QI_GQIP(ip->i_mount)) {
ASSERT(ip->i_udquot == NULL); ASSERT(ip->i_udquot == NULL);
ASSERT(ip->i_gdquot == NULL); ASSERT(ip->i_gdquot == NULL);
read_unlock(&pag->pag_ici_lock); read_unlock(&pag->pag_ici_lock);
continue; return 0;
} }
/* error = xfs_sync_inode_valid(ip, pag);
* If we can't get a reference on the inode, it must be if (error)
* in reclaim. Leave it for the reclaim code to flush. return error;
*/
if (!igrab(VFS_I(ip))) {
read_unlock(&pag->pag_ici_lock);
continue;
}
read_unlock(&pag->pag_ici_lock);
/* avoid new inodes though we shouldn't find any here */
if (xfs_iflags_test(ip, XFS_INEW)) {
IRELE(ip);
continue;
}
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) { if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) {
xfs_qm_dqrele(ip->i_udquot); xfs_qm_dqrele(ip->i_udquot);
ip->i_udquot = NULL; ip->i_udquot = NULL;
} }
if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) && if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) && ip->i_gdquot) {
ip->i_gdquot) {
xfs_qm_dqrele(ip->i_gdquot); xfs_qm_dqrele(ip->i_gdquot);
ip->i_gdquot = NULL; ip->i_gdquot = NULL;
} }
xfs_iput(ip, XFS_ILOCK_EXCL); xfs_iput(ip, XFS_ILOCK_EXCL);
IRELE(ip);
} while (nr_found); return 0;
} }
/* /*
* Go thru all the inodes in the file system, releasing their dquots. * Go thru all the inodes in the file system, releasing their dquots.
*
* Note that the mount structure gets modified to indicate that quotas are off * Note that the mount structure gets modified to indicate that quotas are off
* AFTER this, in the case of quotaoff. This also gets called from * AFTER this, in the case of quotaoff.
* xfs_rootumount.
*/ */
void void
xfs_qm_dqrele_all_inodes( xfs_qm_dqrele_all_inodes(
struct xfs_mount *mp, struct xfs_mount *mp,
uint flags) uint flags)
{ {
int i;
ASSERT(mp->m_quotainfo); ASSERT(mp->m_quotainfo);
for (i = 0; i < mp->m_sb.sb_agcount; i++) { xfs_inode_ag_iterator(mp, xfs_dqrele_inode, flags, XFS_ICI_NO_TAG);
if (!mp->m_perag[i].pag_ici_init)
continue;
xfs_qm_dqrele_inodes_ag(mp, i, flags);
}
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment