diff options
author | Chandra Seetharaman <sekharan@us.ibm.com> | 2013-06-27 18:25:07 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-06-28 14:13:59 -0400 |
commit | 113a56835d938d5cf9b4599053da7afb80d6f710 (patch) | |
tree | 9809139a59790d62d48218d1e1cd305f85ae2e8c /fs/xfs/xfs_qm.c | |
parent | 995961c4510460d9eef9b5ae46789aa2315545fe (diff) |
xfs: Code cleanup and removal of some typedef usage
In preparation for combined pquota/gquota support, for the sake
of readability, do some code cleanup surrounding the affected
code.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_qm.c')
-rw-r--r-- | fs/xfs/xfs_qm.c | 152 |
1 files changed, 80 insertions, 72 deletions
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 8e707d33e106..cf09aa845d8c 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -1260,19 +1260,20 @@ int | |||
1260 | xfs_qm_quotacheck( | 1260 | xfs_qm_quotacheck( |
1261 | xfs_mount_t *mp) | 1261 | xfs_mount_t *mp) |
1262 | { | 1262 | { |
1263 | int done, count, error, error2; | 1263 | int done, count, error, error2; |
1264 | xfs_ino_t lastino; | 1264 | xfs_ino_t lastino; |
1265 | size_t structsz; | 1265 | size_t structsz; |
1266 | xfs_inode_t *uip, *gip; | 1266 | uint flags; |
1267 | uint flags; | 1267 | LIST_HEAD (buffer_list); |
1268 | LIST_HEAD (buffer_list); | 1268 | struct xfs_inode *uip = mp->m_quotainfo->qi_uquotaip; |
1269 | struct xfs_inode *gip = mp->m_quotainfo->qi_gquotaip; | ||
1269 | 1270 | ||
1270 | count = INT_MAX; | 1271 | count = INT_MAX; |
1271 | structsz = 1; | 1272 | structsz = 1; |
1272 | lastino = 0; | 1273 | lastino = 0; |
1273 | flags = 0; | 1274 | flags = 0; |
1274 | 1275 | ||
1275 | ASSERT(mp->m_quotainfo->qi_uquotaip || mp->m_quotainfo->qi_gquotaip); | 1276 | ASSERT(uip || gip); |
1276 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 1277 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
1277 | 1278 | ||
1278 | xfs_notice(mp, "Quotacheck needed: Please wait."); | 1279 | xfs_notice(mp, "Quotacheck needed: Please wait."); |
@@ -1282,7 +1283,6 @@ xfs_qm_quotacheck( | |||
1282 | * their counters to zero. We need a clean slate. | 1283 | * their counters to zero. We need a clean slate. |
1283 | * We don't log our changes till later. | 1284 | * We don't log our changes till later. |
1284 | */ | 1285 | */ |
1285 | uip = mp->m_quotainfo->qi_uquotaip; | ||
1286 | if (uip) { | 1286 | if (uip) { |
1287 | error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA, | 1287 | error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA, |
1288 | &buffer_list); | 1288 | &buffer_list); |
@@ -1291,7 +1291,6 @@ xfs_qm_quotacheck( | |||
1291 | flags |= XFS_UQUOTA_CHKD; | 1291 | flags |= XFS_UQUOTA_CHKD; |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | gip = mp->m_quotainfo->qi_gquotaip; | ||
1295 | if (gip) { | 1294 | if (gip) { |
1296 | error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ? | 1295 | error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ? |
1297 | XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA, | 1296 | XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA, |
@@ -1393,15 +1392,13 @@ STATIC int | |||
1393 | xfs_qm_init_quotainos( | 1392 | xfs_qm_init_quotainos( |
1394 | xfs_mount_t *mp) | 1393 | xfs_mount_t *mp) |
1395 | { | 1394 | { |
1396 | xfs_inode_t *uip, *gip; | 1395 | struct xfs_inode *uip = NULL; |
1397 | int error; | 1396 | struct xfs_inode *gip = NULL; |
1398 | __int64_t sbflags; | 1397 | int error; |
1399 | uint flags; | 1398 | __int64_t sbflags = 0; |
1399 | uint flags = 0; | ||
1400 | 1400 | ||
1401 | ASSERT(mp->m_quotainfo); | 1401 | ASSERT(mp->m_quotainfo); |
1402 | uip = gip = NULL; | ||
1403 | sbflags = 0; | ||
1404 | flags = 0; | ||
1405 | 1402 | ||
1406 | /* | 1403 | /* |
1407 | * Get the uquota and gquota inodes | 1404 | * Get the uquota and gquota inodes |
@@ -1410,19 +1407,18 @@ xfs_qm_init_quotainos( | |||
1410 | if (XFS_IS_UQUOTA_ON(mp) && | 1407 | if (XFS_IS_UQUOTA_ON(mp) && |
1411 | mp->m_sb.sb_uquotino != NULLFSINO) { | 1408 | mp->m_sb.sb_uquotino != NULLFSINO) { |
1412 | ASSERT(mp->m_sb.sb_uquotino > 0); | 1409 | ASSERT(mp->m_sb.sb_uquotino > 0); |
1413 | if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, | 1410 | error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, |
1414 | 0, 0, &uip))) | 1411 | 0, 0, &uip); |
1412 | if (error) | ||
1415 | return XFS_ERROR(error); | 1413 | return XFS_ERROR(error); |
1416 | } | 1414 | } |
1417 | if (XFS_IS_OQUOTA_ON(mp) && | 1415 | if (XFS_IS_OQUOTA_ON(mp) && |
1418 | mp->m_sb.sb_gquotino != NULLFSINO) { | 1416 | mp->m_sb.sb_gquotino != NULLFSINO) { |
1419 | ASSERT(mp->m_sb.sb_gquotino > 0); | 1417 | ASSERT(mp->m_sb.sb_gquotino > 0); |
1420 | if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, | 1418 | error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, |
1421 | 0, 0, &gip))) { | 1419 | 0, 0, &gip); |
1422 | if (uip) | 1420 | if (error) |
1423 | IRELE(uip); | 1421 | goto error_rele; |
1424 | return XFS_ERROR(error); | ||
1425 | } | ||
1426 | } | 1422 | } |
1427 | } else { | 1423 | } else { |
1428 | flags |= XFS_QMOPT_SBVERSION; | 1424 | flags |= XFS_QMOPT_SBVERSION; |
@@ -1437,10 +1433,11 @@ xfs_qm_init_quotainos( | |||
1437 | * temporarily switch to read-write to do this. | 1433 | * temporarily switch to read-write to do this. |
1438 | */ | 1434 | */ |
1439 | if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { | 1435 | if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { |
1440 | if ((error = xfs_qm_qino_alloc(mp, &uip, | 1436 | error = xfs_qm_qino_alloc(mp, &uip, |
1441 | sbflags | XFS_SB_UQUOTINO, | 1437 | sbflags | XFS_SB_UQUOTINO, |
1442 | flags | XFS_QMOPT_UQUOTA))) | 1438 | flags | XFS_QMOPT_UQUOTA); |
1443 | return XFS_ERROR(error); | 1439 | if (error) |
1440 | goto error_rele; | ||
1444 | 1441 | ||
1445 | flags &= ~XFS_QMOPT_SBVERSION; | 1442 | flags &= ~XFS_QMOPT_SBVERSION; |
1446 | } | 1443 | } |
@@ -1449,18 +1446,21 @@ xfs_qm_init_quotainos( | |||
1449 | XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA); | 1446 | XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA); |
1450 | error = xfs_qm_qino_alloc(mp, &gip, | 1447 | error = xfs_qm_qino_alloc(mp, &gip, |
1451 | sbflags | XFS_SB_GQUOTINO, flags); | 1448 | sbflags | XFS_SB_GQUOTINO, flags); |
1452 | if (error) { | 1449 | if (error) |
1453 | if (uip) | 1450 | goto error_rele; |
1454 | IRELE(uip); | ||
1455 | |||
1456 | return XFS_ERROR(error); | ||
1457 | } | ||
1458 | } | 1451 | } |
1459 | 1452 | ||
1460 | mp->m_quotainfo->qi_uquotaip = uip; | 1453 | mp->m_quotainfo->qi_uquotaip = uip; |
1461 | mp->m_quotainfo->qi_gquotaip = gip; | 1454 | mp->m_quotainfo->qi_gquotaip = gip; |
1462 | 1455 | ||
1463 | return 0; | 1456 | return 0; |
1457 | |||
1458 | error_rele: | ||
1459 | if (uip) | ||
1460 | IRELE(uip); | ||
1461 | if (gip) | ||
1462 | IRELE(gip); | ||
1463 | return XFS_ERROR(error); | ||
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | STATIC void | 1466 | STATIC void |
@@ -1657,7 +1657,8 @@ xfs_qm_vop_dqalloc( | |||
1657 | struct xfs_dquot **O_gdqpp) | 1657 | struct xfs_dquot **O_gdqpp) |
1658 | { | 1658 | { |
1659 | struct xfs_mount *mp = ip->i_mount; | 1659 | struct xfs_mount *mp = ip->i_mount; |
1660 | struct xfs_dquot *uq, *gq; | 1660 | struct xfs_dquot *uq = NULL; |
1661 | struct xfs_dquot *gq = NULL; | ||
1661 | int error; | 1662 | int error; |
1662 | uint lockflags; | 1663 | uint lockflags; |
1663 | 1664 | ||
@@ -1682,7 +1683,6 @@ xfs_qm_vop_dqalloc( | |||
1682 | } | 1683 | } |
1683 | } | 1684 | } |
1684 | 1685 | ||
1685 | uq = gq = NULL; | ||
1686 | if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) { | 1686 | if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) { |
1687 | if (ip->i_d.di_uid != uid) { | 1687 | if (ip->i_d.di_uid != uid) { |
1688 | /* | 1688 | /* |
@@ -1695,11 +1695,12 @@ xfs_qm_vop_dqalloc( | |||
1695 | * holding ilock. | 1695 | * holding ilock. |
1696 | */ | 1696 | */ |
1697 | xfs_iunlock(ip, lockflags); | 1697 | xfs_iunlock(ip, lockflags); |
1698 | if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t) uid, | 1698 | error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t) uid, |
1699 | XFS_DQ_USER, | 1699 | XFS_DQ_USER, |
1700 | XFS_QMOPT_DQALLOC | | 1700 | XFS_QMOPT_DQALLOC | |
1701 | XFS_QMOPT_DOWARN, | 1701 | XFS_QMOPT_DOWARN, |
1702 | &uq))) { | 1702 | &uq); |
1703 | if (error) { | ||
1703 | ASSERT(error != ENOENT); | 1704 | ASSERT(error != ENOENT); |
1704 | return error; | 1705 | return error; |
1705 | } | 1706 | } |
@@ -1721,15 +1722,14 @@ xfs_qm_vop_dqalloc( | |||
1721 | if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { | 1722 | if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { |
1722 | if (ip->i_d.di_gid != gid) { | 1723 | if (ip->i_d.di_gid != gid) { |
1723 | xfs_iunlock(ip, lockflags); | 1724 | xfs_iunlock(ip, lockflags); |
1724 | if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid, | 1725 | error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid, |
1725 | XFS_DQ_GROUP, | 1726 | XFS_DQ_GROUP, |
1726 | XFS_QMOPT_DQALLOC | | 1727 | XFS_QMOPT_DQALLOC | |
1727 | XFS_QMOPT_DOWARN, | 1728 | XFS_QMOPT_DOWARN, |
1728 | &gq))) { | 1729 | &gq); |
1729 | if (uq) | 1730 | if (error) { |
1730 | xfs_qm_dqrele(uq); | ||
1731 | ASSERT(error != ENOENT); | 1731 | ASSERT(error != ENOENT); |
1732 | return error; | 1732 | goto error_rele; |
1733 | } | 1733 | } |
1734 | xfs_dqunlock(gq); | 1734 | xfs_dqunlock(gq); |
1735 | lockflags = XFS_ILOCK_SHARED; | 1735 | lockflags = XFS_ILOCK_SHARED; |
@@ -1741,15 +1741,14 @@ xfs_qm_vop_dqalloc( | |||
1741 | } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { | 1741 | } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { |
1742 | if (xfs_get_projid(ip) != prid) { | 1742 | if (xfs_get_projid(ip) != prid) { |
1743 | xfs_iunlock(ip, lockflags); | 1743 | xfs_iunlock(ip, lockflags); |
1744 | if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid, | 1744 | error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid, |
1745 | XFS_DQ_PROJ, | 1745 | XFS_DQ_PROJ, |
1746 | XFS_QMOPT_DQALLOC | | 1746 | XFS_QMOPT_DQALLOC | |
1747 | XFS_QMOPT_DOWARN, | 1747 | XFS_QMOPT_DOWARN, |
1748 | &gq))) { | 1748 | &gq); |
1749 | if (uq) | 1749 | if (error) { |
1750 | xfs_qm_dqrele(uq); | ||
1751 | ASSERT(error != ENOENT); | 1750 | ASSERT(error != ENOENT); |
1752 | return (error); | 1751 | goto error_rele; |
1753 | } | 1752 | } |
1754 | xfs_dqunlock(gq); | 1753 | xfs_dqunlock(gq); |
1755 | lockflags = XFS_ILOCK_SHARED; | 1754 | lockflags = XFS_ILOCK_SHARED; |
@@ -1772,6 +1771,11 @@ xfs_qm_vop_dqalloc( | |||
1772 | else if (gq) | 1771 | else if (gq) |
1773 | xfs_qm_dqrele(gq); | 1772 | xfs_qm_dqrele(gq); |
1774 | return 0; | 1773 | return 0; |
1774 | |||
1775 | error_rele: | ||
1776 | if (uq) | ||
1777 | xfs_qm_dqrele(uq); | ||
1778 | return error; | ||
1775 | } | 1779 | } |
1776 | 1780 | ||
1777 | /* | 1781 | /* |
@@ -1819,29 +1823,31 @@ xfs_qm_vop_chown( | |||
1819 | */ | 1823 | */ |
1820 | int | 1824 | int |
1821 | xfs_qm_vop_chown_reserve( | 1825 | xfs_qm_vop_chown_reserve( |
1822 | xfs_trans_t *tp, | 1826 | struct xfs_trans *tp, |
1823 | xfs_inode_t *ip, | 1827 | struct xfs_inode *ip, |
1824 | xfs_dquot_t *udqp, | 1828 | struct xfs_dquot *udqp, |
1825 | xfs_dquot_t *gdqp, | 1829 | struct xfs_dquot *gdqp, |
1826 | uint flags) | 1830 | uint flags) |
1827 | { | 1831 | { |
1828 | xfs_mount_t *mp = ip->i_mount; | 1832 | struct xfs_mount *mp = ip->i_mount; |
1829 | uint delblks, blkflags, prjflags = 0; | 1833 | uint delblks, blkflags, prjflags = 0; |
1830 | xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; | 1834 | struct xfs_dquot *udq_unres = NULL; |
1831 | int error; | 1835 | struct xfs_dquot *gdq_unres = NULL; |
1836 | struct xfs_dquot *udq_delblks = NULL; | ||
1837 | struct xfs_dquot *gdq_delblks = NULL; | ||
1838 | int error; | ||
1832 | 1839 | ||
1833 | 1840 | ||
1834 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); | 1841 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); |
1835 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 1842 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
1836 | 1843 | ||
1837 | delblks = ip->i_delayed_blks; | 1844 | delblks = ip->i_delayed_blks; |
1838 | delblksudq = delblksgdq = unresudq = unresgdq = NULL; | ||
1839 | blkflags = XFS_IS_REALTIME_INODE(ip) ? | 1845 | blkflags = XFS_IS_REALTIME_INODE(ip) ? |
1840 | XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; | 1846 | XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; |
1841 | 1847 | ||
1842 | if (XFS_IS_UQUOTA_ON(mp) && udqp && | 1848 | if (XFS_IS_UQUOTA_ON(mp) && udqp && |
1843 | ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) { | 1849 | ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) { |
1844 | delblksudq = udqp; | 1850 | udq_delblks = udqp; |
1845 | /* | 1851 | /* |
1846 | * If there are delayed allocation blocks, then we have to | 1852 | * If there are delayed allocation blocks, then we have to |
1847 | * unreserve those from the old dquot, and add them to the | 1853 | * unreserve those from the old dquot, and add them to the |
@@ -1849,7 +1855,7 @@ xfs_qm_vop_chown_reserve( | |||
1849 | */ | 1855 | */ |
1850 | if (delblks) { | 1856 | if (delblks) { |
1851 | ASSERT(ip->i_udquot); | 1857 | ASSERT(ip->i_udquot); |
1852 | unresudq = ip->i_udquot; | 1858 | udq_unres = ip->i_udquot; |
1853 | } | 1859 | } |
1854 | } | 1860 | } |
1855 | if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { | 1861 | if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { |
@@ -1860,18 +1866,19 @@ xfs_qm_vop_chown_reserve( | |||
1860 | if (prjflags || | 1866 | if (prjflags || |
1861 | (XFS_IS_GQUOTA_ON(ip->i_mount) && | 1867 | (XFS_IS_GQUOTA_ON(ip->i_mount) && |
1862 | ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id))) { | 1868 | ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id))) { |
1863 | delblksgdq = gdqp; | 1869 | gdq_delblks = gdqp; |
1864 | if (delblks) { | 1870 | if (delblks) { |
1865 | ASSERT(ip->i_gdquot); | 1871 | ASSERT(ip->i_gdquot); |
1866 | unresgdq = ip->i_gdquot; | 1872 | gdq_unres = ip->i_gdquot; |
1867 | } | 1873 | } |
1868 | } | 1874 | } |
1869 | } | 1875 | } |
1870 | 1876 | ||
1871 | if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount, | 1877 | error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount, |
1872 | delblksudq, delblksgdq, ip->i_d.di_nblocks, 1, | 1878 | udq_delblks, gdq_delblks, ip->i_d.di_nblocks, 1, |
1873 | flags | blkflags | prjflags))) | 1879 | flags | blkflags | prjflags); |
1874 | return (error); | 1880 | if (error) |
1881 | return error; | ||
1875 | 1882 | ||
1876 | /* | 1883 | /* |
1877 | * Do the delayed blks reservations/unreservations now. Since, these | 1884 | * Do the delayed blks reservations/unreservations now. Since, these |
@@ -1883,14 +1890,15 @@ xfs_qm_vop_chown_reserve( | |||
1883 | /* | 1890 | /* |
1884 | * Do the reservations first. Unreservation can't fail. | 1891 | * Do the reservations first. Unreservation can't fail. |
1885 | */ | 1892 | */ |
1886 | ASSERT(delblksudq || delblksgdq); | 1893 | ASSERT(udq_delblks || gdq_delblks); |
1887 | ASSERT(unresudq || unresgdq); | 1894 | ASSERT(udq_unres || gdq_unres); |
1888 | if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, | 1895 | error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, |
1889 | delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0, | 1896 | udq_delblks, gdq_delblks, (xfs_qcnt_t)delblks, 0, |
1890 | flags | blkflags | prjflags))) | 1897 | flags | blkflags | prjflags); |
1891 | return (error); | 1898 | if (error) |
1899 | return error; | ||
1892 | xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, | 1900 | xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, |
1893 | unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0, | 1901 | udq_unres, gdq_unres, -((xfs_qcnt_t)delblks), 0, |
1894 | blkflags); | 1902 | blkflags); |
1895 | } | 1903 | } |
1896 | 1904 | ||