2 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "xfs_trans.h"
28 #include "xfs_alloc.h"
29 #include "xfs_dmapi.h"
30 #include "xfs_quota.h"
31 #include "xfs_mount.h"
32 #include "xfs_bmap_btree.h"
33 #include "xfs_alloc_btree.h"
34 #include "xfs_ialloc_btree.h"
35 #include "xfs_attr_sf.h"
36 #include "xfs_dir_sf.h"
37 #include "xfs_dir2_sf.h"
38 #include "xfs_dinode.h"
39 #include "xfs_inode.h"
40 #include "xfs_ialloc.h"
41 #include "xfs_itable.h"
42 #include "xfs_btree.h"
44 #include "xfs_rtalloc.h"
45 #include "xfs_error.h"
51 #include "xfs_buf_item.h"
52 #include "xfs_trans_priv.h"
55 STATIC
void xfs_trans_alloc_dqinfo(xfs_trans_t
*);
58 * Add the locked dquot to the transaction.
59 * The dquot must be locked, and it cannot be associated with any
69 ASSERT(! XFS_DQ_IS_ADDEDTO_TRX(tp
, dqp
));
70 ASSERT(XFS_DQ_IS_LOCKED(dqp
));
71 ASSERT(XFS_DQ_IS_LOGITEM_INITD(dqp
));
75 * Get a log_item_desc to point at the new item.
77 (void) xfs_trans_add_item(tp
, (xfs_log_item_t
*)(lp
));
80 * Initialize i_transp so we can later determine if this dquot is
81 * associated with this transaction.
88 * This is called to mark the dquot as needing
89 * to be logged when the transaction is committed. The dquot must
90 * already be associated with the given transaction.
91 * Note that it marks the entire transaction as dirty. In the ordinary
92 * case, this gets called via xfs_trans_commit, after the transaction
93 * is already dirty. However, there's nothing stop this from getting
94 * called directly, as done by xfs_qm_scall_setqlim. Hence, the TRANS_DIRTY
102 xfs_log_item_desc_t
*lidp
;
104 ASSERT(XFS_DQ_IS_ADDEDTO_TRX(tp
, dqp
));
105 ASSERT(XFS_DQ_IS_LOCKED(dqp
));
107 lidp
= xfs_trans_find_item(tp
, (xfs_log_item_t
*)(&dqp
->q_logitem
));
108 ASSERT(lidp
!= NULL
);
110 tp
->t_flags
|= XFS_TRANS_DIRTY
;
111 lidp
->lid_flags
|= XFS_LID_DIRTY
;
115 * Carry forward whatever is left of the quota blk reservation to
116 * the spanky new transaction
119 xfs_trans_dup_dqinfo(
123 xfs_dqtrx_t
*oq
, *nq
;
125 xfs_dqtrx_t
*oqa
, *nqa
;
130 xfs_trans_alloc_dqinfo(ntp
);
131 oqa
= otp
->t_dqinfo
->dqa_usrdquots
;
132 nqa
= ntp
->t_dqinfo
->dqa_usrdquots
;
135 * Because the quota blk reservation is carried forward,
136 * it is also necessary to carry forward the DQ_DIRTY flag.
138 if(otp
->t_flags
& XFS_TRANS_DQ_DIRTY
)
139 ntp
->t_flags
|= XFS_TRANS_DQ_DIRTY
;
141 for (j
= 0; j
< 2; j
++) {
142 for (i
= 0; i
< XFS_QM_TRANS_MAXDQS
; i
++) {
143 if (oqa
[i
].qt_dquot
== NULL
)
148 nq
->qt_dquot
= oq
->qt_dquot
;
149 nq
->qt_bcount_delta
= nq
->qt_icount_delta
= 0;
150 nq
->qt_rtbcount_delta
= 0;
153 * Transfer whatever is left of the reservations.
155 nq
->qt_blk_res
= oq
->qt_blk_res
- oq
->qt_blk_res_used
;
156 oq
->qt_blk_res
= oq
->qt_blk_res_used
;
158 nq
->qt_rtblk_res
= oq
->qt_rtblk_res
-
159 oq
->qt_rtblk_res_used
;
160 oq
->qt_rtblk_res
= oq
->qt_rtblk_res_used
;
162 nq
->qt_ino_res
= oq
->qt_ino_res
- oq
->qt_ino_res_used
;
163 oq
->qt_ino_res
= oq
->qt_ino_res_used
;
166 oqa
= otp
->t_dqinfo
->dqa_grpdquots
;
167 nqa
= ntp
->t_dqinfo
->dqa_grpdquots
;
172 * Wrap around mod_dquot to account for both user and group quotas.
175 xfs_trans_mod_dquot_byino(
186 if (!XFS_IS_QUOTA_ON(mp
) ||
187 ip
->i_ino
== mp
->m_sb
.sb_uquotino
||
188 ip
->i_ino
== mp
->m_sb
.sb_gquotino
)
191 if (tp
->t_dqinfo
== NULL
)
192 xfs_trans_alloc_dqinfo(tp
);
194 if (XFS_IS_UQUOTA_ON(mp
) && ip
->i_udquot
)
195 (void) xfs_trans_mod_dquot(tp
, ip
->i_udquot
, field
, delta
);
196 if (XFS_IS_OQUOTA_ON(mp
) && ip
->i_gdquot
)
197 (void) xfs_trans_mod_dquot(tp
, ip
->i_gdquot
, field
, delta
);
208 for (i
= 0; i
< XFS_QM_TRANS_MAXDQS
; i
++) {
209 qa
= XFS_QM_DQP_TO_DQACCT(tp
, dqp
);
211 if (qa
[i
].qt_dquot
== NULL
||
212 qa
[i
].qt_dquot
== dqp
) {
221 * Make the changes in the transaction structure.
222 * The moral equivalent to xfs_trans_mod_sb().
223 * We don't touch any fields in the dquot, so we don't care
224 * if it's locked or not (most of the time it won't be).
238 if (tp
->t_dqinfo
== NULL
)
239 xfs_trans_alloc_dqinfo(tp
);
241 * Find either the first free slot or the slot that belongs
244 qtrx
= xfs_trans_get_dqtrx(tp
, dqp
);
246 if (qtrx
->qt_dquot
== NULL
)
247 qtrx
->qt_dquot
= dqp
;
252 * regular disk blk reservation
254 case XFS_TRANS_DQ_RES_BLKS
:
255 qtrx
->qt_blk_res
+= (ulong
)delta
;
261 case XFS_TRANS_DQ_RES_INOS
:
262 qtrx
->qt_ino_res
+= (ulong
)delta
;
268 case XFS_TRANS_DQ_BCOUNT
:
269 if (qtrx
->qt_blk_res
&& delta
> 0) {
270 qtrx
->qt_blk_res_used
+= (ulong
)delta
;
271 ASSERT(qtrx
->qt_blk_res
>= qtrx
->qt_blk_res_used
);
273 qtrx
->qt_bcount_delta
+= delta
;
276 case XFS_TRANS_DQ_DELBCOUNT
:
277 qtrx
->qt_delbcnt_delta
+= delta
;
283 case XFS_TRANS_DQ_ICOUNT
:
284 if (qtrx
->qt_ino_res
&& delta
> 0) {
285 qtrx
->qt_ino_res_used
+= (ulong
)delta
;
286 ASSERT(qtrx
->qt_ino_res
>= qtrx
->qt_ino_res_used
);
288 qtrx
->qt_icount_delta
+= delta
;
294 case XFS_TRANS_DQ_RES_RTBLKS
:
295 qtrx
->qt_rtblk_res
+= (ulong
)delta
;
301 case XFS_TRANS_DQ_RTBCOUNT
:
302 if (qtrx
->qt_rtblk_res
&& delta
> 0) {
303 qtrx
->qt_rtblk_res_used
+= (ulong
)delta
;
304 ASSERT(qtrx
->qt_rtblk_res
>= qtrx
->qt_rtblk_res_used
);
306 qtrx
->qt_rtbcount_delta
+= delta
;
309 case XFS_TRANS_DQ_DELRTBCOUNT
:
310 qtrx
->qt_delrtb_delta
+= delta
;
316 tp
->t_flags
|= XFS_TRANS_DQ_DIRTY
;
321 * Given an array of dqtrx structures, lock all the dquots associated
322 * and join them to the transaction, provided they have been modified.
323 * We know that the highest number of dquots (of one type - usr OR grp),
324 * involved in a transaction is 2 and that both usr and grp combined - 3.
325 * So, we don't attempt to make this very generic.
328 xfs_trans_dqlockedjoin(
332 ASSERT(q
[0].qt_dquot
!= NULL
);
333 if (q
[1].qt_dquot
== NULL
) {
334 xfs_dqlock(q
[0].qt_dquot
);
335 xfs_trans_dqjoin(tp
, q
[0].qt_dquot
);
337 ASSERT(XFS_QM_TRANS_MAXDQS
== 2);
338 xfs_dqlock2(q
[0].qt_dquot
, q
[1].qt_dquot
);
339 xfs_trans_dqjoin(tp
, q
[0].qt_dquot
);
340 xfs_trans_dqjoin(tp
, q
[1].qt_dquot
);
346 * Called by xfs_trans_commit() and similar in spirit to
347 * xfs_trans_apply_sb_deltas().
348 * Go thru all the dquots belonging to this transaction and modify the
349 * INCORE dquot to reflect the actual usages.
350 * Unreserve just the reservations done by this transaction.
351 * dquot is still left locked at exit.
354 xfs_trans_apply_dquot_deltas(
359 xfs_dqtrx_t
*qtrx
, *qa
;
364 if (! (tp
->t_flags
& XFS_TRANS_DQ_DIRTY
))
367 ASSERT(tp
->t_dqinfo
);
368 qa
= tp
->t_dqinfo
->dqa_usrdquots
;
369 for (j
= 0; j
< 2; j
++) {
370 if (qa
[0].qt_dquot
== NULL
) {
371 qa
= tp
->t_dqinfo
->dqa_grpdquots
;
376 * Lock all of the dquots and join them to the transaction.
378 xfs_trans_dqlockedjoin(tp
, qa
);
380 for (i
= 0; i
< XFS_QM_TRANS_MAXDQS
; i
++) {
383 * The array of dquots is filled
384 * sequentially, not sparsely.
386 if ((dqp
= qtrx
->qt_dquot
) == NULL
)
389 ASSERT(XFS_DQ_IS_LOCKED(dqp
));
390 ASSERT(XFS_DQ_IS_ADDEDTO_TRX(tp
, dqp
));
393 * adjust the actual number of blocks used
398 * The issue here is - sometimes we don't make a blkquota
399 * reservation intentionally to be fair to users
400 * (when the amount is small). On the other hand,
401 * delayed allocs do make reservations, but that's
402 * outside of a transaction, so we have no
403 * idea how much was really reserved.
404 * So, here we've accumulated delayed allocation blks and
405 * non-delay blks. The assumption is that the
406 * delayed ones are always reserved (outside of a
407 * transaction), and the others may or may not have
408 * quota reservations.
410 totalbdelta
= qtrx
->qt_bcount_delta
+
411 qtrx
->qt_delbcnt_delta
;
412 totalrtbdelta
= qtrx
->qt_rtbcount_delta
+
413 qtrx
->qt_delrtb_delta
;
416 ASSERT(be64_to_cpu(d
->d_bcount
) >=
417 (xfs_qcnt_t
) -totalbdelta
);
419 if (totalrtbdelta
< 0)
420 ASSERT(be64_to_cpu(d
->d_rtbcount
) >=
421 (xfs_qcnt_t
) -totalrtbdelta
);
423 if (qtrx
->qt_icount_delta
< 0)
424 ASSERT(be64_to_cpu(d
->d_icount
) >=
425 (xfs_qcnt_t
) -qtrx
->qt_icount_delta
);
428 be64_add(&d
->d_bcount
, (xfs_qcnt_t
)totalbdelta
);
430 if (qtrx
->qt_icount_delta
)
431 be64_add(&d
->d_icount
, (xfs_qcnt_t
)qtrx
->qt_icount_delta
);
434 be64_add(&d
->d_rtbcount
, (xfs_qcnt_t
)totalrtbdelta
);
437 * Get any default limits in use.
438 * Start/reset the timer(s) if needed.
441 xfs_qm_adjust_dqlimits(tp
->t_mountp
, d
);
442 xfs_qm_adjust_dqtimers(tp
->t_mountp
, d
);
445 dqp
->dq_flags
|= XFS_DQ_DIRTY
;
447 * add this to the list of items to get logged
449 xfs_trans_log_dquot(tp
, dqp
);
451 * Take off what's left of the original reservation.
452 * In case of delayed allocations, there's no
453 * reservation that a transaction structure knows of.
455 if (qtrx
->qt_blk_res
!= 0) {
456 if (qtrx
->qt_blk_res
!= qtrx
->qt_blk_res_used
) {
457 if (qtrx
->qt_blk_res
>
458 qtrx
->qt_blk_res_used
)
459 dqp
->q_res_bcount
-= (xfs_qcnt_t
)
461 qtrx
->qt_blk_res_used
);
463 dqp
->q_res_bcount
-= (xfs_qcnt_t
)
464 (qtrx
->qt_blk_res_used
-
469 * These blks were never reserved, either inside
470 * a transaction or outside one (in a delayed
471 * allocation). Also, this isn't always a
472 * negative number since we sometimes
473 * deliberately skip quota reservations.
475 if (qtrx
->qt_bcount_delta
) {
477 (xfs_qcnt_t
)qtrx
->qt_bcount_delta
;
481 * Adjust the RT reservation.
483 if (qtrx
->qt_rtblk_res
!= 0) {
484 if (qtrx
->qt_rtblk_res
!= qtrx
->qt_rtblk_res_used
) {
485 if (qtrx
->qt_rtblk_res
>
486 qtrx
->qt_rtblk_res_used
)
487 dqp
->q_res_rtbcount
-= (xfs_qcnt_t
)
488 (qtrx
->qt_rtblk_res
-
489 qtrx
->qt_rtblk_res_used
);
491 dqp
->q_res_rtbcount
-= (xfs_qcnt_t
)
492 (qtrx
->qt_rtblk_res_used
-
496 if (qtrx
->qt_rtbcount_delta
)
497 dqp
->q_res_rtbcount
+=
498 (xfs_qcnt_t
)qtrx
->qt_rtbcount_delta
;
502 * Adjust the inode reservation.
504 if (qtrx
->qt_ino_res
!= 0) {
505 ASSERT(qtrx
->qt_ino_res
>=
506 qtrx
->qt_ino_res_used
);
507 if (qtrx
->qt_ino_res
> qtrx
->qt_ino_res_used
)
508 dqp
->q_res_icount
-= (xfs_qcnt_t
)
510 qtrx
->qt_ino_res_used
);
512 if (qtrx
->qt_icount_delta
)
514 (xfs_qcnt_t
)qtrx
->qt_icount_delta
;
517 ASSERT(dqp
->q_res_bcount
>=
518 be64_to_cpu(dqp
->q_core
.d_bcount
));
519 ASSERT(dqp
->q_res_icount
>=
520 be64_to_cpu(dqp
->q_core
.d_icount
));
521 ASSERT(dqp
->q_res_rtbcount
>=
522 be64_to_cpu(dqp
->q_core
.d_rtbcount
));
525 * Do the group quotas next
527 qa
= tp
->t_dqinfo
->dqa_grpdquots
;
532 * Release the reservations, and adjust the dquots accordingly.
533 * This is called only when the transaction is being aborted. If by
534 * any chance we have done dquot modifications incore (ie. deltas) already,
535 * we simply throw those away, since that's the expected behavior
536 * when a transaction is curtailed without a commit.
539 xfs_trans_unreserve_and_mod_dquots(
544 xfs_dqtrx_t
*qtrx
, *qa
;
547 if (!tp
->t_dqinfo
|| !(tp
->t_flags
& XFS_TRANS_DQ_DIRTY
))
550 qa
= tp
->t_dqinfo
->dqa_usrdquots
;
552 for (j
= 0; j
< 2; j
++) {
553 for (i
= 0; i
< XFS_QM_TRANS_MAXDQS
; i
++) {
556 * We assume that the array of dquots is filled
557 * sequentially, not sparsely.
559 if ((dqp
= qtrx
->qt_dquot
) == NULL
)
562 * Unreserve the original reservation. We don't care
563 * about the number of blocks used field, or deltas.
564 * Also we don't bother to zero the fields.
567 if (qtrx
->qt_blk_res
) {
571 (xfs_qcnt_t
)qtrx
->qt_blk_res
;
573 if (qtrx
->qt_ino_res
) {
579 (xfs_qcnt_t
)qtrx
->qt_ino_res
;
582 if (qtrx
->qt_rtblk_res
) {
587 dqp
->q_res_rtbcount
-=
588 (xfs_qcnt_t
)qtrx
->qt_rtblk_res
;
594 qa
= tp
->t_dqinfo
->dqa_grpdquots
;
599 * This reserves disk blocks and inodes against a dquot.
600 * Flags indicate if the dquot is to be locked here and also
601 * if the blk reservation is for RT or regular blocks.
602 * Sending in XFS_QMOPT_FORCE_RES flag skips the quota check.
603 * Returns EDQUOT if quota is exceeded.
615 xfs_qcnt_t hardlimit
;
616 xfs_qcnt_t softlimit
;
618 xfs_qwarncnt_t warns
;
619 xfs_qwarncnt_t warnlimit
;
621 xfs_qcnt_t
*resbcountp
;
622 xfs_quotainfo_t
*q
= mp
->m_quotainfo
;
624 if (! (flags
& XFS_QMOPT_DQLOCK
)) {
627 ASSERT(XFS_DQ_IS_LOCKED(dqp
));
628 if (flags
& XFS_TRANS_DQ_RES_BLKS
) {
629 hardlimit
= be64_to_cpu(dqp
->q_core
.d_blk_hardlimit
);
631 hardlimit
= q
->qi_bhardlimit
;
632 softlimit
= be64_to_cpu(dqp
->q_core
.d_blk_softlimit
);
634 softlimit
= q
->qi_bsoftlimit
;
635 timer
= be32_to_cpu(dqp
->q_core
.d_btimer
);
636 warns
= be16_to_cpu(dqp
->q_core
.d_bwarns
);
637 warnlimit
= XFS_QI_BWARNLIMIT(dqp
->q_mount
);
638 resbcountp
= &dqp
->q_res_bcount
;
640 ASSERT(flags
& XFS_TRANS_DQ_RES_RTBLKS
);
641 hardlimit
= be64_to_cpu(dqp
->q_core
.d_rtb_hardlimit
);
643 hardlimit
= q
->qi_rtbhardlimit
;
644 softlimit
= be64_to_cpu(dqp
->q_core
.d_rtb_softlimit
);
646 softlimit
= q
->qi_rtbsoftlimit
;
647 timer
= be32_to_cpu(dqp
->q_core
.d_rtbtimer
);
648 warns
= be16_to_cpu(dqp
->q_core
.d_rtbwarns
);
649 warnlimit
= XFS_QI_RTBWARNLIMIT(dqp
->q_mount
);
650 resbcountp
= &dqp
->q_res_rtbcount
;
654 if ((flags
& XFS_QMOPT_FORCE_RES
) == 0 &&
656 XFS_IS_QUOTA_ENFORCED(dqp
->q_mount
)) {
658 cmn_err(CE_DEBUG
, "BLK Res: nblks=%ld + resbcount=%Ld"
659 " > hardlimit=%Ld?", nblks
, *resbcountp
, hardlimit
);
663 * dquot is locked already. See if we'd go over the
664 * hardlimit or exceed the timelimit if we allocate
667 if (hardlimit
> 0ULL &&
668 (hardlimit
<= nblks
+ *resbcountp
)) {
673 if (softlimit
> 0ULL &&
674 (softlimit
<= nblks
+ *resbcountp
)) {
676 * If timer or warnings has expired,
679 if ((timer
!= 0 && get_seconds() > timer
) ||
680 (warns
!= 0 && warns
>= warnlimit
)) {
687 count
= be64_to_cpu(dqp
->q_core
.d_icount
);
688 timer
= be32_to_cpu(dqp
->q_core
.d_itimer
);
689 warns
= be16_to_cpu(dqp
->q_core
.d_iwarns
);
690 warnlimit
= XFS_QI_IWARNLIMIT(dqp
->q_mount
);
691 hardlimit
= be64_to_cpu(dqp
->q_core
.d_ino_hardlimit
);
693 hardlimit
= q
->qi_ihardlimit
;
694 softlimit
= be64_to_cpu(dqp
->q_core
.d_ino_softlimit
);
696 softlimit
= q
->qi_isoftlimit
;
697 if (hardlimit
> 0ULL && count
>= hardlimit
) {
700 } else if (softlimit
> 0ULL && count
>= softlimit
) {
702 * If timer or warnings has expired,
705 if ((timer
!= 0 && get_seconds() > timer
) ||
706 (warns
!= 0 && warns
>= warnlimit
)) {
715 * Change the reservation, but not the actual usage.
716 * Note that q_res_bcount = q_core.d_bcount + resv
718 (*resbcountp
) += (xfs_qcnt_t
)nblks
;
720 dqp
->q_res_icount
+= (xfs_qcnt_t
)ninos
;
723 * note the reservation amt in the trans struct too,
724 * so that the transaction knows how much was reserved by
725 * it against this particular dquot.
726 * We don't do this when we are reserving for a delayed allocation,
727 * because we don't have the luxury of a transaction envelope then.
730 ASSERT(tp
->t_dqinfo
);
731 ASSERT(flags
& XFS_QMOPT_RESBLK_MASK
);
733 xfs_trans_mod_dquot(tp
, dqp
,
734 flags
& XFS_QMOPT_RESBLK_MASK
,
737 xfs_trans_mod_dquot(tp
, dqp
,
738 XFS_TRANS_DQ_RES_INOS
,
741 ASSERT(dqp
->q_res_bcount
>= be64_to_cpu(dqp
->q_core
.d_bcount
));
742 ASSERT(dqp
->q_res_rtbcount
>= be64_to_cpu(dqp
->q_core
.d_rtbcount
));
743 ASSERT(dqp
->q_res_icount
>= be64_to_cpu(dqp
->q_core
.d_icount
));
746 if (! (flags
& XFS_QMOPT_DQLOCK
)) {
754 * Given a dquot(s), make disk block and/or inode reservations against them.
755 * The fact that this does the reservation against both the usr and
756 * grp quotas is important, because this follows a both-or-nothing
759 * flags = XFS_QMOPT_DQLOCK indicate if dquot(s) need to be locked.
760 * XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown.
761 * XFS_TRANS_DQ_RES_BLKS reserves regular disk blocks
762 * XFS_TRANS_DQ_RES_RTBLKS reserves realtime disk blocks
763 * dquots are unlocked on return, if they were not locked by caller.
766 xfs_trans_reserve_quota_bydquots(
777 if (! XFS_IS_QUOTA_ON(mp
))
780 if (tp
&& tp
->t_dqinfo
== NULL
)
781 xfs_trans_alloc_dqinfo(tp
);
783 ASSERT(flags
& XFS_QMOPT_RESBLK_MASK
);
787 if (xfs_trans_dqresv(tp
, mp
, udqp
, nblks
, ninos
, flags
))
793 if (xfs_trans_dqresv(tp
, mp
, gdqp
, nblks
, ninos
, flags
)) {
795 * can't do it, so backout previous reservation
798 flags
|= XFS_QMOPT_FORCE_RES
;
799 xfs_trans_dqresv(tp
, mp
, udqp
,
800 -nblks
, -ninos
, flags
);
807 * Didnt change anything critical, so, no need to log
814 * Lock the dquot and change the reservation if we can.
815 * This doesn't change the actual usage, just the reservation.
816 * The inode sent in is locked.
818 * Returns 0 on success, EDQUOT or other errors otherwise
821 xfs_trans_reserve_quota_nblks(
831 if (!XFS_IS_QUOTA_ON(mp
))
834 ASSERT(ip
->i_ino
!= mp
->m_sb
.sb_uquotino
);
835 ASSERT(ip
->i_ino
!= mp
->m_sb
.sb_gquotino
);
837 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip
));
838 ASSERT(XFS_IS_QUOTA_RUNNING(ip
->i_mount
));
839 ASSERT((type
& ~XFS_QMOPT_FORCE_RES
) == XFS_TRANS_DQ_RES_RTBLKS
||
840 (type
& ~XFS_QMOPT_FORCE_RES
) == XFS_TRANS_DQ_RES_BLKS
);
843 * Reserve nblks against these dquots, with trans as the mediator.
845 error
= xfs_trans_reserve_quota_bydquots(tp
, mp
,
846 ip
->i_udquot
, ip
->i_gdquot
,
853 * This routine is called to allocate a quotaoff log item.
856 xfs_trans_get_qoff_item(
858 xfs_qoff_logitem_t
*startqoff
,
861 xfs_qoff_logitem_t
*q
;
865 q
= xfs_qm_qoff_logitem_init(tp
->t_mountp
, startqoff
, flags
);
869 * Get a log_item_desc to point at the new item.
871 (void) xfs_trans_add_item(tp
, (xfs_log_item_t
*)q
);
878 * This is called to mark the quotaoff logitem as needing
879 * to be logged when the transaction is committed. The logitem must
880 * already be associated with the given transaction.
883 xfs_trans_log_quotaoff_item(
885 xfs_qoff_logitem_t
*qlp
)
887 xfs_log_item_desc_t
*lidp
;
889 lidp
= xfs_trans_find_item(tp
, (xfs_log_item_t
*)qlp
);
890 ASSERT(lidp
!= NULL
);
892 tp
->t_flags
|= XFS_TRANS_DIRTY
;
893 lidp
->lid_flags
|= XFS_LID_DIRTY
;
897 xfs_trans_alloc_dqinfo(
900 (tp
)->t_dqinfo
= kmem_zone_zalloc(xfs_Gqm
->qm_dqtrxzone
, KM_SLEEP
);
904 xfs_trans_free_dqinfo(
909 kmem_zone_free(xfs_Gqm
->qm_dqtrxzone
, (tp
)->t_dqinfo
);
910 (tp
)->t_dqinfo
= NULL
;
913 xfs_dqtrxops_t xfs_trans_dquot_ops
= {
914 .qo_dup_dqinfo
= xfs_trans_dup_dqinfo
,
915 .qo_free_dqinfo
= xfs_trans_free_dqinfo
,
916 .qo_mod_dquot_byino
= xfs_trans_mod_dquot_byino
,
917 .qo_apply_dquot_deltas
= xfs_trans_apply_dquot_deltas
,
918 .qo_reserve_quota_nblks
= xfs_trans_reserve_quota_nblks
,
919 .qo_reserve_quota_bydquots
= xfs_trans_reserve_quota_bydquots
,
920 .qo_unreserve_and_mod_dquots
= xfs_trans_unreserve_and_mod_dquots
,