61 #define XFS_DQ_LOOKUP_BATCH 32
95 for (i = 0; i < nr_found; i++) {
100 error = execute(batch[i], data);
135 struct xfs_mount *mp = dqp->
q_mount;
174 xfs_warn(mp,
"%s: dquot %p flush failed",
184 ASSERT(XFS_FORCED_SHUTDOWN(mp) ||
200 list_del_init(&dqp->
q_lru);
217 struct xfs_mount *mp,
233 struct xfs_mount *mp)
235 if (mp->m_quotainfo) {
262 if (mp->m_sb.sb_rextents) {
263 xfs_notice(mp,
"Cannot turn on quotas for realtime filesystem");
286 if (XFS_QM_NEED_QUOTACHECK(mp)) {
308 spin_lock(&mp->m_sb_lock);
309 sbf = mp->m_sb.sb_qflags;
310 mp->m_sb.sb_qflags = mp->m_qflags & XFS_MOUNT_QUOTA_ALL;
311 spin_unlock(&mp->m_sb_lock);
313 if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) {
322 xfs_alert(mp,
"%s: Superblock update failed!",
328 xfs_warn(mp,
"Failed to initialize disk quotas.");
354 if (mp->m_quotainfo) {
355 if (mp->m_quotainfo->qi_uquotaip) {
356 IRELE(mp->m_quotainfo->qi_uquotaip);
357 mp->m_quotainfo->qi_uquotaip =
NULL;
359 if (mp->m_quotainfo->qi_gquotaip) {
360 IRELE(mp->m_quotainfo->qi_gquotaip);
361 mp->m_quotainfo->qi_gquotaip =
NULL;
378 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
388 trace_xfs_dqattach_found(dqp);
413 *IO_idqpp = xfs_qm_dqhold(dqp);
414 xfs_dqunlock(udqhint);
424 xfs_dqunlock(udqhint);
439 trace_xfs_dqattach_get(dqp);
479 xfs_qm_need_dqattach(
480 struct xfs_inode *
ip)
482 struct xfs_mount *mp = ip->i_mount;
488 if (!XFS_NOT_DQATTACHED(mp, ip))
490 if (ip->i_ino == mp->m_sb.sb_uquotino ||
491 ip->i_ino == mp->m_sb.sb_gquotino)
508 xfs_mount_t *mp = ip->i_mount;
512 if (!xfs_qm_need_dqattach(ip))
515 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
520 NULL, &ip->i_udquot);
526 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
531 ip->i_udquot, &ip->i_gdquot) :
533 flags & XFS_QMOPT_DQALLOC,
534 ip->i_udquot, &ip->i_gdquot);
549 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
559 if (ip->i_udquot->q_gdquot != ip->i_gdquot)
571 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
578 struct xfs_inode *ip,
583 if (!xfs_qm_need_dqattach(ip))
602 if (!(ip->i_udquot || ip->i_gdquot))
605 trace_xfs_dquot_dqdetach(ip);
607 ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino);
608 ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino);
641 mp->m_quotainfo =
NULL;
736 qi = mp->m_quotainfo;
751 mp->m_quotainfo =
NULL;
791 spin_lock(&mp->m_sb_lock);
793 ASSERT(!xfs_sb_version_hasquota(&mp->m_sb));
799 xfs_sb_version_addquota(&mp->m_sb);
804 mp->m_sb.sb_qflags = 0;
807 mp->m_sb.sb_uquotino = (*ip)->i_ino;
809 mp->m_sb.sb_gquotino = (*ip)->i_ino;
810 spin_unlock(&mp->m_sb_lock);
814 xfs_alert(mp,
"%s failed (error %d)!", __func__, error);
831 trace_xfs_reset_dqcounts(bp,
_RET_IP_);
840 ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
843 for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) {
866 struct xfs_mount *mp,
892 error = xfs_trans_read_buf(mp,
NULL, mp->m_ddev_targp,
894 mp->m_quotainfo->qi_dqchunklen, 0, &bp);
905 firstid += mp->m_quotainfo->qi_dqperchunk;
917 struct xfs_mount *mp,
918 struct xfs_inode *qip,
937 if (qip->i_d.di_nblocks == 0)
959 for (i = 0; i < nmaps; i++) {
970 mp->m_quotainfo->qi_dqperchunk;
979 xfs_buf_readahead(mp->m_ddev_targp,
981 mp->m_quotainfo->qi_dqchunklen);
991 map[i].br_blockcount,
1013 struct xfs_inode *ip,
1019 struct xfs_mount *mp = ip->i_mount;
1034 trace_xfs_dqadjust(dqp);
1085 for (idx = 0; idx < nextents; idx++)
1115 if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) {
1126 error =
xfs_iget(mp,
NULL, ino, 0, XFS_ILOCK_EXCL, &ip);
1132 ASSERT(ip->i_delayed_blks == 0);
1143 nblks = (
xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
1228 xfs_inode_t *uip, *gip;
1237 ASSERT(mp->m_quotainfo->qi_uquotaip || mp->m_quotainfo->qi_gquotaip);
1240 xfs_notice(mp,
"Quotacheck needed: Please wait.");
1247 uip = mp->m_quotainfo->qi_uquotaip;
1256 gip = mp->m_quotainfo->qi_gquotaip;
1273 structsz,
NULL, &done);
1322 mp->m_qflags |=
flags;
1325 while (!list_empty(&buffer_list)) {
1328 list_del_init(&bp->
b_list);
1334 "Quotacheck: Unsuccessful (Error %d): Disabling quotas.",
1343 "Quotacheck: Failed to reset quota flags.");
1346 xfs_notice(mp,
"Quotacheck: Done.");
1358 xfs_inode_t *uip, *gip;
1371 if (xfs_sb_version_hasquota(&mp->m_sb)) {
1374 ASSERT(mp->m_sb.sb_uquotino > 0);
1381 ASSERT(mp->m_sb.sb_gquotino > 0);
1422 mp->m_quotainfo->qi_uquotaip = uip;
1423 mp->m_quotainfo->qi_gquotaip = gip;
1432 struct xfs_mount *mp = dqp->
q_mount;
1451 struct xfs_mount *mp = dqp->
q_mount;
1455 if (!xfs_dqlock_nowait(dqp))
1465 trace_xfs_dqreclaim_want(dqp);
1468 list_del_init(&dqp->
q_lru);
1478 if (!xfs_dqflock_nowait(dqp))
1484 trace_xfs_dqreclaim_dirty(dqp);
1488 xfs_warn(mp,
"%s: dquot %p flush failed",
1510 list_move_tail(&dqp->
q_lru, dispose_list);
1514 trace_xfs_dqreclaim_done(dqp);
1526 trace_xfs_dqreclaim_busy(dqp);
1550 if (nr_to_scan-- <= 0)
1560 xfs_warn(
NULL,
"%s: dquot reclaim failed", __func__);
1562 while (!list_empty(&dispose_list)) {
1564 list_del_init(&dqp->
q_lru);
1586 mp->m_sb.sb_sectsize + 128, 0,
1615 struct xfs_inode *ip,
1623 struct xfs_mount *mp = ip->i_mount;
1631 lockflags = XFS_ILOCK_EXCL;
1635 gid = ip->i_d.di_gid;
1641 if (XFS_NOT_DQATTACHED(mp, ip)) {
1651 if (ip->i_d.di_uid != uid) {
1674 lockflags = XFS_ILOCK_SHARED;
1682 uq = xfs_qm_dqhold(ip->i_udquot);
1686 if (ip->i_d.di_gid != gid) {
1699 lockflags = XFS_ILOCK_SHARED;
1703 gq = xfs_qm_dqhold(ip->i_gdquot);
1706 if (xfs_get_projid(ip) != prid) {
1719 lockflags = XFS_ILOCK_SHARED;
1723 gq = xfs_qm_dqhold(ip->i_gdquot);
1727 trace_xfs_dquot_dqalloc(ip);
1757 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
1776 *IO_olddq = xfs_qm_dqhold(newdq);
1792 xfs_mount_t *mp = ip->i_mount;
1793 uint delblks, blkflags, prjflags = 0;
1794 xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq;
1798 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
1801 delblks = ip->i_delayed_blks;
1802 delblksudq = delblksgdq = unresudq = unresgdq =
NULL;
1816 unresudq = ip->i_udquot;
1830 unresgdq = ip->i_gdquot;
1836 delblksudq, delblksgdq, ip->i_d.di_nblocks, 1,
1837 flags | blkflags | prjflags)))
1850 ASSERT(delblksudq || delblksgdq);
1851 ASSERT(unresudq || unresgdq);
1853 delblksudq, delblksgdq, (
xfs_qcnt_t)delblks, 0,
1854 flags | blkflags | prjflags)))
1857 unresudq, unresgdq, -((
xfs_qcnt_t)delblks), 0,
1866 struct xfs_inode **i_tab)
1868 struct xfs_mount *mp = i_tab[0]->i_mount;
1874 for (i = 0; (i < 4 && i_tab[
i]); i++) {
1875 struct xfs_inode *ip = i_tab[
i];
1881 if (i == 0 || ip != i_tab[i-1]) {
1882 if (XFS_NOT_DQATTACHED(mp, ip)) {
1894 struct xfs_trans *tp,
1895 struct xfs_inode *ip,
1899 struct xfs_mount *mp = tp->t_mountp;
1904 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
1912 ip->i_udquot = xfs_qm_dqhold(udqp);
1919 ip->i_d.di_gid : xfs_get_projid(ip)) ==
1922 ip->i_gdquot = xfs_qm_dqhold(gdqp);