aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/quota/xfs_qm.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/quota/xfs_qm.c')
-rw-r--r--fs/xfs/quota/xfs_qm.c142
1 files changed, 73 insertions, 69 deletions
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 5328a2937127..53a00fb217fa 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -167,7 +167,7 @@ xfs_Gqm_init(void)
167 xqm->qm_dqfree_ratio = XFS_QM_DQFREE_RATIO; 167 xqm->qm_dqfree_ratio = XFS_QM_DQFREE_RATIO;
168 xqm->qm_nrefs = 0; 168 xqm->qm_nrefs = 0;
169#ifdef DEBUG 169#ifdef DEBUG
170 mutex_init(&qcheck_lock, MUTEX_DEFAULT, "qchk"); 170 mutex_init(&qcheck_lock);
171#endif 171#endif
172 return xqm; 172 return xqm;
173} 173}
@@ -497,7 +497,7 @@ xfs_qm_dqflush_all(
497 int error; 497 int error;
498 498
499 if (mp->m_quotainfo == NULL) 499 if (mp->m_quotainfo == NULL)
500 return (0); 500 return 0;
501 niters = 0; 501 niters = 0;
502again: 502again:
503 xfs_qm_mplist_lock(mp); 503 xfs_qm_mplist_lock(mp);
@@ -528,7 +528,7 @@ again:
528 error = xfs_qm_dqflush(dqp, flags); 528 error = xfs_qm_dqflush(dqp, flags);
529 xfs_dqunlock(dqp); 529 xfs_dqunlock(dqp);
530 if (error) 530 if (error)
531 return (error); 531 return error;
532 532
533 xfs_qm_mplist_lock(mp); 533 xfs_qm_mplist_lock(mp);
534 if (recl != XFS_QI_MPLRECLAIMS(mp)) { 534 if (recl != XFS_QI_MPLRECLAIMS(mp)) {
@@ -540,7 +540,7 @@ again:
540 540
541 xfs_qm_mplist_unlock(mp); 541 xfs_qm_mplist_unlock(mp);
542 /* return ! busy */ 542 /* return ! busy */
543 return (0); 543 return 0;
544} 544}
545/* 545/*
546 * Release the group dquot pointers the user dquots may be 546 * Release the group dquot pointers the user dquots may be
@@ -599,7 +599,7 @@ xfs_qm_dqpurge_int(
599 int nmisses; 599 int nmisses;
600 600
601 if (mp->m_quotainfo == NULL) 601 if (mp->m_quotainfo == NULL)
602 return (0); 602 return 0;
603 603
604 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0; 604 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0;
605 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0; 605 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0;
@@ -796,7 +796,7 @@ xfs_qm_dqattach_one(
796 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 796 ASSERT(XFS_DQ_IS_LOCKED(dqp));
797 } 797 }
798#endif 798#endif
799 return (error); 799 return error;
800} 800}
801 801
802 802
@@ -897,7 +897,7 @@ xfs_qm_dqattach(
897 (! XFS_NOT_DQATTACHED(mp, ip)) || 897 (! XFS_NOT_DQATTACHED(mp, ip)) ||
898 (ip->i_ino == mp->m_sb.sb_uquotino) || 898 (ip->i_ino == mp->m_sb.sb_uquotino) ||
899 (ip->i_ino == mp->m_sb.sb_gquotino)) 899 (ip->i_ino == mp->m_sb.sb_gquotino))
900 return (0); 900 return 0;
901 901
902 ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 || 902 ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 ||
903 XFS_ISLOCKED_INODE_EXCL(ip)); 903 XFS_ISLOCKED_INODE_EXCL(ip));
@@ -984,7 +984,7 @@ xfs_qm_dqattach(
984 else 984 else
985 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip)); 985 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
986#endif 986#endif
987 return (error); 987 return error;
988} 988}
989 989
990/* 990/*
@@ -1049,7 +1049,7 @@ xfs_qm_sync(
1049 */ 1049 */
1050 if (! XFS_IS_QUOTA_ON(mp)) { 1050 if (! XFS_IS_QUOTA_ON(mp)) {
1051 xfs_qm_mplist_unlock(mp); 1051 xfs_qm_mplist_unlock(mp);
1052 return (0); 1052 return 0;
1053 } 1053 }
1054 FOREACH_DQUOT_IN_MP(dqp, mp) { 1054 FOREACH_DQUOT_IN_MP(dqp, mp) {
1055 /* 1055 /*
@@ -1109,9 +1109,9 @@ xfs_qm_sync(
1109 error = xfs_qm_dqflush(dqp, flush_flags); 1109 error = xfs_qm_dqflush(dqp, flush_flags);
1110 xfs_dqunlock(dqp); 1110 xfs_dqunlock(dqp);
1111 if (error && XFS_FORCED_SHUTDOWN(mp)) 1111 if (error && XFS_FORCED_SHUTDOWN(mp))
1112 return(0); /* Need to prevent umount failure */ 1112 return 0; /* Need to prevent umount failure */
1113 else if (error) 1113 else if (error)
1114 return (error); 1114 return error;
1115 1115
1116 xfs_qm_mplist_lock(mp); 1116 xfs_qm_mplist_lock(mp);
1117 if (recl != XFS_QI_MPLRECLAIMS(mp)) { 1117 if (recl != XFS_QI_MPLRECLAIMS(mp)) {
@@ -1124,7 +1124,7 @@ xfs_qm_sync(
1124 } 1124 }
1125 1125
1126 xfs_qm_mplist_unlock(mp); 1126 xfs_qm_mplist_unlock(mp);
1127 return (0); 1127 return 0;
1128} 1128}
1129 1129
1130 1130
@@ -1146,7 +1146,7 @@ xfs_qm_init_quotainfo(
1146 * Tell XQM that we exist as soon as possible. 1146 * Tell XQM that we exist as soon as possible.
1147 */ 1147 */
1148 if ((error = xfs_qm_hold_quotafs_ref(mp))) { 1148 if ((error = xfs_qm_hold_quotafs_ref(mp))) {
1149 return (error); 1149 return error;
1150 } 1150 }
1151 1151
1152 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); 1152 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
@@ -1158,7 +1158,7 @@ xfs_qm_init_quotainfo(
1158 if ((error = xfs_qm_init_quotainos(mp))) { 1158 if ((error = xfs_qm_init_quotainos(mp))) {
1159 kmem_free(qinf, sizeof(xfs_quotainfo_t)); 1159 kmem_free(qinf, sizeof(xfs_quotainfo_t));
1160 mp->m_quotainfo = NULL; 1160 mp->m_quotainfo = NULL;
1161 return (error); 1161 return error;
1162 } 1162 }
1163 1163
1164 spinlock_init(&qinf->qi_pinlock, "xfs_qinf_pin"); 1164 spinlock_init(&qinf->qi_pinlock, "xfs_qinf_pin");
@@ -1166,7 +1166,7 @@ xfs_qm_init_quotainfo(
1166 qinf->qi_dqreclaims = 0; 1166 qinf->qi_dqreclaims = 0;
1167 1167
1168 /* mutex used to serialize quotaoffs */ 1168 /* mutex used to serialize quotaoffs */
1169 mutex_init(&qinf->qi_quotaofflock, MUTEX_DEFAULT, "qoff"); 1169 mutex_init(&qinf->qi_quotaofflock);
1170 1170
1171 /* Precalc some constants */ 1171 /* Precalc some constants */
1172 qinf->qi_dqchunklen = XFS_FSB_TO_BB(mp, XFS_DQUOT_CLUSTER_SIZE_FSB); 1172 qinf->qi_dqchunklen = XFS_FSB_TO_BB(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
@@ -1232,7 +1232,7 @@ xfs_qm_init_quotainfo(
1232 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT; 1232 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
1233 } 1233 }
1234 1234
1235 return (0); 1235 return 0;
1236} 1236}
1237 1237
1238 1238
@@ -1285,7 +1285,7 @@ xfs_qm_list_init(
1285 char *str, 1285 char *str,
1286 int n) 1286 int n)
1287{ 1287{
1288 mutex_init(&list->qh_lock, MUTEX_DEFAULT, str); 1288 mutex_init(&list->qh_lock);
1289 list->qh_next = NULL; 1289 list->qh_next = NULL;
1290 list->qh_version = 0; 1290 list->qh_version = 0;
1291 list->qh_nelems = 0; 1291 list->qh_nelems = 0;
@@ -1332,7 +1332,7 @@ xfs_qm_dqget_noattach(
1332 */ 1332 */
1333 ASSERT(error != ESRCH); 1333 ASSERT(error != ESRCH);
1334 ASSERT(error != ENOENT); 1334 ASSERT(error != ENOENT);
1335 return (error); 1335 return error;
1336 } 1336 }
1337 ASSERT(udqp); 1337 ASSERT(udqp);
1338 } 1338 }
@@ -1355,7 +1355,7 @@ xfs_qm_dqget_noattach(
1355 xfs_qm_dqrele(udqp); 1355 xfs_qm_dqrele(udqp);
1356 ASSERT(error != ESRCH); 1356 ASSERT(error != ESRCH);
1357 ASSERT(error != ENOENT); 1357 ASSERT(error != ENOENT);
1358 return (error); 1358 return error;
1359 } 1359 }
1360 ASSERT(gdqp); 1360 ASSERT(gdqp);
1361 1361
@@ -1376,7 +1376,7 @@ xfs_qm_dqget_noattach(
1376 if (udqp) ASSERT(XFS_DQ_IS_LOCKED(udqp)); 1376 if (udqp) ASSERT(XFS_DQ_IS_LOCKED(udqp));
1377 if (gdqp) ASSERT(XFS_DQ_IS_LOCKED(gdqp)); 1377 if (gdqp) ASSERT(XFS_DQ_IS_LOCKED(gdqp));
1378#endif 1378#endif
1379 return (0); 1379 return 0;
1380} 1380}
1381 1381
1382/* 1382/*
@@ -1392,26 +1392,28 @@ xfs_qm_qino_alloc(
1392{ 1392{
1393 xfs_trans_t *tp; 1393 xfs_trans_t *tp;
1394 int error; 1394 int error;
1395 unsigned long s; 1395 unsigned long s;
1396 cred_t zerocr; 1396 cred_t zerocr;
1397 xfs_inode_t zeroino;
1397 int committed; 1398 int committed;
1398 1399
1399 tp = xfs_trans_alloc(mp,XFS_TRANS_QM_QINOCREATE); 1400 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QINOCREATE);
1400 if ((error = xfs_trans_reserve(tp, 1401 if ((error = xfs_trans_reserve(tp,
1401 XFS_QM_QINOCREATE_SPACE_RES(mp), 1402 XFS_QM_QINOCREATE_SPACE_RES(mp),
1402 XFS_CREATE_LOG_RES(mp), 0, 1403 XFS_CREATE_LOG_RES(mp), 0,
1403 XFS_TRANS_PERM_LOG_RES, 1404 XFS_TRANS_PERM_LOG_RES,
1404 XFS_CREATE_LOG_COUNT))) { 1405 XFS_CREATE_LOG_COUNT))) {
1405 xfs_trans_cancel(tp, 0); 1406 xfs_trans_cancel(tp, 0);
1406 return (error); 1407 return error;
1407 } 1408 }
1408 memset(&zerocr, 0, sizeof(zerocr)); 1409 memset(&zerocr, 0, sizeof(zerocr));
1410 memset(&zeroino, 0, sizeof(zeroino));
1409 1411
1410 if ((error = xfs_dir_ialloc(&tp, mp->m_rootip, S_IFREG, 1, 0, 1412 if ((error = xfs_dir_ialloc(&tp, &zeroino, S_IFREG, 1, 0,
1411 &zerocr, 0, 1, ip, &committed))) { 1413 &zerocr, 0, 1, ip, &committed))) {
1412 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | 1414 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |
1413 XFS_TRANS_ABORT); 1415 XFS_TRANS_ABORT);
1414 return (error); 1416 return error;
1415 } 1417 }
1416 1418
1417 /* 1419 /*
@@ -1459,9 +1461,9 @@ xfs_qm_qino_alloc(
1459 if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, 1461 if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES,
1460 NULL))) { 1462 NULL))) {
1461 xfs_fs_cmn_err(CE_ALERT, mp, "XFS qino_alloc failed!"); 1463 xfs_fs_cmn_err(CE_ALERT, mp, "XFS qino_alloc failed!");
1462 return (error); 1464 return error;
1463 } 1465 }
1464 return (0); 1466 return 0;
1465} 1467}
1466 1468
1467 1469
@@ -1506,7 +1508,7 @@ xfs_qm_reset_dqcounts(
1506 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); 1508 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1);
1507 } 1509 }
1508 1510
1509 return (0); 1511 return 0;
1510} 1512}
1511 1513
1512STATIC int 1514STATIC int
@@ -1555,7 +1557,7 @@ xfs_qm_dqiter_bufs(
1555 bno++; 1557 bno++;
1556 firstid += XFS_QM_DQPERBLK(mp); 1558 firstid += XFS_QM_DQPERBLK(mp);
1557 } 1559 }
1558 return (error); 1560 return error;
1559} 1561}
1560 1562
1561/* 1563/*
@@ -1584,7 +1586,7 @@ xfs_qm_dqiterate(
1584 * happens only at mount time which is single threaded. 1586 * happens only at mount time which is single threaded.
1585 */ 1587 */
1586 if (qip->i_d.di_nblocks == 0) 1588 if (qip->i_d.di_nblocks == 0)
1587 return (0); 1589 return 0;
1588 1590
1589 map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP); 1591 map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP);
1590 1592
@@ -1653,7 +1655,7 @@ xfs_qm_dqiterate(
1653 1655
1654 kmem_free(map, XFS_DQITER_MAP_SIZE * sizeof(*map)); 1656 kmem_free(map, XFS_DQITER_MAP_SIZE * sizeof(*map));
1655 1657
1656 return (error); 1658 return error;
1657} 1659}
1658 1660
1659/* 1661/*
@@ -1713,7 +1715,7 @@ xfs_qm_get_rtblks(
1713 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 1715 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1714 if (!(ifp->if_flags & XFS_IFEXTENTS)) { 1716 if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1715 if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK))) 1717 if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK)))
1716 return (error); 1718 return error;
1717 } 1719 }
1718 rtblks = 0; 1720 rtblks = 0;
1719 nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t); 1721 nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
@@ -1721,7 +1723,7 @@ xfs_qm_get_rtblks(
1721 for (ep = base; ep < &base[nextents]; ep++) 1723 for (ep = base; ep < &base[nextents]; ep++)
1722 rtblks += xfs_bmbt_get_blockcount(ep); 1724 rtblks += xfs_bmbt_get_blockcount(ep);
1723 *O_rtblks = (xfs_qcnt_t)rtblks; 1725 *O_rtblks = (xfs_qcnt_t)rtblks;
1724 return (0); 1726 return 0;
1725} 1727}
1726 1728
1727/* 1729/*
@@ -1765,7 +1767,7 @@ xfs_qm_dqusage_adjust(
1765 */ 1767 */
1766 if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) { 1768 if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) {
1767 *res = BULKSTAT_RV_NOTHING; 1769 *res = BULKSTAT_RV_NOTHING;
1768 return (error); 1770 return error;
1769 } 1771 }
1770 1772
1771 if (ip->i_d.di_mode == 0) { 1773 if (ip->i_d.di_mode == 0) {
@@ -1783,7 +1785,7 @@ xfs_qm_dqusage_adjust(
1783 if ((error = xfs_qm_dqget_noattach(ip, &udqp, &gdqp))) { 1785 if ((error = xfs_qm_dqget_noattach(ip, &udqp, &gdqp))) {
1784 xfs_iput(ip, XFS_ILOCK_EXCL); 1786 xfs_iput(ip, XFS_ILOCK_EXCL);
1785 *res = BULKSTAT_RV_GIVEUP; 1787 *res = BULKSTAT_RV_GIVEUP;
1786 return (error); 1788 return error;
1787 } 1789 }
1788 1790
1789 rtblks = 0; 1791 rtblks = 0;
@@ -1800,7 +1802,7 @@ xfs_qm_dqusage_adjust(
1800 if (gdqp) 1802 if (gdqp)
1801 xfs_qm_dqput(gdqp); 1803 xfs_qm_dqput(gdqp);
1802 *res = BULKSTAT_RV_GIVEUP; 1804 *res = BULKSTAT_RV_GIVEUP;
1803 return (error); 1805 return error;
1804 } 1806 }
1805 nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks; 1807 nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
1806 } 1808 }
@@ -1845,7 +1847,7 @@ xfs_qm_dqusage_adjust(
1845 * Goto next inode. 1847 * Goto next inode.
1846 */ 1848 */
1847 *res = BULKSTAT_RV_DIDONE; 1849 *res = BULKSTAT_RV_DIDONE;
1848 return (0); 1850 return 0;
1849} 1851}
1850 1852
1851/* 1853/*
@@ -1918,9 +1920,7 @@ xfs_qm_quotacheck(
1918 * at this point (because we intentionally didn't in dqget_noattach). 1920 * at this point (because we intentionally didn't in dqget_noattach).
1919 */ 1921 */
1920 if (error) { 1922 if (error) {
1921 xfs_qm_dqpurge_all(mp, 1923 xfs_qm_dqpurge_all(mp, XFS_QMOPT_QUOTALL | XFS_QMOPT_QUOTAOFF);
1922 XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA|
1923 XFS_QMOPT_PQUOTA|XFS_QMOPT_QUOTAOFF);
1924 goto error_return; 1924 goto error_return;
1925 } 1925 }
1926 /* 1926 /*
@@ -2041,7 +2041,7 @@ xfs_qm_init_quotainos(
2041 XFS_QI_UQIP(mp) = uip; 2041 XFS_QI_UQIP(mp) = uip;
2042 XFS_QI_GQIP(mp) = gip; 2042 XFS_QI_GQIP(mp) = gip;
2043 2043
2044 return (0); 2044 return 0;
2045} 2045}
2046 2046
2047 2047
@@ -2062,7 +2062,7 @@ xfs_qm_shake_freelist(
2062 int nflushes; 2062 int nflushes;
2063 2063
2064 if (howmany <= 0) 2064 if (howmany <= 0)
2065 return (0); 2065 return 0;
2066 2066
2067 nreclaimed = 0; 2067 nreclaimed = 0;
2068 restarts = 0; 2068 restarts = 0;
@@ -2088,7 +2088,7 @@ xfs_qm_shake_freelist(
2088 xfs_dqunlock(dqp); 2088 xfs_dqunlock(dqp);
2089 xfs_qm_freelist_unlock(xfs_Gqm); 2089 xfs_qm_freelist_unlock(xfs_Gqm);
2090 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) 2090 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
2091 return (nreclaimed); 2091 return nreclaimed;
2092 XQM_STATS_INC(xqmstats.xs_qm_dqwants); 2092 XQM_STATS_INC(xqmstats.xs_qm_dqwants);
2093 goto tryagain; 2093 goto tryagain;
2094 } 2094 }
@@ -2163,7 +2163,7 @@ xfs_qm_shake_freelist(
2163 XFS_DQ_HASH_UNLOCK(hash); 2163 XFS_DQ_HASH_UNLOCK(hash);
2164 xfs_qm_freelist_unlock(xfs_Gqm); 2164 xfs_qm_freelist_unlock(xfs_Gqm);
2165 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) 2165 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
2166 return (nreclaimed); 2166 return nreclaimed;
2167 goto tryagain; 2167 goto tryagain;
2168 } 2168 }
2169 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); 2169 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
@@ -2188,7 +2188,7 @@ xfs_qm_shake_freelist(
2188 dqp = nextdqp; 2188 dqp = nextdqp;
2189 } 2189 }
2190 xfs_qm_freelist_unlock(xfs_Gqm); 2190 xfs_qm_freelist_unlock(xfs_Gqm);
2191 return (nreclaimed); 2191 return nreclaimed;
2192} 2192}
2193 2193
2194 2194
@@ -2202,9 +2202,9 @@ xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask)
2202 int ndqused, nfree, n; 2202 int ndqused, nfree, n;
2203 2203
2204 if (!kmem_shake_allow(gfp_mask)) 2204 if (!kmem_shake_allow(gfp_mask))
2205 return (0); 2205 return 0;
2206 if (!xfs_Gqm) 2206 if (!xfs_Gqm)
2207 return (0); 2207 return 0;
2208 2208
2209 nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */ 2209 nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */
2210 /* incore dquots in all f/s's */ 2210 /* incore dquots in all f/s's */
@@ -2213,7 +2213,7 @@ xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask)
2213 ASSERT(ndqused >= 0); 2213 ASSERT(ndqused >= 0);
2214 2214
2215 if (nfree <= ndqused && nfree < ndquot) 2215 if (nfree <= ndqused && nfree < ndquot)
2216 return (0); 2216 return 0;
2217 2217
2218 ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */ 2218 ndqused *= xfs_Gqm->qm_dqfree_ratio; /* target # of free dquots */
2219 n = nfree - ndqused - ndquot; /* # over target */ 2219 n = nfree - ndqused - ndquot; /* # over target */
@@ -2257,7 +2257,7 @@ xfs_qm_dqreclaim_one(void)
2257 xfs_dqunlock(dqp); 2257 xfs_dqunlock(dqp);
2258 xfs_qm_freelist_unlock(xfs_Gqm); 2258 xfs_qm_freelist_unlock(xfs_Gqm);
2259 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) 2259 if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
2260 return (NULL); 2260 return NULL;
2261 XQM_STATS_INC(xqmstats.xs_qm_dqwants); 2261 XQM_STATS_INC(xqmstats.xs_qm_dqwants);
2262 goto startagain; 2262 goto startagain;
2263 } 2263 }
@@ -2333,7 +2333,7 @@ xfs_qm_dqreclaim_one(void)
2333 } 2333 }
2334 2334
2335 xfs_qm_freelist_unlock(xfs_Gqm); 2335 xfs_qm_freelist_unlock(xfs_Gqm);
2336 return (dqpout); 2336 return dqpout;
2337} 2337}
2338 2338
2339 2339
@@ -2369,7 +2369,7 @@ xfs_qm_dqalloc_incore(
2369 */ 2369 */
2370 memset(&dqp->q_core, 0, sizeof(dqp->q_core)); 2370 memset(&dqp->q_core, 0, sizeof(dqp->q_core));
2371 *O_dqpp = dqp; 2371 *O_dqpp = dqp;
2372 return (B_FALSE); 2372 return B_FALSE;
2373 } 2373 }
2374 XQM_STATS_INC(xqmstats.xs_qm_dqreclaim_misses); 2374 XQM_STATS_INC(xqmstats.xs_qm_dqreclaim_misses);
2375 } 2375 }
@@ -2382,7 +2382,7 @@ xfs_qm_dqalloc_incore(
2382 *O_dqpp = kmem_zone_zalloc(xfs_Gqm->qm_dqzone, KM_SLEEP); 2382 *O_dqpp = kmem_zone_zalloc(xfs_Gqm->qm_dqzone, KM_SLEEP);
2383 atomic_inc(&xfs_Gqm->qm_totaldquots); 2383 atomic_inc(&xfs_Gqm->qm_totaldquots);
2384 2384
2385 return (B_TRUE); 2385 return B_TRUE;
2386} 2386}
2387 2387
2388 2388
@@ -2407,13 +2407,13 @@ xfs_qm_write_sb_changes(
2407 0, 2407 0,
2408 XFS_DEFAULT_LOG_COUNT))) { 2408 XFS_DEFAULT_LOG_COUNT))) {
2409 xfs_trans_cancel(tp, 0); 2409 xfs_trans_cancel(tp, 0);
2410 return (error); 2410 return error;
2411 } 2411 }
2412 2412
2413 xfs_mod_sb(tp, flags); 2413 xfs_mod_sb(tp, flags);
2414 (void) xfs_trans_commit(tp, 0, NULL); 2414 (void) xfs_trans_commit(tp, 0, NULL);
2415 2415
2416 return (0); 2416 return 0;
2417} 2417}
2418 2418
2419 2419
@@ -2463,7 +2463,7 @@ xfs_qm_vop_dqalloc(
2463 if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC | 2463 if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC |
2464 XFS_QMOPT_ILOCKED))) { 2464 XFS_QMOPT_ILOCKED))) {
2465 xfs_iunlock(ip, lockflags); 2465 xfs_iunlock(ip, lockflags);
2466 return (error); 2466 return error;
2467 } 2467 }
2468 } 2468 }
2469 2469
@@ -2486,7 +2486,7 @@ xfs_qm_vop_dqalloc(
2486 XFS_QMOPT_DOWARN, 2486 XFS_QMOPT_DOWARN,
2487 &uq))) { 2487 &uq))) {
2488 ASSERT(error != ENOENT); 2488 ASSERT(error != ENOENT);
2489 return (error); 2489 return error;
2490 } 2490 }
2491 /* 2491 /*
2492 * Get the ilock in the right order. 2492 * Get the ilock in the right order.
@@ -2517,7 +2517,7 @@ xfs_qm_vop_dqalloc(
2517 if (uq) 2517 if (uq)
2518 xfs_qm_dqrele(uq); 2518 xfs_qm_dqrele(uq);
2519 ASSERT(error != ENOENT); 2519 ASSERT(error != ENOENT);
2520 return (error); 2520 return error;
2521 } 2521 }
2522 xfs_dqunlock(gq); 2522 xfs_dqunlock(gq);
2523 lockflags = XFS_ILOCK_SHARED; 2523 lockflags = XFS_ILOCK_SHARED;
@@ -2565,7 +2565,7 @@ xfs_qm_vop_dqalloc(
2565 *O_gdqpp = gq; 2565 *O_gdqpp = gq;
2566 else if (gq) 2566 else if (gq)
2567 xfs_qm_dqrele(gq); 2567 xfs_qm_dqrele(gq);
2568 return (0); 2568 return 0;
2569} 2569}
2570 2570
2571/* 2571/*
@@ -2608,7 +2608,7 @@ xfs_qm_vop_chown(
2608 xfs_dqunlock(newdq); 2608 xfs_dqunlock(newdq);
2609 *IO_olddq = newdq; 2609 *IO_olddq = newdq;
2610 2610
2611 return (prevdq); 2611 return prevdq;
2612} 2612}
2613 2613
2614/* 2614/*
@@ -2702,12 +2702,12 @@ xfs_qm_vop_rename_dqattach(
2702 ip = i_tab[0]; 2702 ip = i_tab[0];
2703 2703
2704 if (! XFS_IS_QUOTA_ON(ip->i_mount)) 2704 if (! XFS_IS_QUOTA_ON(ip->i_mount))
2705 return (0); 2705 return 0;
2706 2706
2707 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2707 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) {
2708 error = xfs_qm_dqattach(ip, 0); 2708 error = xfs_qm_dqattach(ip, 0);
2709 if (error) 2709 if (error)
2710 return (error); 2710 return error;
2711 } 2711 }
2712 for (i = 1; (i < 4 && i_tab[i]); i++) { 2712 for (i = 1; (i < 4 && i_tab[i]); i++) {
2713 /* 2713 /*
@@ -2717,11 +2717,11 @@ xfs_qm_vop_rename_dqattach(
2717 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2717 if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) {
2718 error = xfs_qm_dqattach(ip, 0); 2718 error = xfs_qm_dqattach(ip, 0);
2719 if (error) 2719 if (error)
2720 return (error); 2720 return error;
2721 } 2721 }
2722 } 2722 }
2723 } 2723 }
2724 return (0); 2724 return 0;
2725} 2725}
2726 2726
2727void 2727void
@@ -2743,6 +2743,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
2743 xfs_dqunlock(udqp); 2743 xfs_dqunlock(udqp);
2744 ASSERT(ip->i_udquot == NULL); 2744 ASSERT(ip->i_udquot == NULL);
2745 ip->i_udquot = udqp; 2745 ip->i_udquot = udqp;
2746 ASSERT(XFS_IS_UQUOTA_ON(tp->t_mountp));
2746 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); 2747 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id));
2747 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); 2748 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);
2748 } 2749 }
@@ -2752,7 +2753,10 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
2752 xfs_dqunlock(gdqp); 2753 xfs_dqunlock(gdqp);
2753 ASSERT(ip->i_gdquot == NULL); 2754 ASSERT(ip->i_gdquot == NULL);
2754 ip->i_gdquot = gdqp; 2755 ip->i_gdquot = gdqp;
2755 ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); 2756 ASSERT(XFS_IS_OQUOTA_ON(tp->t_mountp));
2757 ASSERT((XFS_IS_GQUOTA_ON(tp->t_mountp) ?
2758 ip->i_d.di_gid : ip->i_d.di_projid) ==
2759 be32_to_cpu(gdqp->q_core.d_id));
2756 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); 2760 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
2757 } 2761 }
2758} 2762}
@@ -2762,7 +2766,7 @@ STATIC void
2762xfs_qm_freelist_init(xfs_frlist_t *ql) 2766xfs_qm_freelist_init(xfs_frlist_t *ql)
2763{ 2767{
2764 ql->qh_next = ql->qh_prev = (xfs_dquot_t *) ql; 2768 ql->qh_next = ql->qh_prev = (xfs_dquot_t *) ql;
2765 mutex_init(&ql->qh_lock, MUTEX_DEFAULT, "dqf"); 2769 mutex_init(&ql->qh_lock);
2766 ql->qh_version = 0; 2770 ql->qh_version = 0;
2767 ql->qh_nelems = 0; 2771 ql->qh_nelems = 0;
2768} 2772}
@@ -2772,7 +2776,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql)
2772{ 2776{
2773 xfs_dquot_t *dqp, *nextdqp; 2777 xfs_dquot_t *dqp, *nextdqp;
2774 2778
2775 mutex_lock(&ql->qh_lock, PINOD); 2779 mutex_lock(&ql->qh_lock);
2776 for (dqp = ql->qh_next; 2780 for (dqp = ql->qh_next;
2777 dqp != (xfs_dquot_t *)ql; ) { 2781 dqp != (xfs_dquot_t *)ql; ) {
2778 xfs_dqlock(dqp); 2782 xfs_dqlock(dqp);
@@ -2830,7 +2834,7 @@ xfs_qm_dqhashlock_nowait(
2830 int locked; 2834 int locked;
2831 2835
2832 locked = mutex_trylock(&((dqp)->q_hash->qh_lock)); 2836 locked = mutex_trylock(&((dqp)->q_hash->qh_lock));
2833 return (locked); 2837 return locked;
2834} 2838}
2835 2839
2836int 2840int
@@ -2840,7 +2844,7 @@ xfs_qm_freelist_lock_nowait(
2840 int locked; 2844 int locked;
2841 2845
2842 locked = mutex_trylock(&(xqm->qm_dqfreelist.qh_lock)); 2846 locked = mutex_trylock(&(xqm->qm_dqfreelist.qh_lock));
2843 return (locked); 2847 return locked;
2844} 2848}
2845 2849
2846STATIC int 2850STATIC int
@@ -2851,5 +2855,5 @@ xfs_qm_mplist_nowait(
2851 2855
2852 ASSERT(mp->m_quotainfo); 2856 ASSERT(mp->m_quotainfo);
2853 locked = mutex_trylock(&(XFS_QI_MPLLOCK(mp))); 2857 locked = mutex_trylock(&(XFS_QI_MPLLOCK(mp)));
2854 return (locked); 2858 return locked;
2855} 2859}