Lines Matching +full:ip +full:- +full:blocks
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
35 ASSERT(dqp->q_logitem.qli_dquot == dqp); in xfs_trans_dqjoin()
40 xfs_trans_add_item(tp, &dqp->q_logitem.qli_item); in xfs_trans_dqjoin()
61 if (dqp->q_id != 0 && in xfs_trans_log_dquot()
62 xfs_has_bigtime(tp->t_mountp) && in xfs_trans_log_dquot()
63 !(dqp->q_type & XFS_DQTYPE_BIGTIME)) in xfs_trans_log_dquot()
64 dqp->q_type |= XFS_DQTYPE_BIGTIME; in xfs_trans_log_dquot()
66 tp->t_flags |= XFS_TRANS_DIRTY; in xfs_trans_log_dquot()
67 set_bit(XFS_LI_DIRTY, &dqp->q_logitem.qli_item.li_flags); in xfs_trans_log_dquot()
84 if (!otp->t_dqinfo) in xfs_trans_dup_dqinfo()
90 oqa = otp->t_dqinfo->dqs[j]; in xfs_trans_dup_dqinfo()
91 nqa = ntp->t_dqinfo->dqs[j]; in xfs_trans_dup_dqinfo()
100 if (oq->qt_blk_res && oq->qt_bcount_delta > 0) in xfs_trans_dup_dqinfo()
101 blk_res_used = oq->qt_bcount_delta; in xfs_trans_dup_dqinfo()
103 nq->qt_dquot = oq->qt_dquot; in xfs_trans_dup_dqinfo()
104 nq->qt_bcount_delta = nq->qt_icount_delta = 0; in xfs_trans_dup_dqinfo()
105 nq->qt_rtbcount_delta = 0; in xfs_trans_dup_dqinfo()
110 nq->qt_blk_res = oq->qt_blk_res - blk_res_used; in xfs_trans_dup_dqinfo()
111 oq->qt_blk_res = blk_res_used; in xfs_trans_dup_dqinfo()
113 nq->qt_rtblk_res = oq->qt_rtblk_res - in xfs_trans_dup_dqinfo()
114 oq->qt_rtblk_res_used; in xfs_trans_dup_dqinfo()
115 oq->qt_rtblk_res = oq->qt_rtblk_res_used; in xfs_trans_dup_dqinfo()
117 nq->qt_ino_res = oq->qt_ino_res - oq->qt_ino_res_used; in xfs_trans_dup_dqinfo()
118 oq->qt_ino_res = oq->qt_ino_res_used; in xfs_trans_dup_dqinfo()
154 struct xfs_inode *ip, in xfs_trans_mod_ino_dquot() argument
159 if (xfs_is_metadir_inode(ip)) in xfs_trans_mod_ino_dquot()
167 .ino = ip->i_ino, in xfs_trans_mod_ino_dquot()
169 .q_id = dqp->q_id, in xfs_trans_mod_ino_dquot()
172 struct xfs_quotainfo *qi = tp->t_mountp->m_quotainfo; in xfs_trans_mod_ino_dquot()
174 xfs_hooks_call(&qi->qi_mod_ino_dqtrx_hooks, field, &p); in xfs_trans_mod_ino_dquot()
194 error = xfs_hooks_add(&qi->qi_apply_dqtrx_hooks, &hook->apply_hook); in xfs_dqtrx_hook_add()
198 error = xfs_hooks_add(&qi->qi_mod_ino_dqtrx_hooks, &hook->mod_hook); in xfs_dqtrx_hook_add()
205 xfs_hooks_del(&qi->qi_apply_dqtrx_hooks, &hook->apply_hook); in xfs_dqtrx_hook_add()
221 xfs_hooks_del(&qi->qi_mod_ino_dqtrx_hooks, &hook->mod_hook); in xfs_dqtrx_hook_del()
222 xfs_hooks_del(&qi->qi_apply_dqtrx_hooks, &hook->apply_hook); in xfs_dqtrx_hook_del()
232 xfs_hook_setup(&hook->mod_hook, mod_fn); in xfs_dqtrx_hook_setup()
233 xfs_hook_setup(&hook->apply_hook, apply_fn); in xfs_dqtrx_hook_setup()
243 xfs_inode_t *ip, in xfs_trans_mod_dquot_byino() argument
247 xfs_mount_t *mp = tp->t_mountp; in xfs_trans_mod_dquot_byino()
250 xfs_is_quota_inode(&mp->m_sb, ip->i_ino) || in xfs_trans_mod_dquot_byino()
251 xfs_is_metadir_inode(ip)) in xfs_trans_mod_dquot_byino()
254 if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) in xfs_trans_mod_dquot_byino()
255 xfs_trans_mod_ino_dquot(tp, ip, ip->i_udquot, field, delta); in xfs_trans_mod_dquot_byino()
256 if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot) in xfs_trans_mod_dquot_byino()
257 xfs_trans_mod_ino_dquot(tp, ip, ip->i_gdquot, field, delta); in xfs_trans_mod_dquot_byino()
258 if (XFS_IS_PQUOTA_ON(mp) && ip->i_pdquot) in xfs_trans_mod_dquot_byino()
259 xfs_trans_mod_ino_dquot(tp, ip, ip->i_pdquot, field, delta); in xfs_trans_mod_dquot_byino()
272 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR]; in xfs_trans_get_dqtrx()
275 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP]; in xfs_trans_get_dqtrx()
278 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ]; in xfs_trans_get_dqtrx()
309 ASSERT(XFS_IS_QUOTA_ON(tp->t_mountp)); in xfs_trans_mod_dquot()
315 if (tp->t_dqinfo == NULL) in xfs_trans_mod_dquot()
323 if (qtrx->qt_dquot == NULL) in xfs_trans_mod_dquot()
324 qtrx->qt_dquot = dqp; in xfs_trans_mod_dquot()
332 qtrx->qt_blk_res += delta; in xfs_trans_mod_dquot()
337 qtrx->qt_ino_res += delta; in xfs_trans_mod_dquot()
340 /* disk blocks used. */ in xfs_trans_mod_dquot()
342 qtrx->qt_bcount_delta += delta; in xfs_trans_mod_dquot()
346 qtrx->qt_delbcnt_delta += delta; in xfs_trans_mod_dquot()
351 if (qtrx->qt_ino_res && delta > 0) { in xfs_trans_mod_dquot()
352 qtrx->qt_ino_res_used += delta; in xfs_trans_mod_dquot()
353 ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); in xfs_trans_mod_dquot()
355 qtrx->qt_icount_delta += delta; in xfs_trans_mod_dquot()
360 qtrx->qt_rtblk_res += delta; in xfs_trans_mod_dquot()
365 if (qtrx->qt_rtblk_res && delta > 0) { in xfs_trans_mod_dquot()
366 qtrx->qt_rtblk_res_used += delta; in xfs_trans_mod_dquot()
367 ASSERT(qtrx->qt_rtblk_res >= qtrx->qt_rtblk_res_used); in xfs_trans_mod_dquot()
369 qtrx->qt_rtbcount_delta += delta; in xfs_trans_mod_dquot()
373 qtrx->qt_delrtb_delta += delta; in xfs_trans_mod_dquot()
427 * more quota blocks than were reserved for the transaction. in xfs_apply_quota_reservation_deltas()
432 res->reserved -= abs(reserved - res_used); in xfs_apply_quota_reservation_deltas()
440 res->reserved += count_delta; in xfs_apply_quota_reservation_deltas()
455 .q_id = dqp->q_id, in xfs_trans_apply_dquot_deltas_hook()
457 struct xfs_quotainfo *qi = tp->t_mountp->m_quotainfo; in xfs_trans_apply_dquot_deltas_hook()
459 xfs_hooks_call(&qi->qi_apply_dqtrx_hooks, in xfs_trans_apply_dquot_deltas_hook()
485 if (!tp->t_dqinfo) in xfs_trans_apply_dquot_deltas()
488 ASSERT(tp->t_dqinfo); in xfs_trans_apply_dquot_deltas()
490 qa = tp->t_dqinfo->dqs[j]; in xfs_trans_apply_dquot_deltas()
507 if ((dqp = qtrx->qt_dquot) == NULL) in xfs_trans_apply_dquot_deltas()
515 * adjust the actual number of blocks used in xfs_trans_apply_dquot_deltas()
519 * The issue here is - sometimes we don't make a blkquota in xfs_trans_apply_dquot_deltas()
526 * non-delay blks. The assumption is that the in xfs_trans_apply_dquot_deltas()
531 totalbdelta = qtrx->qt_bcount_delta + in xfs_trans_apply_dquot_deltas()
532 qtrx->qt_delbcnt_delta; in xfs_trans_apply_dquot_deltas()
533 totalrtbdelta = qtrx->qt_rtbcount_delta + in xfs_trans_apply_dquot_deltas()
534 qtrx->qt_delrtb_delta; in xfs_trans_apply_dquot_deltas()
537 qtrx->qt_icount_delta != 0) { in xfs_trans_apply_dquot_deltas()
544 ASSERT(dqp->q_blk.count >= -totalbdelta); in xfs_trans_apply_dquot_deltas()
547 ASSERT(dqp->q_rtb.count >= -totalrtbdelta); in xfs_trans_apply_dquot_deltas()
549 if (qtrx->qt_icount_delta < 0) in xfs_trans_apply_dquot_deltas()
550 ASSERT(dqp->q_ino.count >= -qtrx->qt_icount_delta); in xfs_trans_apply_dquot_deltas()
553 dqp->q_blk.count += totalbdelta; in xfs_trans_apply_dquot_deltas()
555 if (qtrx->qt_icount_delta) in xfs_trans_apply_dquot_deltas()
556 dqp->q_ino.count += qtrx->qt_icount_delta; in xfs_trans_apply_dquot_deltas()
559 dqp->q_rtb.count += totalrtbdelta; in xfs_trans_apply_dquot_deltas()
562 qtrx->qt_icount_delta != 0) in xfs_trans_apply_dquot_deltas()
569 if (dqp->q_id) { in xfs_trans_apply_dquot_deltas()
574 dqp->q_flags |= XFS_DQFLAG_DIRTY; in xfs_trans_apply_dquot_deltas()
584 blk_res_used = max_t(int64_t, 0, qtrx->qt_bcount_delta); in xfs_trans_apply_dquot_deltas()
585 xfs_apply_quota_reservation_deltas(&dqp->q_blk, in xfs_trans_apply_dquot_deltas()
586 qtrx->qt_blk_res, blk_res_used, in xfs_trans_apply_dquot_deltas()
587 qtrx->qt_bcount_delta); in xfs_trans_apply_dquot_deltas()
592 xfs_apply_quota_reservation_deltas(&dqp->q_rtb, in xfs_trans_apply_dquot_deltas()
593 qtrx->qt_rtblk_res, in xfs_trans_apply_dquot_deltas()
594 qtrx->qt_rtblk_res_used, in xfs_trans_apply_dquot_deltas()
595 qtrx->qt_rtbcount_delta); in xfs_trans_apply_dquot_deltas()
600 ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); in xfs_trans_apply_dquot_deltas()
601 xfs_apply_quota_reservation_deltas(&dqp->q_ino, in xfs_trans_apply_dquot_deltas()
602 qtrx->qt_ino_res, in xfs_trans_apply_dquot_deltas()
603 qtrx->qt_ino_res_used, in xfs_trans_apply_dquot_deltas()
604 qtrx->qt_icount_delta); in xfs_trans_apply_dquot_deltas()
606 ASSERT(dqp->q_blk.reserved >= dqp->q_blk.count); in xfs_trans_apply_dquot_deltas()
607 ASSERT(dqp->q_ino.reserved >= dqp->q_ino.count); in xfs_trans_apply_dquot_deltas()
608 ASSERT(dqp->q_rtb.reserved >= dqp->q_rtb.count); in xfs_trans_apply_dquot_deltas()
615 qtrx->qt_blk_res = 0; in xfs_trans_apply_dquot_deltas()
616 qtrx->qt_bcount_delta = 0; in xfs_trans_apply_dquot_deltas()
617 qtrx->qt_delbcnt_delta = 0; in xfs_trans_apply_dquot_deltas()
619 qtrx->qt_rtblk_res = 0; in xfs_trans_apply_dquot_deltas()
620 qtrx->qt_rtblk_res_used = 0; in xfs_trans_apply_dquot_deltas()
621 qtrx->qt_rtbcount_delta = 0; in xfs_trans_apply_dquot_deltas()
622 qtrx->qt_delrtb_delta = 0; in xfs_trans_apply_dquot_deltas()
624 qtrx->qt_ino_res = 0; in xfs_trans_apply_dquot_deltas()
625 qtrx->qt_ino_res_used = 0; in xfs_trans_apply_dquot_deltas()
626 qtrx->qt_icount_delta = 0; in xfs_trans_apply_dquot_deltas()
642 .q_id = dqp->q_id, in xfs_trans_unreserve_and_mod_dquots_hook()
644 struct xfs_quotainfo *qi = tp->t_mountp->m_quotainfo; in xfs_trans_unreserve_and_mod_dquots_hook()
646 xfs_hooks_call(&qi->qi_apply_dqtrx_hooks, in xfs_trans_unreserve_and_mod_dquots_hook()
671 if (!tp->t_dqinfo) in xfs_trans_unreserve_and_mod_dquots()
675 qa = tp->t_dqinfo->dqs[j]; in xfs_trans_unreserve_and_mod_dquots()
683 if ((dqp = qtrx->qt_dquot) == NULL) in xfs_trans_unreserve_and_mod_dquots()
690 * about the number of blocks used field, or deltas. in xfs_trans_unreserve_and_mod_dquots()
694 if (qtrx->qt_blk_res) { in xfs_trans_unreserve_and_mod_dquots()
699 dqp->q_blk.reserved -= in xfs_trans_unreserve_and_mod_dquots()
700 (xfs_qcnt_t)qtrx->qt_blk_res; in xfs_trans_unreserve_and_mod_dquots()
702 if (qtrx->qt_ino_res) { in xfs_trans_unreserve_and_mod_dquots()
707 dqp->q_ino.reserved -= in xfs_trans_unreserve_and_mod_dquots()
708 (xfs_qcnt_t)qtrx->qt_ino_res; in xfs_trans_unreserve_and_mod_dquots()
711 if (qtrx->qt_rtblk_res) { in xfs_trans_unreserve_and_mod_dquots()
716 dqp->q_rtb.reserved -= in xfs_trans_unreserve_and_mod_dquots()
717 (xfs_qcnt_t)qtrx->qt_rtblk_res; in xfs_trans_unreserve_and_mod_dquots()
748 quota_send_warning(make_kqid(&init_user_ns, qtype, dqp->q_id), in xfs_quota_warn()
749 mp->m_super->s_dev, type); in xfs_quota_warn()
767 xfs_qcnt_t hardlimit = res->hardlimit; in xfs_dqresv_check()
768 xfs_qcnt_t softlimit = res->softlimit; in xfs_dqresv_check()
769 xfs_qcnt_t total_count = res->reserved + delta; in xfs_dqresv_check()
780 hardlimit = qlim->hard; in xfs_dqresv_check()
782 softlimit = qlim->soft; in xfs_dqresv_check()
792 if (res->timer != 0 && now > res->timer) { in xfs_dqresv_check()
804 * This reserves disk blocks and inodes against a dquot.
806 * if the blk reservation is for RT or regular blocks.
818 struct xfs_quotainfo *q = mp->m_quotainfo; in xfs_trans_dqresv()
828 blkres = &dqp->q_blk; in xfs_trans_dqresv()
829 qlim = &defq->blk; in xfs_trans_dqresv()
831 blkres = &dqp->q_rtb; in xfs_trans_dqresv()
832 qlim = &defq->rtb; in xfs_trans_dqresv()
835 if ((flags & XFS_QMOPT_FORCE_RES) == 0 && dqp->q_id && in xfs_trans_dqresv()
855 quota_nl = xfs_dqresv_check(&dqp->q_ino, &defq->ino, ninos, in xfs_trans_dqresv()
868 blkres->reserved += (xfs_qcnt_t)nblks; in xfs_trans_dqresv()
869 dqp->q_ino.reserved += (xfs_qcnt_t)ninos; in xfs_trans_dqresv()
885 if (XFS_IS_CORRUPT(mp, dqp->q_blk.reserved < dqp->q_blk.count) || in xfs_trans_dqresv()
886 XFS_IS_CORRUPT(mp, dqp->q_rtb.reserved < dqp->q_rtb.count) || in xfs_trans_dqresv()
887 XFS_IS_CORRUPT(mp, dqp->q_ino.reserved < dqp->q_ino.count)) in xfs_trans_dqresv()
896 return -ENOSPC; in xfs_trans_dqresv()
897 return -EDQUOT; in xfs_trans_dqresv()
902 return -EFSCORRUPTED; in xfs_trans_dqresv()
909 * project quotas is important, because this follows a all-or-nothing
914 * XFS_TRANS_DQ_RES_BLKS reserves regular disk blocks
915 * XFS_TRANS_DQ_RES_RTBLKS reserves realtime disk blocks
962 xfs_trans_dqresv(tp, mp, gdqp, -nblks, -ninos, flags); in xfs_trans_reserve_quota_bydquots()
966 xfs_trans_dqresv(tp, mp, udqp, -nblks, -ninos, flags); in xfs_trans_reserve_quota_bydquots()
979 struct xfs_inode *ip, in xfs_trans_reserve_quota_nblks() argument
984 struct xfs_mount *mp = ip->i_mount; in xfs_trans_reserve_quota_nblks()
990 if (xfs_is_metadir_inode(ip)) in xfs_trans_reserve_quota_nblks()
993 ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino)); in xfs_trans_reserve_quota_nblks()
994 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); in xfs_trans_reserve_quota_nblks()
1000 error = xfs_trans_reserve_quota_bydquots(tp, mp, ip->i_udquot, in xfs_trans_reserve_quota_nblks()
1001 ip->i_gdquot, ip->i_pdquot, dblocks, 0, in xfs_trans_reserve_quota_nblks()
1006 /* Do the same but for realtime blocks. */ in xfs_trans_reserve_quota_nblks()
1007 error = xfs_trans_reserve_quota_bydquots(tp, mp, ip->i_udquot, in xfs_trans_reserve_quota_nblks()
1008 ip->i_gdquot, ip->i_pdquot, rblocks, 0, in xfs_trans_reserve_quota_nblks()
1011 xfs_trans_reserve_quota_bydquots(tp, mp, ip->i_udquot, in xfs_trans_reserve_quota_nblks()
1012 ip->i_gdquot, ip->i_pdquot, -dblocks, 0, in xfs_trans_reserve_quota_nblks()
1029 struct xfs_mount *mp = tp->t_mountp; in xfs_trans_reserve_quota_icreate()
1042 tp->t_dqinfo = kmem_cache_zalloc(xfs_dqtrx_cache, in xfs_trans_alloc_dqinfo()
1050 if (!tp->t_dqinfo) in xfs_trans_free_dqinfo()
1052 kmem_cache_free(xfs_dqtrx_cache, tp->t_dqinfo); in xfs_trans_free_dqinfo()
1053 tp->t_dqinfo = NULL; in xfs_trans_free_dqinfo()
1058 struct xfs_inode *ip, in xfs_quota_reserve_blkres() argument
1059 int64_t blocks) in xfs_quota_reserve_blkres() argument
1061 if (XFS_IS_REALTIME_INODE(ip)) in xfs_quota_reserve_blkres()
1062 return xfs_trans_reserve_quota_nblks(NULL, ip, 0, blocks, in xfs_quota_reserve_blkres()
1064 return xfs_trans_reserve_quota_nblks(NULL, ip, blocks, 0, false); in xfs_quota_reserve_blkres()