diff options
Diffstat (limited to 'fs/xfs/xfs_inode_item.c')
-rw-r--r-- | fs/xfs/xfs_inode_item.c | 141 |
1 files changed, 65 insertions, 76 deletions
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index a01990dbb94..2626aaca42f 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -36,6 +36,12 @@ | |||
36 | 36 | ||
37 | kmem_zone_t *xfs_ili_zone; /* inode log item zone */ | 37 | kmem_zone_t *xfs_ili_zone; /* inode log item zone */ |
38 | 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 | |||
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 | */ |
46 | STATIC uint | 52 | STATIC uint |
47 | xfs_inode_item_size( | 53 | xfs_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 | */ |
203 | STATIC void | 207 | STATIC void |
204 | xfs_inode_item_format( | 208 | xfs_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 | */ |
530 | STATIC void | 531 | STATIC void |
531 | xfs_inode_item_pin( | 532 | xfs_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 | */ |
547 | STATIC void | 550 | STATIC void |
548 | xfs_inode_item_unpin( | 551 | xfs_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 | */ |
573 | STATIC uint | 576 | STATIC uint |
574 | xfs_inode_item_trylock( | 577 | xfs_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 | */ |
625 | STATIC void | 625 | STATIC void |
626 | xfs_inode_item_unlock( | 626 | xfs_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*/ | ||
710 | STATIC xfs_lsn_t | 710 | STATIC xfs_lsn_t |
711 | xfs_inode_item_committed( | 711 | xfs_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 | */ |
725 | STATIC void | 725 | STATIC void |
726 | xfs_inode_item_pushbuf( | 726 | xfs_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 | */ |
765 | STATIC void | 761 | STATIC void |
766 | xfs_inode_item_push( | 762 | xfs_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 */ | ||
806 | STATIC void | 799 | STATIC void |
807 | xfs_inode_item_committing( | 800 | xfs_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 | */ |
818 | static struct xfs_item_ops xfs_inode_item_ops = { | 810 | static 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 | */ |
838 | void | 827 | void |
839 | xfs_inode_item_init( | 828 | xfs_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); |