Lines Matching +full:user +full:- +full:otp
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
34 ASSERT(dqp->q_logitem.qli_dquot == dqp); in xfs_trans_dqjoin()
39 xfs_trans_add_item(tp, &dqp->q_logitem.qli_item); in xfs_trans_dqjoin()
60 if (dqp->q_id != 0 && in xfs_trans_log_dquot()
61 xfs_sb_version_hasbigtime(&tp->t_mountp->m_sb) && in xfs_trans_log_dquot()
62 !(dqp->q_type & XFS_DQTYPE_BIGTIME)) in xfs_trans_log_dquot()
63 dqp->q_type |= XFS_DQTYPE_BIGTIME; in xfs_trans_log_dquot()
65 tp->t_flags |= XFS_TRANS_DIRTY; in xfs_trans_log_dquot()
66 set_bit(XFS_LI_DIRTY, &dqp->q_logitem.qli_item.li_flags); in xfs_trans_log_dquot()
75 struct xfs_trans *otp, in xfs_trans_dup_dqinfo() argument
83 if (!otp->t_dqinfo) in xfs_trans_dup_dqinfo()
92 if (otp->t_flags & XFS_TRANS_DQ_DIRTY) in xfs_trans_dup_dqinfo()
93 ntp->t_flags |= XFS_TRANS_DQ_DIRTY; in xfs_trans_dup_dqinfo()
96 oqa = otp->t_dqinfo->dqs[j]; in xfs_trans_dup_dqinfo()
97 nqa = ntp->t_dqinfo->dqs[j]; in xfs_trans_dup_dqinfo()
106 if (oq->qt_blk_res && oq->qt_bcount_delta > 0) in xfs_trans_dup_dqinfo()
107 blk_res_used = oq->qt_bcount_delta; in xfs_trans_dup_dqinfo()
109 nq->qt_dquot = oq->qt_dquot; in xfs_trans_dup_dqinfo()
110 nq->qt_bcount_delta = nq->qt_icount_delta = 0; in xfs_trans_dup_dqinfo()
111 nq->qt_rtbcount_delta = 0; in xfs_trans_dup_dqinfo()
116 nq->qt_blk_res = oq->qt_blk_res - blk_res_used; in xfs_trans_dup_dqinfo()
117 oq->qt_blk_res = blk_res_used; in xfs_trans_dup_dqinfo()
119 nq->qt_rtblk_res = oq->qt_rtblk_res - in xfs_trans_dup_dqinfo()
120 oq->qt_rtblk_res_used; in xfs_trans_dup_dqinfo()
121 oq->qt_rtblk_res = oq->qt_rtblk_res_used; in xfs_trans_dup_dqinfo()
123 nq->qt_ino_res = oq->qt_ino_res - oq->qt_ino_res_used; in xfs_trans_dup_dqinfo()
124 oq->qt_ino_res = oq->qt_ino_res_used; in xfs_trans_dup_dqinfo()
131 * Wrap around mod_dquot to account for both user and group quotas.
140 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_dquot_byino()
144 xfs_is_quota_inode(&mp->m_sb, ip->i_ino)) in xfs_trans_mod_dquot_byino()
147 if (tp->t_dqinfo == NULL) in xfs_trans_mod_dquot_byino()
150 if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) in xfs_trans_mod_dquot_byino()
151 (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta); in xfs_trans_mod_dquot_byino()
152 if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot) in xfs_trans_mod_dquot_byino()
153 (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta); in xfs_trans_mod_dquot_byino()
154 if (XFS_IS_PQUOTA_ON(mp) && ip->i_pdquot) in xfs_trans_mod_dquot_byino()
155 (void) xfs_trans_mod_dquot(tp, ip->i_pdquot, field, delta); in xfs_trans_mod_dquot_byino()
168 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR]; in xfs_trans_get_dqtrx()
171 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP]; in xfs_trans_get_dqtrx()
174 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ]; in xfs_trans_get_dqtrx()
205 ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); in xfs_trans_mod_dquot()
208 if (tp->t_dqinfo == NULL) in xfs_trans_mod_dquot()
216 if (qtrx->qt_dquot == NULL) in xfs_trans_mod_dquot()
217 qtrx->qt_dquot = dqp; in xfs_trans_mod_dquot()
227 qtrx->qt_blk_res += delta; in xfs_trans_mod_dquot()
232 qtrx->qt_ino_res += delta; in xfs_trans_mod_dquot()
237 qtrx->qt_bcount_delta += delta; in xfs_trans_mod_dquot()
241 qtrx->qt_delbcnt_delta += delta; in xfs_trans_mod_dquot()
246 if (qtrx->qt_ino_res && delta > 0) { in xfs_trans_mod_dquot()
247 qtrx->qt_ino_res_used += delta; in xfs_trans_mod_dquot()
248 ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); in xfs_trans_mod_dquot()
250 qtrx->qt_icount_delta += delta; in xfs_trans_mod_dquot()
255 qtrx->qt_rtblk_res += delta; in xfs_trans_mod_dquot()
260 if (qtrx->qt_rtblk_res && delta > 0) { in xfs_trans_mod_dquot()
261 qtrx->qt_rtblk_res_used += delta; in xfs_trans_mod_dquot()
262 ASSERT(qtrx->qt_rtblk_res >= qtrx->qt_rtblk_res_used); in xfs_trans_mod_dquot()
264 qtrx->qt_rtbcount_delta += delta; in xfs_trans_mod_dquot()
268 qtrx->qt_delrtb_delta += delta; in xfs_trans_mod_dquot()
278 tp->t_flags |= XFS_TRANS_DQ_DIRTY; in xfs_trans_mod_dquot()
285 * highest number of dquots of one type - usr, grp and prj - involved in a
325 res->reserved -= abs(reserved - res_used); in xfs_apply_quota_reservation_deltas()
333 res->reserved += count_delta; in xfs_apply_quota_reservation_deltas()
355 if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY)) in xfs_trans_apply_dquot_deltas()
358 ASSERT(tp->t_dqinfo); in xfs_trans_apply_dquot_deltas()
360 qa = tp->t_dqinfo->dqs[j]; in xfs_trans_apply_dquot_deltas()
377 if ((dqp = qtrx->qt_dquot) == NULL) in xfs_trans_apply_dquot_deltas()
387 * The issue here is - sometimes we don't make a blkquota in xfs_trans_apply_dquot_deltas()
394 * non-delay blks. The assumption is that the in xfs_trans_apply_dquot_deltas()
399 totalbdelta = qtrx->qt_bcount_delta + in xfs_trans_apply_dquot_deltas()
400 qtrx->qt_delbcnt_delta; in xfs_trans_apply_dquot_deltas()
401 totalrtbdelta = qtrx->qt_rtbcount_delta + in xfs_trans_apply_dquot_deltas()
402 qtrx->qt_delrtb_delta; in xfs_trans_apply_dquot_deltas()
405 qtrx->qt_icount_delta != 0) { in xfs_trans_apply_dquot_deltas()
412 ASSERT(dqp->q_blk.count >= -totalbdelta); in xfs_trans_apply_dquot_deltas()
415 ASSERT(dqp->q_rtb.count >= -totalrtbdelta); in xfs_trans_apply_dquot_deltas()
417 if (qtrx->qt_icount_delta < 0) in xfs_trans_apply_dquot_deltas()
418 ASSERT(dqp->q_ino.count >= -qtrx->qt_icount_delta); in xfs_trans_apply_dquot_deltas()
421 dqp->q_blk.count += totalbdelta; in xfs_trans_apply_dquot_deltas()
423 if (qtrx->qt_icount_delta) in xfs_trans_apply_dquot_deltas()
424 dqp->q_ino.count += qtrx->qt_icount_delta; in xfs_trans_apply_dquot_deltas()
427 dqp->q_rtb.count += totalrtbdelta; in xfs_trans_apply_dquot_deltas()
430 qtrx->qt_icount_delta != 0) in xfs_trans_apply_dquot_deltas()
437 if (dqp->q_id) { in xfs_trans_apply_dquot_deltas()
442 dqp->q_flags |= XFS_DQFLAG_DIRTY; in xfs_trans_apply_dquot_deltas()
452 blk_res_used = max_t(int64_t, 0, qtrx->qt_bcount_delta); in xfs_trans_apply_dquot_deltas()
453 xfs_apply_quota_reservation_deltas(&dqp->q_blk, in xfs_trans_apply_dquot_deltas()
454 qtrx->qt_blk_res, blk_res_used, in xfs_trans_apply_dquot_deltas()
455 qtrx->qt_bcount_delta); in xfs_trans_apply_dquot_deltas()
460 xfs_apply_quota_reservation_deltas(&dqp->q_rtb, in xfs_trans_apply_dquot_deltas()
461 qtrx->qt_rtblk_res, in xfs_trans_apply_dquot_deltas()
462 qtrx->qt_rtblk_res_used, in xfs_trans_apply_dquot_deltas()
463 qtrx->qt_rtbcount_delta); in xfs_trans_apply_dquot_deltas()
468 ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); in xfs_trans_apply_dquot_deltas()
469 xfs_apply_quota_reservation_deltas(&dqp->q_ino, in xfs_trans_apply_dquot_deltas()
470 qtrx->qt_ino_res, in xfs_trans_apply_dquot_deltas()
471 qtrx->qt_ino_res_used, in xfs_trans_apply_dquot_deltas()
472 qtrx->qt_icount_delta); in xfs_trans_apply_dquot_deltas()
474 ASSERT(dqp->q_blk.reserved >= dqp->q_blk.count); in xfs_trans_apply_dquot_deltas()
475 ASSERT(dqp->q_ino.reserved >= dqp->q_ino.count); in xfs_trans_apply_dquot_deltas()
476 ASSERT(dqp->q_rtb.reserved >= dqp->q_rtb.count); in xfs_trans_apply_dquot_deltas()
497 if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) in xfs_trans_unreserve_and_mod_dquots()
501 qa = tp->t_dqinfo->dqs[j]; in xfs_trans_unreserve_and_mod_dquots()
509 if ((dqp = qtrx->qt_dquot) == NULL) in xfs_trans_unreserve_and_mod_dquots()
517 if (qtrx->qt_blk_res) { in xfs_trans_unreserve_and_mod_dquots()
520 dqp->q_blk.reserved -= in xfs_trans_unreserve_and_mod_dquots()
521 (xfs_qcnt_t)qtrx->qt_blk_res; in xfs_trans_unreserve_and_mod_dquots()
523 if (qtrx->qt_ino_res) { in xfs_trans_unreserve_and_mod_dquots()
528 dqp->q_ino.reserved -= in xfs_trans_unreserve_and_mod_dquots()
529 (xfs_qcnt_t)qtrx->qt_ino_res; in xfs_trans_unreserve_and_mod_dquots()
532 if (qtrx->qt_rtblk_res) { in xfs_trans_unreserve_and_mod_dquots()
537 dqp->q_rtb.reserved -= in xfs_trans_unreserve_and_mod_dquots()
538 (xfs_qcnt_t)qtrx->qt_rtblk_res; in xfs_trans_unreserve_and_mod_dquots()
569 quota_send_warning(make_kqid(&init_user_ns, qtype, dqp->q_id), in xfs_quota_warn()
570 mp->m_super->s_dev, type); in xfs_quota_warn()
588 xfs_qcnt_t hardlimit = res->hardlimit; in xfs_dqresv_check()
589 xfs_qcnt_t softlimit = res->softlimit; in xfs_dqresv_check()
590 xfs_qcnt_t total_count = res->reserved + delta; in xfs_dqresv_check()
601 hardlimit = qlim->hard; in xfs_dqresv_check()
603 softlimit = qlim->soft; in xfs_dqresv_check()
613 if ((res->timer != 0 && now > res->timer) || in xfs_dqresv_check()
614 (res->warnings != 0 && res->warnings >= qlim->warn)) { in xfs_dqresv_check()
640 struct xfs_quotainfo *q = mp->m_quotainfo; in xfs_trans_dqresv()
650 blkres = &dqp->q_blk; in xfs_trans_dqresv()
651 qlim = &defq->blk; in xfs_trans_dqresv()
653 blkres = &dqp->q_rtb; in xfs_trans_dqresv()
654 qlim = &defq->rtb; in xfs_trans_dqresv()
657 if ((flags & XFS_QMOPT_FORCE_RES) == 0 && dqp->q_id && in xfs_trans_dqresv()
677 quota_nl = xfs_dqresv_check(&dqp->q_ino, &defq->ino, ninos, in xfs_trans_dqresv()
690 blkres->reserved += (xfs_qcnt_t)nblks; in xfs_trans_dqresv()
691 dqp->q_ino.reserved += (xfs_qcnt_t)ninos; in xfs_trans_dqresv()
701 ASSERT(tp->t_dqinfo); in xfs_trans_dqresv()
713 if (XFS_IS_CORRUPT(mp, dqp->q_blk.reserved < dqp->q_blk.count) || in xfs_trans_dqresv()
714 XFS_IS_CORRUPT(mp, dqp->q_rtb.reserved < dqp->q_rtb.count) || in xfs_trans_dqresv()
715 XFS_IS_CORRUPT(mp, dqp->q_ino.reserved < dqp->q_ino.count)) in xfs_trans_dqresv()
724 return -ENOSPC; in xfs_trans_dqresv()
725 return -EDQUOT; in xfs_trans_dqresv()
729 return -EFSCORRUPTED; in xfs_trans_dqresv()
735 * The fact that this does the reservation against user, group and
736 * project quotas is important, because this follows a all-or-nothing
761 if (tp && tp->t_dqinfo == NULL) in xfs_trans_reserve_quota_bydquots()
792 xfs_trans_dqresv(tp, mp, gdqp, -nblks, -ninos, flags); in xfs_trans_reserve_quota_bydquots()
796 xfs_trans_dqresv(tp, mp, udqp, -nblks, -ninos, flags); in xfs_trans_reserve_quota_bydquots()
814 struct xfs_mount *mp = ip->i_mount; in xfs_trans_reserve_quota_nblks()
819 ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino)); in xfs_trans_reserve_quota_nblks()
829 ip->i_udquot, ip->i_gdquot, in xfs_trans_reserve_quota_nblks()
830 ip->i_pdquot, in xfs_trans_reserve_quota_nblks()
847 q = xfs_qm_qoff_logitem_init(tp->t_mountp, startqoff, flags); in xfs_trans_get_qoff_item()
853 xfs_trans_add_item(tp, &q->qql_item); in xfs_trans_get_qoff_item()
868 tp->t_flags |= XFS_TRANS_DIRTY; in xfs_trans_log_quotaoff_item()
869 set_bit(XFS_LI_DIRTY, &qlp->qql_item.li_flags); in xfs_trans_log_quotaoff_item()
876 tp->t_dqinfo = kmem_cache_zalloc(xfs_qm_dqtrxzone, in xfs_trans_alloc_dqinfo()
884 if (!tp->t_dqinfo) in xfs_trans_free_dqinfo()
886 kmem_cache_free(xfs_qm_dqtrxzone, tp->t_dqinfo); in xfs_trans_free_dqinfo()
887 tp->t_dqinfo = NULL; in xfs_trans_free_dqinfo()