aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c268
-rw-r--r--fs/xfs/xfs_buf_item.c129
-rw-r--r--fs/xfs/xfs_extfree_item.c226
-rw-r--r--fs/xfs/xfs_inode_item.c141
4 files changed, 360 insertions, 404 deletions
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index fa2b6744937e..cd86bc317d59 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -37,18 +37,22 @@
37#include "xfs_trans_priv.h" 37#include "xfs_trans_priv.h"
38#include "xfs_qm.h" 38#include "xfs_qm.h"
39 39
40static inline struct xfs_dq_logitem *DQUOT_ITEM(struct xfs_log_item *lip)
41{
42 return container_of(lip, struct xfs_dq_logitem, qli_item);
43}
44
40/* 45/*
41 * returns the number of iovecs needed to log the given dquot item. 46 * returns the number of iovecs needed to log the given dquot item.
42 */ 47 */
43/* ARGSUSED */
44STATIC uint 48STATIC uint
45xfs_qm_dquot_logitem_size( 49xfs_qm_dquot_logitem_size(
46 xfs_dq_logitem_t *logitem) 50 struct xfs_log_item *lip)
47{ 51{
48 /* 52 /*
49 * we need only two iovecs, one for the format, one for the real thing 53 * we need only two iovecs, one for the format, one for the real thing
50 */ 54 */
51 return (2); 55 return 2;
52} 56}
53 57
54/* 58/*
@@ -56,22 +60,21 @@ xfs_qm_dquot_logitem_size(
56 */ 60 */
57STATIC void 61STATIC void
58xfs_qm_dquot_logitem_format( 62xfs_qm_dquot_logitem_format(
59 xfs_dq_logitem_t *logitem, 63 struct xfs_log_item *lip,
60 xfs_log_iovec_t *logvec) 64 struct xfs_log_iovec *logvec)
61{ 65{
62 ASSERT(logitem); 66 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);
63 ASSERT(logitem->qli_dquot);
64 67
65 logvec->i_addr = (xfs_caddr_t)&logitem->qli_format; 68 logvec->i_addr = (xfs_caddr_t)&qlip->qli_format;
66 logvec->i_len = sizeof(xfs_dq_logformat_t); 69 logvec->i_len = sizeof(xfs_dq_logformat_t);
67 logvec->i_type = XLOG_REG_TYPE_QFORMAT; 70 logvec->i_type = XLOG_REG_TYPE_QFORMAT;
68 logvec++; 71 logvec++;
69 logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core; 72 logvec->i_addr = (xfs_caddr_t)&qlip->qli_dquot->q_core;
70 logvec->i_len = sizeof(xfs_disk_dquot_t); 73 logvec->i_len = sizeof(xfs_disk_dquot_t);
71 logvec->i_type = XLOG_REG_TYPE_DQUOT; 74 logvec->i_type = XLOG_REG_TYPE_DQUOT;
72 75
73 ASSERT(2 == logitem->qli_item.li_desc->lid_size); 76 ASSERT(2 == lip->li_desc->lid_size);
74 logitem->qli_format.qlf_size = 2; 77 qlip->qli_format.qlf_size = 2;
75 78
76} 79}
77 80
@@ -80,9 +83,9 @@ xfs_qm_dquot_logitem_format(
80 */ 83 */
81STATIC void 84STATIC void
82xfs_qm_dquot_logitem_pin( 85xfs_qm_dquot_logitem_pin(
83 xfs_dq_logitem_t *logitem) 86 struct xfs_log_item *lip)
84{ 87{
85 xfs_dquot_t *dqp = logitem->qli_dquot; 88 struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot;
86 89
87 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 90 ASSERT(XFS_DQ_IS_LOCKED(dqp));
88 atomic_inc(&dqp->q_pincount); 91 atomic_inc(&dqp->q_pincount);
@@ -94,13 +97,12 @@ xfs_qm_dquot_logitem_pin(
94 * dquot must have been previously pinned with a call to 97 * dquot must have been previously pinned with a call to
95 * xfs_qm_dquot_logitem_pin(). 98 * xfs_qm_dquot_logitem_pin().
96 */ 99 */
97/* ARGSUSED */
98STATIC void 100STATIC void
99xfs_qm_dquot_logitem_unpin( 101xfs_qm_dquot_logitem_unpin(
100 xfs_dq_logitem_t *logitem, 102 struct xfs_log_item *lip,
101 int remove) 103 int remove)
102{ 104{
103 xfs_dquot_t *dqp = logitem->qli_dquot; 105 struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot;
104 106
105 ASSERT(atomic_read(&dqp->q_pincount) > 0); 107 ASSERT(atomic_read(&dqp->q_pincount) > 0);
106 if (atomic_dec_and_test(&dqp->q_pincount)) 108 if (atomic_dec_and_test(&dqp->q_pincount))
@@ -115,12 +117,10 @@ xfs_qm_dquot_logitem_unpin(
115 */ 117 */
116STATIC void 118STATIC void
117xfs_qm_dquot_logitem_push( 119xfs_qm_dquot_logitem_push(
118 xfs_dq_logitem_t *logitem) 120 struct xfs_log_item *lip)
119{ 121{
120 xfs_dquot_t *dqp; 122 struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot;
121 int error; 123 int error;
122
123 dqp = logitem->qli_dquot;
124 124
125 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 125 ASSERT(XFS_DQ_IS_LOCKED(dqp));
126 ASSERT(!completion_done(&dqp->q_flush)); 126 ASSERT(!completion_done(&dqp->q_flush));
@@ -142,27 +142,25 @@ xfs_qm_dquot_logitem_push(
142 xfs_dqunlock(dqp); 142 xfs_dqunlock(dqp);
143} 143}
144 144
145/*ARGSUSED*/
146STATIC xfs_lsn_t 145STATIC xfs_lsn_t
147xfs_qm_dquot_logitem_committed( 146xfs_qm_dquot_logitem_committed(
148 xfs_dq_logitem_t *l, 147 struct xfs_log_item *lip,
149 xfs_lsn_t lsn) 148 xfs_lsn_t lsn)
150{ 149{
151 /* 150 /*
152 * We always re-log the entire dquot when it becomes dirty, 151 * We always re-log the entire dquot when it becomes dirty,
153 * so, the latest copy _is_ the only one that matters. 152 * so, the latest copy _is_ the only one that matters.
154 */ 153 */
155 return (lsn); 154 return lsn;
156} 155}
157 156
158
159/* 157/*
160 * This is called to wait for the given dquot to be unpinned. 158 * This is called to wait for the given dquot to be unpinned.
161 * Most of these pin/unpin routines are plagiarized from inode code. 159 * Most of these pin/unpin routines are plagiarized from inode code.
162 */ 160 */
163void 161void
164xfs_qm_dqunpin_wait( 162xfs_qm_dqunpin_wait(
165 xfs_dquot_t *dqp) 163 struct xfs_dquot *dqp)
166{ 164{
167 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 165 ASSERT(XFS_DQ_IS_LOCKED(dqp));
168 if (atomic_read(&dqp->q_pincount) == 0) 166 if (atomic_read(&dqp->q_pincount) == 0)
@@ -188,13 +186,12 @@ xfs_qm_dqunpin_wait(
188 */ 186 */
189STATIC void 187STATIC void
190xfs_qm_dquot_logitem_pushbuf( 188xfs_qm_dquot_logitem_pushbuf(
191 xfs_dq_logitem_t *qip) 189 struct xfs_log_item *lip)
192{ 190{
193 xfs_dquot_t *dqp; 191 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);
194 xfs_mount_t *mp; 192 struct xfs_dquot *dqp = qlip->qli_dquot;
195 xfs_buf_t *bp; 193 struct xfs_buf *bp;
196 194
197 dqp = qip->qli_dquot;
198 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 195 ASSERT(XFS_DQ_IS_LOCKED(dqp));
199 196
200 /* 197 /*
@@ -202,22 +199,20 @@ xfs_qm_dquot_logitem_pushbuf(
202 * inode flush completed and the inode was taken off the AIL. 199 * inode flush completed and the inode was taken off the AIL.
203 * So, just get out. 200 * So, just get out.
204 */ 201 */
205 if (completion_done(&dqp->q_flush) || 202 if (completion_done(&dqp->q_flush) ||
206 ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) { 203 !(lip->li_flags & XFS_LI_IN_AIL)) {
207 xfs_dqunlock(dqp); 204 xfs_dqunlock(dqp);
208 return; 205 return;
209 } 206 }
210 mp = dqp->q_mount; 207
211 bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno, 208 bp = xfs_incore(dqp->q_mount->m_ddev_targp, qlip->qli_format.qlf_blkno,
212 mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK); 209 dqp->q_mount->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK);
213 xfs_dqunlock(dqp); 210 xfs_dqunlock(dqp);
214 if (!bp) 211 if (!bp)
215 return; 212 return;
216 if (XFS_BUF_ISDELAYWRITE(bp)) 213 if (XFS_BUF_ISDELAYWRITE(bp))
217 xfs_buf_delwri_promote(bp); 214 xfs_buf_delwri_promote(bp);
218 xfs_buf_relse(bp); 215 xfs_buf_relse(bp);
219 return;
220
221} 216}
222 217
223/* 218/*
@@ -232,15 +227,14 @@ xfs_qm_dquot_logitem_pushbuf(
232 */ 227 */
233STATIC uint 228STATIC uint
234xfs_qm_dquot_logitem_trylock( 229xfs_qm_dquot_logitem_trylock(
235 xfs_dq_logitem_t *qip) 230 struct xfs_log_item *lip)
236{ 231{
237 xfs_dquot_t *dqp; 232 struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot;
238 233
239 dqp = qip->qli_dquot;
240 if (atomic_read(&dqp->q_pincount) > 0) 234 if (atomic_read(&dqp->q_pincount) > 0)
241 return XFS_ITEM_PINNED; 235 return XFS_ITEM_PINNED;
242 236
243 if (! xfs_qm_dqlock_nowait(dqp)) 237 if (!xfs_qm_dqlock_nowait(dqp))
244 return XFS_ITEM_LOCKED; 238 return XFS_ITEM_LOCKED;
245 239
246 if (!xfs_dqflock_nowait(dqp)) { 240 if (!xfs_dqflock_nowait(dqp)) {
@@ -251,11 +245,10 @@ xfs_qm_dquot_logitem_trylock(
251 return XFS_ITEM_PUSHBUF; 245 return XFS_ITEM_PUSHBUF;
252 } 246 }
253 247
254 ASSERT(qip->qli_item.li_flags & XFS_LI_IN_AIL); 248 ASSERT(lip->li_flags & XFS_LI_IN_AIL);
255 return XFS_ITEM_SUCCESS; 249 return XFS_ITEM_SUCCESS;
256} 250}
257 251
258
259/* 252/*
260 * Unlock the dquot associated with the log item. 253 * Unlock the dquot associated with the log item.
261 * Clear the fields of the dquot and dquot log item that 254 * Clear the fields of the dquot and dquot log item that
@@ -264,12 +257,10 @@ xfs_qm_dquot_logitem_trylock(
264 */ 257 */
265STATIC void 258STATIC void
266xfs_qm_dquot_logitem_unlock( 259xfs_qm_dquot_logitem_unlock(
267 xfs_dq_logitem_t *ql) 260 struct xfs_log_item *lip)
268{ 261{
269 xfs_dquot_t *dqp; 262 struct xfs_dquot *dqp = DQUOT_ITEM(lip)->qli_dquot;
270 263
271 ASSERT(ql != NULL);
272 dqp = ql->qli_dquot;
273 ASSERT(XFS_DQ_IS_LOCKED(dqp)); 264 ASSERT(XFS_DQ_IS_LOCKED(dqp));
274 265
275 /* 266 /*
@@ -286,41 +277,32 @@ xfs_qm_dquot_logitem_unlock(
286 xfs_dqunlock(dqp); 277 xfs_dqunlock(dqp);
287} 278}
288 279
289
290/* 280/*
291 * this needs to stamp an lsn into the dquot, I think. 281 * this needs to stamp an lsn into the dquot, I think.
292 * rpc's that look at user dquot's would then have to 282 * rpc's that look at user dquot's would then have to
293 * push on the dependency recorded in the dquot 283 * push on the dependency recorded in the dquot
294 */ 284 */
295/* ARGSUSED */
296STATIC void 285STATIC void
297xfs_qm_dquot_logitem_committing( 286xfs_qm_dquot_logitem_committing(
298 xfs_dq_logitem_t *l, 287 struct xfs_log_item *lip,
299 xfs_lsn_t lsn) 288 xfs_lsn_t lsn)
300{ 289{
301 return;
302} 290}
303 291
304
305/* 292/*
306 * This is the ops vector for dquots 293 * This is the ops vector for dquots
307 */ 294 */
308static struct xfs_item_ops xfs_dquot_item_ops = { 295static struct xfs_item_ops xfs_dquot_item_ops = {
309 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size, 296 .iop_size = xfs_qm_dquot_logitem_size,
310 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 297 .iop_format = xfs_qm_dquot_logitem_format,
311 xfs_qm_dquot_logitem_format, 298 .iop_pin = xfs_qm_dquot_logitem_pin,
312 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_pin, 299 .iop_unpin = xfs_qm_dquot_logitem_unpin,
313 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_qm_dquot_logitem_unpin, 300 .iop_trylock = xfs_qm_dquot_logitem_trylock,
314 .iop_trylock = (uint(*)(xfs_log_item_t*)) 301 .iop_unlock = xfs_qm_dquot_logitem_unlock,
315 xfs_qm_dquot_logitem_trylock, 302 .iop_committed = xfs_qm_dquot_logitem_committed,
316 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unlock, 303 .iop_push = xfs_qm_dquot_logitem_push,
317 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 304 .iop_pushbuf = xfs_qm_dquot_logitem_pushbuf,
318 xfs_qm_dquot_logitem_committed, 305 .iop_committing = xfs_qm_dquot_logitem_committing
319 .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push,
320 .iop_pushbuf = (void(*)(xfs_log_item_t*))
321 xfs_qm_dquot_logitem_pushbuf,
322 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
323 xfs_qm_dquot_logitem_committing
324}; 306};
325 307
326/* 308/*
@@ -330,10 +312,9 @@ static struct xfs_item_ops xfs_dquot_item_ops = {
330 */ 312 */
331void 313void
332xfs_qm_dquot_logitem_init( 314xfs_qm_dquot_logitem_init(
333 struct xfs_dquot *dqp) 315 struct xfs_dquot *dqp)
334{ 316{
335 xfs_dq_logitem_t *lp; 317 struct xfs_dq_logitem *lp = &dqp->q_logitem;
336 lp = &dqp->q_logitem;
337 318
338 xfs_log_item_init(dqp->q_mount, &lp->qli_item, XFS_LI_DQUOT, 319 xfs_log_item_init(dqp->q_mount, &lp->qli_item, XFS_LI_DQUOT,
339 &xfs_dquot_item_ops); 320 &xfs_dquot_item_ops);
@@ -354,16 +335,22 @@ xfs_qm_dquot_logitem_init(
354 335
355/*------------------ QUOTAOFF LOG ITEMS -------------------*/ 336/*------------------ QUOTAOFF LOG ITEMS -------------------*/
356 337
338static inline struct xfs_qoff_logitem *QOFF_ITEM(struct xfs_log_item *lip)
339{
340 return container_of(lip, struct xfs_qoff_logitem, qql_item);
341}
342
343
357/* 344/*
358 * This returns the number of iovecs needed to log the given quotaoff item. 345 * This returns the number of iovecs needed to log the given quotaoff item.
359 * We only need 1 iovec for an quotaoff item. It just logs the 346 * We only need 1 iovec for an quotaoff item. It just logs the
360 * quotaoff_log_format structure. 347 * quotaoff_log_format structure.
361 */ 348 */
362/*ARGSUSED*/
363STATIC uint 349STATIC uint
364xfs_qm_qoff_logitem_size(xfs_qoff_logitem_t *qf) 350xfs_qm_qoff_logitem_size(
351 struct xfs_log_item *lip)
365{ 352{
366 return (1); 353 return 1;
367} 354}
368 355
369/* 356/*
@@ -374,46 +361,46 @@ xfs_qm_qoff_logitem_size(xfs_qoff_logitem_t *qf)
374 * slots in the quotaoff item have been filled. 361 * slots in the quotaoff item have been filled.
375 */ 362 */
376STATIC void 363STATIC void
377xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf, 364xfs_qm_qoff_logitem_format(
378 xfs_log_iovec_t *log_vector) 365 struct xfs_log_item *lip,
366 struct xfs_log_iovec *log_vector)
379{ 367{
380 ASSERT(qf->qql_format.qf_type == XFS_LI_QUOTAOFF); 368 struct xfs_qoff_logitem *qflip = QOFF_ITEM(lip);
381 369
382 log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format); 370 ASSERT(qflip->qql_format.qf_type == XFS_LI_QUOTAOFF);
371
372 log_vector->i_addr = (xfs_caddr_t)&(qflip->qql_format);
383 log_vector->i_len = sizeof(xfs_qoff_logitem_t); 373 log_vector->i_len = sizeof(xfs_qoff_logitem_t);
384 log_vector->i_type = XLOG_REG_TYPE_QUOTAOFF; 374 log_vector->i_type = XLOG_REG_TYPE_QUOTAOFF;
385 qf->qql_format.qf_size = 1; 375 qflip->qql_format.qf_size = 1;
386} 376}
387 377
388
389/* 378/*
390 * Pinning has no meaning for an quotaoff item, so just return. 379 * Pinning has no meaning for an quotaoff item, so just return.
391 */ 380 */
392/*ARGSUSED*/
393STATIC void 381STATIC void
394xfs_qm_qoff_logitem_pin(xfs_qoff_logitem_t *qf) 382xfs_qm_qoff_logitem_pin(
383 struct xfs_log_item *lip)
395{ 384{
396 return;
397} 385}
398 386
399
400/* 387/*
401 * Since pinning has no meaning for an quotaoff item, unpinning does 388 * Since pinning has no meaning for an quotaoff item, unpinning does
402 * not either. 389 * not either.
403 */ 390 */
404/*ARGSUSED*/
405STATIC void 391STATIC void
406xfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf, int remove) 392xfs_qm_qoff_logitem_unpin(
393 struct xfs_log_item *lip,
394 int remove)
407{ 395{
408 return;
409} 396}
410 397
411/* 398/*
412 * Quotaoff items have no locking, so just return success. 399 * Quotaoff items have no locking, so just return success.
413 */ 400 */
414/*ARGSUSED*/
415STATIC uint 401STATIC uint
416xfs_qm_qoff_logitem_trylock(xfs_qoff_logitem_t *qf) 402xfs_qm_qoff_logitem_trylock(
403 struct xfs_log_item *lip)
417{ 404{
418 return XFS_ITEM_LOCKED; 405 return XFS_ITEM_LOCKED;
419} 406}
@@ -422,53 +409,51 @@ xfs_qm_qoff_logitem_trylock(xfs_qoff_logitem_t *qf)
422 * Quotaoff items have no locking or pushing, so return failure 409 * Quotaoff items have no locking or pushing, so return failure
423 * so that the caller doesn't bother with us. 410 * so that the caller doesn't bother with us.
424 */ 411 */
425/*ARGSUSED*/
426STATIC void 412STATIC void
427xfs_qm_qoff_logitem_unlock(xfs_qoff_logitem_t *qf) 413xfs_qm_qoff_logitem_unlock(
414 struct xfs_log_item *lip)
428{ 415{
429 return;
430} 416}
431 417
432/* 418/*
433 * The quotaoff-start-item is logged only once and cannot be moved in the log, 419 * The quotaoff-start-item is logged only once and cannot be moved in the log,
434 * so simply return the lsn at which it's been logged. 420 * so simply return the lsn at which it's been logged.
435 */ 421 */
436/*ARGSUSED*/
437STATIC xfs_lsn_t 422STATIC xfs_lsn_t
438xfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn) 423xfs_qm_qoff_logitem_committed(
424 struct xfs_log_item *lip,
425 xfs_lsn_t lsn)
439{ 426{
440 return (lsn); 427 return lsn;
441} 428}
442 429
443/* 430/*
444 * There isn't much you can do to push on an quotaoff item. It is simply 431 * There isn't much you can do to push on an quotaoff item. It is simply
445 * stuck waiting for the log to be flushed to disk. 432 * stuck waiting for the log to be flushed to disk.
446 */ 433 */
447/*ARGSUSED*/
448STATIC void 434STATIC void
449xfs_qm_qoff_logitem_push(xfs_qoff_logitem_t *qf) 435xfs_qm_qoff_logitem_push(
436 struct xfs_log_item *lip)
450{ 437{
451 return;
452} 438}
453 439
454 440
455/*ARGSUSED*/
456STATIC xfs_lsn_t 441STATIC xfs_lsn_t
457xfs_qm_qoffend_logitem_committed( 442xfs_qm_qoffend_logitem_committed(
458 xfs_qoff_logitem_t *qfe, 443 struct xfs_log_item *lip,
459 xfs_lsn_t lsn) 444 xfs_lsn_t lsn)
460{ 445{
461 xfs_qoff_logitem_t *qfs; 446 struct xfs_qoff_logitem *qfe = QOFF_ITEM(lip);
462 struct xfs_ail *ailp; 447 struct xfs_qoff_logitem *qfs = qfe->qql_start_lip;
448 struct xfs_ail *ailp = qfs->qql_item.li_ailp;
463 449
464 qfs = qfe->qql_start_lip;
465 ailp = qfs->qql_item.li_ailp;
466 spin_lock(&ailp->xa_lock);
467 /* 450 /*
468 * Delete the qoff-start logitem from the AIL. 451 * Delete the qoff-start logitem from the AIL.
469 * xfs_trans_ail_delete() drops the AIL lock. 452 * xfs_trans_ail_delete() drops the AIL lock.
470 */ 453 */
454 spin_lock(&ailp->xa_lock);
471 xfs_trans_ail_delete(ailp, (xfs_log_item_t *)qfs); 455 xfs_trans_ail_delete(ailp, (xfs_log_item_t *)qfs);
456
472 kmem_free(qfs); 457 kmem_free(qfs);
473 kmem_free(qfe); 458 kmem_free(qfe);
474 return (xfs_lsn_t)-1; 459 return (xfs_lsn_t)-1;
@@ -488,67 +473,52 @@ xfs_qm_qoffend_logitem_committed(
488 * (truly makes the quotaoff irrevocable). If we do something else, 473 * (truly makes the quotaoff irrevocable). If we do something else,
489 * then maybe we don't need two. 474 * then maybe we don't need two.
490 */ 475 */
491/* ARGSUSED */
492STATIC void
493xfs_qm_qoff_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
494{
495 return;
496}
497
498/* ARGSUSED */
499STATIC void 476STATIC void
500xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn) 477xfs_qm_qoff_logitem_committing(
478 struct xfs_log_item *lip,
479 xfs_lsn_t commit_lsn)
501{ 480{
502 return;
503} 481}
504 482
505static struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { 483static struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
506 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, 484 .iop_size = xfs_qm_qoff_logitem_size,
507 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 485 .iop_format = xfs_qm_qoff_logitem_format,
508 xfs_qm_qoff_logitem_format, 486 .iop_pin = xfs_qm_qoff_logitem_pin,
509 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin, 487 .iop_unpin = xfs_qm_qoff_logitem_unpin,
510 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_qm_qoff_logitem_unpin, 488 .iop_trylock = xfs_qm_qoff_logitem_trylock,
511 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock, 489 .iop_unlock = xfs_qm_qoff_logitem_unlock,
512 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock, 490 .iop_committed = xfs_qm_qoffend_logitem_committed,
513 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 491 .iop_push = xfs_qm_qoff_logitem_push,
514 xfs_qm_qoffend_logitem_committed, 492 .iop_committing = xfs_qm_qoff_logitem_committing
515 .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
516 .iop_pushbuf = NULL,
517 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
518 xfs_qm_qoffend_logitem_committing
519}; 493};
520 494
521/* 495/*
522 * This is the ops vector shared by all quotaoff-start log items. 496 * This is the ops vector shared by all quotaoff-start log items.
523 */ 497 */
524static struct xfs_item_ops xfs_qm_qoff_logitem_ops = { 498static struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
525 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, 499 .iop_size = xfs_qm_qoff_logitem_size,
526 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 500 .iop_format = xfs_qm_qoff_logitem_format,
527 xfs_qm_qoff_logitem_format, 501 .iop_pin = xfs_qm_qoff_logitem_pin,
528 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin, 502 .iop_unpin = xfs_qm_qoff_logitem_unpin,
529 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_qm_qoff_logitem_unpin, 503 .iop_trylock = xfs_qm_qoff_logitem_trylock,
530 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock, 504 .iop_unlock = xfs_qm_qoff_logitem_unlock,
531 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock, 505 .iop_committed = xfs_qm_qoff_logitem_committed,
532 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 506 .iop_push = xfs_qm_qoff_logitem_push,
533 xfs_qm_qoff_logitem_committed, 507 .iop_committing = xfs_qm_qoff_logitem_committing
534 .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push,
535 .iop_pushbuf = NULL,
536 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
537 xfs_qm_qoff_logitem_committing
538}; 508};
539 509
540/* 510/*
541 * Allocate and initialize an quotaoff item of the correct quota type(s). 511 * Allocate and initialize an quotaoff item of the correct quota type(s).
542 */ 512 */
543xfs_qoff_logitem_t * 513struct xfs_qoff_logitem *
544xfs_qm_qoff_logitem_init( 514xfs_qm_qoff_logitem_init(
545 struct xfs_mount *mp, 515 struct xfs_mount *mp,
546 xfs_qoff_logitem_t *start, 516 struct xfs_qoff_logitem *start,
547 uint flags) 517 uint flags)
548{ 518{
549 xfs_qoff_logitem_t *qf; 519 struct xfs_qoff_logitem *qf;
550 520
551 qf = (xfs_qoff_logitem_t*) kmem_zalloc(sizeof(xfs_qoff_logitem_t), KM_SLEEP); 521 qf = kmem_zalloc(sizeof(struct xfs_qoff_logitem), KM_SLEEP);
552 522
553 xfs_log_item_init(mp, &qf->qql_item, XFS_LI_QUOTAOFF, start ? 523 xfs_log_item_init(mp, &qf->qql_item, XFS_LI_QUOTAOFF, start ?
554 &xfs_qm_qoffend_logitem_ops : &xfs_qm_qoff_logitem_ops); 524 &xfs_qm_qoffend_logitem_ops : &xfs_qm_qoff_logitem_ops);
@@ -556,5 +526,5 @@ xfs_qm_qoff_logitem_init(
556 qf->qql_format.qf_type = XFS_LI_QUOTAOFF; 526 qf->qql_format.qf_type = XFS_LI_QUOTAOFF;
557 qf->qql_format.qf_flags = flags; 527 qf->qql_format.qf_flags = flags;
558 qf->qql_start_lip = start; 528 qf->qql_start_lip = start;
559 return (qf); 529 return qf;
560} 530}
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 93899953c603..992d6be101cb 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -33,6 +33,12 @@
33 33
34kmem_zone_t *xfs_buf_item_zone; 34kmem_zone_t *xfs_buf_item_zone;
35 35
36static inline struct xfs_buf_log_item *BUF_ITEM(struct xfs_log_item *lip)
37{
38 return container_of(lip, struct xfs_buf_log_item, bli_item);
39}
40
41
36#ifdef XFS_TRANS_DEBUG 42#ifdef XFS_TRANS_DEBUG
37/* 43/*
38 * This function uses an alternate strategy for tracking the bytes 44 * This function uses an alternate strategy for tracking the bytes
@@ -150,12 +156,13 @@ STATIC void xfs_buf_do_callbacks(xfs_buf_t *bp, xfs_log_item_t *lip);
150 */ 156 */
151STATIC uint 157STATIC uint
152xfs_buf_item_size( 158xfs_buf_item_size(
153 xfs_buf_log_item_t *bip) 159 struct xfs_log_item *lip)
154{ 160{
155 uint nvecs; 161 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
156 int next_bit; 162 struct xfs_buf *bp = bip->bli_buf;
157 int last_bit; 163 uint nvecs;
158 xfs_buf_t *bp; 164 int next_bit;
165 int last_bit;
159 166
160 ASSERT(atomic_read(&bip->bli_refcount) > 0); 167 ASSERT(atomic_read(&bip->bli_refcount) > 0);
161 if (bip->bli_flags & XFS_BLI_STALE) { 168 if (bip->bli_flags & XFS_BLI_STALE) {
@@ -169,7 +176,6 @@ xfs_buf_item_size(
169 return 1; 176 return 1;
170 } 177 }
171 178
172 bp = bip->bli_buf;
173 ASSERT(bip->bli_flags & XFS_BLI_LOGGED); 179 ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
174 nvecs = 1; 180 nvecs = 1;
175 last_bit = xfs_next_bit(bip->bli_format.blf_data_map, 181 last_bit = xfs_next_bit(bip->bli_format.blf_data_map,
@@ -218,13 +224,13 @@ xfs_buf_item_size(
218 */ 224 */
219STATIC void 225STATIC void
220xfs_buf_item_format( 226xfs_buf_item_format(
221 xfs_buf_log_item_t *bip, 227 struct xfs_log_item *lip,
222 xfs_log_iovec_t *log_vector) 228 struct xfs_log_iovec *vecp)
223{ 229{
230 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
231 struct xfs_buf *bp = bip->bli_buf;
224 uint base_size; 232 uint base_size;
225 uint nvecs; 233 uint nvecs;
226 xfs_log_iovec_t *vecp;
227 xfs_buf_t *bp;
228 int first_bit; 234 int first_bit;
229 int last_bit; 235 int last_bit;
230 int next_bit; 236 int next_bit;
@@ -234,8 +240,6 @@ xfs_buf_item_format(
234 ASSERT(atomic_read(&bip->bli_refcount) > 0); 240 ASSERT(atomic_read(&bip->bli_refcount) > 0);
235 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || 241 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
236 (bip->bli_flags & XFS_BLI_STALE)); 242 (bip->bli_flags & XFS_BLI_STALE));
237 bp = bip->bli_buf;
238 vecp = log_vector;
239 243
240 /* 244 /*
241 * The size of the base structure is the size of the 245 * The size of the base structure is the size of the
@@ -262,7 +266,7 @@ xfs_buf_item_format(
262 */ 266 */
263 if (bip->bli_flags & XFS_BLI_INODE_BUF) { 267 if (bip->bli_flags & XFS_BLI_INODE_BUF) {
264 if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && 268 if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
265 xfs_log_item_in_current_chkpt(&bip->bli_item))) 269 xfs_log_item_in_current_chkpt(lip)))
266 bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF; 270 bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF;
267 bip->bli_flags &= ~XFS_BLI_INODE_BUF; 271 bip->bli_flags &= ~XFS_BLI_INODE_BUF;
268 } 272 }
@@ -365,21 +369,20 @@ xfs_buf_item_format(
365 369
366STATIC void 370STATIC void
367xfs_buf_item_pin( 371xfs_buf_item_pin(
368 xfs_buf_log_item_t *bip) 372 struct xfs_log_item *lip)
369{ 373{
370 xfs_buf_t *bp; 374 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
371 375
372 bp = bip->bli_buf; 376 ASSERT(XFS_BUF_ISBUSY(bip->bli_buf));
373 ASSERT(XFS_BUF_ISBUSY(bp));
374 ASSERT(atomic_read(&bip->bli_refcount) > 0); 377 ASSERT(atomic_read(&bip->bli_refcount) > 0);
375 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || 378 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
376 (bip->bli_flags & XFS_BLI_STALE)); 379 (bip->bli_flags & XFS_BLI_STALE));
380
377 atomic_inc(&bip->bli_refcount); 381 atomic_inc(&bip->bli_refcount);
378 trace_xfs_buf_item_pin(bip); 382 trace_xfs_buf_item_pin(bip);
379 xfs_bpin(bp); 383 xfs_bpin(bip->bli_buf);
380} 384}
381 385
382
383/* 386/*
384 * This is called to unpin the buffer associated with the buf log 387 * This is called to unpin the buffer associated with the buf log
385 * item which was previously pinned with a call to xfs_buf_item_pin(). 388 * item which was previously pinned with a call to xfs_buf_item_pin().
@@ -396,13 +399,14 @@ xfs_buf_item_pin(
396 */ 399 */
397STATIC void 400STATIC void
398xfs_buf_item_unpin( 401xfs_buf_item_unpin(
399 xfs_buf_log_item_t *bip, 402 struct xfs_log_item *lip,
400 int remove) 403 int remove)
401{ 404{
402 struct xfs_ail *ailp; 405 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
403 xfs_buf_t *bp = bip->bli_buf; 406 xfs_buf_t *bp = bip->bli_buf;
404 int freed; 407 struct xfs_ail *ailp = lip->li_ailp;
405 int stale = bip->bli_flags & XFS_BLI_STALE; 408 int stale = bip->bli_flags & XFS_BLI_STALE;
409 int freed;
406 410
407 ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip); 411 ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip);
408 ASSERT(atomic_read(&bip->bli_refcount) > 0); 412 ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -410,8 +414,8 @@ xfs_buf_item_unpin(
410 trace_xfs_buf_item_unpin(bip); 414 trace_xfs_buf_item_unpin(bip);
411 415
412 freed = atomic_dec_and_test(&bip->bli_refcount); 416 freed = atomic_dec_and_test(&bip->bli_refcount);
413 ailp = bip->bli_item.li_ailp;
414 xfs_bunpin(bp); 417 xfs_bunpin(bp);
418
415 if (freed && stale) { 419 if (freed && stale) {
416 ASSERT(bip->bli_flags & XFS_BLI_STALE); 420 ASSERT(bip->bli_flags & XFS_BLI_STALE);
417 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); 421 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
@@ -429,7 +433,7 @@ xfs_buf_item_unpin(
429 * in xfs_trans_uncommit() will ry to reference the 433 * in xfs_trans_uncommit() will ry to reference the
430 * buffer which we no longer have a hold on. 434 * buffer which we no longer have a hold on.
431 */ 435 */
432 xfs_trans_del_item(&bip->bli_item); 436 xfs_trans_del_item(lip);
433 437
434 /* 438 /*
435 * Since the transaction no longer refers to the buffer, 439 * Since the transaction no longer refers to the buffer,
@@ -468,11 +472,11 @@ xfs_buf_item_unpin(
468 */ 472 */
469STATIC uint 473STATIC uint
470xfs_buf_item_trylock( 474xfs_buf_item_trylock(
471 xfs_buf_log_item_t *bip) 475 struct xfs_log_item *lip)
472{ 476{
473 xfs_buf_t *bp; 477 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
478 struct xfs_buf *bp = bip->bli_buf;
474 479
475 bp = bip->bli_buf;
476 if (XFS_BUF_ISPINNED(bp)) 480 if (XFS_BUF_ISPINNED(bp))
477 return XFS_ITEM_PINNED; 481 return XFS_ITEM_PINNED;
478 if (!XFS_BUF_CPSEMA(bp)) 482 if (!XFS_BUF_CPSEMA(bp))
@@ -509,13 +513,12 @@ xfs_buf_item_trylock(
509 */ 513 */
510STATIC void 514STATIC void
511xfs_buf_item_unlock( 515xfs_buf_item_unlock(
512 xfs_buf_log_item_t *bip) 516 struct xfs_log_item *lip)
513{ 517{
514 int aborted; 518 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
515 xfs_buf_t *bp; 519 struct xfs_buf *bp = bip->bli_buf;
516 uint hold; 520 int aborted;
517 521 uint hold;
518 bp = bip->bli_buf;
519 522
520 /* Clear the buffer's association with this transaction. */ 523 /* Clear the buffer's association with this transaction. */
521 XFS_BUF_SET_FSPRIVATE2(bp, NULL); 524 XFS_BUF_SET_FSPRIVATE2(bp, NULL);
@@ -526,7 +529,7 @@ xfs_buf_item_unlock(
526 * (cancelled) buffers at unpin time, but we'll never go through the 529 * (cancelled) buffers at unpin time, but we'll never go through the
527 * pin/unpin cycle if we abort inside commit. 530 * pin/unpin cycle if we abort inside commit.
528 */ 531 */
529 aborted = (bip->bli_item.li_flags & XFS_LI_ABORTED) != 0; 532 aborted = (lip->li_flags & XFS_LI_ABORTED) != 0;
530 533
531 /* 534 /*
532 * Before possibly freeing the buf item, determine if we should 535 * Before possibly freeing the buf item, determine if we should
@@ -587,16 +590,16 @@ xfs_buf_item_unlock(
587 */ 590 */
588STATIC xfs_lsn_t 591STATIC xfs_lsn_t
589xfs_buf_item_committed( 592xfs_buf_item_committed(
590 xfs_buf_log_item_t *bip, 593 struct xfs_log_item *lip,
591 xfs_lsn_t lsn) 594 xfs_lsn_t lsn)
592{ 595{
596 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
597
593 trace_xfs_buf_item_committed(bip); 598 trace_xfs_buf_item_committed(bip);
594 599
595 if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && 600 if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && lip->li_lsn != 0)
596 (bip->bli_item.li_lsn != 0)) { 601 return lip->li_lsn;
597 return bip->bli_item.li_lsn; 602 return lsn;
598 }
599 return (lsn);
600} 603}
601 604
602/* 605/*
@@ -606,15 +609,16 @@ xfs_buf_item_committed(
606 */ 609 */
607STATIC void 610STATIC void
608xfs_buf_item_push( 611xfs_buf_item_push(
609 xfs_buf_log_item_t *bip) 612 struct xfs_log_item *lip)
610{ 613{
611 xfs_buf_t *bp; 614 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
615 struct xfs_buf *bp = bip->bli_buf;
612 616
613 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 617 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
618 ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
619
614 trace_xfs_buf_item_push(bip); 620 trace_xfs_buf_item_push(bip);
615 621
616 bp = bip->bli_buf;
617 ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
618 xfs_buf_relse(bp); 622 xfs_buf_relse(bp);
619} 623}
620 624
@@ -626,22 +630,24 @@ xfs_buf_item_push(
626 */ 630 */
627STATIC void 631STATIC void
628xfs_buf_item_pushbuf( 632xfs_buf_item_pushbuf(
629 xfs_buf_log_item_t *bip) 633 struct xfs_log_item *lip)
630{ 634{
631 xfs_buf_t *bp; 635 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
636 struct xfs_buf *bp = bip->bli_buf;
632 637
633 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 638 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
639 ASSERT(XFS_BUF_ISDELAYWRITE(bp));
640
634 trace_xfs_buf_item_pushbuf(bip); 641 trace_xfs_buf_item_pushbuf(bip);
635 642
636 bp = bip->bli_buf;
637 ASSERT(XFS_BUF_ISDELAYWRITE(bp));
638 xfs_buf_delwri_promote(bp); 643 xfs_buf_delwri_promote(bp);
639 xfs_buf_relse(bp); 644 xfs_buf_relse(bp);
640} 645}
641 646
642/* ARGSUSED */
643STATIC void 647STATIC void
644xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn) 648xfs_buf_item_committing(
649 struct xfs_log_item *lip,
650 xfs_lsn_t commit_lsn)
645{ 651{
646} 652}
647 653
@@ -649,19 +655,16 @@ xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
649 * This is the ops vector shared by all buf log items. 655 * This is the ops vector shared by all buf log items.
650 */ 656 */
651static struct xfs_item_ops xfs_buf_item_ops = { 657static struct xfs_item_ops xfs_buf_item_ops = {
652 .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size, 658 .iop_size = xfs_buf_item_size,
653 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 659 .iop_format = xfs_buf_item_format,
654 xfs_buf_item_format, 660 .iop_pin = xfs_buf_item_pin,
655 .iop_pin = (void(*)(xfs_log_item_t*))xfs_buf_item_pin, 661 .iop_unpin = xfs_buf_item_unpin,
656 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_buf_item_unpin, 662 .iop_trylock = xfs_buf_item_trylock,
657 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_buf_item_trylock, 663 .iop_unlock = xfs_buf_item_unlock,
658 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_buf_item_unlock, 664 .iop_committed = xfs_buf_item_committed,
659 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 665 .iop_push = xfs_buf_item_push,
660 xfs_buf_item_committed, 666 .iop_pushbuf = xfs_buf_item_pushbuf,
661 .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push, 667 .iop_committing = xfs_buf_item_committing
662 .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_buf_item_pushbuf,
663 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
664 xfs_buf_item_committing
665}; 668};
666 669
667 670
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 6ac7e596c54c..61d83c64ed32 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -32,18 +32,19 @@
32kmem_zone_t *xfs_efi_zone; 32kmem_zone_t *xfs_efi_zone;
33kmem_zone_t *xfs_efd_zone; 33kmem_zone_t *xfs_efd_zone;
34 34
35STATIC void xfs_efi_item_unlock(xfs_efi_log_item_t *); 35static inline struct xfs_efi_log_item *EFI_ITEM(struct xfs_log_item *lip)
36{
37 return container_of(lip, struct xfs_efi_log_item, efi_item);
38}
36 39
37void 40void
38xfs_efi_item_free(xfs_efi_log_item_t *efip) 41xfs_efi_item_free(
42 struct xfs_efi_log_item *efip)
39{ 43{
40 int nexts = efip->efi_format.efi_nextents; 44 if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
41
42 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
43 kmem_free(efip); 45 kmem_free(efip);
44 } else { 46 else
45 kmem_zone_free(xfs_efi_zone, efip); 47 kmem_zone_free(xfs_efi_zone, efip);
46 }
47} 48}
48 49
49/* 50/*
@@ -51,9 +52,9 @@ xfs_efi_item_free(xfs_efi_log_item_t *efip)
51 * We only need 1 iovec for an efi item. It just logs the efi_log_format 52 * We only need 1 iovec for an efi item. It just logs the efi_log_format
52 * structure. 53 * structure.
53 */ 54 */
54/*ARGSUSED*/
55STATIC uint 55STATIC uint
56xfs_efi_item_size(xfs_efi_log_item_t *efip) 56xfs_efi_item_size(
57 struct xfs_log_item *lip)
57{ 58{
58 return 1; 59 return 1;
59} 60}
@@ -66,10 +67,12 @@ xfs_efi_item_size(xfs_efi_log_item_t *efip)
66 * slots in the efi item have been filled. 67 * slots in the efi item have been filled.
67 */ 68 */
68STATIC void 69STATIC void
69xfs_efi_item_format(xfs_efi_log_item_t *efip, 70xfs_efi_item_format(
70 xfs_log_iovec_t *log_vector) 71 struct xfs_log_item *lip,
72 struct xfs_log_iovec *log_vector)
71{ 73{
72 uint size; 74 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
75 uint size;
73 76
74 ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents); 77 ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents);
75 78
@@ -79,7 +82,7 @@ xfs_efi_item_format(xfs_efi_log_item_t *efip,
79 size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t); 82 size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t);
80 efip->efi_format.efi_size = 1; 83 efip->efi_format.efi_size = 1;
81 84
82 log_vector->i_addr = (xfs_caddr_t)&(efip->efi_format); 85 log_vector->i_addr = (xfs_caddr_t)&efip->efi_format;
83 log_vector->i_len = size; 86 log_vector->i_len = size;
84 log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; 87 log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT;
85 ASSERT(size >= sizeof(xfs_efi_log_format_t)); 88 ASSERT(size >= sizeof(xfs_efi_log_format_t));
@@ -89,14 +92,12 @@ xfs_efi_item_format(xfs_efi_log_item_t *efip,
89/* 92/*
90 * Pinning has no meaning for an efi item, so just return. 93 * Pinning has no meaning for an efi item, so just return.
91 */ 94 */
92/*ARGSUSED*/
93STATIC void 95STATIC void
94xfs_efi_item_pin(xfs_efi_log_item_t *efip) 96xfs_efi_item_pin(
97 struct xfs_log_item *lip)
95{ 98{
96 return;
97} 99}
98 100
99
100/* 101/*
101 * While EFIs cannot really be pinned, the unpin operation is the 102 * While EFIs cannot really be pinned, the unpin operation is the
102 * last place at which the EFI is manipulated during a transaction. 103 * last place at which the EFI is manipulated during a transaction.
@@ -104,14 +105,15 @@ xfs_efi_item_pin(xfs_efi_log_item_t *efip)
104 * free the EFI. 105 * free the EFI.
105 */ 106 */
106STATIC void 107STATIC void
107xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int remove) 108xfs_efi_item_unpin(
109 struct xfs_log_item *lip,
110 int remove)
108{ 111{
109 struct xfs_ail *ailp = efip->efi_item.li_ailp; 112 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
113 struct xfs_ail *ailp = lip->li_ailp;
110 114
111 spin_lock(&ailp->xa_lock); 115 spin_lock(&ailp->xa_lock);
112 if (efip->efi_flags & XFS_EFI_CANCELED) { 116 if (efip->efi_flags & XFS_EFI_CANCELED) {
113 struct xfs_log_item *lip = &efip->efi_item;
114
115 if (remove) 117 if (remove)
116 xfs_trans_del_item(lip); 118 xfs_trans_del_item(lip);
117 119
@@ -131,9 +133,9 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int remove)
131 * XFS_ITEM_PINNED so that the caller will eventually flush the log. 133 * XFS_ITEM_PINNED so that the caller will eventually flush the log.
132 * This should help in getting the EFI out of the AIL. 134 * This should help in getting the EFI out of the AIL.
133 */ 135 */
134/*ARGSUSED*/
135STATIC uint 136STATIC uint
136xfs_efi_item_trylock(xfs_efi_log_item_t *efip) 137xfs_efi_item_trylock(
138 struct xfs_log_item *lip)
137{ 139{
138 return XFS_ITEM_PINNED; 140 return XFS_ITEM_PINNED;
139} 141}
@@ -141,13 +143,12 @@ xfs_efi_item_trylock(xfs_efi_log_item_t *efip)
141/* 143/*
142 * Efi items have no locking, so just return. 144 * Efi items have no locking, so just return.
143 */ 145 */
144/*ARGSUSED*/
145STATIC void 146STATIC void
146xfs_efi_item_unlock(xfs_efi_log_item_t *efip) 147xfs_efi_item_unlock(
148 struct xfs_log_item *lip)
147{ 149{
148 if (efip->efi_item.li_flags & XFS_LI_ABORTED) 150 if (lip->li_flags & XFS_LI_ABORTED)
149 xfs_efi_item_free(efip); 151 xfs_efi_item_free(EFI_ITEM(lip));
150 return;
151} 152}
152 153
153/* 154/*
@@ -156,9 +157,10 @@ xfs_efi_item_unlock(xfs_efi_log_item_t *efip)
156 * flag is not paid any attention here. Checking for that is delayed 157 * flag is not paid any attention here. Checking for that is delayed
157 * until the EFI is unpinned. 158 * until the EFI is unpinned.
158 */ 159 */
159/*ARGSUSED*/
160STATIC xfs_lsn_t 160STATIC xfs_lsn_t
161xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn) 161xfs_efi_item_committed(
162 struct xfs_log_item *lip,
163 xfs_lsn_t lsn)
162{ 164{
163 return lsn; 165 return lsn;
164} 166}
@@ -168,11 +170,10 @@ xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
168 * stuck waiting for all of its corresponding efd items to be 170 * stuck waiting for all of its corresponding efd items to be
169 * committed to disk. 171 * committed to disk.
170 */ 172 */
171/*ARGSUSED*/
172STATIC void 173STATIC void
173xfs_efi_item_push(xfs_efi_log_item_t *efip) 174xfs_efi_item_push(
175 struct xfs_log_item *lip)
174{ 176{
175 return;
176} 177}
177 178
178/* 179/*
@@ -182,59 +183,55 @@ xfs_efi_item_push(xfs_efi_log_item_t *efip)
182 * example, for inodes, the inode is locked throughout the extent freeing 183 * example, for inodes, the inode is locked throughout the extent freeing
183 * so the dependency should be recorded there. 184 * so the dependency should be recorded there.
184 */ 185 */
185/*ARGSUSED*/
186STATIC void 186STATIC void
187xfs_efi_item_committing(xfs_efi_log_item_t *efip, xfs_lsn_t lsn) 187xfs_efi_item_committing(
188 struct xfs_log_item *lip,
189 xfs_lsn_t lsn)
188{ 190{
189 return;
190} 191}
191 192
192/* 193/*
193 * This is the ops vector shared by all efi log items. 194 * This is the ops vector shared by all efi log items.
194 */ 195 */
195static struct xfs_item_ops xfs_efi_item_ops = { 196static struct xfs_item_ops xfs_efi_item_ops = {
196 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size, 197 .iop_size = xfs_efi_item_size,
197 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 198 .iop_format = xfs_efi_item_format,
198 xfs_efi_item_format, 199 .iop_pin = xfs_efi_item_pin,
199 .iop_pin = (void(*)(xfs_log_item_t*))xfs_efi_item_pin, 200 .iop_unpin = xfs_efi_item_unpin,
200 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_efi_item_unpin, 201 .iop_trylock = xfs_efi_item_trylock,
201 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efi_item_trylock, 202 .iop_unlock = xfs_efi_item_unlock,
202 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_efi_item_unlock, 203 .iop_committed = xfs_efi_item_committed,
203 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 204 .iop_push = xfs_efi_item_push,
204 xfs_efi_item_committed, 205 .iop_committing = xfs_efi_item_committing
205 .iop_push = (void(*)(xfs_log_item_t*))xfs_efi_item_push,
206 .iop_pushbuf = NULL,
207 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
208 xfs_efi_item_committing
209}; 206};
210 207
211 208
212/* 209/*
213 * Allocate and initialize an efi item with the given number of extents. 210 * Allocate and initialize an efi item with the given number of extents.
214 */ 211 */
215xfs_efi_log_item_t * 212struct xfs_efi_log_item *
216xfs_efi_init(xfs_mount_t *mp, 213xfs_efi_init(
217 uint nextents) 214 struct xfs_mount *mp,
215 uint nextents)
218 216
219{ 217{
220 xfs_efi_log_item_t *efip; 218 struct xfs_efi_log_item *efip;
221 uint size; 219 uint size;
222 220
223 ASSERT(nextents > 0); 221 ASSERT(nextents > 0);
224 if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { 222 if (nextents > XFS_EFI_MAX_FAST_EXTENTS) {
225 size = (uint)(sizeof(xfs_efi_log_item_t) + 223 size = (uint)(sizeof(xfs_efi_log_item_t) +
226 ((nextents - 1) * sizeof(xfs_extent_t))); 224 ((nextents - 1) * sizeof(xfs_extent_t)));
227 efip = (xfs_efi_log_item_t*)kmem_zalloc(size, KM_SLEEP); 225 efip = kmem_zalloc(size, KM_SLEEP);
228 } else { 226 } else {
229 efip = (xfs_efi_log_item_t*)kmem_zone_zalloc(xfs_efi_zone, 227 efip = kmem_zone_zalloc(xfs_efi_zone, KM_SLEEP);
230 KM_SLEEP);
231 } 228 }
232 229
233 xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops); 230 xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops);
234 efip->efi_format.efi_nextents = nextents; 231 efip->efi_format.efi_nextents = nextents;
235 efip->efi_format.efi_id = (__psint_t)(void*)efip; 232 efip->efi_format.efi_id = (__psint_t)(void*)efip;
236 233
237 return (efip); 234 return efip;
238} 235}
239 236
240/* 237/*
@@ -327,16 +324,18 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
327 } 324 }
328} 325}
329 326
330STATIC void 327static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
331xfs_efd_item_free(xfs_efd_log_item_t *efdp)
332{ 328{
333 int nexts = efdp->efd_format.efd_nextents; 329 return container_of(lip, struct xfs_efd_log_item, efd_item);
330}
334 331
335 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) { 332STATIC void
333xfs_efd_item_free(struct xfs_efd_log_item *efdp)
334{
335 if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
336 kmem_free(efdp); 336 kmem_free(efdp);
337 } else { 337 else
338 kmem_zone_free(xfs_efd_zone, efdp); 338 kmem_zone_free(xfs_efd_zone, efdp);
339 }
340} 339}
341 340
342/* 341/*
@@ -344,9 +343,9 @@ xfs_efd_item_free(xfs_efd_log_item_t *efdp)
344 * We only need 1 iovec for an efd item. It just logs the efd_log_format 343 * We only need 1 iovec for an efd item. It just logs the efd_log_format
345 * structure. 344 * structure.
346 */ 345 */
347/*ARGSUSED*/
348STATIC uint 346STATIC uint
349xfs_efd_item_size(xfs_efd_log_item_t *efdp) 347xfs_efd_item_size(
348 struct xfs_log_item *lip)
350{ 349{
351 return 1; 350 return 1;
352} 351}
@@ -359,10 +358,12 @@ xfs_efd_item_size(xfs_efd_log_item_t *efdp)
359 * slots in the efd item have been filled. 358 * slots in the efd item have been filled.
360 */ 359 */
361STATIC void 360STATIC void
362xfs_efd_item_format(xfs_efd_log_item_t *efdp, 361xfs_efd_item_format(
363 xfs_log_iovec_t *log_vector) 362 struct xfs_log_item *lip,
363 struct xfs_log_iovec *log_vector)
364{ 364{
365 uint size; 365 struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
366 uint size;
366 367
367 ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents); 368 ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents);
368 369
@@ -372,41 +373,38 @@ xfs_efd_item_format(xfs_efd_log_item_t *efdp,
372 size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t); 373 size += (efdp->efd_format.efd_nextents - 1) * sizeof(xfs_extent_t);
373 efdp->efd_format.efd_size = 1; 374 efdp->efd_format.efd_size = 1;
374 375
375 log_vector->i_addr = (xfs_caddr_t)&(efdp->efd_format); 376 log_vector->i_addr = (xfs_caddr_t)&efdp->efd_format;
376 log_vector->i_len = size; 377 log_vector->i_len = size;
377 log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; 378 log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT;
378 ASSERT(size >= sizeof(xfs_efd_log_format_t)); 379 ASSERT(size >= sizeof(xfs_efd_log_format_t));
379} 380}
380 381
381
382/* 382/*
383 * Pinning has no meaning for an efd item, so just return. 383 * Pinning has no meaning for an efd item, so just return.
384 */ 384 */
385/*ARGSUSED*/
386STATIC void 385STATIC void
387xfs_efd_item_pin(xfs_efd_log_item_t *efdp) 386xfs_efd_item_pin(
387 struct xfs_log_item *lip)
388{ 388{
389 return;
390} 389}
391 390
392
393/* 391/*
394 * Since pinning has no meaning for an efd item, unpinning does 392 * Since pinning has no meaning for an efd item, unpinning does
395 * not either. 393 * not either.
396 */ 394 */
397/*ARGSUSED*/
398STATIC void 395STATIC void
399xfs_efd_item_unpin(xfs_efd_log_item_t *efdp, int remove) 396xfs_efd_item_unpin(
397 struct xfs_log_item *lip,
398 int remove)
400{ 399{
401 return;
402} 400}
403 401
404/* 402/*
405 * Efd items have no locking, so just return success. 403 * Efd items have no locking, so just return success.
406 */ 404 */
407/*ARGSUSED*/
408STATIC uint 405STATIC uint
409xfs_efd_item_trylock(xfs_efd_log_item_t *efdp) 406xfs_efd_item_trylock(
407 struct xfs_log_item *lip)
410{ 408{
411 return XFS_ITEM_LOCKED; 409 return XFS_ITEM_LOCKED;
412} 410}
@@ -415,13 +413,12 @@ xfs_efd_item_trylock(xfs_efd_log_item_t *efdp)
415 * Efd items have no locking or pushing, so return failure 413 * Efd items have no locking or pushing, so return failure
416 * so that the caller doesn't bother with us. 414 * so that the caller doesn't bother with us.
417 */ 415 */
418/*ARGSUSED*/
419STATIC void 416STATIC void
420xfs_efd_item_unlock(xfs_efd_log_item_t *efdp) 417xfs_efd_item_unlock(
418 struct xfs_log_item *lip)
421{ 419{
422 if (efdp->efd_item.li_flags & XFS_LI_ABORTED) 420 if (lip->li_flags & XFS_LI_ABORTED)
423 xfs_efd_item_free(efdp); 421 xfs_efd_item_free(EFD_ITEM(lip));
424 return;
425} 422}
426 423
427/* 424/*
@@ -431,15 +428,18 @@ xfs_efd_item_unlock(xfs_efd_log_item_t *efdp)
431 * return -1 to keep the transaction code from further referencing 428 * return -1 to keep the transaction code from further referencing
432 * this item. 429 * this item.
433 */ 430 */
434/*ARGSUSED*/
435STATIC xfs_lsn_t 431STATIC xfs_lsn_t
436xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn) 432xfs_efd_item_committed(
433 struct xfs_log_item *lip,
434 xfs_lsn_t lsn)
437{ 435{
436 struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
437
438 /* 438 /*
439 * If we got a log I/O error, it's always the case that the LR with the 439 * If we got a log I/O error, it's always the case that the LR with the
440 * EFI got unpinned and freed before the EFD got aborted. 440 * EFI got unpinned and freed before the EFD got aborted.
441 */ 441 */
442 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) 442 if (!(lip->li_flags & XFS_LI_ABORTED))
443 xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents); 443 xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents);
444 444
445 xfs_efd_item_free(efdp); 445 xfs_efd_item_free(efdp);
@@ -450,11 +450,10 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
450 * There isn't much you can do to push on an efd item. It is simply 450 * There isn't much you can do to push on an efd item. It is simply
451 * stuck waiting for the log to be flushed to disk. 451 * stuck waiting for the log to be flushed to disk.
452 */ 452 */
453/*ARGSUSED*/
454STATIC void 453STATIC void
455xfs_efd_item_push(xfs_efd_log_item_t *efdp) 454xfs_efd_item_push(
455 struct xfs_log_item *lip)
456{ 456{
457 return;
458} 457}
459 458
460/* 459/*
@@ -464,53 +463,48 @@ xfs_efd_item_push(xfs_efd_log_item_t *efdp)
464 * example, for inodes, the inode is locked throughout the extent freeing 463 * example, for inodes, the inode is locked throughout the extent freeing
465 * so the dependency should be recorded there. 464 * so the dependency should be recorded there.
466 */ 465 */
467/*ARGSUSED*/
468STATIC void 466STATIC void
469xfs_efd_item_committing(xfs_efd_log_item_t *efip, xfs_lsn_t lsn) 467xfs_efd_item_committing(
468 struct xfs_log_item *lip,
469 xfs_lsn_t lsn)
470{ 470{
471 return;
472} 471}
473 472
474/* 473/*
475 * This is the ops vector shared by all efd log items. 474 * This is the ops vector shared by all efd log items.
476 */ 475 */
477static struct xfs_item_ops xfs_efd_item_ops = { 476static struct xfs_item_ops xfs_efd_item_ops = {
478 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size, 477 .iop_size = xfs_efd_item_size,
479 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 478 .iop_format = xfs_efd_item_format,
480 xfs_efd_item_format, 479 .iop_pin = xfs_efd_item_pin,
481 .iop_pin = (void(*)(xfs_log_item_t*))xfs_efd_item_pin, 480 .iop_unpin = xfs_efd_item_unpin,
482 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_efd_item_unpin, 481 .iop_trylock = xfs_efd_item_trylock,
483 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efd_item_trylock, 482 .iop_unlock = xfs_efd_item_unlock,
484 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_efd_item_unlock, 483 .iop_committed = xfs_efd_item_committed,
485 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 484 .iop_push = xfs_efd_item_push,
486 xfs_efd_item_committed, 485 .iop_committing = xfs_efd_item_committing
487 .iop_push = (void(*)(xfs_log_item_t*))xfs_efd_item_push,
488 .iop_pushbuf = NULL,
489 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
490 xfs_efd_item_committing
491}; 486};
492 487
493
494/* 488/*
495 * Allocate and initialize an efd item with the given number of extents. 489 * Allocate and initialize an efd item with the given number of extents.
496 */ 490 */
497xfs_efd_log_item_t * 491struct xfs_efd_log_item *
498xfs_efd_init(xfs_mount_t *mp, 492xfs_efd_init(
499 xfs_efi_log_item_t *efip, 493 struct xfs_mount *mp,
500 uint nextents) 494 struct xfs_efi_log_item *efip,
495 uint nextents)
501 496
502{ 497{
503 xfs_efd_log_item_t *efdp; 498 struct xfs_efd_log_item *efdp;
504 uint size; 499 uint size;
505 500
506 ASSERT(nextents > 0); 501 ASSERT(nextents > 0);
507 if (nextents > XFS_EFD_MAX_FAST_EXTENTS) { 502 if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
508 size = (uint)(sizeof(xfs_efd_log_item_t) + 503 size = (uint)(sizeof(xfs_efd_log_item_t) +
509 ((nextents - 1) * sizeof(xfs_extent_t))); 504 ((nextents - 1) * sizeof(xfs_extent_t)));
510 efdp = (xfs_efd_log_item_t*)kmem_zalloc(size, KM_SLEEP); 505 efdp = kmem_zalloc(size, KM_SLEEP);
511 } else { 506 } else {
512 efdp = (xfs_efd_log_item_t*)kmem_zone_zalloc(xfs_efd_zone, 507 efdp = kmem_zone_zalloc(xfs_efd_zone, KM_SLEEP);
513 KM_SLEEP);
514 } 508 }
515 509
516 xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops); 510 xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops);
@@ -518,5 +512,5 @@ xfs_efd_init(xfs_mount_t *mp,
518 efdp->efd_format.efd_nextents = nextents; 512 efdp->efd_format.efd_nextents = nextents;
519 efdp->efd_format.efd_efi_id = efip->efi_format.efi_id; 513 efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
520 514
521 return (efdp); 515 return efdp;
522} 516}
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index a01990dbb945..2626aaca42f2 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -36,6 +36,12 @@
36 36
37kmem_zone_t *xfs_ili_zone; /* inode log item zone */ 37kmem_zone_t *xfs_ili_zone; /* inode log item zone */
38 38
39static inline struct xfs_inode_log_item *INODE_ITEM(struct xfs_log_item *lip)
40{
41 return container_of(lip, struct xfs_inode_log_item, ili_item);
42}
43
44
39/* 45/*
40 * This returns the number of iovecs needed to log the given inode item. 46 * This returns the number of iovecs needed to log the given inode item.
41 * 47 *
@@ -45,13 +51,11 @@ kmem_zone_t *xfs_ili_zone; /* inode log item zone */
45 */ 51 */
46STATIC uint 52STATIC uint
47xfs_inode_item_size( 53xfs_inode_item_size(
48 xfs_inode_log_item_t *iip) 54 struct xfs_log_item *lip)
49{ 55{
50 uint nvecs; 56 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
51 xfs_inode_t *ip; 57 struct xfs_inode *ip = iip->ili_inode;
52 58 uint nvecs = 2;
53 ip = iip->ili_inode;
54 nvecs = 2;
55 59
56 /* 60 /*
57 * Only log the data/extents/b-tree root if there is something 61 * Only log the data/extents/b-tree root if there is something
@@ -202,20 +206,17 @@ xfs_inode_item_size(
202 */ 206 */
203STATIC void 207STATIC void
204xfs_inode_item_format( 208xfs_inode_item_format(
205 xfs_inode_log_item_t *iip, 209 struct xfs_log_item *lip,
206 xfs_log_iovec_t *log_vector) 210 struct xfs_log_iovec *vecp)
207{ 211{
212 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
213 struct xfs_inode *ip = iip->ili_inode;
208 uint nvecs; 214 uint nvecs;
209 xfs_log_iovec_t *vecp;
210 xfs_inode_t *ip;
211 size_t data_bytes; 215 size_t data_bytes;
212 xfs_bmbt_rec_t *ext_buffer; 216 xfs_bmbt_rec_t *ext_buffer;
213 int nrecs; 217 int nrecs;
214 xfs_mount_t *mp; 218 xfs_mount_t *mp;
215 219
216 ip = iip->ili_inode;
217 vecp = log_vector;
218
219 vecp->i_addr = (xfs_caddr_t)&iip->ili_format; 220 vecp->i_addr = (xfs_caddr_t)&iip->ili_format;
220 vecp->i_len = sizeof(xfs_inode_log_format_t); 221 vecp->i_len = sizeof(xfs_inode_log_format_t);
221 vecp->i_type = XLOG_REG_TYPE_IFORMAT; 222 vecp->i_type = XLOG_REG_TYPE_IFORMAT;
@@ -427,7 +428,7 @@ xfs_inode_item_format(
427 * Assert that no attribute-related log flags are set. 428 * Assert that no attribute-related log flags are set.
428 */ 429 */
429 if (!XFS_IFORK_Q(ip)) { 430 if (!XFS_IFORK_Q(ip)) {
430 ASSERT(nvecs == iip->ili_item.li_desc->lid_size); 431 ASSERT(nvecs == lip->li_desc->lid_size);
431 iip->ili_format.ilf_size = nvecs; 432 iip->ili_format.ilf_size = nvecs;
432 ASSERT(!(iip->ili_format.ilf_fields & 433 ASSERT(!(iip->ili_format.ilf_fields &
433 (XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT))); 434 (XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT)));
@@ -518,7 +519,7 @@ xfs_inode_item_format(
518 break; 519 break;
519 } 520 }
520 521
521 ASSERT(nvecs == iip->ili_item.li_desc->lid_size); 522 ASSERT(nvecs == lip->li_desc->lid_size);
522 iip->ili_format.ilf_size = nvecs; 523 iip->ili_format.ilf_size = nvecs;
523} 524}
524 525
@@ -529,12 +530,14 @@ xfs_inode_item_format(
529 */ 530 */
530STATIC void 531STATIC void
531xfs_inode_item_pin( 532xfs_inode_item_pin(
532 xfs_inode_log_item_t *iip) 533 struct xfs_log_item *lip)
533{ 534{
534 ASSERT(xfs_isilocked(iip->ili_inode, XFS_ILOCK_EXCL)); 535 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
535 536
536 trace_xfs_inode_pin(iip->ili_inode, _RET_IP_); 537 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
537 atomic_inc(&iip->ili_inode->i_pincount); 538
539 trace_xfs_inode_pin(ip, _RET_IP_);
540 atomic_inc(&ip->i_pincount);
538} 541}
539 542
540 543
@@ -546,10 +549,10 @@ xfs_inode_item_pin(
546 */ 549 */
547STATIC void 550STATIC void
548xfs_inode_item_unpin( 551xfs_inode_item_unpin(
549 xfs_inode_log_item_t *iip, 552 struct xfs_log_item *lip,
550 int remove) 553 int remove)
551{ 554{
552 struct xfs_inode *ip = iip->ili_inode; 555 struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode;
553 556
554 trace_xfs_inode_unpin(ip, _RET_IP_); 557 trace_xfs_inode_unpin(ip, _RET_IP_);
555 ASSERT(atomic_read(&ip->i_pincount) > 0); 558 ASSERT(atomic_read(&ip->i_pincount) > 0);
@@ -572,19 +575,16 @@ xfs_inode_item_unpin(
572 */ 575 */
573STATIC uint 576STATIC uint
574xfs_inode_item_trylock( 577xfs_inode_item_trylock(
575 xfs_inode_log_item_t *iip) 578 struct xfs_log_item *lip)
576{ 579{
577 register xfs_inode_t *ip; 580 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
578 581 struct xfs_inode *ip = iip->ili_inode;
579 ip = iip->ili_inode;
580 582
581 if (xfs_ipincount(ip) > 0) { 583 if (xfs_ipincount(ip) > 0)
582 return XFS_ITEM_PINNED; 584 return XFS_ITEM_PINNED;
583 }
584 585
585 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { 586 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED))
586 return XFS_ITEM_LOCKED; 587 return XFS_ITEM_LOCKED;
587 }
588 588
589 if (!xfs_iflock_nowait(ip)) { 589 if (!xfs_iflock_nowait(ip)) {
590 /* 590 /*
@@ -610,7 +610,7 @@ xfs_inode_item_trylock(
610 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { 610 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
611 ASSERT(iip->ili_format.ilf_fields != 0); 611 ASSERT(iip->ili_format.ilf_fields != 0);
612 ASSERT(iip->ili_logged == 0); 612 ASSERT(iip->ili_logged == 0);
613 ASSERT(iip->ili_item.li_flags & XFS_LI_IN_AIL); 613 ASSERT(lip->li_flags & XFS_LI_IN_AIL);
614 } 614 }
615#endif 615#endif
616 return XFS_ITEM_SUCCESS; 616 return XFS_ITEM_SUCCESS;
@@ -624,12 +624,13 @@ xfs_inode_item_trylock(
624 */ 624 */
625STATIC void 625STATIC void
626xfs_inode_item_unlock( 626xfs_inode_item_unlock(
627 xfs_inode_log_item_t *iip) 627 struct xfs_log_item *lip)
628{ 628{
629 uint hold; 629 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
630 uint iolocked; 630 struct xfs_inode *ip = iip->ili_inode;
631 uint lock_flags; 631 uint hold;
632 xfs_inode_t *ip; 632 uint iolocked;
633 uint lock_flags;
633 634
634 ASSERT(iip != NULL); 635 ASSERT(iip != NULL);
635 ASSERT(iip->ili_inode->i_itemp != NULL); 636 ASSERT(iip->ili_inode->i_itemp != NULL);
@@ -640,10 +641,10 @@ xfs_inode_item_unlock(
640 ASSERT((!(iip->ili_inode->i_itemp->ili_flags & 641 ASSERT((!(iip->ili_inode->i_itemp->ili_flags &
641 XFS_ILI_IOLOCKED_SHARED)) || 642 XFS_ILI_IOLOCKED_SHARED)) ||
642 xfs_isilocked(iip->ili_inode, XFS_IOLOCK_SHARED)); 643 xfs_isilocked(iip->ili_inode, XFS_IOLOCK_SHARED));
644
643 /* 645 /*
644 * Clear the transaction pointer in the inode. 646 * Clear the transaction pointer in the inode.
645 */ 647 */
646 ip = iip->ili_inode;
647 ip->i_transp = NULL; 648 ip->i_transp = NULL;
648 649
649 /* 650 /*
@@ -706,13 +707,12 @@ xfs_inode_item_unlock(
706 * is the only one that matters. Therefore, simply return the 707 * is the only one that matters. Therefore, simply return the
707 * given lsn. 708 * given lsn.
708 */ 709 */
709/*ARGSUSED*/
710STATIC xfs_lsn_t 710STATIC xfs_lsn_t
711xfs_inode_item_committed( 711xfs_inode_item_committed(
712 xfs_inode_log_item_t *iip, 712 struct xfs_log_item *lip,
713 xfs_lsn_t lsn) 713 xfs_lsn_t lsn)
714{ 714{
715 return (lsn); 715 return lsn;
716} 716}
717 717
718/* 718/*
@@ -724,13 +724,12 @@ xfs_inode_item_committed(
724 */ 724 */
725STATIC void 725STATIC void
726xfs_inode_item_pushbuf( 726xfs_inode_item_pushbuf(
727 xfs_inode_log_item_t *iip) 727 struct xfs_log_item *lip)
728{ 728{
729 xfs_inode_t *ip; 729 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
730 xfs_mount_t *mp; 730 struct xfs_inode *ip = iip->ili_inode;
731 xfs_buf_t *bp; 731 struct xfs_buf *bp;
732 732
733 ip = iip->ili_inode;
734 ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); 733 ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
735 734
736 /* 735 /*
@@ -738,14 +737,13 @@ xfs_inode_item_pushbuf(
738 * inode was taken off the AIL. So, just get out. 737 * inode was taken off the AIL. So, just get out.
739 */ 738 */
740 if (completion_done(&ip->i_flush) || 739 if (completion_done(&ip->i_flush) ||
741 ((iip->ili_item.li_flags & XFS_LI_IN_AIL) == 0)) { 740 !(lip->li_flags & XFS_LI_IN_AIL)) {
742 xfs_iunlock(ip, XFS_ILOCK_SHARED); 741 xfs_iunlock(ip, XFS_ILOCK_SHARED);
743 return; 742 return;
744 } 743 }
745 744
746 mp = ip->i_mount; 745 bp = xfs_incore(ip->i_mount->m_ddev_targp, iip->ili_format.ilf_blkno,
747 bp = xfs_incore(mp->m_ddev_targp, iip->ili_format.ilf_blkno, 746 iip->ili_format.ilf_len, XBF_TRYLOCK);
748 iip->ili_format.ilf_len, XBF_TRYLOCK);
749 747
750 xfs_iunlock(ip, XFS_ILOCK_SHARED); 748 xfs_iunlock(ip, XFS_ILOCK_SHARED);
751 if (!bp) 749 if (!bp)
@@ -753,10 +751,8 @@ xfs_inode_item_pushbuf(
753 if (XFS_BUF_ISDELAYWRITE(bp)) 751 if (XFS_BUF_ISDELAYWRITE(bp))
754 xfs_buf_delwri_promote(bp); 752 xfs_buf_delwri_promote(bp);
755 xfs_buf_relse(bp); 753 xfs_buf_relse(bp);
756 return;
757} 754}
758 755
759
760/* 756/*
761 * This is called to asynchronously write the inode associated with this 757 * This is called to asynchronously write the inode associated with this
762 * inode log item out to disk. The inode will already have been locked by 758 * inode log item out to disk. The inode will already have been locked by
@@ -764,14 +760,14 @@ xfs_inode_item_pushbuf(
764 */ 760 */
765STATIC void 761STATIC void
766xfs_inode_item_push( 762xfs_inode_item_push(
767 xfs_inode_log_item_t *iip) 763 struct xfs_log_item *lip)
768{ 764{
769 xfs_inode_t *ip; 765 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
770 766 struct xfs_inode *ip = iip->ili_inode;
771 ip = iip->ili_inode;
772 767
773 ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); 768 ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED));
774 ASSERT(!completion_done(&ip->i_flush)); 769 ASSERT(!completion_done(&ip->i_flush));
770
775 /* 771 /*
776 * Since we were able to lock the inode's flush lock and 772 * Since we were able to lock the inode's flush lock and
777 * we found it on the AIL, the inode must be dirty. This 773 * we found it on the AIL, the inode must be dirty. This
@@ -794,41 +790,34 @@ xfs_inode_item_push(
794 */ 790 */
795 (void) xfs_iflush(ip, 0); 791 (void) xfs_iflush(ip, 0);
796 xfs_iunlock(ip, XFS_ILOCK_SHARED); 792 xfs_iunlock(ip, XFS_ILOCK_SHARED);
797
798 return;
799} 793}
800 794
801/* 795/*
802 * XXX rcc - this one really has to do something. Probably needs 796 * XXX rcc - this one really has to do something. Probably needs
803 * to stamp in a new field in the incore inode. 797 * to stamp in a new field in the incore inode.
804 */ 798 */
805/* ARGSUSED */
806STATIC void 799STATIC void
807xfs_inode_item_committing( 800xfs_inode_item_committing(
808 xfs_inode_log_item_t *iip, 801 struct xfs_log_item *lip,
809 xfs_lsn_t lsn) 802 xfs_lsn_t lsn)
810{ 803{
811 iip->ili_last_lsn = lsn; 804 INODE_ITEM(lip)->ili_last_lsn = lsn;
812 return;
813} 805}
814 806
815/* 807/*
816 * This is the ops vector shared by all buf log items. 808 * This is the ops vector shared by all buf log items.
817 */ 809 */
818static struct xfs_item_ops xfs_inode_item_ops = { 810static struct xfs_item_ops xfs_inode_item_ops = {
819 .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size, 811 .iop_size = xfs_inode_item_size,
820 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 812 .iop_format = xfs_inode_item_format,
821 xfs_inode_item_format, 813 .iop_pin = xfs_inode_item_pin,
822 .iop_pin = (void(*)(xfs_log_item_t*))xfs_inode_item_pin, 814 .iop_unpin = xfs_inode_item_unpin,
823 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_inode_item_unpin, 815 .iop_trylock = xfs_inode_item_trylock,
824 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_inode_item_trylock, 816 .iop_unlock = xfs_inode_item_unlock,
825 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_inode_item_unlock, 817 .iop_committed = xfs_inode_item_committed,
826 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 818 .iop_push = xfs_inode_item_push,
827 xfs_inode_item_committed, 819 .iop_pushbuf = xfs_inode_item_pushbuf,
828 .iop_push = (void(*)(xfs_log_item_t*))xfs_inode_item_push, 820 .iop_committing = xfs_inode_item_committing
829 .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_inode_item_pushbuf,
830 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
831 xfs_inode_item_committing
832}; 821};
833 822
834 823
@@ -837,10 +826,10 @@ static struct xfs_item_ops xfs_inode_item_ops = {
837 */ 826 */
838void 827void
839xfs_inode_item_init( 828xfs_inode_item_init(
840 xfs_inode_t *ip, 829 struct xfs_inode *ip,
841 xfs_mount_t *mp) 830 struct xfs_mount *mp)
842{ 831{
843 xfs_inode_log_item_t *iip; 832 struct xfs_inode_log_item *iip;
844 833
845 ASSERT(ip->i_itemp == NULL); 834 ASSERT(ip->i_itemp == NULL);
846 iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP); 835 iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP);