Lines Matching defs:dq

155 	struct dquot *dq;
180 if ((dq = ip->i_dquot[i]) == NODQUOT)
182 DQI_LOCK(dq);
183 DQI_WAIT(dq, PINOD+1, "chkdq1");
184 ncurblocks = dq->dq_curblocks + change;
186 dq->dq_curblocks = ncurblocks;
188 dq->dq_curblocks = 0;
189 dq->dq_flags &= ~DQ_BLKS;
190 dq->dq_flags |= DQ_MOD;
191 DQI_UNLOCK(dq);
201 if ((dq = ip->i_dquot[i]) == NODQUOT)
204 DQI_LOCK(dq);
205 DQI_WAIT(dq, PINOD+1, "chkdq2");
215 dq = ip->i_dquot[i];
216 if (dq == NODQUOT)
218 DQI_LOCK(dq);
219 DQI_WAIT(dq, PINOD+1, "chkdq3");
220 ncurblocks = dq->dq_curblocks - change;
222 dq->dq_curblocks = ncurblocks;
224 dq->dq_curblocks = 0;
225 dq->dq_flags &= ~DQ_BLKS;
226 dq->dq_flags |= DQ_MOD;
227 DQI_UNLOCK(dq);
233 if (dq->dq_curblocks + change >= dq->dq_bsoftlimit &&
234 dq->dq_curblocks < dq->dq_bsoftlimit)
235 dq->dq_btime = time_second + ip->i_ump->um_btime[i];
236 dq->dq_curblocks += change;
237 dq->dq_flags |= DQ_MOD;
238 DQI_UNLOCK(dq);
255 struct dquot *dq = ip->i_dquot[type];
256 ufs2_daddr_t ncurblocks = dq->dq_curblocks + change;
261 if (ncurblocks >= dq->dq_bhardlimit && dq->dq_bhardlimit) {
262 if ((dq->dq_flags & DQ_BLKS) == 0 &&
264 dq->dq_flags |= DQ_BLKS;
265 DQI_UNLOCK(dq);
271 DQI_UNLOCK(dq);
278 if (ncurblocks >= dq->dq_bsoftlimit && dq->dq_bsoftlimit) {
279 if (dq->dq_curblocks < dq->dq_bsoftlimit) {
280 dq->dq_btime = time_second + ip->i_ump->um_btime[type];
285 if (time_second > dq->dq_btime) {
286 if ((dq->dq_flags & DQ_BLKS) == 0 &&
288 dq->dq_flags |= DQ_BLKS;
289 DQI_UNLOCK(dq);
296 DQI_UNLOCK(dq);
309 struct dquot *dq;
321 if ((dq = ip->i_dquot[i]) == NODQUOT)
323 DQI_LOCK(dq);
324 DQI_WAIT(dq, PINOD+1, "chkiq1");
325 ncurinodes = dq->dq_curinodes + change;
327 if (dq->dq_curinodes != 0 && ncurinodes >= 0)
328 dq->dq_curinodes = ncurinodes;
330 dq->dq_curinodes = 0;
331 dq->dq_flags &= ~DQ_INODS;
332 dq->dq_flags |= DQ_MOD;
333 DQI_UNLOCK(dq);
343 if ((dq = ip->i_dquot[i]) == NODQUOT)
346 DQI_LOCK(dq);
347 DQI_WAIT(dq, PINOD+1, "chkiq2");
357 dq = ip->i_dquot[i];
358 if (dq == NODQUOT)
360 DQI_LOCK(dq);
361 DQI_WAIT(dq, PINOD+1, "chkiq3");
362 ncurinodes = dq->dq_curinodes - change;
364 if (dq->dq_curinodes != 0 &&
366 dq->dq_curinodes = ncurinodes;
368 dq->dq_curinodes = 0;
369 dq->dq_flags &= ~DQ_INODS;
370 dq->dq_flags |= DQ_MOD;
371 DQI_UNLOCK(dq);
377 if (dq->dq_curinodes + change >= dq->dq_isoftlimit &&
378 dq->dq_curinodes < dq->dq_isoftlimit)
379 dq->dq_itime = time_second + ip->i_ump->um_itime[i];
380 dq->dq_curinodes += change;
381 dq->dq_flags |= DQ_MOD;
382 DQI_UNLOCK(dq);
398 struct dquot *dq = ip->i_dquot[type];
399 ino_t ncurinodes = dq->dq_curinodes + change;
404 if (ncurinodes >= dq->dq_ihardlimit && dq->dq_ihardlimit) {
405 if ((dq->dq_flags & DQ_INODS) == 0 &&
407 dq->dq_flags |= DQ_INODS;
408 DQI_UNLOCK(dq);
414 DQI_UNLOCK(dq);
421 if (ncurinodes >= dq->dq_isoftlimit && dq->dq_isoftlimit) {
422 if (dq->dq_curinodes < dq->dq_isoftlimit) {
423 dq->dq_itime = time_second + ip->i_ump->um_itime[type];
428 if (time_second > dq->dq_itime) {
429 if ((dq->dq_flags & DQ_INODS) == 0 &&
431 dq->dq_flags |= DQ_INODS;
432 DQI_UNLOCK(dq);
439 DQI_UNLOCK(dq);
499 struct dquot *dq;
511 dq = NODQUOT;
582 if (dqget(NULLVP, 0, ump, type, &dq) == 0) {
583 if (dq->dq_btime > 0)
584 ump->um_btime[type] = dq->dq_btime;
585 if (dq->dq_itime > 0)
586 ump->um_itime[type] = dq->dq_itime;
587 dqrele(NULLVP, dq);
643 struct dquot *dq;
676 dq = ip->i_dquot[type];
678 dqrele(vp, dq);
768 struct dquot *dq;
793 dq = NODQUOT;
794 error = dqget(NULLVP, id, VFSTOUFS(mp), type, &dq);
797 *dqb = dq->dq_dqb;
798 dqrele(NULLVP, dq);
809 struct dquot *dq;
827 dq = ndq;
828 DQI_LOCK(dq);
829 DQI_WAIT(dq, PINOD+1, "setqta");
835 newlim.dqb_curblocks = dq->dq_curblocks;
836 newlim.dqb_curinodes = dq->dq_curinodes;
837 if (dq->dq_id != 0) {
838 newlim.dqb_btime = dq->dq_btime;
839 newlim.dqb_itime = dq->dq_itime;
842 dq->dq_curblocks >= newlim.dqb_bsoftlimit &&
843 (dq->dq_bsoftlimit == 0 || dq->dq_curblocks < dq->dq_bsoftlimit))
846 dq->dq_curinodes >= newlim.dqb_isoftlimit &&
847 (dq->dq_isoftlimit == 0 || dq->dq_curinodes < dq->dq_isoftlimit))
849 dq->dq_dqb = newlim;
850 if (dq->dq_curblocks < dq->dq_bsoftlimit)
851 dq->dq_flags &= ~DQ_BLKS;
852 if (dq->dq_curinodes < dq->dq_isoftlimit)
853 dq->dq_flags &= ~DQ_INODS;
854 if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 &&
855 dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0)
856 dq->dq_flags |= DQ_FAKE;
858 dq->dq_flags &= ~DQ_FAKE;
859 dq->dq_flags |= DQ_MOD;
860 DQI_UNLOCK(dq);
861 dqrele(NULLVP, dq);
872 struct dquot *dq;
890 dq = ndq;
891 DQI_LOCK(dq);
892 DQI_WAIT(dq, PINOD+1, "setuse");
897 if (dq->dq_bsoftlimit && dq->dq_curblocks < dq->dq_bsoftlimit &&
898 usage.dqb_curblocks >= dq->dq_bsoftlimit)
899 dq->dq_btime = time_second + ump->um_btime[type];
900 if (dq->dq_isoftlimit && dq->dq_curinodes < dq->dq_isoftlimit &&
901 usage.dqb_curinodes >= dq->dq_isoftlimit)
902 dq->dq_itime = time_second + ump->um_itime[type];
903 dq->dq_curblocks = usage.dqb_curblocks;
904 dq->dq_curinodes = usage.dqb_curinodes;
905 if (dq->dq_curblocks < dq->dq_bsoftlimit)
906 dq->dq_flags &= ~DQ_BLKS;
907 if (dq->dq_curinodes < dq->dq_isoftlimit)
908 dq->dq_flags &= ~DQ_INODS;
909 dq->dq_flags |= DQ_MOD;
910 DQI_UNLOCK(dq);
911 dqrele(NULLVP, dq);
1032 struct dquot *dq;
1065 dq = VTOI(vp)->i_dquot[i];
1066 if (dq != NODQUOT)
1067 dqsync(vp, dq);
1081 struct dquot *dq;
1100 dq = VTOI(vp)->i_dquot[i];
1101 if (dq != NODQUOT)
1102 dqsync(vp, dq);
1123 * Lock to protect quota hash, dq free list and dq_cnt ref counters of
1152 struct dquot *dq;
1155 while ((dq = TAILQ_FIRST(&dqfreelist)) != NULL) {
1156 TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
1157 mtx_destroy(&dq->dq_lock);
1158 free(dq, M_DQUOT);
1166 struct dquot *dq;
1169 LIST_FOREACH(dq, dqh, dq_hash) {
1170 if (dq->dq_id != id ||
1171 dq->dq_ump->um_quotas[dq->dq_type] != dqvp)
1177 if (dq->dq_cnt == 0)
1178 TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
1179 DQREF(dq);
1180 return (dq);
1248 struct dquot *dq, *dq1;
1287 dq = dqhashfind(dqh, id, dqvp);
1288 if (dq != NULL) {
1290 hfound: DQI_LOCK(dq);
1291 DQI_WAIT(dq, PINOD+1, "dqget");
1292 DQI_UNLOCK(dq);
1293 if (dq->dq_ump == NULL) {
1294 dqrele(vp, dq);
1295 dq = NODQUOT;
1298 *dqp = dq;
1310 * since new dq will appear on the hash chain DQ_LOCKed.
1320 dq = dqhashfind(dqh, id, dqvp);
1321 if (dq != NULL) {
1343 dq = dqhashfind(dqh, id, dqvp);
1344 if (dq != NULL) {
1351 dq = dq1;
1353 if ((dq = TAILQ_FIRST(&dqfreelist)) == NULL) {
1365 if (dq->dq_cnt || (dq->dq_flags & DQ_MOD))
1366 panic("dqget: free dquot isn't %p", dq);
1367 TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
1368 if (dq->dq_ump != NULL)
1369 LIST_REMOVE(dq, dq_hash);
1376 dq->dq_flags = DQ_LOCK;
1377 dq->dq_id = id;
1378 dq->dq_type = type;
1379 dq->dq_ump = ump;
1380 LIST_INSERT_HEAD(dqh, dq, dq_hash);
1381 DQREF(dq);
1408 bzero(&dq->dq_dqb, sizeof(dq->dq_dqb));
1411 dqb64_dq((struct dqblk64 *)buf, dq);
1413 dqb32_dq((struct dqblk32 *)buf, dq);
1426 dq->dq_ump = NULL;
1427 LIST_REMOVE(dq, dq_hash);
1429 DQI_LOCK(dq);
1430 if (dq->dq_flags & DQ_WANT)
1431 wakeup(dq);
1432 dq->dq_flags = 0;
1433 DQI_UNLOCK(dq);
1434 dqrele(vp, dq);
1438 DQI_LOCK(dq);
1443 if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 &&
1444 dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0)
1445 dq->dq_flags |= DQ_FAKE;
1446 if (dq->dq_id != 0) {
1447 if (dq->dq_btime == 0) {
1448 dq->dq_btime = time_second + ump->um_btime[type];
1449 if (dq->dq_bsoftlimit &&
1450 dq->dq_curblocks >= dq->dq_bsoftlimit)
1451 dq->dq_flags |= DQ_MOD;
1453 if (dq->dq_itime == 0) {
1454 dq->dq_itime = time_second + ump->um_itime[type];
1455 if (dq->dq_isoftlimit &&
1456 dq->dq_curinodes >= dq->dq_isoftlimit)
1457 dq->dq_flags |= DQ_MOD;
1460 DQI_WAKEUP(dq);
1461 DQI_UNLOCK(dq);
1462 *dqp = dq;
1471 dqref(struct dquot *dq)
1474 dq->dq_cnt++;
1482 dqrele(struct vnode *vp, struct dquot *dq)
1485 if (dq == NODQUOT)
1488 KASSERT(dq->dq_cnt > 0, ("Lost dq %p reference 1", dq));
1489 if (dq->dq_cnt > 1) {
1490 dq->dq_cnt--;
1496 (void) dqsync(vp, dq);
1499 KASSERT(dq->dq_cnt > 0, ("Lost dq %p reference 2", dq));
1500 if (--dq->dq_cnt > 0)
1507 * The dq may become dirty after it is synced but before it is
1509 * locking dq should be safe since no other references to the
1510 * dq exist.
1512 if ((dq->dq_flags & DQ_MOD) != 0) {
1513 dq->dq_cnt++;
1517 TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
1525 dqsync(struct vnode *vp, struct dquot *dq)
1543 if (dq == NODQUOT)
1545 if ((ump = dq->dq_ump) == NULL)
1548 if ((dqvp = ump->um_quotas[dq->dq_type]) == NULLVP)
1554 DQI_LOCK(dq);
1555 if ((dq->dq_flags & DQ_MOD) == 0) {
1556 DQI_UNLOCK(dq);
1561 DQI_UNLOCK(dq);
1568 DQI_LOCK(dq);
1569 DQI_WAIT(dq, PINOD+2, "dqsync");
1570 if ((dq->dq_flags & DQ_MOD) == 0)
1572 dq->dq_flags |= DQ_LOCK;
1573 DQI_UNLOCK(dq);
1579 if (ump->um_qflags[dq->dq_type] & QTF_64BIT) {
1580 dq_dqb64(dq, (struct dqblk64 *)buf);
1584 dq_dqb32(dq, (struct dqblk32 *)buf);
1594 auio.uio_offset = base + dq->dq_id * recsize;
1599 error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]);
1604 DQI_LOCK(dq);
1605 DQI_WAKEUP(dq);
1606 dq->dq_flags &= ~DQ_MOD;
1608 DQI_UNLOCK(dq);
1625 struct dquot *dq, *nextdq;
1637 for (dq = LIST_FIRST(dqh); dq; dq = nextdq) {
1638 nextdq = LIST_NEXT(dq, dq_hash);
1639 if (dq->dq_ump->um_quotas[dq->dq_type] != vp)
1641 if (dq->dq_cnt)
1644 LIST_REMOVE(dq, dq_hash);
1645 dq->dq_ump = NULL;
1668 struct dquot *dq;
1686 if ((dq = ip->i_dquot[i]) == NODQUOT)
1688 DQREF(dq);
1689 qrp[i] = dq;
1703 struct dquot *dq;
1707 if ((dq = qrp[i]) == NODQUOT)
1709 dqrele(NULL, dq);
1723 struct dquot *dq;
1730 if ((dq = qrp[i]) == NODQUOT)
1732 DQI_LOCK(dq);
1733 DQI_WAIT(dq, PINOD+1, "adjqta");
1734 ncurblocks = dq->dq_curblocks + blkcount;
1736 dq->dq_curblocks = ncurblocks;
1738 dq->dq_curblocks = 0;
1740 dq->dq_flags &= ~DQ_BLKS;
1741 else if (dq->dq_curblocks + blkcount >= dq->dq_bsoftlimit &&
1742 dq->dq_curblocks < dq->dq_bsoftlimit)
1743 dq->dq_btime = time_second + ump->um_btime[i];
1744 dq->dq_flags |= DQ_MOD;
1745 DQI_UNLOCK(dq);
1765 dqb32_dq(const struct dqblk32 *dqb32, struct dquot *dq)
1768 dq->dq_bhardlimit = dqb32->dqb_bhardlimit;
1769 dq->dq_bsoftlimit = dqb32->dqb_bsoftlimit;
1770 dq->dq_curblocks = dqb32->dqb_curblocks;
1771 dq->dq_ihardlimit = dqb32->dqb_ihardlimit;
1772 dq->dq_isoftlimit = dqb32->dqb_isoftlimit;
1773 dq->dq_curinodes = dqb32->dqb_curinodes;
1774 dq->dq_btime = dqb32->dqb_btime;
1775 dq->dq_itime = dqb32->dqb_itime;
1782 dqb64_dq(const struct dqblk64 *dqb64, struct dquot *dq)
1785 dq->dq_bhardlimit = be64toh(dqb64->dqb_bhardlimit);
1786 dq->dq_bsoftlimit = be64toh(dqb64->dqb_bsoftlimit);
1787 dq->dq_curblocks = be64toh(dqb64->dqb_curblocks);
1788 dq->dq_ihardlimit = be64toh(dqb64->dqb_ihardlimit);
1789 dq->dq_isoftlimit = be64toh(dqb64->dqb_isoftlimit);
1790 dq->dq_curinodes = be64toh(dqb64->dqb_curinodes);
1791 dq->dq_btime = be64toh(dqb64->dqb_btime);
1792 dq->dq_itime = be64toh(dqb64->dqb_itime);
1799 dq_dqb32(const struct dquot *dq, struct dqblk32 *dqb32)
1802 dqb32->dqb_bhardlimit = CLIP32(dq->dq_bhardlimit);
1803 dqb32->dqb_bsoftlimit = CLIP32(dq->dq_bsoftlimit);
1804 dqb32->dqb_curblocks = CLIP32(dq->dq_curblocks);
1805 dqb32->dqb_ihardlimit = CLIP32(dq->dq_ihardlimit);
1806 dqb32->dqb_isoftlimit = CLIP32(dq->dq_isoftlimit);
1807 dqb32->dqb_curinodes = CLIP32(dq->dq_curinodes);
1808 dqb32->dqb_btime = CLIP32(dq->dq_btime);
1809 dqb32->dqb_itime = CLIP32(dq->dq_itime);
1816 dq_dqb64(const struct dquot *dq, struct dqblk64 *dqb64)
1819 dqb64->dqb_bhardlimit = htobe64(dq->dq_bhardlimit);
1820 dqb64->dqb_bsoftlimit = htobe64(dq->dq_bsoftlimit);
1821 dqb64->dqb_curblocks = htobe64(dq->dq_curblocks);
1822 dqb64->dqb_ihardlimit = htobe64(dq->dq_ihardlimit);
1823 dqb64->dqb_isoftlimit = htobe64(dq->dq_isoftlimit);
1824 dqb64->dqb_curinodes = htobe64(dq->dq_curinodes);
1825 dqb64->dqb_btime = htobe64(dq->dq_btime);
1826 dqb64->dqb_itime = htobe64(dq->dq_itime);