]>
Commit | Line | Data |
---|---|---|
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" | |
1da177e4 | 26 | #include "xfs_alloc.h" |
1da177e4 LT |
27 | #include "xfs_quota.h" |
28 | #include "xfs_mount.h" | |
1da177e4 | 29 | #include "xfs_bmap_btree.h" |
1da177e4 LT |
30 | #include "xfs_inode.h" |
31 | #include "xfs_bmap.h" | |
1da177e4 LT |
32 | #include "xfs_rtalloc.h" |
33 | #include "xfs_error.h" | |
34 | #include "xfs_itable.h" | |
1da177e4 LT |
35 | #include "xfs_attr.h" |
36 | #include "xfs_buf_item.h" | |
37 | #include "xfs_trans_priv.h" | |
1da177e4 LT |
38 | #include "xfs_qm.h" |
39 | ||
1da177e4 LT |
40 | /* |
41 | * returns the number of iovecs needed to log the given dquot item. | |
42 | */ | |
43 | /* ARGSUSED */ | |
44 | STATIC uint | |
45 | xfs_qm_dquot_logitem_size( | |
46 | xfs_dq_logitem_t *logitem) | |
47 | { | |
48 | /* | |
49 | * we need only two iovecs, one for the format, one for the real thing | |
50 | */ | |
51 | return (2); | |
52 | } | |
53 | ||
54 | /* | |
55 | * fills in the vector of log iovecs for the given dquot log item. | |
56 | */ | |
57 | STATIC void | |
58 | xfs_qm_dquot_logitem_format( | |
59 | xfs_dq_logitem_t *logitem, | |
60 | xfs_log_iovec_t *logvec) | |
61 | { | |
62 | ASSERT(logitem); | |
63 | ASSERT(logitem->qli_dquot); | |
64 | ||
65 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_format; | |
66 | logvec->i_len = sizeof(xfs_dq_logformat_t); | |
4139b3b3 | 67 | logvec->i_type = XLOG_REG_TYPE_QFORMAT; |
1da177e4 LT |
68 | logvec++; |
69 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core; | |
70 | logvec->i_len = sizeof(xfs_disk_dquot_t); | |
4139b3b3 | 71 | logvec->i_type = XLOG_REG_TYPE_DQUOT; |
1da177e4 LT |
72 | |
73 | ASSERT(2 == logitem->qli_item.li_desc->lid_size); | |
74 | logitem->qli_format.qlf_size = 2; | |
75 | ||
76 | } | |
77 | ||
78 | /* | |
79 | * Increment the pin count of the given dquot. | |
1da177e4 LT |
80 | */ |
81 | STATIC void | |
82 | xfs_qm_dquot_logitem_pin( | |
83 | xfs_dq_logitem_t *logitem) | |
84 | { | |
bc3048e3 | 85 | xfs_dquot_t *dqp = logitem->qli_dquot; |
1da177e4 | 86 | |
1da177e4 | 87 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
d1de8021 | 88 | atomic_inc(&dqp->q_pincount); |
1da177e4 LT |
89 | } |
90 | ||
91 | /* | |
92 | * Decrement the pin count of the given dquot, and wake up | |
93 | * anyone in xfs_dqwait_unpin() if the count goes to 0. The | |
bc3048e3 PL |
94 | * dquot must have been previously pinned with a call to |
95 | * xfs_qm_dquot_logitem_pin(). | |
1da177e4 LT |
96 | */ |
97 | /* ARGSUSED */ | |
98 | STATIC void | |
99 | xfs_qm_dquot_logitem_unpin( | |
8e123850 | 100 | xfs_dq_logitem_t *logitem) |
1da177e4 | 101 | { |
bc3048e3 | 102 | xfs_dquot_t *dqp = logitem->qli_dquot; |
1da177e4 | 103 | |
bc3048e3 PL |
104 | ASSERT(atomic_read(&dqp->q_pincount) > 0); |
105 | if (atomic_dec_and_test(&dqp->q_pincount)) | |
106 | wake_up(&dqp->q_pinwait); | |
1da177e4 LT |
107 | } |
108 | ||
109 | /* ARGSUSED */ | |
110 | STATIC void | |
111 | xfs_qm_dquot_logitem_unpin_remove( | |
112 | xfs_dq_logitem_t *logitem, | |
113 | xfs_trans_t *tp) | |
114 | { | |
8e123850 | 115 | xfs_qm_dquot_logitem_unpin(logitem); |
1da177e4 LT |
116 | } |
117 | ||
118 | /* | |
119 | * Given the logitem, this writes the corresponding dquot entry to disk | |
120 | * asynchronously. This is called with the dquot entry securely locked; | |
121 | * we simply get xfs_qm_dqflush() to do the work, and unlock the dquot | |
122 | * at the end. | |
123 | */ | |
124 | STATIC void | |
125 | xfs_qm_dquot_logitem_push( | |
126 | xfs_dq_logitem_t *logitem) | |
127 | { | |
128 | xfs_dquot_t *dqp; | |
3c56836f | 129 | int error; |
1da177e4 LT |
130 | |
131 | dqp = logitem->qli_dquot; | |
132 | ||
133 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | |
e1f49cf2 | 134 | ASSERT(!completion_done(&dqp->q_flush)); |
1da177e4 LT |
135 | |
136 | /* | |
137 | * Since we were able to lock the dquot's flush lock and | |
138 | * we found it on the AIL, the dquot must be dirty. This | |
139 | * is because the dquot is removed from the AIL while still | |
140 | * holding the flush lock in xfs_dqflush_done(). Thus, if | |
141 | * we found it in the AIL and were able to obtain the flush | |
142 | * lock without sleeping, then there must not have been | |
143 | * anyone in the process of flushing the dquot. | |
144 | */ | |
20026d92 | 145 | error = xfs_qm_dqflush(dqp, 0); |
3c56836f DC |
146 | if (error) |
147 | xfs_fs_cmn_err(CE_WARN, dqp->q_mount, | |
148 | "xfs_qm_dquot_logitem_push: push error %d on dqp %p", | |
149 | error, dqp); | |
1da177e4 LT |
150 | xfs_dqunlock(dqp); |
151 | } | |
152 | ||
153 | /*ARGSUSED*/ | |
154 | STATIC xfs_lsn_t | |
155 | xfs_qm_dquot_logitem_committed( | |
156 | xfs_dq_logitem_t *l, | |
157 | xfs_lsn_t lsn) | |
158 | { | |
159 | /* | |
160 | * We always re-log the entire dquot when it becomes dirty, | |
161 | * so, the latest copy _is_ the only one that matters. | |
162 | */ | |
163 | return (lsn); | |
164 | } | |
165 | ||
166 | ||
167 | /* | |
168 | * This is called to wait for the given dquot to be unpinned. | |
169 | * Most of these pin/unpin routines are plagiarized from inode code. | |
170 | */ | |
171 | void | |
172 | xfs_qm_dqunpin_wait( | |
173 | xfs_dquot_t *dqp) | |
174 | { | |
1da177e4 | 175 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
bc3048e3 | 176 | if (atomic_read(&dqp->q_pincount) == 0) |
1da177e4 | 177 | return; |
1da177e4 LT |
178 | |
179 | /* | |
180 | * Give the log a push so we don't wait here too long. | |
181 | */ | |
a14a348b | 182 | xfs_log_force(dqp->q_mount, 0); |
bc3048e3 | 183 | wait_event(dqp->q_pinwait, (atomic_read(&dqp->q_pincount) == 0)); |
1da177e4 LT |
184 | } |
185 | ||
186 | /* | |
187 | * This is called when IOP_TRYLOCK returns XFS_ITEM_PUSHBUF to indicate that | |
188 | * the dquot is locked by us, but the flush lock isn't. So, here we are | |
189 | * going to see if the relevant dquot buffer is incore, waiting on DELWRI. | |
190 | * If so, we want to push it out to help us take this item off the AIL as soon | |
191 | * as possible. | |
192 | * | |
287f3dad DD |
193 | * We must not be holding the AIL lock at this point. Calling incore() to |
194 | * search the buffer cache can be a time consuming thing, and AIL lock is a | |
1da177e4 LT |
195 | * spinlock. |
196 | */ | |
197 | STATIC void | |
198 | xfs_qm_dquot_logitem_pushbuf( | |
199 | xfs_dq_logitem_t *qip) | |
200 | { | |
201 | xfs_dquot_t *dqp; | |
202 | xfs_mount_t *mp; | |
203 | xfs_buf_t *bp; | |
1da177e4 LT |
204 | |
205 | dqp = qip->qli_dquot; | |
206 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | |
207 | ||
1da177e4 LT |
208 | /* |
209 | * If flushlock isn't locked anymore, chances are that the | |
210 | * inode flush completed and the inode was taken off the AIL. | |
211 | * So, just get out. | |
212 | */ | |
e1f49cf2 | 213 | if (completion_done(&dqp->q_flush) || |
1da177e4 | 214 | ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) { |
1da177e4 LT |
215 | xfs_dqunlock(dqp); |
216 | return; | |
217 | } | |
218 | mp = dqp->q_mount; | |
219 | bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno, | |
8a7b8a89 | 220 | mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK); |
d808f617 DC |
221 | xfs_dqunlock(dqp); |
222 | if (!bp) | |
1da177e4 | 223 | return; |
d808f617 DC |
224 | if (XFS_BUF_ISDELAYWRITE(bp)) |
225 | xfs_buf_delwri_promote(bp); | |
226 | xfs_buf_relse(bp); | |
227 | return; | |
1da177e4 | 228 | |
1da177e4 LT |
229 | } |
230 | ||
231 | /* | |
232 | * This is called to attempt to lock the dquot associated with this | |
233 | * dquot log item. Don't sleep on the dquot lock or the flush lock. | |
234 | * If the flush lock is already held, indicating that the dquot has | |
235 | * been or is in the process of being flushed, then see if we can | |
236 | * find the dquot's buffer in the buffer cache without sleeping. If | |
237 | * we can and it is marked delayed write, then we want to send it out. | |
238 | * We delay doing so until the push routine, though, to avoid sleeping | |
239 | * in any device strategy routines. | |
240 | */ | |
241 | STATIC uint | |
242 | xfs_qm_dquot_logitem_trylock( | |
243 | xfs_dq_logitem_t *qip) | |
244 | { | |
245 | xfs_dquot_t *dqp; | |
1da177e4 LT |
246 | |
247 | dqp = qip->qli_dquot; | |
bc3048e3 | 248 | if (atomic_read(&dqp->q_pincount) > 0) |
d808f617 | 249 | return XFS_ITEM_PINNED; |
1da177e4 LT |
250 | |
251 | if (! xfs_qm_dqlock_nowait(dqp)) | |
d808f617 | 252 | return XFS_ITEM_LOCKED; |
1da177e4 | 253 | |
e1f49cf2 | 254 | if (!xfs_dqflock_nowait(dqp)) { |
1da177e4 | 255 | /* |
d808f617 DC |
256 | * dquot has already been flushed to the backing buffer, |
257 | * leave it locked, pushbuf routine will unlock it. | |
1da177e4 | 258 | */ |
d808f617 | 259 | return XFS_ITEM_PUSHBUF; |
1da177e4 LT |
260 | } |
261 | ||
262 | ASSERT(qip->qli_item.li_flags & XFS_LI_IN_AIL); | |
d808f617 | 263 | return XFS_ITEM_SUCCESS; |
1da177e4 LT |
264 | } |
265 | ||
266 | ||
267 | /* | |
268 | * Unlock the dquot associated with the log item. | |
269 | * Clear the fields of the dquot and dquot log item that | |
270 | * are specific to the current transaction. If the | |
271 | * hold flags is set, do not unlock the dquot. | |
272 | */ | |
273 | STATIC void | |
274 | xfs_qm_dquot_logitem_unlock( | |
275 | xfs_dq_logitem_t *ql) | |
276 | { | |
277 | xfs_dquot_t *dqp; | |
278 | ||
279 | ASSERT(ql != NULL); | |
280 | dqp = ql->qli_dquot; | |
281 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | |
282 | ||
283 | /* | |
284 | * Clear the transaction pointer in the dquot | |
285 | */ | |
286 | dqp->q_transp = NULL; | |
287 | ||
288 | /* | |
289 | * dquots are never 'held' from getting unlocked at the end of | |
290 | * a transaction. Their locking and unlocking is hidden inside the | |
291 | * transaction layer, within trans_commit. Hence, no LI_HOLD flag | |
292 | * for the logitem. | |
293 | */ | |
294 | xfs_dqunlock(dqp); | |
295 | } | |
296 | ||
297 | ||
1da177e4 LT |
298 | /* |
299 | * this needs to stamp an lsn into the dquot, I think. | |
300 | * rpc's that look at user dquot's would then have to | |
301 | * push on the dependency recorded in the dquot | |
302 | */ | |
303 | /* ARGSUSED */ | |
304 | STATIC void | |
305 | xfs_qm_dquot_logitem_committing( | |
306 | xfs_dq_logitem_t *l, | |
307 | xfs_lsn_t lsn) | |
308 | { | |
309 | return; | |
310 | } | |
311 | ||
312 | ||
313 | /* | |
314 | * This is the ops vector for dquots | |
315 | */ | |
7989cb8e | 316 | static struct xfs_item_ops xfs_dquot_item_ops = { |
1da177e4 LT |
317 | .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size, |
318 | .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) | |
319 | xfs_qm_dquot_logitem_format, | |
320 | .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_pin, | |
8e123850 | 321 | .iop_unpin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unpin, |
1da177e4 LT |
322 | .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*)) |
323 | xfs_qm_dquot_logitem_unpin_remove, | |
324 | .iop_trylock = (uint(*)(xfs_log_item_t*)) | |
325 | xfs_qm_dquot_logitem_trylock, | |
326 | .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unlock, | |
327 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | |
328 | xfs_qm_dquot_logitem_committed, | |
329 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push, | |
1da177e4 LT |
330 | .iop_pushbuf = (void(*)(xfs_log_item_t*)) |
331 | xfs_qm_dquot_logitem_pushbuf, | |
332 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | |
333 | xfs_qm_dquot_logitem_committing | |
334 | }; | |
335 | ||
336 | /* | |
337 | * Initialize the dquot log item for a newly allocated dquot. | |
338 | * The dquot isn't locked at this point, but it isn't on any of the lists | |
339 | * either, so we don't care. | |
340 | */ | |
341 | void | |
342 | xfs_qm_dquot_logitem_init( | |
343 | struct xfs_dquot *dqp) | |
344 | { | |
345 | xfs_dq_logitem_t *lp; | |
346 | lp = &dqp->q_logitem; | |
347 | ||
43f5efc5 DC |
348 | xfs_log_item_init(dqp->q_mount, &lp->qli_item, XFS_LI_DQUOT, |
349 | &xfs_dquot_item_ops); | |
1da177e4 LT |
350 | lp->qli_dquot = dqp; |
351 | lp->qli_format.qlf_type = XFS_LI_DQUOT; | |
1149d96a | 352 | lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id); |
1da177e4 LT |
353 | lp->qli_format.qlf_blkno = dqp->q_blkno; |
354 | lp->qli_format.qlf_len = 1; | |
355 | /* | |
356 | * This is just the offset of this dquot within its buffer | |
357 | * (which is currently 1 FSB and probably won't change). | |
358 | * Hence 32 bits for this offset should be just fine. | |
359 | * Alternatively, we can store (bufoffset / sizeof(xfs_dqblk_t)) | |
360 | * here, and recompute it at recovery time. | |
361 | */ | |
362 | lp->qli_format.qlf_boffset = (__uint32_t)dqp->q_bufoffset; | |
363 | } | |
364 | ||
365 | /*------------------ QUOTAOFF LOG ITEMS -------------------*/ | |
366 | ||
367 | /* | |
368 | * This returns the number of iovecs needed to log the given quotaoff item. | |
369 | * We only need 1 iovec for an quotaoff item. It just logs the | |
370 | * quotaoff_log_format structure. | |
371 | */ | |
372 | /*ARGSUSED*/ | |
373 | STATIC uint | |
374 | xfs_qm_qoff_logitem_size(xfs_qoff_logitem_t *qf) | |
375 | { | |
376 | return (1); | |
377 | } | |
378 | ||
379 | /* | |
380 | * This is called to fill in the vector of log iovecs for the | |
381 | * given quotaoff log item. We use only 1 iovec, and we point that | |
382 | * at the quotaoff_log_format structure embedded in the quotaoff item. | |
383 | * It is at this point that we assert that all of the extent | |
384 | * slots in the quotaoff item have been filled. | |
385 | */ | |
386 | STATIC void | |
387 | xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf, | |
388 | xfs_log_iovec_t *log_vector) | |
389 | { | |
390 | ASSERT(qf->qql_format.qf_type == XFS_LI_QUOTAOFF); | |
391 | ||
392 | log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format); | |
393 | log_vector->i_len = sizeof(xfs_qoff_logitem_t); | |
4139b3b3 | 394 | log_vector->i_type = XLOG_REG_TYPE_QUOTAOFF; |
1da177e4 LT |
395 | qf->qql_format.qf_size = 1; |
396 | } | |
397 | ||
398 | ||
399 | /* | |
400 | * Pinning has no meaning for an quotaoff item, so just return. | |
401 | */ | |
402 | /*ARGSUSED*/ | |
403 | STATIC void | |
404 | xfs_qm_qoff_logitem_pin(xfs_qoff_logitem_t *qf) | |
405 | { | |
406 | return; | |
407 | } | |
408 | ||
409 | ||
410 | /* | |
411 | * Since pinning has no meaning for an quotaoff item, unpinning does | |
412 | * not either. | |
413 | */ | |
414 | /*ARGSUSED*/ | |
415 | STATIC void | |
8e123850 | 416 | xfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf) |
1da177e4 LT |
417 | { |
418 | return; | |
419 | } | |
420 | ||
421 | /*ARGSUSED*/ | |
422 | STATIC void | |
423 | xfs_qm_qoff_logitem_unpin_remove(xfs_qoff_logitem_t *qf, xfs_trans_t *tp) | |
424 | { | |
425 | return; | |
426 | } | |
427 | ||
428 | /* | |
429 | * Quotaoff items have no locking, so just return success. | |
430 | */ | |
431 | /*ARGSUSED*/ | |
432 | STATIC uint | |
433 | xfs_qm_qoff_logitem_trylock(xfs_qoff_logitem_t *qf) | |
434 | { | |
435 | return XFS_ITEM_LOCKED; | |
436 | } | |
437 | ||
438 | /* | |
439 | * Quotaoff items have no locking or pushing, so return failure | |
440 | * so that the caller doesn't bother with us. | |
441 | */ | |
442 | /*ARGSUSED*/ | |
443 | STATIC void | |
444 | xfs_qm_qoff_logitem_unlock(xfs_qoff_logitem_t *qf) | |
445 | { | |
446 | return; | |
447 | } | |
448 | ||
449 | /* | |
450 | * The quotaoff-start-item is logged only once and cannot be moved in the log, | |
451 | * so simply return the lsn at which it's been logged. | |
452 | */ | |
453 | /*ARGSUSED*/ | |
454 | STATIC xfs_lsn_t | |
455 | xfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn) | |
456 | { | |
457 | return (lsn); | |
458 | } | |
459 | ||
1da177e4 LT |
460 | /* |
461 | * There isn't much you can do to push on an quotaoff item. It is simply | |
462 | * stuck waiting for the log to be flushed to disk. | |
463 | */ | |
464 | /*ARGSUSED*/ | |
465 | STATIC void | |
466 | xfs_qm_qoff_logitem_push(xfs_qoff_logitem_t *qf) | |
467 | { | |
468 | return; | |
469 | } | |
470 | ||
471 | ||
472 | /*ARGSUSED*/ | |
473 | STATIC xfs_lsn_t | |
474 | xfs_qm_qoffend_logitem_committed( | |
475 | xfs_qoff_logitem_t *qfe, | |
476 | xfs_lsn_t lsn) | |
477 | { | |
478 | xfs_qoff_logitem_t *qfs; | |
783a2f65 | 479 | struct xfs_ail *ailp; |
1da177e4 LT |
480 | |
481 | qfs = qfe->qql_start_lip; | |
783a2f65 DC |
482 | ailp = qfs->qql_item.li_ailp; |
483 | spin_lock(&ailp->xa_lock); | |
1da177e4 LT |
484 | /* |
485 | * Delete the qoff-start logitem from the AIL. | |
783a2f65 | 486 | * xfs_trans_ail_delete() drops the AIL lock. |
1da177e4 | 487 | */ |
783a2f65 | 488 | xfs_trans_ail_delete(ailp, (xfs_log_item_t *)qfs); |
f0e2d93c DV |
489 | kmem_free(qfs); |
490 | kmem_free(qfe); | |
1da177e4 LT |
491 | return (xfs_lsn_t)-1; |
492 | } | |
493 | ||
494 | /* | |
495 | * XXX rcc - don't know quite what to do with this. I think we can | |
496 | * just ignore it. The only time that isn't the case is if we allow | |
497 | * the client to somehow see that quotas have been turned off in which | |
498 | * we can't allow that to get back until the quotaoff hits the disk. | |
499 | * So how would that happen? Also, do we need different routines for | |
500 | * quotaoff start and quotaoff end? I suspect the answer is yes but | |
501 | * to be sure, I need to look at the recovery code and see how quota off | |
502 | * recovery is handled (do we roll forward or back or do something else). | |
503 | * If we roll forwards or backwards, then we need two separate routines, | |
504 | * one that does nothing and one that stamps in the lsn that matters | |
505 | * (truly makes the quotaoff irrevocable). If we do something else, | |
506 | * then maybe we don't need two. | |
507 | */ | |
508 | /* ARGSUSED */ | |
509 | STATIC void | |
510 | xfs_qm_qoff_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn) | |
511 | { | |
512 | return; | |
513 | } | |
514 | ||
515 | /* ARGSUSED */ | |
516 | STATIC void | |
517 | xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn) | |
518 | { | |
519 | return; | |
520 | } | |
521 | ||
7989cb8e | 522 | static struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { |
1da177e4 LT |
523 | .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, |
524 | .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) | |
525 | xfs_qm_qoff_logitem_format, | |
526 | .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin, | |
8e123850 | 527 | .iop_unpin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unpin, |
1da177e4 LT |
528 | .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*)) |
529 | xfs_qm_qoff_logitem_unpin_remove, | |
530 | .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock, | |
531 | .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock, | |
532 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | |
533 | xfs_qm_qoffend_logitem_committed, | |
534 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, | |
1da177e4 LT |
535 | .iop_pushbuf = NULL, |
536 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | |
537 | xfs_qm_qoffend_logitem_committing | |
538 | }; | |
539 | ||
540 | /* | |
541 | * This is the ops vector shared by all quotaoff-start log items. | |
542 | */ | |
7989cb8e | 543 | static struct xfs_item_ops xfs_qm_qoff_logitem_ops = { |
1da177e4 LT |
544 | .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, |
545 | .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) | |
546 | xfs_qm_qoff_logitem_format, | |
547 | .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin, | |
8e123850 | 548 | .iop_unpin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unpin, |
1da177e4 LT |
549 | .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*)) |
550 | xfs_qm_qoff_logitem_unpin_remove, | |
551 | .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock, | |
552 | .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock, | |
553 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | |
554 | xfs_qm_qoff_logitem_committed, | |
555 | .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, | |
1da177e4 LT |
556 | .iop_pushbuf = NULL, |
557 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | |
558 | xfs_qm_qoff_logitem_committing | |
559 | }; | |
560 | ||
561 | /* | |
562 | * Allocate and initialize an quotaoff item of the correct quota type(s). | |
563 | */ | |
564 | xfs_qoff_logitem_t * | |
565 | xfs_qm_qoff_logitem_init( | |
566 | struct xfs_mount *mp, | |
567 | xfs_qoff_logitem_t *start, | |
568 | uint flags) | |
569 | { | |
570 | xfs_qoff_logitem_t *qf; | |
571 | ||
572 | qf = (xfs_qoff_logitem_t*) kmem_zalloc(sizeof(xfs_qoff_logitem_t), KM_SLEEP); | |
573 | ||
43f5efc5 DC |
574 | xfs_log_item_init(mp, &qf->qql_item, XFS_LI_QUOTAOFF, start ? |
575 | &xfs_qm_qoffend_logitem_ops : &xfs_qm_qoff_logitem_ops); | |
1da177e4 LT |
576 | qf->qql_item.li_mountp = mp; |
577 | qf->qql_format.qf_type = XFS_LI_QUOTAOFF; | |
578 | qf->qql_format.qf_flags = flags; | |
579 | qf->qql_start_lip = start; | |
580 | return (qf); | |
581 | } |