Commit 5b4d89ae authored by David Chinner's avatar David Chinner Committed by Lachlan McIlroy

[XFS] Traverse inode trees when releasing dquots

Make releasing all inode dquots traverse the per-ag inode radix trees
rather than the mount inode list. This removes another user of the mount
inode list.

Version 3 o fix comment relating to avoiding trying to release the

quota inodes and those in reclaim.

Version 2 o add comment explaining use of gang lookups for a single inode
o use IRELE, not VN_RELE o move check for ag initialisation to caller.

SGI-PV: 988139

SGI-Modid: xfs-linux-melb:xfs-kern:32291a
Signed-off-by: default avatarDavid Chinner <david@fromorbit.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
parent 683a8970
...@@ -1022,101 +1022,92 @@ xfs_qm_export_flags( ...@@ -1022,101 +1022,92 @@ xfs_qm_export_flags(
/* /*
* Go thru all the inodes in the file system, releasing their dquots. * Release all the dquots on the inodes in an AG.
* 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
* xfs_rootumount.
*/ */
void STATIC void
xfs_qm_dqrele_all_inodes( xfs_qm_dqrele_inodes_ag(
struct xfs_mount *mp, xfs_mount_t *mp,
int ag,
uint flags) uint flags)
{ {
xfs_inode_t *ip, *topino; xfs_inode_t *ip = NULL;
uint ireclaims; struct inode *vp = NULL;
struct inode *vp; xfs_perag_t *pag = &mp->m_perag[ag];
boolean_t vnode_refd; int first_index = 0;
int nr_found;
ASSERT(mp->m_quotainfo);
XFS_MOUNT_ILOCK(mp);
again:
ip = mp->m_inodes;
if (ip == NULL) {
XFS_MOUNT_IUNLOCK(mp);
return;
}
do { do {
/* Skip markers inserted by xfs_sync */ boolean_t vnode_refd = B_FALSE;
if (ip->i_mount == NULL) {
ip = ip->i_mnext; /*
continue; * use a gang lookup to find the next inode in the tree
} * as the tree is sparse and a gang lookup walks to find
/* Root inode, rbmip and rsumip have associated blocks */ * the number of objects requested.
if (ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) { */
ASSERT(ip->i_udquot == NULL); read_lock(&pag->pag_ici_lock);
ASSERT(ip->i_gdquot == NULL); nr_found = radix_tree_gang_lookup(&pag->pag_ici_root,
ip = ip->i_mnext; (void**)&ip, first_index, 1);
continue;
if (!nr_found) {
read_unlock(&pag->pag_ici_lock);
break;
} }
/* update the index for the next lookup */
first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);
/* skip quota inodes and those in reclaim */
vp = VFS_I(ip); vp = VFS_I(ip);
if (!vp) { if (!vp || ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) {
ASSERT(ip->i_udquot == NULL); ASSERT(ip->i_udquot == NULL);
ASSERT(ip->i_gdquot == NULL); ASSERT(ip->i_gdquot == NULL);
ip = ip->i_mnext; read_unlock(&pag->pag_ici_lock);
continue; continue;
} }
vnode_refd = B_FALSE;
if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) { if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
ireclaims = mp->m_ireclaims;
topino = mp->m_inodes;
vp = vn_grab(vp); vp = vn_grab(vp);
read_unlock(&pag->pag_ici_lock);
if (!vp) if (!vp)
goto again; continue;
XFS_MOUNT_IUNLOCK(mp);
/* XXX restart limit ? */
xfs_ilock(ip, XFS_ILOCK_EXCL);
vnode_refd = B_TRUE; vnode_refd = B_TRUE;
xfs_ilock(ip, XFS_ILOCK_EXCL);
} else { } else {
ireclaims = mp->m_ireclaims; read_unlock(&pag->pag_ici_lock);
topino = mp->m_inodes;
XFS_MOUNT_IUNLOCK(mp);
} }
/*
* We don't keep the mountlock across the dqrele() call,
* since it can take a while..
*/
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) && ip->i_gdquot) { if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) &&
ip->i_gdquot) {
xfs_qm_dqrele(ip->i_gdquot); xfs_qm_dqrele(ip->i_gdquot);
ip->i_gdquot = NULL; ip->i_gdquot = NULL;
} }
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
/*
* Wait until we've dropped the ilock and mountlock to
* do the vn_rele. Or be condemned to an eternity in the
* inactive code in hell.
*/
if (vnode_refd) if (vnode_refd)
IRELE(ip); IRELE(ip);
XFS_MOUNT_ILOCK(mp); } while (nr_found);
/* }
* If an inode was inserted or removed, we gotta
* start over again. /*
* 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
* AFTER this, in the case of quotaoff. This also gets called from
* xfs_rootumount.
*/ */
if (topino != mp->m_inodes || mp->m_ireclaims != ireclaims) { void
/* XXX use a sentinel */ xfs_qm_dqrele_all_inodes(
goto again; struct xfs_mount *mp,
} uint flags)
ip = ip->i_mnext; {
} while (ip != mp->m_inodes); int i;
XFS_MOUNT_IUNLOCK(mp); ASSERT(mp->m_quotainfo);
for (i = 0; i < mp->m_sb.sb_agcount; i++) {
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