blob: 4d630d2c280436a545d8b82beb3f25da3b6d25f0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott4ce31212005-11-02 14:59:41 +11002 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott4ce31212005-11-02 14:59:41 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott4ce31212005-11-02 14:59:41 +11009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott4ce31212005-11-02 14:59:41 +110014 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
19#include "xfs_fs.h"
Dave Chinner6ca1c902013-08-12 20:49:26 +100020#include "xfs_format.h"
Dave Chinner70a9883c2013-10-23 10:36:05 +110021#include "xfs_shared.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include "xfs_log.h"
23#include "xfs_trans.h"
24#include "xfs_sb.h"
25#include "xfs_ag.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include "xfs_alloc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include "xfs_quota.h"
28#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include "xfs_bmap_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include "xfs_inode.h"
Nathan Scotta844f452005-11-02 14:38:42 +110031#include "xfs_itable.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "xfs_bmap.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "xfs_rtalloc.h"
34#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include "xfs_attr.h"
36#include "xfs_buf_item.h"
37#include "xfs_trans_priv.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include "xfs_qm.h"
39
40STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *);
41
42/*
43 * Add the locked dquot to the transaction.
44 * The dquot must be locked, and it cannot be associated with any
45 * transaction.
46 */
47void
48xfs_trans_dqjoin(
49 xfs_trans_t *tp,
50 xfs_dquot_t *dqp)
51{
Christoph Hellwig191f8482010-04-20 17:01:53 +100052 ASSERT(dqp->q_transp != tp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 ASSERT(XFS_DQ_IS_LOCKED(dqp));
Christoph Hellwige98c4142010-06-23 18:11:15 +100054 ASSERT(dqp->q_logitem.qli_dquot == dqp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56 /*
57 * Get a log_item_desc to point at the new item.
58 */
Christoph Hellwige98c4142010-06-23 18:11:15 +100059 xfs_trans_add_item(tp, &dqp->q_logitem.qli_item);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 /*
Christoph Hellwigf3ca87382011-07-08 14:34:47 +020062 * Initialize d_transp so we can later determine if this dquot is
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 * associated with this transaction.
64 */
65 dqp->q_transp = tp;
66}
67
68
69/*
70 * This is called to mark the dquot as needing
71 * to be logged when the transaction is committed. The dquot must
72 * already be associated with the given transaction.
73 * Note that it marks the entire transaction as dirty. In the ordinary
74 * case, this gets called via xfs_trans_commit, after the transaction
75 * is already dirty. However, there's nothing stop this from getting
76 * called directly, as done by xfs_qm_scall_setqlim. Hence, the TRANS_DIRTY
77 * flag.
78 */
79void
80xfs_trans_log_dquot(
81 xfs_trans_t *tp,
82 xfs_dquot_t *dqp)
83{
Christoph Hellwig191f8482010-04-20 17:01:53 +100084 ASSERT(dqp->q_transp == tp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 ASSERT(XFS_DQ_IS_LOCKED(dqp));
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 tp->t_flags |= XFS_TRANS_DIRTY;
Christoph Hellwige98c4142010-06-23 18:11:15 +100088 dqp->q_logitem.qli_item.li_desc->lid_flags |= XFS_LID_DIRTY;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
90
91/*
92 * Carry forward whatever is left of the quota blk reservation to
93 * the spanky new transaction
94 */
Christoph Hellwig7d095252009-06-08 15:33:32 +020095void
Linus Torvalds1da177e2005-04-16 15:20:36 -070096xfs_trans_dup_dqinfo(
97 xfs_trans_t *otp,
98 xfs_trans_t *ntp)
99{
100 xfs_dqtrx_t *oq, *nq;
101 int i,j;
102 xfs_dqtrx_t *oqa, *nqa;
103
104 if (!otp->t_dqinfo)
105 return;
106
107 xfs_trans_alloc_dqinfo(ntp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
109 /*
110 * Because the quota blk reservation is carried forward,
111 * it is also necessary to carry forward the DQ_DIRTY flag.
112 */
113 if(otp->t_flags & XFS_TRANS_DQ_DIRTY)
114 ntp->t_flags |= XFS_TRANS_DQ_DIRTY;
115
Chandra Seetharaman0e6436d2013-06-27 17:25:09 -0500116 for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
117 oqa = otp->t_dqinfo->dqs[j];
118 nqa = ntp->t_dqinfo->dqs[j];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
120 if (oqa[i].qt_dquot == NULL)
121 break;
122 oq = &oqa[i];
123 nq = &nqa[i];
124
125 nq->qt_dquot = oq->qt_dquot;
126 nq->qt_bcount_delta = nq->qt_icount_delta = 0;
127 nq->qt_rtbcount_delta = 0;
128
129 /*
130 * Transfer whatever is left of the reservations.
131 */
132 nq->qt_blk_res = oq->qt_blk_res - oq->qt_blk_res_used;
133 oq->qt_blk_res = oq->qt_blk_res_used;
134
135 nq->qt_rtblk_res = oq->qt_rtblk_res -
136 oq->qt_rtblk_res_used;
137 oq->qt_rtblk_res = oq->qt_rtblk_res_used;
138
139 nq->qt_ino_res = oq->qt_ino_res - oq->qt_ino_res_used;
140 oq->qt_ino_res = oq->qt_ino_res_used;
141
142 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 }
144}
145
146/*
147 * Wrap around mod_dquot to account for both user and group quotas.
148 */
Christoph Hellwig7d095252009-06-08 15:33:32 +0200149void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150xfs_trans_mod_dquot_byino(
151 xfs_trans_t *tp,
152 xfs_inode_t *ip,
153 uint field,
154 long delta)
155{
Christoph Hellwig7d095252009-06-08 15:33:32 +0200156 xfs_mount_t *mp = tp->t_mountp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Christoph Hellwig7d095252009-06-08 15:33:32 +0200158 if (!XFS_IS_QUOTA_RUNNING(mp) ||
159 !XFS_IS_QUOTA_ON(mp) ||
Chandra Seetharaman9cad19d2013-06-27 17:25:04 -0500160 xfs_is_quota_inode(&mp->m_sb, ip->i_ino))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 return;
162
163 if (tp->t_dqinfo == NULL)
164 xfs_trans_alloc_dqinfo(tp);
165
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000166 if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta);
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500168 if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta);
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500170 if (XFS_IS_PQUOTA_ON(mp) && ip->i_pdquot)
171 (void) xfs_trans_mod_dquot(tp, ip->i_pdquot, field, delta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172}
173
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500174STATIC struct xfs_dqtrx *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175xfs_trans_get_dqtrx(
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500176 struct xfs_trans *tp,
177 struct xfs_dquot *dqp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178{
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500179 int i;
180 struct xfs_dqtrx *qa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Chandra Seetharaman0e6436d2013-06-27 17:25:09 -0500182 if (XFS_QM_ISUDQ(dqp))
183 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR];
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500184 else if (XFS_QM_ISGDQ(dqp))
Chandra Seetharaman0e6436d2013-06-27 17:25:09 -0500185 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP];
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500186 else if (XFS_QM_ISPDQ(dqp))
187 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ];
188 else
189 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Christoph Hellwig191f8482010-04-20 17:01:53 +1000191 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 if (qa[i].qt_dquot == NULL ||
Christoph Hellwig191f8482010-04-20 17:01:53 +1000193 qa[i].qt_dquot == dqp)
194 return &qa[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 }
196
Christoph Hellwig191f8482010-04-20 17:01:53 +1000197 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198}
199
200/*
201 * Make the changes in the transaction structure.
202 * The moral equivalent to xfs_trans_mod_sb().
203 * We don't touch any fields in the dquot, so we don't care
204 * if it's locked or not (most of the time it won't be).
205 */
206void
207xfs_trans_mod_dquot(
208 xfs_trans_t *tp,
209 xfs_dquot_t *dqp,
210 uint field,
211 long delta)
212{
213 xfs_dqtrx_t *qtrx;
214
215 ASSERT(tp);
Christoph Hellwig7d095252009-06-08 15:33:32 +0200216 ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 qtrx = NULL;
218
219 if (tp->t_dqinfo == NULL)
220 xfs_trans_alloc_dqinfo(tp);
221 /*
222 * Find either the first free slot or the slot that belongs
223 * to this dquot.
224 */
225 qtrx = xfs_trans_get_dqtrx(tp, dqp);
226 ASSERT(qtrx);
227 if (qtrx->qt_dquot == NULL)
228 qtrx->qt_dquot = dqp;
229
230 switch (field) {
231
232 /*
233 * regular disk blk reservation
234 */
235 case XFS_TRANS_DQ_RES_BLKS:
236 qtrx->qt_blk_res += (ulong)delta;
237 break;
238
239 /*
240 * inode reservation
241 */
242 case XFS_TRANS_DQ_RES_INOS:
243 qtrx->qt_ino_res += (ulong)delta;
244 break;
245
246 /*
247 * disk blocks used.
248 */
249 case XFS_TRANS_DQ_BCOUNT:
250 if (qtrx->qt_blk_res && delta > 0) {
251 qtrx->qt_blk_res_used += (ulong)delta;
252 ASSERT(qtrx->qt_blk_res >= qtrx->qt_blk_res_used);
253 }
254 qtrx->qt_bcount_delta += delta;
255 break;
256
257 case XFS_TRANS_DQ_DELBCOUNT:
258 qtrx->qt_delbcnt_delta += delta;
259 break;
260
261 /*
262 * Inode Count
263 */
264 case XFS_TRANS_DQ_ICOUNT:
265 if (qtrx->qt_ino_res && delta > 0) {
266 qtrx->qt_ino_res_used += (ulong)delta;
267 ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used);
268 }
269 qtrx->qt_icount_delta += delta;
270 break;
271
272 /*
273 * rtblk reservation
274 */
275 case XFS_TRANS_DQ_RES_RTBLKS:
276 qtrx->qt_rtblk_res += (ulong)delta;
277 break;
278
279 /*
280 * rtblk count
281 */
282 case XFS_TRANS_DQ_RTBCOUNT:
283 if (qtrx->qt_rtblk_res && delta > 0) {
284 qtrx->qt_rtblk_res_used += (ulong)delta;
285 ASSERT(qtrx->qt_rtblk_res >= qtrx->qt_rtblk_res_used);
286 }
287 qtrx->qt_rtbcount_delta += delta;
288 break;
289
290 case XFS_TRANS_DQ_DELRTBCOUNT:
291 qtrx->qt_delrtb_delta += delta;
292 break;
293
294 default:
295 ASSERT(0);
296 }
297 tp->t_flags |= XFS_TRANS_DQ_DIRTY;
298}
299
300
301/*
Dave Chinnerb0a9dab2013-07-10 07:04:01 +1000302 * Given an array of dqtrx structures, lock all the dquots associated and join
303 * them to the transaction, provided they have been modified. We know that the
304 * highest number of dquots of one type - usr, grp OR prj - involved in a
305 * transaction is 2 so we don't need to make this very generic.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 */
307STATIC void
308xfs_trans_dqlockedjoin(
309 xfs_trans_t *tp,
310 xfs_dqtrx_t *q)
311{
312 ASSERT(q[0].qt_dquot != NULL);
313 if (q[1].qt_dquot == NULL) {
314 xfs_dqlock(q[0].qt_dquot);
315 xfs_trans_dqjoin(tp, q[0].qt_dquot);
316 } else {
317 ASSERT(XFS_QM_TRANS_MAXDQS == 2);
318 xfs_dqlock2(q[0].qt_dquot, q[1].qt_dquot);
319 xfs_trans_dqjoin(tp, q[0].qt_dquot);
320 xfs_trans_dqjoin(tp, q[1].qt_dquot);
321 }
322}
323
324
325/*
326 * Called by xfs_trans_commit() and similar in spirit to
327 * xfs_trans_apply_sb_deltas().
328 * Go thru all the dquots belonging to this transaction and modify the
329 * INCORE dquot to reflect the actual usages.
330 * Unreserve just the reservations done by this transaction.
331 * dquot is still left locked at exit.
332 */
Christoph Hellwig7d095252009-06-08 15:33:32 +0200333void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334xfs_trans_apply_dquot_deltas(
Brian Foster4b6eae2e2013-03-18 10:51:45 -0400335 struct xfs_trans *tp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336{
337 int i, j;
Brian Foster4b6eae2e2013-03-18 10:51:45 -0400338 struct xfs_dquot *dqp;
339 struct xfs_dqtrx *qtrx, *qa;
340 struct xfs_disk_dquot *d;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 long totalbdelta;
342 long totalrtbdelta;
343
Christoph Hellwig7d095252009-06-08 15:33:32 +0200344 if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 return;
346
347 ASSERT(tp->t_dqinfo);
Chandra Seetharaman0e6436d2013-06-27 17:25:09 -0500348 for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
349 qa = tp->t_dqinfo->dqs[j];
350 if (qa[0].qt_dquot == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /*
354 * Lock all of the dquots and join them to the transaction.
355 */
356 xfs_trans_dqlockedjoin(tp, qa);
357
358 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
359 qtrx = &qa[i];
360 /*
361 * The array of dquots is filled
362 * sequentially, not sparsely.
363 */
364 if ((dqp = qtrx->qt_dquot) == NULL)
365 break;
366
367 ASSERT(XFS_DQ_IS_LOCKED(dqp));
Christoph Hellwig191f8482010-04-20 17:01:53 +1000368 ASSERT(dqp->q_transp == tp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
370 /*
371 * adjust the actual number of blocks used
372 */
373 d = &dqp->q_core;
374
375 /*
376 * The issue here is - sometimes we don't make a blkquota
377 * reservation intentionally to be fair to users
378 * (when the amount is small). On the other hand,
379 * delayed allocs do make reservations, but that's
380 * outside of a transaction, so we have no
381 * idea how much was really reserved.
382 * So, here we've accumulated delayed allocation blks and
383 * non-delay blks. The assumption is that the
384 * delayed ones are always reserved (outside of a
385 * transaction), and the others may or may not have
386 * quota reservations.
387 */
388 totalbdelta = qtrx->qt_bcount_delta +
389 qtrx->qt_delbcnt_delta;
390 totalrtbdelta = qtrx->qt_rtbcount_delta +
391 qtrx->qt_delrtb_delta;
Christoph Hellwigea15ab32011-07-13 13:43:50 +0200392#ifdef DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 if (totalbdelta < 0)
Christoph Hellwig1149d962005-11-02 15:01:12 +1100394 ASSERT(be64_to_cpu(d->d_bcount) >=
Christoph Hellwigea15ab32011-07-13 13:43:50 +0200395 -totalbdelta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
397 if (totalrtbdelta < 0)
Christoph Hellwig1149d962005-11-02 15:01:12 +1100398 ASSERT(be64_to_cpu(d->d_rtbcount) >=
Christoph Hellwigea15ab32011-07-13 13:43:50 +0200399 -totalrtbdelta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401 if (qtrx->qt_icount_delta < 0)
Christoph Hellwig1149d962005-11-02 15:01:12 +1100402 ASSERT(be64_to_cpu(d->d_icount) >=
Christoph Hellwigea15ab32011-07-13 13:43:50 +0200403 -qtrx->qt_icount_delta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404#endif
405 if (totalbdelta)
Marcin Slusarz413d57c2008-02-13 15:03:29 -0800406 be64_add_cpu(&d->d_bcount, (xfs_qcnt_t)totalbdelta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
408 if (qtrx->qt_icount_delta)
Marcin Slusarz413d57c2008-02-13 15:03:29 -0800409 be64_add_cpu(&d->d_icount, (xfs_qcnt_t)qtrx->qt_icount_delta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
411 if (totalrtbdelta)
Marcin Slusarz413d57c2008-02-13 15:03:29 -0800412 be64_add_cpu(&d->d_rtbcount, (xfs_qcnt_t)totalrtbdelta);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
414 /*
415 * Get any default limits in use.
416 * Start/reset the timer(s) if needed.
417 */
418 if (d->d_id) {
Brian Foster4b6eae2e2013-03-18 10:51:45 -0400419 xfs_qm_adjust_dqlimits(tp->t_mountp, dqp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 xfs_qm_adjust_dqtimers(tp->t_mountp, d);
421 }
422
423 dqp->dq_flags |= XFS_DQ_DIRTY;
424 /*
425 * add this to the list of items to get logged
426 */
427 xfs_trans_log_dquot(tp, dqp);
428 /*
429 * Take off what's left of the original reservation.
430 * In case of delayed allocations, there's no
431 * reservation that a transaction structure knows of.
432 */
433 if (qtrx->qt_blk_res != 0) {
434 if (qtrx->qt_blk_res != qtrx->qt_blk_res_used) {
435 if (qtrx->qt_blk_res >
436 qtrx->qt_blk_res_used)
437 dqp->q_res_bcount -= (xfs_qcnt_t)
438 (qtrx->qt_blk_res -
439 qtrx->qt_blk_res_used);
440 else
441 dqp->q_res_bcount -= (xfs_qcnt_t)
442 (qtrx->qt_blk_res_used -
443 qtrx->qt_blk_res);
444 }
445 } else {
446 /*
447 * These blks were never reserved, either inside
448 * a transaction or outside one (in a delayed
449 * allocation). Also, this isn't always a
450 * negative number since we sometimes
451 * deliberately skip quota reservations.
452 */
453 if (qtrx->qt_bcount_delta) {
454 dqp->q_res_bcount +=
455 (xfs_qcnt_t)qtrx->qt_bcount_delta;
456 }
457 }
458 /*
459 * Adjust the RT reservation.
460 */
461 if (qtrx->qt_rtblk_res != 0) {
Nathan Scott06d10dd2005-06-21 15:48:47 +1000462 if (qtrx->qt_rtblk_res != qtrx->qt_rtblk_res_used) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 if (qtrx->qt_rtblk_res >
464 qtrx->qt_rtblk_res_used)
465 dqp->q_res_rtbcount -= (xfs_qcnt_t)
466 (qtrx->qt_rtblk_res -
467 qtrx->qt_rtblk_res_used);
468 else
469 dqp->q_res_rtbcount -= (xfs_qcnt_t)
470 (qtrx->qt_rtblk_res_used -
471 qtrx->qt_rtblk_res);
472 }
473 } else {
474 if (qtrx->qt_rtbcount_delta)
475 dqp->q_res_rtbcount +=
476 (xfs_qcnt_t)qtrx->qt_rtbcount_delta;
477 }
478
479 /*
480 * Adjust the inode reservation.
481 */
482 if (qtrx->qt_ino_res != 0) {
483 ASSERT(qtrx->qt_ino_res >=
484 qtrx->qt_ino_res_used);
485 if (qtrx->qt_ino_res > qtrx->qt_ino_res_used)
486 dqp->q_res_icount -= (xfs_qcnt_t)
487 (qtrx->qt_ino_res -
488 qtrx->qt_ino_res_used);
489 } else {
490 if (qtrx->qt_icount_delta)
491 dqp->q_res_icount +=
492 (xfs_qcnt_t)qtrx->qt_icount_delta;
493 }
494
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 ASSERT(dqp->q_res_bcount >=
Christoph Hellwig1149d962005-11-02 15:01:12 +1100496 be64_to_cpu(dqp->q_core.d_bcount));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 ASSERT(dqp->q_res_icount >=
Christoph Hellwig1149d962005-11-02 15:01:12 +1100498 be64_to_cpu(dqp->q_core.d_icount));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 ASSERT(dqp->q_res_rtbcount >=
Christoph Hellwig1149d962005-11-02 15:01:12 +1100500 be64_to_cpu(dqp->q_core.d_rtbcount));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 }
503}
504
505/*
506 * Release the reservations, and adjust the dquots accordingly.
507 * This is called only when the transaction is being aborted. If by
508 * any chance we have done dquot modifications incore (ie. deltas) already,
509 * we simply throw those away, since that's the expected behavior
510 * when a transaction is curtailed without a commit.
511 */
Christoph Hellwig7d095252009-06-08 15:33:32 +0200512void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513xfs_trans_unreserve_and_mod_dquots(
514 xfs_trans_t *tp)
515{
516 int i, j;
517 xfs_dquot_t *dqp;
518 xfs_dqtrx_t *qtrx, *qa;
Thiago Farina667a9292012-11-12 21:32:59 -0200519 bool locked;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
521 if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY))
522 return;
523
Chandra Seetharaman0e6436d2013-06-27 17:25:09 -0500524 for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
525 qa = tp->t_dqinfo->dqs[j];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
528 qtrx = &qa[i];
529 /*
530 * We assume that the array of dquots is filled
531 * sequentially, not sparsely.
532 */
533 if ((dqp = qtrx->qt_dquot) == NULL)
534 break;
535 /*
536 * Unreserve the original reservation. We don't care
537 * about the number of blocks used field, or deltas.
538 * Also we don't bother to zero the fields.
539 */
Thiago Farina667a9292012-11-12 21:32:59 -0200540 locked = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 if (qtrx->qt_blk_res) {
542 xfs_dqlock(dqp);
Thiago Farina667a9292012-11-12 21:32:59 -0200543 locked = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 dqp->q_res_bcount -=
545 (xfs_qcnt_t)qtrx->qt_blk_res;
546 }
547 if (qtrx->qt_ino_res) {
548 if (!locked) {
549 xfs_dqlock(dqp);
Thiago Farina667a9292012-11-12 21:32:59 -0200550 locked = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 }
552 dqp->q_res_icount -=
553 (xfs_qcnt_t)qtrx->qt_ino_res;
554 }
555
556 if (qtrx->qt_rtblk_res) {
557 if (!locked) {
558 xfs_dqlock(dqp);
Thiago Farina667a9292012-11-12 21:32:59 -0200559 locked = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 }
561 dqp->q_res_rtbcount -=
562 (xfs_qcnt_t)qtrx->qt_rtblk_res;
563 }
564 if (locked)
565 xfs_dqunlock(dqp);
566
567 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 }
569}
570
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000571STATIC void
572xfs_quota_warn(
573 struct xfs_mount *mp,
574 struct xfs_dquot *dqp,
575 int type)
576{
577 /* no warnings for project quotas - we just return ENOSPC later */
578 if (dqp->dq_flags & XFS_DQ_PROJ)
579 return;
Eric W. Biederman431f1972012-09-16 02:32:43 -0700580 quota_send_warning(make_kqid(&init_user_ns,
581 (dqp->dq_flags & XFS_DQ_USER) ?
582 USRQUOTA : GRPQUOTA,
583 be32_to_cpu(dqp->q_core.d_id)),
584 mp->m_super->s_dev, type);
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000585}
586
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587/*
588 * This reserves disk blocks and inodes against a dquot.
589 * Flags indicate if the dquot is to be locked here and also
590 * if the blk reservation is for RT or regular blocks.
591 * Sending in XFS_QMOPT_FORCE_RES flag skips the quota check.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 */
593STATIC int
594xfs_trans_dqresv(
595 xfs_trans_t *tp,
596 xfs_mount_t *mp,
597 xfs_dquot_t *dqp,
598 long nblks,
599 long ninos,
600 uint flags)
601{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 xfs_qcnt_t hardlimit;
603 xfs_qcnt_t softlimit;
Nathan Scott06d10dd2005-06-21 15:48:47 +1000604 time_t timer;
605 xfs_qwarncnt_t warns;
606 xfs_qwarncnt_t warnlimit;
Mitsuo Hayasaka70b54372012-02-06 12:51:05 +0000607 xfs_qcnt_t total_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 xfs_qcnt_t *resbcountp;
609 xfs_quotainfo_t *q = mp->m_quotainfo;
610
Christoph Hellwig8e9b6e72009-02-08 21:51:42 +0100611
612 xfs_dqlock(dqp);
613
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 if (flags & XFS_TRANS_DQ_RES_BLKS) {
Christoph Hellwig1149d962005-11-02 15:01:12 +1100615 hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 if (!hardlimit)
617 hardlimit = q->qi_bhardlimit;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100618 softlimit = be64_to_cpu(dqp->q_core.d_blk_softlimit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 if (!softlimit)
620 softlimit = q->qi_bsoftlimit;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100621 timer = be32_to_cpu(dqp->q_core.d_btimer);
622 warns = be16_to_cpu(dqp->q_core.d_bwarns);
Christoph Hellwig8a7b8a82010-04-20 17:01:30 +1000623 warnlimit = dqp->q_mount->m_quotainfo->qi_bwarnlimit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 resbcountp = &dqp->q_res_bcount;
625 } else {
626 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
Christoph Hellwig1149d962005-11-02 15:01:12 +1100627 hardlimit = be64_to_cpu(dqp->q_core.d_rtb_hardlimit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 if (!hardlimit)
629 hardlimit = q->qi_rtbhardlimit;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100630 softlimit = be64_to_cpu(dqp->q_core.d_rtb_softlimit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 if (!softlimit)
632 softlimit = q->qi_rtbsoftlimit;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100633 timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
634 warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
Christoph Hellwig8a7b8a82010-04-20 17:01:30 +1000635 warnlimit = dqp->q_mount->m_quotainfo->qi_rtbwarnlimit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 resbcountp = &dqp->q_res_rtbcount;
637 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
639 if ((flags & XFS_QMOPT_FORCE_RES) == 0 &&
640 dqp->q_core.d_id &&
Kouta Ooizumie6d29422007-05-08 13:49:33 +1000641 ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) ||
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500642 (XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) ||
643 (XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 if (nblks > 0) {
645 /*
646 * dquot is locked already. See if we'd go over the
647 * hardlimit or exceed the timelimit if we allocate
648 * nblks.
649 */
Mitsuo Hayasaka70b54372012-02-06 12:51:05 +0000650 total_count = *resbcountp + nblks;
651 if (hardlimit && total_count > hardlimit) {
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000652 xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 goto error_return;
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000654 }
Mitsuo Hayasaka70b54372012-02-06 12:51:05 +0000655 if (softlimit && total_count > softlimit) {
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000656 if ((timer != 0 && get_seconds() > timer) ||
657 (warns != 0 && warns >= warnlimit)) {
658 xfs_quota_warn(mp, dqp,
659 QUOTA_NL_BSOFTLONGWARN);
660 goto error_return;
661 }
662
663 xfs_quota_warn(mp, dqp, QUOTA_NL_BSOFTWARN);
664 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 }
666 if (ninos > 0) {
Mitsuo Hayasaka70b54372012-02-06 12:51:05 +0000667 total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100668 timer = be32_to_cpu(dqp->q_core.d_itimer);
669 warns = be16_to_cpu(dqp->q_core.d_iwarns);
Christoph Hellwig8a7b8a82010-04-20 17:01:30 +1000670 warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100671 hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 if (!hardlimit)
673 hardlimit = q->qi_ihardlimit;
Christoph Hellwig1149d962005-11-02 15:01:12 +1100674 softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 if (!softlimit)
676 softlimit = q->qi_isoftlimit;
Christoph Hellwig4d1f88d2010-01-13 22:05:49 +0000677
Mitsuo Hayasaka70b54372012-02-06 12:51:05 +0000678 if (hardlimit && total_count > hardlimit) {
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000679 xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 goto error_return;
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000681 }
Mitsuo Hayasaka70b54372012-02-06 12:51:05 +0000682 if (softlimit && total_count > softlimit) {
Christoph Hellwiga210c1a2010-01-17 22:36:19 +0000683 if ((timer != 0 && get_seconds() > timer) ||
684 (warns != 0 && warns >= warnlimit)) {
685 xfs_quota_warn(mp, dqp,
686 QUOTA_NL_ISOFTLONGWARN);
687 goto error_return;
688 }
689 xfs_quota_warn(mp, dqp, QUOTA_NL_ISOFTWARN);
690 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 }
692 }
693
694 /*
695 * Change the reservation, but not the actual usage.
696 * Note that q_res_bcount = q_core.d_bcount + resv
697 */
698 (*resbcountp) += (xfs_qcnt_t)nblks;
699 if (ninos != 0)
700 dqp->q_res_icount += (xfs_qcnt_t)ninos;
701
702 /*
703 * note the reservation amt in the trans struct too,
704 * so that the transaction knows how much was reserved by
705 * it against this particular dquot.
706 * We don't do this when we are reserving for a delayed allocation,
707 * because we don't have the luxury of a transaction envelope then.
708 */
709 if (tp) {
710 ASSERT(tp->t_dqinfo);
711 ASSERT(flags & XFS_QMOPT_RESBLK_MASK);
712 if (nblks != 0)
713 xfs_trans_mod_dquot(tp, dqp,
714 flags & XFS_QMOPT_RESBLK_MASK,
715 nblks);
716 if (ninos != 0)
717 xfs_trans_mod_dquot(tp, dqp,
718 XFS_TRANS_DQ_RES_INOS,
719 ninos);
720 }
Christoph Hellwig1149d962005-11-02 15:01:12 +1100721 ASSERT(dqp->q_res_bcount >= be64_to_cpu(dqp->q_core.d_bcount));
722 ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount));
723 ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724
Christoph Hellwig4d1f88d2010-01-13 22:05:49 +0000725 xfs_dqunlock(dqp);
726 return 0;
727
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728error_return:
Christoph Hellwig8e9b6e72009-02-08 21:51:42 +0100729 xfs_dqunlock(dqp);
Christoph Hellwig4d1f88d2010-01-13 22:05:49 +0000730 if (flags & XFS_QMOPT_ENOSPC)
731 return ENOSPC;
732 return EDQUOT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733}
734
735
736/*
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000737 * Given dquot(s), make disk block and/or inode reservations against them.
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500738 * The fact that this does the reservation against user, group and
739 * project quotas is important, because this follows a all-or-nothing
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 * approach.
741 *
Christoph Hellwig8e9b6e72009-02-08 21:51:42 +0100742 * flags = XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown.
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000743 * XFS_QMOPT_ENOSPC returns ENOSPC not EDQUOT. Used by pquota.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 * XFS_TRANS_DQ_RES_BLKS reserves regular disk blocks
745 * XFS_TRANS_DQ_RES_RTBLKS reserves realtime disk blocks
746 * dquots are unlocked on return, if they were not locked by caller.
747 */
748int
749xfs_trans_reserve_quota_bydquots(
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500750 struct xfs_trans *tp,
751 struct xfs_mount *mp,
752 struct xfs_dquot *udqp,
753 struct xfs_dquot *gdqp,
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500754 struct xfs_dquot *pdqp,
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500755 long nblks,
756 long ninos,
757 uint flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758{
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500759 int error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760
Christoph Hellwig7d095252009-06-08 15:33:32 +0200761 if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000762 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763
764 if (tp && tp->t_dqinfo == NULL)
765 xfs_trans_alloc_dqinfo(tp);
766
767 ASSERT(flags & XFS_QMOPT_RESBLK_MASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768
769 if (udqp) {
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000770 error = xfs_trans_dqresv(tp, mp, udqp, nblks, ninos,
771 (flags & ~XFS_QMOPT_ENOSPC));
772 if (error)
773 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 }
775
776 if (gdqp) {
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000777 error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags);
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500778 if (error)
779 goto unwind_usr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 }
781
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500782 if (pdqp) {
783 error = xfs_trans_dqresv(tp, mp, pdqp, nblks, ninos, flags);
784 if (error)
785 goto unwind_grp;
786 }
787
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 /*
Nathan Scottc41564b2006-03-29 08:55:14 +1000789 * Didn't change anything critical, so, no need to log
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 */
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000791 return 0;
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500792
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500793unwind_grp:
794 flags |= XFS_QMOPT_FORCE_RES;
795 if (gdqp)
796 xfs_trans_dqresv(tp, mp, gdqp, -nblks, -ninos, flags);
Chandra Seetharaman113a5682013-06-27 17:25:07 -0500797unwind_usr:
798 flags |= XFS_QMOPT_FORCE_RES;
799 if (udqp)
800 xfs_trans_dqresv(tp, mp, udqp, -nblks, -ninos, flags);
801 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802}
803
804
805/*
806 * Lock the dquot and change the reservation if we can.
807 * This doesn't change the actual usage, just the reservation.
808 * The inode sent in is locked.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 */
Christoph Hellwig7d095252009-06-08 15:33:32 +0200810int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811xfs_trans_reserve_quota_nblks(
Christoph Hellwig7d095252009-06-08 15:33:32 +0200812 struct xfs_trans *tp,
813 struct xfs_inode *ip,
814 long nblks,
815 long ninos,
816 uint flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817{
Christoph Hellwig7d095252009-06-08 15:33:32 +0200818 struct xfs_mount *mp = ip->i_mount;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819
Christoph Hellwig7d095252009-06-08 15:33:32 +0200820 if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000821 return 0;
822 if (XFS_IS_PQUOTA_ON(mp))
823 flags |= XFS_QMOPT_ENOSPC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824
Chandra Seetharaman9cad19d2013-06-27 17:25:04 -0500825 ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826
Christoph Hellwig579aa9c2008-04-22 17:34:00 +1000827 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000828 ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
829 XFS_TRANS_DQ_RES_RTBLKS ||
830 (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
831 XFS_TRANS_DQ_RES_BLKS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832
833 /*
834 * Reserve nblks against these dquots, with trans as the mediator.
835 */
Christoph Hellwig7d095252009-06-08 15:33:32 +0200836 return xfs_trans_reserve_quota_bydquots(tp, mp,
837 ip->i_udquot, ip->i_gdquot,
Chandra Seetharaman92f8ff72013-07-11 00:00:40 -0500838 ip->i_pdquot,
Christoph Hellwig7d095252009-06-08 15:33:32 +0200839 nblks, ninos, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840}
841
842/*
843 * This routine is called to allocate a quotaoff log item.
844 */
845xfs_qoff_logitem_t *
846xfs_trans_get_qoff_item(
847 xfs_trans_t *tp,
848 xfs_qoff_logitem_t *startqoff,
849 uint flags)
850{
851 xfs_qoff_logitem_t *q;
852
853 ASSERT(tp != NULL);
854
855 q = xfs_qm_qoff_logitem_init(tp->t_mountp, startqoff, flags);
856 ASSERT(q != NULL);
857
858 /*
859 * Get a log_item_desc to point at the new item.
860 */
Christoph Hellwige98c4142010-06-23 18:11:15 +1000861 xfs_trans_add_item(tp, &q->qql_item);
862 return q;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863}
864
865
866/*
867 * This is called to mark the quotaoff logitem as needing
868 * to be logged when the transaction is committed. The logitem must
869 * already be associated with the given transaction.
870 */
871void
872xfs_trans_log_quotaoff_item(
873 xfs_trans_t *tp,
874 xfs_qoff_logitem_t *qlp)
875{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 tp->t_flags |= XFS_TRANS_DIRTY;
Christoph Hellwige98c4142010-06-23 18:11:15 +1000877 qlp->qql_item.li_desc->lid_flags |= XFS_LID_DIRTY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878}
879
880STATIC void
881xfs_trans_alloc_dqinfo(
882 xfs_trans_t *tp)
883{
Christoph Hellwiga05931c2012-03-13 08:52:37 +0000884 tp->t_dqinfo = kmem_zone_zalloc(xfs_qm_dqtrxzone, KM_SLEEP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885}
886
Christoph Hellwig7d095252009-06-08 15:33:32 +0200887void
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888xfs_trans_free_dqinfo(
889 xfs_trans_t *tp)
890{
891 if (!tp->t_dqinfo)
892 return;
Christoph Hellwiga05931c2012-03-13 08:52:37 +0000893 kmem_zone_free(xfs_qm_dqtrxzone, tp->t_dqinfo);
Christoph Hellwig7d095252009-06-08 15:33:32 +0200894 tp->t_dqinfo = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895}