Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[linux-2.6] / fs / xfs / quota / xfs_dquot_item.c
1 /*
2  * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
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.
8  *
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.
13  *
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
17  */
18 #include "xfs.h"
19 #include "xfs_fs.h"
20 #include "xfs_bit.h"
21 #include "xfs_log.h"
22 #include "xfs_inum.h"
23 #include "xfs_trans.h"
24 #include "xfs_sb.h"
25 #include "xfs_ag.h"
26 #include "xfs_dir2.h"
27 #include "xfs_alloc.h"
28 #include "xfs_dmapi.h"
29 #include "xfs_quota.h"
30 #include "xfs_mount.h"
31 #include "xfs_bmap_btree.h"
32 #include "xfs_alloc_btree.h"
33 #include "xfs_ialloc_btree.h"
34 #include "xfs_dir2_sf.h"
35 #include "xfs_attr_sf.h"
36 #include "xfs_dinode.h"
37 #include "xfs_inode.h"
38 #include "xfs_bmap.h"
39 #include "xfs_btree.h"
40 #include "xfs_ialloc.h"
41 #include "xfs_rtalloc.h"
42 #include "xfs_error.h"
43 #include "xfs_itable.h"
44 #include "xfs_rw.h"
45 #include "xfs_acl.h"
46 #include "xfs_cap.h"
47 #include "xfs_mac.h"
48 #include "xfs_attr.h"
49 #include "xfs_buf_item.h"
50 #include "xfs_trans_priv.h"
51 #include "xfs_qm.h"
52
53 /*
54  * returns the number of iovecs needed to log the given dquot item.
55  */
56 /* ARGSUSED */
57 STATIC uint
58 xfs_qm_dquot_logitem_size(
59         xfs_dq_logitem_t        *logitem)
60 {
61         /*
62          * we need only two iovecs, one for the format, one for the real thing
63          */
64         return (2);
65 }
66
67 /*
68  * fills in the vector of log iovecs for the given dquot log item.
69  */
70 STATIC void
71 xfs_qm_dquot_logitem_format(
72         xfs_dq_logitem_t        *logitem,
73         xfs_log_iovec_t         *logvec)
74 {
75         ASSERT(logitem);
76         ASSERT(logitem->qli_dquot);
77
78         logvec->i_addr = (xfs_caddr_t)&logitem->qli_format;
79         logvec->i_len  = sizeof(xfs_dq_logformat_t);
80         XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_QFORMAT);
81         logvec++;
82         logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core;
83         logvec->i_len  = sizeof(xfs_disk_dquot_t);
84         XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_DQUOT);
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  */
95 STATIC void
96 xfs_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 */
115 STATIC void
116 xfs_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 */
134 STATIC void
135 xfs_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  */
148 STATIC void
149 xfs_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*/
173 STATIC xfs_lsn_t
174 xfs_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  */
190 void
191 xfs_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 buffer cache can be a time consuming thing, and AIL_LOCK is a
223  * spinlock.
224  */
225 STATIC void
226 xfs_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 == current_pid());
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 (!issemalocked(&(dqp->q_flock))  ||
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                                   issemalocked(&(dqp->q_flock)));
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  */
301 STATIC uint
302 xfs_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 = current_pid();
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  */
359 STATIC void
360 xfs_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  * this needs to stamp an lsn into the dquot, I think.
386  * rpc's that look at user dquot's would then have to
387  * push on the dependency recorded in the dquot
388  */
389 /* ARGSUSED */
390 STATIC void
391 xfs_qm_dquot_logitem_committing(
392         xfs_dq_logitem_t        *l,
393         xfs_lsn_t               lsn)
394 {
395         return;
396 }
397
398
399 /*
400  * This is the ops vector for dquots
401  */
402 STATIC struct xfs_item_ops xfs_dquot_item_ops = {
403         .iop_size       = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size,
404         .iop_format     = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
405                                         xfs_qm_dquot_logitem_format,
406         .iop_pin        = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_pin,
407         .iop_unpin      = (void(*)(xfs_log_item_t*, int))
408                                         xfs_qm_dquot_logitem_unpin,
409         .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
410                                         xfs_qm_dquot_logitem_unpin_remove,
411         .iop_trylock    = (uint(*)(xfs_log_item_t*))
412                                         xfs_qm_dquot_logitem_trylock,
413         .iop_unlock     = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unlock,
414         .iop_committed  = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
415                                         xfs_qm_dquot_logitem_committed,
416         .iop_push       = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push,
417         .iop_pushbuf    = (void(*)(xfs_log_item_t*))
418                                         xfs_qm_dquot_logitem_pushbuf,
419         .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
420                                         xfs_qm_dquot_logitem_committing
421 };
422
423 /*
424  * Initialize the dquot log item for a newly allocated dquot.
425  * The dquot isn't locked at this point, but it isn't on any of the lists
426  * either, so we don't care.
427  */
428 void
429 xfs_qm_dquot_logitem_init(
430         struct xfs_dquot *dqp)
431 {
432         xfs_dq_logitem_t  *lp;
433         lp = &dqp->q_logitem;
434
435         lp->qli_item.li_type = XFS_LI_DQUOT;
436         lp->qli_item.li_ops = &xfs_dquot_item_ops;
437         lp->qli_item.li_mountp = dqp->q_mount;
438         lp->qli_dquot = dqp;
439         lp->qli_format.qlf_type = XFS_LI_DQUOT;
440         lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id);
441         lp->qli_format.qlf_blkno = dqp->q_blkno;
442         lp->qli_format.qlf_len = 1;
443         /*
444          * This is just the offset of this dquot within its buffer
445          * (which is currently 1 FSB and probably won't change).
446          * Hence 32 bits for this offset should be just fine.
447          * Alternatively, we can store (bufoffset / sizeof(xfs_dqblk_t))
448          * here, and recompute it at recovery time.
449          */
450         lp->qli_format.qlf_boffset = (__uint32_t)dqp->q_bufoffset;
451 }
452
453 /*------------------  QUOTAOFF LOG ITEMS  -------------------*/
454
455 /*
456  * This returns the number of iovecs needed to log the given quotaoff item.
457  * We only need 1 iovec for an quotaoff item.  It just logs the
458  * quotaoff_log_format structure.
459  */
460 /*ARGSUSED*/
461 STATIC uint
462 xfs_qm_qoff_logitem_size(xfs_qoff_logitem_t *qf)
463 {
464         return (1);
465 }
466
467 /*
468  * This is called to fill in the vector of log iovecs for the
469  * given quotaoff log item. We use only 1 iovec, and we point that
470  * at the quotaoff_log_format structure embedded in the quotaoff item.
471  * It is at this point that we assert that all of the extent
472  * slots in the quotaoff item have been filled.
473  */
474 STATIC void
475 xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t   *qf,
476                            xfs_log_iovec_t      *log_vector)
477 {
478         ASSERT(qf->qql_format.qf_type == XFS_LI_QUOTAOFF);
479
480         log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format);
481         log_vector->i_len = sizeof(xfs_qoff_logitem_t);
482         XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_QUOTAOFF);
483         qf->qql_format.qf_size = 1;
484 }
485
486
487 /*
488  * Pinning has no meaning for an quotaoff item, so just return.
489  */
490 /*ARGSUSED*/
491 STATIC void
492 xfs_qm_qoff_logitem_pin(xfs_qoff_logitem_t *qf)
493 {
494         return;
495 }
496
497
498 /*
499  * Since pinning has no meaning for an quotaoff item, unpinning does
500  * not either.
501  */
502 /*ARGSUSED*/
503 STATIC void
504 xfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf, int stale)
505 {
506         return;
507 }
508
509 /*ARGSUSED*/
510 STATIC void
511 xfs_qm_qoff_logitem_unpin_remove(xfs_qoff_logitem_t *qf, xfs_trans_t *tp)
512 {
513         return;
514 }
515
516 /*
517  * Quotaoff items have no locking, so just return success.
518  */
519 /*ARGSUSED*/
520 STATIC uint
521 xfs_qm_qoff_logitem_trylock(xfs_qoff_logitem_t *qf)
522 {
523         return XFS_ITEM_LOCKED;
524 }
525
526 /*
527  * Quotaoff items have no locking or pushing, so return failure
528  * so that the caller doesn't bother with us.
529  */
530 /*ARGSUSED*/
531 STATIC void
532 xfs_qm_qoff_logitem_unlock(xfs_qoff_logitem_t *qf)
533 {
534         return;
535 }
536
537 /*
538  * The quotaoff-start-item is logged only once and cannot be moved in the log,
539  * so simply return the lsn at which it's been logged.
540  */
541 /*ARGSUSED*/
542 STATIC xfs_lsn_t
543 xfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn)
544 {
545         return (lsn);
546 }
547
548 /*
549  * There isn't much you can do to push on an quotaoff item.  It is simply
550  * stuck waiting for the log to be flushed to disk.
551  */
552 /*ARGSUSED*/
553 STATIC void
554 xfs_qm_qoff_logitem_push(xfs_qoff_logitem_t *qf)
555 {
556         return;
557 }
558
559
560 /*ARGSUSED*/
561 STATIC xfs_lsn_t
562 xfs_qm_qoffend_logitem_committed(
563         xfs_qoff_logitem_t *qfe,
564         xfs_lsn_t lsn)
565 {
566         xfs_qoff_logitem_t      *qfs;
567         SPLDECL(s);
568
569         qfs = qfe->qql_start_lip;
570         AIL_LOCK(qfs->qql_item.li_mountp,s);
571         /*
572          * Delete the qoff-start logitem from the AIL.
573          * xfs_trans_delete_ail() drops the AIL lock.
574          */
575         xfs_trans_delete_ail(qfs->qql_item.li_mountp, (xfs_log_item_t *)qfs, s);
576         kmem_free(qfs, sizeof(xfs_qoff_logitem_t));
577         kmem_free(qfe, sizeof(xfs_qoff_logitem_t));
578         return (xfs_lsn_t)-1;
579 }
580
581 /*
582  * XXX rcc - don't know quite what to do with this.  I think we can
583  * just ignore it.  The only time that isn't the case is if we allow
584  * the client to somehow see that quotas have been turned off in which
585  * we can't allow that to get back until the quotaoff hits the disk.
586  * So how would that happen?  Also, do we need different routines for
587  * quotaoff start and quotaoff end?  I suspect the answer is yes but
588  * to be sure, I need to look at the recovery code and see how quota off
589  * recovery is handled (do we roll forward or back or do something else).
590  * If we roll forwards or backwards, then we need two separate routines,
591  * one that does nothing and one that stamps in the lsn that matters
592  * (truly makes the quotaoff irrevocable).  If we do something else,
593  * then maybe we don't need two.
594  */
595 /* ARGSUSED */
596 STATIC void
597 xfs_qm_qoff_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
598 {
599         return;
600 }
601
602 /* ARGSUSED */
603 STATIC void
604 xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
605 {
606         return;
607 }
608
609 STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
610         .iop_size       = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
611         .iop_format     = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
612                                         xfs_qm_qoff_logitem_format,
613         .iop_pin        = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin,
614         .iop_unpin      = (void(*)(xfs_log_item_t* ,int))
615                                         xfs_qm_qoff_logitem_unpin,
616         .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*))
617                                         xfs_qm_qoff_logitem_unpin_remove,
618         .iop_trylock    = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock,
619         .iop_unlock     = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock,
620         .iop_committed  = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
621                                         xfs_qm_qoffend_logitem_committed,
622         .iop_push       = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
623         .iop_pushbuf    = NULL,
624         .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
625                                         xfs_qm_qoffend_logitem_committing
626 };
627
628 /*
629  * This is the ops vector shared by all quotaoff-start log items.
630  */
631 STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
632         .iop_size       = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
633         .iop_format     = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
634                                         xfs_qm_qoff_logitem_format,
635         .iop_pin        = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin,
636         .iop_unpin      = (void(*)(xfs_log_item_t*, int))
637                                         xfs_qm_qoff_logitem_unpin,
638         .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*))
639                                         xfs_qm_qoff_logitem_unpin_remove,
640         .iop_trylock    = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock,
641         .iop_unlock     = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock,
642         .iop_committed  = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t))
643                                         xfs_qm_qoff_logitem_committed,
644         .iop_push       = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
645         .iop_pushbuf    = NULL,
646         .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
647                                         xfs_qm_qoff_logitem_committing
648 };
649
650 /*
651  * Allocate and initialize an quotaoff item of the correct quota type(s).
652  */
653 xfs_qoff_logitem_t *
654 xfs_qm_qoff_logitem_init(
655         struct xfs_mount *mp,
656         xfs_qoff_logitem_t *start,
657         uint flags)
658 {
659         xfs_qoff_logitem_t      *qf;
660
661         qf = (xfs_qoff_logitem_t*) kmem_zalloc(sizeof(xfs_qoff_logitem_t), KM_SLEEP);
662
663         qf->qql_item.li_type = XFS_LI_QUOTAOFF;
664         if (start)
665                 qf->qql_item.li_ops = &xfs_qm_qoffend_logitem_ops;
666         else
667                 qf->qql_item.li_ops = &xfs_qm_qoff_logitem_ops;
668         qf->qql_item.li_mountp = mp;
669         qf->qql_format.qf_type = XFS_LI_QUOTAOFF;
670         qf->qql_format.qf_flags = flags;
671         qf->qql_start_lip = start;
672         return (qf);
673 }