diff options
Diffstat (limited to 'fs/xfs/xfs_inode_item.c')
-rw-r--r-- | fs/xfs/xfs_inode_item.c | 273 |
1 files changed, 100 insertions, 173 deletions
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index cf8249a60004..fe00777e2796 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -22,30 +22,26 @@ | |||
22 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | 23 | #include "xfs_inum.h" |
24 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
25 | #include "xfs_buf_item.h" | ||
26 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
28 | #include "xfs_dir2.h" | ||
29 | #include "xfs_dmapi.h" | ||
30 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
31 | #include "xfs_trans_priv.h" | 28 | #include "xfs_trans_priv.h" |
32 | #include "xfs_bmap_btree.h" | 29 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
34 | #include "xfs_ialloc_btree.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | 30 | #include "xfs_dinode.h" |
38 | #include "xfs_inode.h" | 31 | #include "xfs_inode.h" |
39 | #include "xfs_inode_item.h" | 32 | #include "xfs_inode_item.h" |
40 | #include "xfs_btree.h" | ||
41 | #include "xfs_ialloc.h" | ||
42 | #include "xfs_rw.h" | ||
43 | #include "xfs_error.h" | 33 | #include "xfs_error.h" |
44 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
45 | 35 | ||
46 | 36 | ||
47 | kmem_zone_t *xfs_ili_zone; /* inode log item zone */ | 37 | kmem_zone_t *xfs_ili_zone; /* inode log item zone */ |
48 | 38 | ||
39 | static 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 | |||
49 | /* | 45 | /* |
50 | * 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. |
51 | * | 47 | * |
@@ -55,13 +51,11 @@ kmem_zone_t *xfs_ili_zone; /* inode log item zone */ | |||
55 | */ | 51 | */ |
56 | STATIC uint | 52 | STATIC uint |
57 | xfs_inode_item_size( | 53 | xfs_inode_item_size( |
58 | xfs_inode_log_item_t *iip) | 54 | struct xfs_log_item *lip) |
59 | { | 55 | { |
60 | uint nvecs; | 56 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
61 | xfs_inode_t *ip; | 57 | struct xfs_inode *ip = iip->ili_inode; |
62 | 58 | uint nvecs = 2; | |
63 | ip = iip->ili_inode; | ||
64 | nvecs = 2; | ||
65 | 59 | ||
66 | /* | 60 | /* |
67 | * 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 |
@@ -212,21 +206,17 @@ xfs_inode_item_size( | |||
212 | */ | 206 | */ |
213 | STATIC void | 207 | STATIC void |
214 | xfs_inode_item_format( | 208 | xfs_inode_item_format( |
215 | xfs_inode_log_item_t *iip, | 209 | struct xfs_log_item *lip, |
216 | xfs_log_iovec_t *log_vector) | 210 | struct xfs_log_iovec *vecp) |
217 | { | 211 | { |
212 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); | ||
213 | struct xfs_inode *ip = iip->ili_inode; | ||
218 | uint nvecs; | 214 | uint nvecs; |
219 | xfs_log_iovec_t *vecp; | ||
220 | xfs_inode_t *ip; | ||
221 | size_t data_bytes; | 215 | size_t data_bytes; |
222 | xfs_bmbt_rec_t *ext_buffer; | 216 | xfs_bmbt_rec_t *ext_buffer; |
223 | int nrecs; | ||
224 | xfs_mount_t *mp; | 217 | xfs_mount_t *mp; |
225 | 218 | ||
226 | ip = iip->ili_inode; | 219 | vecp->i_addr = &iip->ili_format; |
227 | vecp = log_vector; | ||
228 | |||
229 | vecp->i_addr = (xfs_caddr_t)&iip->ili_format; | ||
230 | vecp->i_len = sizeof(xfs_inode_log_format_t); | 220 | vecp->i_len = sizeof(xfs_inode_log_format_t); |
231 | vecp->i_type = XLOG_REG_TYPE_IFORMAT; | 221 | vecp->i_type = XLOG_REG_TYPE_IFORMAT; |
232 | vecp++; | 222 | vecp++; |
@@ -277,7 +267,7 @@ xfs_inode_item_format( | |||
277 | */ | 267 | */ |
278 | xfs_synchronize_times(ip); | 268 | xfs_synchronize_times(ip); |
279 | 269 | ||
280 | vecp->i_addr = (xfs_caddr_t)&ip->i_d; | 270 | vecp->i_addr = &ip->i_d; |
281 | vecp->i_len = sizeof(struct xfs_icdinode); | 271 | vecp->i_len = sizeof(struct xfs_icdinode); |
282 | vecp->i_type = XLOG_REG_TYPE_ICORE; | 272 | vecp->i_type = XLOG_REG_TYPE_ICORE; |
283 | vecp++; | 273 | vecp++; |
@@ -323,18 +313,17 @@ xfs_inode_item_format( | |||
323 | ASSERT(ip->i_df.if_u1.if_extents != NULL); | 313 | ASSERT(ip->i_df.if_u1.if_extents != NULL); |
324 | ASSERT(ip->i_d.di_nextents > 0); | 314 | ASSERT(ip->i_d.di_nextents > 0); |
325 | ASSERT(iip->ili_extents_buf == NULL); | 315 | ASSERT(iip->ili_extents_buf == NULL); |
326 | nrecs = ip->i_df.if_bytes / | 316 | ASSERT((ip->i_df.if_bytes / |
327 | (uint)sizeof(xfs_bmbt_rec_t); | 317 | (uint)sizeof(xfs_bmbt_rec_t)) > 0); |
328 | ASSERT(nrecs > 0); | ||
329 | #ifdef XFS_NATIVE_HOST | 318 | #ifdef XFS_NATIVE_HOST |
330 | if (nrecs == ip->i_d.di_nextents) { | 319 | if (ip->i_d.di_nextents == ip->i_df.if_bytes / |
320 | (uint)sizeof(xfs_bmbt_rec_t)) { | ||
331 | /* | 321 | /* |
332 | * There are no delayed allocation | 322 | * There are no delayed allocation |
333 | * extents, so just point to the | 323 | * extents, so just point to the |
334 | * real extents array. | 324 | * real extents array. |
335 | */ | 325 | */ |
336 | vecp->i_addr = | 326 | vecp->i_addr = ip->i_df.if_u1.if_extents; |
337 | (char *)(ip->i_df.if_u1.if_extents); | ||
338 | vecp->i_len = ip->i_df.if_bytes; | 327 | vecp->i_len = ip->i_df.if_bytes; |
339 | vecp->i_type = XLOG_REG_TYPE_IEXT; | 328 | vecp->i_type = XLOG_REG_TYPE_IEXT; |
340 | } else | 329 | } else |
@@ -352,7 +341,7 @@ xfs_inode_item_format( | |||
352 | ext_buffer = kmem_alloc(ip->i_df.if_bytes, | 341 | ext_buffer = kmem_alloc(ip->i_df.if_bytes, |
353 | KM_SLEEP); | 342 | KM_SLEEP); |
354 | iip->ili_extents_buf = ext_buffer; | 343 | iip->ili_extents_buf = ext_buffer; |
355 | vecp->i_addr = (xfs_caddr_t)ext_buffer; | 344 | vecp->i_addr = ext_buffer; |
356 | vecp->i_len = xfs_iextents_copy(ip, ext_buffer, | 345 | vecp->i_len = xfs_iextents_copy(ip, ext_buffer, |
357 | XFS_DATA_FORK); | 346 | XFS_DATA_FORK); |
358 | vecp->i_type = XLOG_REG_TYPE_IEXT; | 347 | vecp->i_type = XLOG_REG_TYPE_IEXT; |
@@ -371,7 +360,7 @@ xfs_inode_item_format( | |||
371 | if (iip->ili_format.ilf_fields & XFS_ILOG_DBROOT) { | 360 | if (iip->ili_format.ilf_fields & XFS_ILOG_DBROOT) { |
372 | ASSERT(ip->i_df.if_broot_bytes > 0); | 361 | ASSERT(ip->i_df.if_broot_bytes > 0); |
373 | ASSERT(ip->i_df.if_broot != NULL); | 362 | ASSERT(ip->i_df.if_broot != NULL); |
374 | vecp->i_addr = (xfs_caddr_t)ip->i_df.if_broot; | 363 | vecp->i_addr = ip->i_df.if_broot; |
375 | vecp->i_len = ip->i_df.if_broot_bytes; | 364 | vecp->i_len = ip->i_df.if_broot_bytes; |
376 | vecp->i_type = XLOG_REG_TYPE_IBROOT; | 365 | vecp->i_type = XLOG_REG_TYPE_IBROOT; |
377 | vecp++; | 366 | vecp++; |
@@ -389,7 +378,7 @@ xfs_inode_item_format( | |||
389 | ASSERT(ip->i_df.if_u1.if_data != NULL); | 378 | ASSERT(ip->i_df.if_u1.if_data != NULL); |
390 | ASSERT(ip->i_d.di_size > 0); | 379 | ASSERT(ip->i_d.di_size > 0); |
391 | 380 | ||
392 | vecp->i_addr = (xfs_caddr_t)ip->i_df.if_u1.if_data; | 381 | vecp->i_addr = ip->i_df.if_u1.if_data; |
393 | /* | 382 | /* |
394 | * Round i_bytes up to a word boundary. | 383 | * Round i_bytes up to a word boundary. |
395 | * The underlying memory is guaranteed to | 384 | * The underlying memory is guaranteed to |
@@ -437,7 +426,7 @@ xfs_inode_item_format( | |||
437 | * Assert that no attribute-related log flags are set. | 426 | * Assert that no attribute-related log flags are set. |
438 | */ | 427 | */ |
439 | if (!XFS_IFORK_Q(ip)) { | 428 | if (!XFS_IFORK_Q(ip)) { |
440 | ASSERT(nvecs == iip->ili_item.li_desc->lid_size); | 429 | ASSERT(nvecs == lip->li_desc->lid_size); |
441 | iip->ili_format.ilf_size = nvecs; | 430 | iip->ili_format.ilf_size = nvecs; |
442 | ASSERT(!(iip->ili_format.ilf_fields & | 431 | ASSERT(!(iip->ili_format.ilf_fields & |
443 | (XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT))); | 432 | (XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT))); |
@@ -449,21 +438,21 @@ xfs_inode_item_format( | |||
449 | ASSERT(!(iip->ili_format.ilf_fields & | 438 | ASSERT(!(iip->ili_format.ilf_fields & |
450 | (XFS_ILOG_ADATA | XFS_ILOG_ABROOT))); | 439 | (XFS_ILOG_ADATA | XFS_ILOG_ABROOT))); |
451 | if (iip->ili_format.ilf_fields & XFS_ILOG_AEXT) { | 440 | if (iip->ili_format.ilf_fields & XFS_ILOG_AEXT) { |
452 | ASSERT(ip->i_afp->if_bytes > 0); | ||
453 | ASSERT(ip->i_afp->if_u1.if_extents != NULL); | ||
454 | ASSERT(ip->i_d.di_anextents > 0); | ||
455 | #ifdef DEBUG | 441 | #ifdef DEBUG |
456 | nrecs = ip->i_afp->if_bytes / | 442 | int nrecs = ip->i_afp->if_bytes / |
457 | (uint)sizeof(xfs_bmbt_rec_t); | 443 | (uint)sizeof(xfs_bmbt_rec_t); |
458 | #endif | ||
459 | ASSERT(nrecs > 0); | 444 | ASSERT(nrecs > 0); |
460 | ASSERT(nrecs == ip->i_d.di_anextents); | 445 | ASSERT(nrecs == ip->i_d.di_anextents); |
446 | ASSERT(ip->i_afp->if_bytes > 0); | ||
447 | ASSERT(ip->i_afp->if_u1.if_extents != NULL); | ||
448 | ASSERT(ip->i_d.di_anextents > 0); | ||
449 | #endif | ||
461 | #ifdef XFS_NATIVE_HOST | 450 | #ifdef XFS_NATIVE_HOST |
462 | /* | 451 | /* |
463 | * There are not delayed allocation extents | 452 | * There are not delayed allocation extents |
464 | * for attributes, so just point at the array. | 453 | * for attributes, so just point at the array. |
465 | */ | 454 | */ |
466 | vecp->i_addr = (char *)(ip->i_afp->if_u1.if_extents); | 455 | vecp->i_addr = ip->i_afp->if_u1.if_extents; |
467 | vecp->i_len = ip->i_afp->if_bytes; | 456 | vecp->i_len = ip->i_afp->if_bytes; |
468 | #else | 457 | #else |
469 | ASSERT(iip->ili_aextents_buf == NULL); | 458 | ASSERT(iip->ili_aextents_buf == NULL); |
@@ -473,7 +462,7 @@ xfs_inode_item_format( | |||
473 | ext_buffer = kmem_alloc(ip->i_afp->if_bytes, | 462 | ext_buffer = kmem_alloc(ip->i_afp->if_bytes, |
474 | KM_SLEEP); | 463 | KM_SLEEP); |
475 | iip->ili_aextents_buf = ext_buffer; | 464 | iip->ili_aextents_buf = ext_buffer; |
476 | vecp->i_addr = (xfs_caddr_t)ext_buffer; | 465 | vecp->i_addr = ext_buffer; |
477 | vecp->i_len = xfs_iextents_copy(ip, ext_buffer, | 466 | vecp->i_len = xfs_iextents_copy(ip, ext_buffer, |
478 | XFS_ATTR_FORK); | 467 | XFS_ATTR_FORK); |
479 | #endif | 468 | #endif |
@@ -490,7 +479,7 @@ xfs_inode_item_format( | |||
490 | if (iip->ili_format.ilf_fields & XFS_ILOG_ABROOT) { | 479 | if (iip->ili_format.ilf_fields & XFS_ILOG_ABROOT) { |
491 | ASSERT(ip->i_afp->if_broot_bytes > 0); | 480 | ASSERT(ip->i_afp->if_broot_bytes > 0); |
492 | ASSERT(ip->i_afp->if_broot != NULL); | 481 | ASSERT(ip->i_afp->if_broot != NULL); |
493 | vecp->i_addr = (xfs_caddr_t)ip->i_afp->if_broot; | 482 | vecp->i_addr = ip->i_afp->if_broot; |
494 | vecp->i_len = ip->i_afp->if_broot_bytes; | 483 | vecp->i_len = ip->i_afp->if_broot_bytes; |
495 | vecp->i_type = XLOG_REG_TYPE_IATTR_BROOT; | 484 | vecp->i_type = XLOG_REG_TYPE_IATTR_BROOT; |
496 | vecp++; | 485 | vecp++; |
@@ -506,7 +495,7 @@ xfs_inode_item_format( | |||
506 | ASSERT(ip->i_afp->if_bytes > 0); | 495 | ASSERT(ip->i_afp->if_bytes > 0); |
507 | ASSERT(ip->i_afp->if_u1.if_data != NULL); | 496 | ASSERT(ip->i_afp->if_u1.if_data != NULL); |
508 | 497 | ||
509 | vecp->i_addr = (xfs_caddr_t)ip->i_afp->if_u1.if_data; | 498 | vecp->i_addr = ip->i_afp->if_u1.if_data; |
510 | /* | 499 | /* |
511 | * Round i_bytes up to a word boundary. | 500 | * Round i_bytes up to a word boundary. |
512 | * The underlying memory is guaranteed to | 501 | * The underlying memory is guaranteed to |
@@ -528,7 +517,7 @@ xfs_inode_item_format( | |||
528 | break; | 517 | break; |
529 | } | 518 | } |
530 | 519 | ||
531 | ASSERT(nvecs == iip->ili_item.li_desc->lid_size); | 520 | ASSERT(nvecs == lip->li_desc->lid_size); |
532 | iip->ili_format.ilf_size = nvecs; | 521 | iip->ili_format.ilf_size = nvecs; |
533 | } | 522 | } |
534 | 523 | ||
@@ -539,12 +528,14 @@ xfs_inode_item_format( | |||
539 | */ | 528 | */ |
540 | STATIC void | 529 | STATIC void |
541 | xfs_inode_item_pin( | 530 | xfs_inode_item_pin( |
542 | xfs_inode_log_item_t *iip) | 531 | struct xfs_log_item *lip) |
543 | { | 532 | { |
544 | ASSERT(xfs_isilocked(iip->ili_inode, XFS_ILOCK_EXCL)); | 533 | struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode; |
534 | |||
535 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
545 | 536 | ||
546 | trace_xfs_inode_pin(iip->ili_inode, _RET_IP_); | 537 | trace_xfs_inode_pin(ip, _RET_IP_); |
547 | atomic_inc(&iip->ili_inode->i_pincount); | 538 | atomic_inc(&ip->i_pincount); |
548 | } | 539 | } |
549 | 540 | ||
550 | 541 | ||
@@ -554,12 +545,12 @@ xfs_inode_item_pin( | |||
554 | * | 545 | * |
555 | * Also wake up anyone in xfs_iunpin_wait() if the count goes to 0. | 546 | * Also wake up anyone in xfs_iunpin_wait() if the count goes to 0. |
556 | */ | 547 | */ |
557 | /* ARGSUSED */ | ||
558 | STATIC void | 548 | STATIC void |
559 | xfs_inode_item_unpin( | 549 | xfs_inode_item_unpin( |
560 | xfs_inode_log_item_t *iip) | 550 | struct xfs_log_item *lip, |
551 | int remove) | ||
561 | { | 552 | { |
562 | struct xfs_inode *ip = iip->ili_inode; | 553 | struct xfs_inode *ip = INODE_ITEM(lip)->ili_inode; |
563 | 554 | ||
564 | trace_xfs_inode_unpin(ip, _RET_IP_); | 555 | trace_xfs_inode_unpin(ip, _RET_IP_); |
565 | ASSERT(atomic_read(&ip->i_pincount) > 0); | 556 | ASSERT(atomic_read(&ip->i_pincount) > 0); |
@@ -567,15 +558,6 @@ xfs_inode_item_unpin( | |||
567 | wake_up(&ip->i_ipin_wait); | 558 | wake_up(&ip->i_ipin_wait); |
568 | } | 559 | } |
569 | 560 | ||
570 | /* ARGSUSED */ | ||
571 | STATIC void | ||
572 | xfs_inode_item_unpin_remove( | ||
573 | xfs_inode_log_item_t *iip, | ||
574 | xfs_trans_t *tp) | ||
575 | { | ||
576 | xfs_inode_item_unpin(iip); | ||
577 | } | ||
578 | |||
579 | /* | 561 | /* |
580 | * This is called to attempt to lock the inode associated with this | 562 | * This is called to attempt to lock the inode associated with this |
581 | * inode log item, in preparation for the push routine which does the actual | 563 | * inode log item, in preparation for the push routine which does the actual |
@@ -591,19 +573,16 @@ xfs_inode_item_unpin_remove( | |||
591 | */ | 573 | */ |
592 | STATIC uint | 574 | STATIC uint |
593 | xfs_inode_item_trylock( | 575 | xfs_inode_item_trylock( |
594 | xfs_inode_log_item_t *iip) | 576 | struct xfs_log_item *lip) |
595 | { | 577 | { |
596 | register xfs_inode_t *ip; | 578 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
597 | 579 | struct xfs_inode *ip = iip->ili_inode; | |
598 | ip = iip->ili_inode; | ||
599 | 580 | ||
600 | if (xfs_ipincount(ip) > 0) { | 581 | if (xfs_ipincount(ip) > 0) |
601 | return XFS_ITEM_PINNED; | 582 | return XFS_ITEM_PINNED; |
602 | } | ||
603 | 583 | ||
604 | if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { | 584 | if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) |
605 | return XFS_ITEM_LOCKED; | 585 | return XFS_ITEM_LOCKED; |
606 | } | ||
607 | 586 | ||
608 | if (!xfs_iflock_nowait(ip)) { | 587 | if (!xfs_iflock_nowait(ip)) { |
609 | /* | 588 | /* |
@@ -629,7 +608,7 @@ xfs_inode_item_trylock( | |||
629 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 608 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
630 | ASSERT(iip->ili_format.ilf_fields != 0); | 609 | ASSERT(iip->ili_format.ilf_fields != 0); |
631 | ASSERT(iip->ili_logged == 0); | 610 | ASSERT(iip->ili_logged == 0); |
632 | ASSERT(iip->ili_item.li_flags & XFS_LI_IN_AIL); | 611 | ASSERT(lip->li_flags & XFS_LI_IN_AIL); |
633 | } | 612 | } |
634 | #endif | 613 | #endif |
635 | return XFS_ITEM_SUCCESS; | 614 | return XFS_ITEM_SUCCESS; |
@@ -643,26 +622,18 @@ xfs_inode_item_trylock( | |||
643 | */ | 622 | */ |
644 | STATIC void | 623 | STATIC void |
645 | xfs_inode_item_unlock( | 624 | xfs_inode_item_unlock( |
646 | xfs_inode_log_item_t *iip) | 625 | struct xfs_log_item *lip) |
647 | { | 626 | { |
648 | uint hold; | 627 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
649 | uint iolocked; | 628 | struct xfs_inode *ip = iip->ili_inode; |
650 | uint lock_flags; | 629 | unsigned short lock_flags; |
651 | xfs_inode_t *ip; | ||
652 | 630 | ||
653 | ASSERT(iip != NULL); | ||
654 | ASSERT(iip->ili_inode->i_itemp != NULL); | 631 | ASSERT(iip->ili_inode->i_itemp != NULL); |
655 | ASSERT(xfs_isilocked(iip->ili_inode, XFS_ILOCK_EXCL)); | 632 | ASSERT(xfs_isilocked(iip->ili_inode, XFS_ILOCK_EXCL)); |
656 | ASSERT((!(iip->ili_inode->i_itemp->ili_flags & | 633 | |
657 | XFS_ILI_IOLOCKED_EXCL)) || | ||
658 | xfs_isilocked(iip->ili_inode, XFS_IOLOCK_EXCL)); | ||
659 | ASSERT((!(iip->ili_inode->i_itemp->ili_flags & | ||
660 | XFS_ILI_IOLOCKED_SHARED)) || | ||
661 | xfs_isilocked(iip->ili_inode, XFS_IOLOCK_SHARED)); | ||
662 | /* | 634 | /* |
663 | * Clear the transaction pointer in the inode. | 635 | * Clear the transaction pointer in the inode. |
664 | */ | 636 | */ |
665 | ip = iip->ili_inode; | ||
666 | ip->i_transp = NULL; | 637 | ip->i_transp = NULL; |
667 | 638 | ||
668 | /* | 639 | /* |
@@ -686,34 +657,11 @@ xfs_inode_item_unlock( | |||
686 | iip->ili_aextents_buf = NULL; | 657 | iip->ili_aextents_buf = NULL; |
687 | } | 658 | } |
688 | 659 | ||
689 | /* | 660 | lock_flags = iip->ili_lock_flags; |
690 | * Figure out if we should unlock the inode or not. | 661 | iip->ili_lock_flags = 0; |
691 | */ | 662 | if (lock_flags) { |
692 | hold = iip->ili_flags & XFS_ILI_HOLD; | 663 | xfs_iunlock(iip->ili_inode, lock_flags); |
693 | 664 | IRELE(iip->ili_inode); | |
694 | /* | ||
695 | * Before clearing out the flags, remember whether we | ||
696 | * are holding the inode's IO lock. | ||
697 | */ | ||
698 | iolocked = iip->ili_flags & XFS_ILI_IOLOCKED_ANY; | ||
699 | |||
700 | /* | ||
701 | * Clear out the fields of the inode log item particular | ||
702 | * to the current transaction. | ||
703 | */ | ||
704 | iip->ili_flags = 0; | ||
705 | |||
706 | /* | ||
707 | * Unlock the inode if XFS_ILI_HOLD was not set. | ||
708 | */ | ||
709 | if (!hold) { | ||
710 | lock_flags = XFS_ILOCK_EXCL; | ||
711 | if (iolocked & XFS_ILI_IOLOCKED_EXCL) { | ||
712 | lock_flags |= XFS_IOLOCK_EXCL; | ||
713 | } else if (iolocked & XFS_ILI_IOLOCKED_SHARED) { | ||
714 | lock_flags |= XFS_IOLOCK_SHARED; | ||
715 | } | ||
716 | xfs_iput(iip->ili_inode, lock_flags); | ||
717 | } | 665 | } |
718 | } | 666 | } |
719 | 667 | ||
@@ -725,13 +673,12 @@ xfs_inode_item_unlock( | |||
725 | * is the only one that matters. Therefore, simply return the | 673 | * is the only one that matters. Therefore, simply return the |
726 | * given lsn. | 674 | * given lsn. |
727 | */ | 675 | */ |
728 | /*ARGSUSED*/ | ||
729 | STATIC xfs_lsn_t | 676 | STATIC xfs_lsn_t |
730 | xfs_inode_item_committed( | 677 | xfs_inode_item_committed( |
731 | xfs_inode_log_item_t *iip, | 678 | struct xfs_log_item *lip, |
732 | xfs_lsn_t lsn) | 679 | xfs_lsn_t lsn) |
733 | { | 680 | { |
734 | return (lsn); | 681 | return lsn; |
735 | } | 682 | } |
736 | 683 | ||
737 | /* | 684 | /* |
@@ -743,13 +690,12 @@ xfs_inode_item_committed( | |||
743 | */ | 690 | */ |
744 | STATIC void | 691 | STATIC void |
745 | xfs_inode_item_pushbuf( | 692 | xfs_inode_item_pushbuf( |
746 | xfs_inode_log_item_t *iip) | 693 | struct xfs_log_item *lip) |
747 | { | 694 | { |
748 | xfs_inode_t *ip; | 695 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
749 | xfs_mount_t *mp; | 696 | struct xfs_inode *ip = iip->ili_inode; |
750 | xfs_buf_t *bp; | 697 | struct xfs_buf *bp; |
751 | 698 | ||
752 | ip = iip->ili_inode; | ||
753 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); | 699 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); |
754 | 700 | ||
755 | /* | 701 | /* |
@@ -757,14 +703,13 @@ xfs_inode_item_pushbuf( | |||
757 | * inode was taken off the AIL. So, just get out. | 703 | * inode was taken off the AIL. So, just get out. |
758 | */ | 704 | */ |
759 | if (completion_done(&ip->i_flush) || | 705 | if (completion_done(&ip->i_flush) || |
760 | ((iip->ili_item.li_flags & XFS_LI_IN_AIL) == 0)) { | 706 | !(lip->li_flags & XFS_LI_IN_AIL)) { |
761 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 707 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
762 | return; | 708 | return; |
763 | } | 709 | } |
764 | 710 | ||
765 | mp = ip->i_mount; | 711 | bp = xfs_incore(ip->i_mount->m_ddev_targp, iip->ili_format.ilf_blkno, |
766 | bp = xfs_incore(mp->m_ddev_targp, iip->ili_format.ilf_blkno, | 712 | iip->ili_format.ilf_len, XBF_TRYLOCK); |
767 | iip->ili_format.ilf_len, XBF_TRYLOCK); | ||
768 | 713 | ||
769 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 714 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
770 | if (!bp) | 715 | if (!bp) |
@@ -772,10 +717,8 @@ xfs_inode_item_pushbuf( | |||
772 | if (XFS_BUF_ISDELAYWRITE(bp)) | 717 | if (XFS_BUF_ISDELAYWRITE(bp)) |
773 | xfs_buf_delwri_promote(bp); | 718 | xfs_buf_delwri_promote(bp); |
774 | xfs_buf_relse(bp); | 719 | xfs_buf_relse(bp); |
775 | return; | ||
776 | } | 720 | } |
777 | 721 | ||
778 | |||
779 | /* | 722 | /* |
780 | * This is called to asynchronously write the inode associated with this | 723 | * This is called to asynchronously write the inode associated with this |
781 | * inode log item out to disk. The inode will already have been locked by | 724 | * inode log item out to disk. The inode will already have been locked by |
@@ -783,14 +726,14 @@ xfs_inode_item_pushbuf( | |||
783 | */ | 726 | */ |
784 | STATIC void | 727 | STATIC void |
785 | xfs_inode_item_push( | 728 | xfs_inode_item_push( |
786 | xfs_inode_log_item_t *iip) | 729 | struct xfs_log_item *lip) |
787 | { | 730 | { |
788 | xfs_inode_t *ip; | 731 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
789 | 732 | struct xfs_inode *ip = iip->ili_inode; | |
790 | ip = iip->ili_inode; | ||
791 | 733 | ||
792 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); | 734 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED)); |
793 | ASSERT(!completion_done(&ip->i_flush)); | 735 | ASSERT(!completion_done(&ip->i_flush)); |
736 | |||
794 | /* | 737 | /* |
795 | * Since we were able to lock the inode's flush lock and | 738 | * Since we were able to lock the inode's flush lock and |
796 | * we found it on the AIL, the inode must be dirty. This | 739 | * we found it on the AIL, the inode must be dirty. This |
@@ -813,43 +756,34 @@ xfs_inode_item_push( | |||
813 | */ | 756 | */ |
814 | (void) xfs_iflush(ip, 0); | 757 | (void) xfs_iflush(ip, 0); |
815 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 758 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
816 | |||
817 | return; | ||
818 | } | 759 | } |
819 | 760 | ||
820 | /* | 761 | /* |
821 | * XXX rcc - this one really has to do something. Probably needs | 762 | * XXX rcc - this one really has to do something. Probably needs |
822 | * to stamp in a new field in the incore inode. | 763 | * to stamp in a new field in the incore inode. |
823 | */ | 764 | */ |
824 | /* ARGSUSED */ | ||
825 | STATIC void | 765 | STATIC void |
826 | xfs_inode_item_committing( | 766 | xfs_inode_item_committing( |
827 | xfs_inode_log_item_t *iip, | 767 | struct xfs_log_item *lip, |
828 | xfs_lsn_t lsn) | 768 | xfs_lsn_t lsn) |
829 | { | 769 | { |
830 | iip->ili_last_lsn = lsn; | 770 | INODE_ITEM(lip)->ili_last_lsn = lsn; |
831 | return; | ||
832 | } | 771 | } |
833 | 772 | ||
834 | /* | 773 | /* |
835 | * This is the ops vector shared by all buf log items. | 774 | * This is the ops vector shared by all buf log items. |
836 | */ | 775 | */ |
837 | static struct xfs_item_ops xfs_inode_item_ops = { | 776 | static struct xfs_item_ops xfs_inode_item_ops = { |
838 | .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size, | 777 | .iop_size = xfs_inode_item_size, |
839 | .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) | 778 | .iop_format = xfs_inode_item_format, |
840 | xfs_inode_item_format, | 779 | .iop_pin = xfs_inode_item_pin, |
841 | .iop_pin = (void(*)(xfs_log_item_t*))xfs_inode_item_pin, | 780 | .iop_unpin = xfs_inode_item_unpin, |
842 | .iop_unpin = (void(*)(xfs_log_item_t*))xfs_inode_item_unpin, | 781 | .iop_trylock = xfs_inode_item_trylock, |
843 | .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*)) | 782 | .iop_unlock = xfs_inode_item_unlock, |
844 | xfs_inode_item_unpin_remove, | 783 | .iop_committed = xfs_inode_item_committed, |
845 | .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_inode_item_trylock, | 784 | .iop_push = xfs_inode_item_push, |
846 | .iop_unlock = (void(*)(xfs_log_item_t*))xfs_inode_item_unlock, | 785 | .iop_pushbuf = xfs_inode_item_pushbuf, |
847 | .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) | 786 | .iop_committing = xfs_inode_item_committing |
848 | xfs_inode_item_committed, | ||
849 | .iop_push = (void(*)(xfs_log_item_t*))xfs_inode_item_push, | ||
850 | .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_inode_item_pushbuf, | ||
851 | .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) | ||
852 | xfs_inode_item_committing | ||
853 | }; | 787 | }; |
854 | 788 | ||
855 | 789 | ||
@@ -858,10 +792,10 @@ static struct xfs_item_ops xfs_inode_item_ops = { | |||
858 | */ | 792 | */ |
859 | void | 793 | void |
860 | xfs_inode_item_init( | 794 | xfs_inode_item_init( |
861 | xfs_inode_t *ip, | 795 | struct xfs_inode *ip, |
862 | xfs_mount_t *mp) | 796 | struct xfs_mount *mp) |
863 | { | 797 | { |
864 | xfs_inode_log_item_t *iip; | 798 | struct xfs_inode_log_item *iip; |
865 | 799 | ||
866 | ASSERT(ip->i_itemp == NULL); | 800 | ASSERT(ip->i_itemp == NULL); |
867 | iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP); | 801 | iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP); |
@@ -899,14 +833,14 @@ xfs_inode_item_destroy( | |||
899 | * from the AIL if it has not been re-logged, and unlocking the inode's | 833 | * from the AIL if it has not been re-logged, and unlocking the inode's |
900 | * flush lock. | 834 | * flush lock. |
901 | */ | 835 | */ |
902 | /*ARGSUSED*/ | ||
903 | void | 836 | void |
904 | xfs_iflush_done( | 837 | xfs_iflush_done( |
905 | xfs_buf_t *bp, | 838 | struct xfs_buf *bp, |
906 | xfs_inode_log_item_t *iip) | 839 | struct xfs_log_item *lip) |
907 | { | 840 | { |
841 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); | ||
908 | xfs_inode_t *ip = iip->ili_inode; | 842 | xfs_inode_t *ip = iip->ili_inode; |
909 | struct xfs_ail *ailp = iip->ili_item.li_ailp; | 843 | struct xfs_ail *ailp = lip->li_ailp; |
910 | 844 | ||
911 | /* | 845 | /* |
912 | * We only want to pull the item from the AIL if it is | 846 | * We only want to pull the item from the AIL if it is |
@@ -917,12 +851,11 @@ xfs_iflush_done( | |||
917 | * the lock since it's cheaper, and then we recheck while | 851 | * the lock since it's cheaper, and then we recheck while |
918 | * holding the lock before removing the inode from the AIL. | 852 | * holding the lock before removing the inode from the AIL. |
919 | */ | 853 | */ |
920 | if (iip->ili_logged && | 854 | if (iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn) { |
921 | (iip->ili_item.li_lsn == iip->ili_flush_lsn)) { | ||
922 | spin_lock(&ailp->xa_lock); | 855 | spin_lock(&ailp->xa_lock); |
923 | if (iip->ili_item.li_lsn == iip->ili_flush_lsn) { | 856 | if (lip->li_lsn == iip->ili_flush_lsn) { |
924 | /* xfs_trans_ail_delete() drops the AIL lock. */ | 857 | /* xfs_trans_ail_delete() drops the AIL lock. */ |
925 | xfs_trans_ail_delete(ailp, (xfs_log_item_t*)iip); | 858 | xfs_trans_ail_delete(ailp, lip); |
926 | } else { | 859 | } else { |
927 | spin_unlock(&ailp->xa_lock); | 860 | spin_unlock(&ailp->xa_lock); |
928 | } | 861 | } |
@@ -940,8 +873,6 @@ xfs_iflush_done( | |||
940 | * Release the inode's flush lock since we're done with it. | 873 | * Release the inode's flush lock since we're done with it. |
941 | */ | 874 | */ |
942 | xfs_ifunlock(ip); | 875 | xfs_ifunlock(ip); |
943 | |||
944 | return; | ||
945 | } | 876 | } |
946 | 877 | ||
947 | /* | 878 | /* |
@@ -957,10 +888,8 @@ xfs_iflush_abort( | |||
957 | xfs_inode_t *ip) | 888 | xfs_inode_t *ip) |
958 | { | 889 | { |
959 | xfs_inode_log_item_t *iip = ip->i_itemp; | 890 | xfs_inode_log_item_t *iip = ip->i_itemp; |
960 | xfs_mount_t *mp; | ||
961 | 891 | ||
962 | iip = ip->i_itemp; | 892 | iip = ip->i_itemp; |
963 | mp = ip->i_mount; | ||
964 | if (iip) { | 893 | if (iip) { |
965 | struct xfs_ail *ailp = iip->ili_item.li_ailp; | 894 | struct xfs_ail *ailp = iip->ili_item.li_ailp; |
966 | if (iip->ili_item.li_flags & XFS_LI_IN_AIL) { | 895 | if (iip->ili_item.li_flags & XFS_LI_IN_AIL) { |
@@ -991,10 +920,10 @@ xfs_iflush_abort( | |||
991 | 920 | ||
992 | void | 921 | void |
993 | xfs_istale_done( | 922 | xfs_istale_done( |
994 | xfs_buf_t *bp, | 923 | struct xfs_buf *bp, |
995 | xfs_inode_log_item_t *iip) | 924 | struct xfs_log_item *lip) |
996 | { | 925 | { |
997 | xfs_iflush_abort(iip->ili_inode); | 926 | xfs_iflush_abort(INODE_ITEM(lip)->ili_inode); |
998 | } | 927 | } |
999 | 928 | ||
1000 | /* | 929 | /* |
@@ -1007,9 +936,8 @@ xfs_inode_item_format_convert( | |||
1007 | xfs_inode_log_format_t *in_f) | 936 | xfs_inode_log_format_t *in_f) |
1008 | { | 937 | { |
1009 | if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) { | 938 | if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) { |
1010 | xfs_inode_log_format_32_t *in_f32; | 939 | xfs_inode_log_format_32_t *in_f32 = buf->i_addr; |
1011 | 940 | ||
1012 | in_f32 = (xfs_inode_log_format_32_t *)buf->i_addr; | ||
1013 | in_f->ilf_type = in_f32->ilf_type; | 941 | in_f->ilf_type = in_f32->ilf_type; |
1014 | in_f->ilf_size = in_f32->ilf_size; | 942 | in_f->ilf_size = in_f32->ilf_size; |
1015 | in_f->ilf_fields = in_f32->ilf_fields; | 943 | in_f->ilf_fields = in_f32->ilf_fields; |
@@ -1025,9 +953,8 @@ xfs_inode_item_format_convert( | |||
1025 | in_f->ilf_boffset = in_f32->ilf_boffset; | 953 | in_f->ilf_boffset = in_f32->ilf_boffset; |
1026 | return 0; | 954 | return 0; |
1027 | } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){ | 955 | } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){ |
1028 | xfs_inode_log_format_64_t *in_f64; | 956 | xfs_inode_log_format_64_t *in_f64 = buf->i_addr; |
1029 | 957 | ||
1030 | in_f64 = (xfs_inode_log_format_64_t *)buf->i_addr; | ||
1031 | in_f->ilf_type = in_f64->ilf_type; | 958 | in_f->ilf_type = in_f64->ilf_type; |
1032 | in_f->ilf_size = in_f64->ilf_size; | 959 | in_f->ilf_size = in_f64->ilf_size; |
1033 | in_f->ilf_fields = in_f64->ilf_fields; | 960 | in_f->ilf_fields = in_f64->ilf_fields; |