]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/xfs/quota/xfs_dquot_item.c
[XFS] Show additional mount options in /proc/mounts, fix up some debug
[mirror_ubuntu-bionic-kernel.git] / fs / xfs / quota / xfs_dquot_item.c
CommitLineData
1da177e4 1/*
4ce3121f
NS
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
1da177e4 4 *
4ce3121f
NS
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
1da177e4
LT
7 * published by the Free Software Foundation.
8 *
4ce3121f
NS
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.
1da177e4 13 *
4ce3121f
NS
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
1da177e4 17 */
1da177e4
LT
18#include "xfs.h"
19#include "xfs_fs.h"
a844f451 20#include "xfs_bit.h"
1da177e4 21#include "xfs_log.h"
a844f451 22#include "xfs_inum.h"
1da177e4
LT
23#include "xfs_trans.h"
24#include "xfs_sb.h"
25#include "xfs_ag.h"
26#include "xfs_dir.h"
27#include "xfs_dir2.h"
28#include "xfs_alloc.h"
29#include "xfs_dmapi.h"
30#include "xfs_quota.h"
31#include "xfs_mount.h"
1da177e4 32#include "xfs_bmap_btree.h"
a844f451 33#include "xfs_alloc_btree.h"
1da177e4 34#include "xfs_ialloc_btree.h"
1da177e4
LT
35#include "xfs_dir_sf.h"
36#include "xfs_dir2_sf.h"
a844f451 37#include "xfs_attr_sf.h"
1da177e4
LT
38#include "xfs_dinode.h"
39#include "xfs_inode.h"
40#include "xfs_bmap.h"
a844f451
NS
41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
1da177e4
LT
43#include "xfs_rtalloc.h"
44#include "xfs_error.h"
45#include "xfs_itable.h"
46#include "xfs_rw.h"
47#include "xfs_acl.h"
48#include "xfs_cap.h"
49#include "xfs_mac.h"
50#include "xfs_attr.h"
51#include "xfs_buf_item.h"
52#include "xfs_trans_priv.h"
1da177e4
LT
53#include "xfs_qm.h"
54
1da177e4
LT
55/*
56 * returns the number of iovecs needed to log the given dquot item.
57 */
58/* ARGSUSED */
59STATIC uint
60xfs_qm_dquot_logitem_size(
61 xfs_dq_logitem_t *logitem)
62{
63 /*
64 * we need only two iovecs, one for the format, one for the real thing
65 */
66 return (2);
67}
68
69/*
70 * fills in the vector of log iovecs for the given dquot log item.
71 */
72STATIC void
73xfs_qm_dquot_logitem_format(
74 xfs_dq_logitem_t *logitem,
75 xfs_log_iovec_t *logvec)
76{
77 ASSERT(logitem);
78 ASSERT(logitem->qli_dquot);
79
80 logvec->i_addr = (xfs_caddr_t)&logitem->qli_format;
81 logvec->i_len = sizeof(xfs_dq_logformat_t);
82 logvec++;
83 logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core;
84 logvec->i_len = sizeof(xfs_disk_dquot_t);
85
86 ASSERT(2 == logitem->qli_item.li_desc->lid_size);
87 logitem->qli_format.qlf_size = 2;
88
89}
90
91/*
92 * Increment the pin count of the given dquot.
93 * This value is protected by pinlock spinlock in the xQM structure.
94 */
95STATIC void
96xfs_qm_dquot_logitem_pin(
97 xfs_dq_logitem_t *logitem)
98{
99 unsigned long s;
100 xfs_dquot_t *dqp;
101
102 dqp = logitem->qli_dquot;
103 ASSERT(XFS_DQ_IS_LOCKED(dqp));
104 s = XFS_DQ_PINLOCK(dqp);
105 dqp->q_pincount++;
106 XFS_DQ_PINUNLOCK(dqp, s);
107}
108
109/*
110 * Decrement the pin count of the given dquot, and wake up
111 * anyone in xfs_dqwait_unpin() if the count goes to 0. The
112 * dquot must have been previously pinned with a call to xfs_dqpin().
113 */
114/* ARGSUSED */
115STATIC void
116xfs_qm_dquot_logitem_unpin(
117 xfs_dq_logitem_t *logitem,
118 int stale)
119{
120 unsigned long s;
121 xfs_dquot_t *dqp;
122
123 dqp = logitem->qli_dquot;
124 ASSERT(dqp->q_pincount > 0);
125 s = XFS_DQ_PINLOCK(dqp);
126 dqp->q_pincount--;
127 if (dqp->q_pincount == 0) {
128 sv_broadcast(&dqp->q_pinwait);
129 }
130 XFS_DQ_PINUNLOCK(dqp, s);
131}
132
133/* ARGSUSED */
134STATIC void
135xfs_qm_dquot_logitem_unpin_remove(
136 xfs_dq_logitem_t *logitem,
137 xfs_trans_t *tp)
138{
139 xfs_qm_dquot_logitem_unpin(logitem, 0);
140}
141
142/*
143 * Given the logitem, this writes the corresponding dquot entry to disk
144 * asynchronously. This is called with the dquot entry securely locked;
145 * we simply get xfs_qm_dqflush() to do the work, and unlock the dquot
146 * at the end.
147 */
148STATIC void
149xfs_qm_dquot_logitem_push(
150 xfs_dq_logitem_t *logitem)
151{
152 xfs_dquot_t *dqp;
153
154 dqp = logitem->qli_dquot;
155
156 ASSERT(XFS_DQ_IS_LOCKED(dqp));
157 ASSERT(XFS_DQ_IS_FLUSH_LOCKED(dqp));
158
159 /*
160 * Since we were able to lock the dquot's flush lock and
161 * we found it on the AIL, the dquot must be dirty. This
162 * is because the dquot is removed from the AIL while still
163 * holding the flush lock in xfs_dqflush_done(). Thus, if
164 * we found it in the AIL and were able to obtain the flush
165 * lock without sleeping, then there must not have been
166 * anyone in the process of flushing the dquot.
167 */
168 xfs_qm_dqflush(dqp, XFS_B_DELWRI);
169 xfs_dqunlock(dqp);
170}
171
172/*ARGSUSED*/
173STATIC xfs_lsn_t
174xfs_qm_dquot_logitem_committed(
175 xfs_dq_logitem_t *l,
176 xfs_lsn_t lsn)
177{
178 /*
179 * We always re-log the entire dquot when it becomes dirty,
180 * so, the latest copy _is_ the only one that matters.
181 */
182 return (lsn);
183}
184
185
186/*
187 * This is called to wait for the given dquot to be unpinned.
188 * Most of these pin/unpin routines are plagiarized from inode code.
189 */
190void
191xfs_qm_dqunpin_wait(
192 xfs_dquot_t *dqp)
193{
194 SPLDECL(s);
195
196 ASSERT(XFS_DQ_IS_LOCKED(dqp));
197 if (dqp->q_pincount == 0) {
198 return;
199 }
200
201 /*
202 * Give the log a push so we don't wait here too long.
203 */
204 xfs_log_force(dqp->q_mount, (xfs_lsn_t)0, XFS_LOG_FORCE);
205 s = XFS_DQ_PINLOCK(dqp);
206 if (dqp->q_pincount == 0) {
207 XFS_DQ_PINUNLOCK(dqp, s);
208 return;
209 }
210 sv_wait(&(dqp->q_pinwait), PINOD,
211 &(XFS_DQ_TO_QINF(dqp)->qi_pinlock), s);
212}
213
214/*
215 * This is called when IOP_TRYLOCK returns XFS_ITEM_PUSHBUF to indicate that
216 * the dquot is locked by us, but the flush lock isn't. So, here we are
217 * going to see if the relevant dquot buffer is incore, waiting on DELWRI.
218 * If so, we want to push it out to help us take this item off the AIL as soon
219 * as possible.
220 *
221 * We must not be holding the AIL_LOCK at this point. Calling incore() to
222 * search the buffercache can be a time consuming thing, and AIL_LOCK is a
223 * spinlock.
224 */
225STATIC void
226xfs_qm_dquot_logitem_pushbuf(
227 xfs_dq_logitem_t *qip)
228{
229 xfs_dquot_t *dqp;
230 xfs_mount_t *mp;
231 xfs_buf_t *bp;
232 uint dopush;
233
234 dqp = qip->qli_dquot;
235 ASSERT(XFS_DQ_IS_LOCKED(dqp));
236
237 /*
238 * The qli_pushbuf_flag keeps others from
239 * trying to duplicate our effort.
240 */
241 ASSERT(qip->qli_pushbuf_flag != 0);
242 ASSERT(qip->qli_push_owner == get_thread_id());
243
244 /*
245 * If flushlock isn't locked anymore, chances are that the
246 * inode flush completed and the inode was taken off the AIL.
247 * So, just get out.
248 */
249 if ((valusema(&(dqp->q_flock)) > 0) ||
250 ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) {
251 qip->qli_pushbuf_flag = 0;
252 xfs_dqunlock(dqp);
253 return;
254 }
255 mp = dqp->q_mount;
256 bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno,
257 XFS_QI_DQCHUNKLEN(mp),
258 XFS_INCORE_TRYLOCK);
259 if (bp != NULL) {
260 if (XFS_BUF_ISDELAYWRITE(bp)) {
261 dopush = ((qip->qli_item.li_flags & XFS_LI_IN_AIL) &&
262 (valusema(&(dqp->q_flock)) <= 0));
263 qip->qli_pushbuf_flag = 0;
264 xfs_dqunlock(dqp);
265
266 if (XFS_BUF_ISPINNED(bp)) {
267 xfs_log_force(mp, (xfs_lsn_t)0,
268 XFS_LOG_FORCE);
269 }
270 if (dopush) {
271#ifdef XFSRACEDEBUG
272 delay_for_intr();
273 delay(300);
274#endif
275 xfs_bawrite(mp, bp);
276 } else {
277 xfs_buf_relse(bp);
278 }
279 } else {
280 qip->qli_pushbuf_flag = 0;
281 xfs_dqunlock(dqp);
282 xfs_buf_relse(bp);
283 }
284 return;
285 }
286
287 qip->qli_pushbuf_flag = 0;
288 xfs_dqunlock(dqp);
289}
290
291/*
292 * This is called to attempt to lock the dquot associated with this
293 * dquot log item. Don't sleep on the dquot lock or the flush lock.
294 * If the flush lock is already held, indicating that the dquot has
295 * been or is in the process of being flushed, then see if we can
296 * find the dquot's buffer in the buffer cache without sleeping. If
297 * we can and it is marked delayed write, then we want to send it out.
298 * We delay doing so until the push routine, though, to avoid sleeping
299 * in any device strategy routines.
300 */
301STATIC uint
302xfs_qm_dquot_logitem_trylock(
303 xfs_dq_logitem_t *qip)
304{
305 xfs_dquot_t *dqp;
306 uint retval;
307
308 dqp = qip->qli_dquot;
309 if (dqp->q_pincount > 0)
310 return (XFS_ITEM_PINNED);
311
312 if (! xfs_qm_dqlock_nowait(dqp))
313 return (XFS_ITEM_LOCKED);
314
315 retval = XFS_ITEM_SUCCESS;
316 if (! xfs_qm_dqflock_nowait(dqp)) {
317 /*
318 * The dquot is already being flushed. It may have been
319 * flushed delayed write, however, and we don't want to
320 * get stuck waiting for that to complete. So, we want to check
321 * to see if we can lock the dquot's buffer without sleeping.
322 * If we can and it is marked for delayed write, then we
323 * hold it and send it out from the push routine. We don't
324 * want to do that now since we might sleep in the device
325 * strategy routine. We also don't want to grab the buffer lock
326 * here because we'd like not to call into the buffer cache
327 * while holding the AIL_LOCK.
328 * Make sure to only return PUSHBUF if we set pushbuf_flag
329 * ourselves. If someone else is doing it then we don't
330 * want to go to the push routine and duplicate their efforts.
331 */
332 if (qip->qli_pushbuf_flag == 0) {
333 qip->qli_pushbuf_flag = 1;
334 ASSERT(qip->qli_format.qlf_blkno == dqp->q_blkno);
335#ifdef DEBUG
336 qip->qli_push_owner = get_thread_id();
337#endif
338 /*
339 * The dquot is left locked.
340 */
341 retval = XFS_ITEM_PUSHBUF;
342 } else {
343 retval = XFS_ITEM_FLUSHING;
344 xfs_dqunlock_nonotify(dqp);
345 }
346 }
347
348 ASSERT(qip->qli_item.li_flags & XFS_LI_IN_AIL);
349 return (retval);
350}
351
352
353/*
354 * Unlock the dquot associated with the log item.
355 * Clear the fields of the dquot and dquot log item that
356 * are specific to the current transaction. If the
357 * hold flags is set, do not unlock the dquot.
358 */
359STATIC void
360xfs_qm_dquot_logitem_unlock(
361 xfs_dq_logitem_t *ql)
362{
363 xfs_dquot_t *dqp;
364
365 ASSERT(ql != NULL);
366 dqp = ql->qli_dquot;
367 ASSERT(XFS_DQ_IS_LOCKED(dqp));
368
369 /*
370 * Clear the transaction pointer in the dquot
371 */
372 dqp->q_transp = NULL;
373
374 /*
375 * dquots are never 'held' from getting unlocked at the end of
376 * a transaction. Their locking and unlocking is hidden inside the
377 * transaction layer, within trans_commit. Hence, no LI_HOLD flag
378 * for the logitem.
379 */
380 xfs_dqunlock(dqp);
381}
382
383
384/*
385 * The transaction with the dquot locked has aborted. The dquot
386 * must not be dirty within the transaction. We simply unlock just
387 * as if the transaction had been cancelled.
388 */
389STATIC void
390xfs_qm_dquot_logitem_abort(
391 xfs_dq_logitem_t *ql)
392{
393 xfs_qm_dquot_logitem_unlock(ql);
394}
395
396/*
397 * this needs to stamp an lsn into the dquot, I think.
398 * rpc's that look at user dquot's would then have to
399 * push on the dependency recorded in the dquot
400 */
401/* ARGSUSED */
402STATIC void
403xfs_qm_dquot_logitem_committing(
404 xfs_dq_logitem_t *l,
405 xfs_lsn_t lsn)
406{
407 return;
408}
409
410
411/*
412 * This is the ops vector for dquots
413 */
ba0f32d4 414STATIC struct xfs_item_ops xfs_dquot_item_ops = {
1da177e4
LT
415 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size,
416 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
417 xfs_qm_dquot_logitem_format,
418 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_pin,
419 .iop_unpin = (void(*)(xfs_log_item_t*, int))
420 xfs_qm_dquot_logitem_unpin,
421 .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
422 xfs_qm_dquot_logitem_unpin_remove,
423 .iop_trylock = (uint(*)(xfs_log_item_t*))
424 xfs_qm_dquot_logitem_trylock,
425 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unlock,
426 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
427 xfs_qm_dquot_logitem_committed,
428 .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push,
429 .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_abort,
430 .iop_pushbuf = (void(*)(xfs_log_item_t*))
431 xfs_qm_dquot_logitem_pushbuf,
432 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
433 xfs_qm_dquot_logitem_committing
434};
435
436/*
437 * Initialize the dquot log item for a newly allocated dquot.
438 * The dquot isn't locked at this point, but it isn't on any of the lists
439 * either, so we don't care.
440 */
441void
442xfs_qm_dquot_logitem_init(
443 struct xfs_dquot *dqp)
444{
445 xfs_dq_logitem_t *lp;
446 lp = &dqp->q_logitem;
447
448 lp->qli_item.li_type = XFS_LI_DQUOT;
449 lp->qli_item.li_ops = &xfs_dquot_item_ops;
450 lp->qli_item.li_mountp = dqp->q_mount;
451 lp->qli_dquot = dqp;
452 lp->qli_format.qlf_type = XFS_LI_DQUOT;
453 lp->qli_format.qlf_id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT);
454 lp->qli_format.qlf_blkno = dqp->q_blkno;
455 lp->qli_format.qlf_len = 1;
456 /*
457 * This is just the offset of this dquot within its buffer
458 * (which is currently 1 FSB and probably won't change).
459 * Hence 32 bits for this offset should be just fine.
460 * Alternatively, we can store (bufoffset / sizeof(xfs_dqblk_t))
461 * here, and recompute it at recovery time.
462 */
463 lp->qli_format.qlf_boffset = (__uint32_t)dqp->q_bufoffset;
464}
465
466/*------------------ QUOTAOFF LOG ITEMS -------------------*/
467
468/*
469 * This returns the number of iovecs needed to log the given quotaoff item.
470 * We only need 1 iovec for an quotaoff item. It just logs the
471 * quotaoff_log_format structure.
472 */
473/*ARGSUSED*/
474STATIC uint
475xfs_qm_qoff_logitem_size(xfs_qoff_logitem_t *qf)
476{
477 return (1);
478}
479
480/*
481 * This is called to fill in the vector of log iovecs for the
482 * given quotaoff log item. We use only 1 iovec, and we point that
483 * at the quotaoff_log_format structure embedded in the quotaoff item.
484 * It is at this point that we assert that all of the extent
485 * slots in the quotaoff item have been filled.
486 */
487STATIC void
488xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf,
489 xfs_log_iovec_t *log_vector)
490{
491 ASSERT(qf->qql_format.qf_type == XFS_LI_QUOTAOFF);
492
493 log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format);
494 log_vector->i_len = sizeof(xfs_qoff_logitem_t);
7e9c6396 495 XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_QUOTAOFF);
1da177e4
LT
496 qf->qql_format.qf_size = 1;
497}
498
499
500/*
501 * Pinning has no meaning for an quotaoff item, so just return.
502 */
503/*ARGSUSED*/
504STATIC void
505xfs_qm_qoff_logitem_pin(xfs_qoff_logitem_t *qf)
506{
507 return;
508}
509
510
511/*
512 * Since pinning has no meaning for an quotaoff item, unpinning does
513 * not either.
514 */
515/*ARGSUSED*/
516STATIC void
517xfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf, int stale)
518{
519 return;
520}
521
522/*ARGSUSED*/
523STATIC void
524xfs_qm_qoff_logitem_unpin_remove(xfs_qoff_logitem_t *qf, xfs_trans_t *tp)
525{
526 return;
527}
528
529/*
530 * Quotaoff items have no locking, so just return success.
531 */
532/*ARGSUSED*/
533STATIC uint
534xfs_qm_qoff_logitem_trylock(xfs_qoff_logitem_t *qf)
535{
536 return XFS_ITEM_LOCKED;
537}
538
539/*
540 * Quotaoff items have no locking or pushing, so return failure
541 * so that the caller doesn't bother with us.
542 */
543/*ARGSUSED*/
544STATIC void
545xfs_qm_qoff_logitem_unlock(xfs_qoff_logitem_t *qf)
546{
547 return;
548}
549
550/*
551 * The quotaoff-start-item is logged only once and cannot be moved in the log,
552 * so simply return the lsn at which it's been logged.
553 */
554/*ARGSUSED*/
555STATIC xfs_lsn_t
556xfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn)
557{
558 return (lsn);
559}
560
561/*
562 * The transaction of which this QUOTAOFF is a part has been aborted.
563 * Just clean up after ourselves.
564 * Shouldn't this never happen in the case of qoffend logitems? XXX
565 */
566STATIC void
567xfs_qm_qoff_logitem_abort(xfs_qoff_logitem_t *qf)
568{
569 kmem_free(qf, sizeof(xfs_qoff_logitem_t));
570}
571
572/*
573 * There isn't much you can do to push on an quotaoff item. It is simply
574 * stuck waiting for the log to be flushed to disk.
575 */
576/*ARGSUSED*/
577STATIC void
578xfs_qm_qoff_logitem_push(xfs_qoff_logitem_t *qf)
579{
580 return;
581}
582
583
584/*ARGSUSED*/
585STATIC xfs_lsn_t
586xfs_qm_qoffend_logitem_committed(
587 xfs_qoff_logitem_t *qfe,
588 xfs_lsn_t lsn)
589{
590 xfs_qoff_logitem_t *qfs;
591 SPLDECL(s);
592
593 qfs = qfe->qql_start_lip;
594 AIL_LOCK(qfs->qql_item.li_mountp,s);
595 /*
596 * Delete the qoff-start logitem from the AIL.
597 * xfs_trans_delete_ail() drops the AIL lock.
598 */
599 xfs_trans_delete_ail(qfs->qql_item.li_mountp, (xfs_log_item_t *)qfs, s);
600 kmem_free(qfs, sizeof(xfs_qoff_logitem_t));
601 kmem_free(qfe, sizeof(xfs_qoff_logitem_t));
602 return (xfs_lsn_t)-1;
603}
604
605/*
606 * XXX rcc - don't know quite what to do with this. I think we can
607 * just ignore it. The only time that isn't the case is if we allow
608 * the client to somehow see that quotas have been turned off in which
609 * we can't allow that to get back until the quotaoff hits the disk.
610 * So how would that happen? Also, do we need different routines for
611 * quotaoff start and quotaoff end? I suspect the answer is yes but
612 * to be sure, I need to look at the recovery code and see how quota off
613 * recovery is handled (do we roll forward or back or do something else).
614 * If we roll forwards or backwards, then we need two separate routines,
615 * one that does nothing and one that stamps in the lsn that matters
616 * (truly makes the quotaoff irrevocable). If we do something else,
617 * then maybe we don't need two.
618 */
619/* ARGSUSED */
620STATIC void
621xfs_qm_qoff_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
622{
623 return;
624}
625
626/* ARGSUSED */
627STATIC void
628xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
629{
630 return;
631}
632
ba0f32d4 633STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
1da177e4
LT
634 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
635 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
636 xfs_qm_qoff_logitem_format,
637 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin,
638 .iop_unpin = (void(*)(xfs_log_item_t* ,int))
639 xfs_qm_qoff_logitem_unpin,
640 .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*))
641 xfs_qm_qoff_logitem_unpin_remove,
642 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock,
643 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock,
644 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
645 xfs_qm_qoffend_logitem_committed,
646 .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
647 .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort,
648 .iop_pushbuf = NULL,
649 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
650 xfs_qm_qoffend_logitem_committing
651};
652
653/*
654 * This is the ops vector shared by all quotaoff-start log items.
655 */
ba0f32d4 656STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
1da177e4
LT
657 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
658 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
659 xfs_qm_qoff_logitem_format,
660 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin,
661 .iop_unpin = (void(*)(xfs_log_item_t*, int))
662 xfs_qm_qoff_logitem_unpin,
663 .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*))
664 xfs_qm_qoff_logitem_unpin_remove,
665 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock,
666 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock,
667 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
668 xfs_qm_qoff_logitem_committed,
669 .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
670 .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort,
671 .iop_pushbuf = NULL,
672 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
673 xfs_qm_qoff_logitem_committing
674};
675
676/*
677 * Allocate and initialize an quotaoff item of the correct quota type(s).
678 */
679xfs_qoff_logitem_t *
680xfs_qm_qoff_logitem_init(
681 struct xfs_mount *mp,
682 xfs_qoff_logitem_t *start,
683 uint flags)
684{
685 xfs_qoff_logitem_t *qf;
686
687 qf = (xfs_qoff_logitem_t*) kmem_zalloc(sizeof(xfs_qoff_logitem_t), KM_SLEEP);
688
689 qf->qql_item.li_type = XFS_LI_QUOTAOFF;
690 if (start)
691 qf->qql_item.li_ops = &xfs_qm_qoffend_logitem_ops;
692 else
693 qf->qql_item.li_ops = &xfs_qm_qoff_logitem_ops;
694 qf->qql_item.li_mountp = mp;
695 qf->qql_format.qf_type = XFS_LI_QUOTAOFF;
696 qf->qql_format.qf_flags = flags;
697 qf->qql_start_lip = start;
698 return (qf);
699}