diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-04-03 01:11:30 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-04-27 14:01:58 -0400 |
commit | 61fe135c1dde112f483bba01d645debd881b5428 (patch) | |
tree | 6ec57ed9730f555b29b94aeb6983b4ddbebffe51 /fs/xfs/xfs_trans_buf.c | |
parent | d75afeb3d302019527331520a2632b6614425b40 (diff) |
xfs: buffer type overruns blf_flags field
The buffer type passed to log recvoery in the buffer log item
overruns the blf_flags field. I had assumed that flags field was a
32 bit value, and it turns out it is a unisgned short. Therefore
having 19 flags doesn't really work.
Convert the buffer type field to numeric value, and use the top 5
bits of the flags field for it. We currently have 17 types of
buffers, so using 5 bits gives us plenty of room for expansion in
future....
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_trans_buf.c')
-rw-r--r-- | fs/xfs/xfs_trans_buf.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 40871bf607f0..73a5fa457e16 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -659,7 +659,7 @@ xfs_trans_binval( | |||
659 | ASSERT(XFS_BUF_ISSTALE(bp)); | 659 | ASSERT(XFS_BUF_ISSTALE(bp)); |
660 | ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY))); | 660 | ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY))); |
661 | ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_INODE_BUF)); | 661 | ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_INODE_BUF)); |
662 | ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_TYPE_MASK)); | 662 | ASSERT(!(bip->__bli_format.blf_flags & XFS_BLFT_MASK)); |
663 | ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); | 663 | ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); |
664 | ASSERT(bip->bli_item.li_desc->lid_flags & XFS_LID_DIRTY); | 664 | ASSERT(bip->bli_item.li_desc->lid_flags & XFS_LID_DIRTY); |
665 | ASSERT(tp->t_flags & XFS_TRANS_DIRTY); | 665 | ASSERT(tp->t_flags & XFS_TRANS_DIRTY); |
@@ -672,7 +672,7 @@ xfs_trans_binval( | |||
672 | bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); | 672 | bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); |
673 | bip->__bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; | 673 | bip->__bli_format.blf_flags &= ~XFS_BLF_INODE_BUF; |
674 | bip->__bli_format.blf_flags |= XFS_BLF_CANCEL; | 674 | bip->__bli_format.blf_flags |= XFS_BLF_CANCEL; |
675 | bip->__bli_format.blf_flags &= ~XFS_BLF_TYPE_MASK; | 675 | bip->__bli_format.blf_flags &= ~XFS_BLFT_MASK; |
676 | for (i = 0; i < bip->bli_format_count; i++) { | 676 | for (i = 0; i < bip->bli_format_count; i++) { |
677 | memset(bip->bli_formats[i].blf_data_map, 0, | 677 | memset(bip->bli_formats[i].blf_data_map, 0, |
678 | (bip->bli_formats[i].blf_map_size * sizeof(uint))); | 678 | (bip->bli_formats[i].blf_map_size * sizeof(uint))); |
@@ -704,7 +704,7 @@ xfs_trans_inode_buf( | |||
704 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 704 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
705 | 705 | ||
706 | bip->bli_flags |= XFS_BLI_INODE_BUF; | 706 | bip->bli_flags |= XFS_BLI_INODE_BUF; |
707 | xfs_trans_buf_set_type(tp, bp, XFS_BLF_DINO_BUF); | 707 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF); |
708 | } | 708 | } |
709 | 709 | ||
710 | /* | 710 | /* |
@@ -729,7 +729,7 @@ xfs_trans_stale_inode_buf( | |||
729 | 729 | ||
730 | bip->bli_flags |= XFS_BLI_STALE_INODE; | 730 | bip->bli_flags |= XFS_BLI_STALE_INODE; |
731 | bip->bli_item.li_cb = xfs_buf_iodone; | 731 | bip->bli_item.li_cb = xfs_buf_iodone; |
732 | xfs_trans_buf_set_type(tp, bp, XFS_BLF_DINO_BUF); | 732 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF); |
733 | } | 733 | } |
734 | 734 | ||
735 | /* | 735 | /* |
@@ -753,7 +753,7 @@ xfs_trans_inode_alloc_buf( | |||
753 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 753 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
754 | 754 | ||
755 | bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF; | 755 | bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF; |
756 | xfs_trans_buf_set_type(tp, bp, XFS_BLF_DINO_BUF); | 756 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DINO_BUF); |
757 | } | 757 | } |
758 | 758 | ||
759 | /* | 759 | /* |
@@ -764,7 +764,7 @@ void | |||
764 | xfs_trans_buf_set_type( | 764 | xfs_trans_buf_set_type( |
765 | struct xfs_trans *tp, | 765 | struct xfs_trans *tp, |
766 | struct xfs_buf *bp, | 766 | struct xfs_buf *bp, |
767 | uint type) | 767 | enum xfs_blft type) |
768 | { | 768 | { |
769 | struct xfs_buf_log_item *bip = bp->b_fspriv; | 769 | struct xfs_buf_log_item *bip = bp->b_fspriv; |
770 | 770 | ||
@@ -774,10 +774,8 @@ xfs_trans_buf_set_type( | |||
774 | ASSERT(bp->b_transp == tp); | 774 | ASSERT(bp->b_transp == tp); |
775 | ASSERT(bip != NULL); | 775 | ASSERT(bip != NULL); |
776 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 776 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
777 | ASSERT((type & XFS_BLF_TYPE_MASK) != 0); | ||
778 | 777 | ||
779 | bip->__bli_format.blf_flags &= ~XFS_BLF_TYPE_MASK; | 778 | xfs_blft_to_flags(&bip->__bli_format, type); |
780 | bip->__bli_format.blf_flags |= type; | ||
781 | } | 779 | } |
782 | 780 | ||
783 | void | 781 | void |
@@ -787,11 +785,10 @@ xfs_trans_buf_copy_type( | |||
787 | { | 785 | { |
788 | struct xfs_buf_log_item *sbip = src_bp->b_fspriv; | 786 | struct xfs_buf_log_item *sbip = src_bp->b_fspriv; |
789 | struct xfs_buf_log_item *dbip = dst_bp->b_fspriv; | 787 | struct xfs_buf_log_item *dbip = dst_bp->b_fspriv; |
790 | uint type; | 788 | enum xfs_blft type; |
791 | 789 | ||
792 | type = sbip->__bli_format.blf_flags & XFS_BLF_TYPE_MASK; | 790 | type = xfs_blft_from_flags(&sbip->__bli_format); |
793 | dbip->__bli_format.blf_flags &= ~XFS_BLF_TYPE_MASK; | 791 | xfs_blft_to_flags(&dbip->__bli_format, type); |
794 | dbip->__bli_format.blf_flags |= type; | ||
795 | } | 792 | } |
796 | 793 | ||
797 | /* | 794 | /* |
@@ -811,9 +808,28 @@ xfs_trans_dquot_buf( | |||
811 | xfs_buf_t *bp, | 808 | xfs_buf_t *bp, |
812 | uint type) | 809 | uint type) |
813 | { | 810 | { |
811 | struct xfs_buf_log_item *bip = bp->b_fspriv; | ||
812 | |||
814 | ASSERT(type == XFS_BLF_UDQUOT_BUF || | 813 | ASSERT(type == XFS_BLF_UDQUOT_BUF || |
815 | type == XFS_BLF_PDQUOT_BUF || | 814 | type == XFS_BLF_PDQUOT_BUF || |
816 | type == XFS_BLF_GDQUOT_BUF); | 815 | type == XFS_BLF_GDQUOT_BUF); |
817 | 816 | ||
817 | bip->__bli_format.blf_flags |= type; | ||
818 | |||
819 | switch (type) { | ||
820 | case XFS_BLF_UDQUOT_BUF: | ||
821 | type = XFS_BLFT_UDQUOT_BUF; | ||
822 | break; | ||
823 | case XFS_BLF_PDQUOT_BUF: | ||
824 | type = XFS_BLFT_PDQUOT_BUF; | ||
825 | break; | ||
826 | case XFS_BLF_GDQUOT_BUF: | ||
827 | type = XFS_BLFT_GDQUOT_BUF; | ||
828 | break; | ||
829 | default: | ||
830 | type = XFS_BLFT_UNKNOWN_BUF; | ||
831 | break; | ||
832 | } | ||
833 | |||
818 | xfs_trans_buf_set_type(tp, bp, type); | 834 | xfs_trans_buf_set_type(tp, bp, type); |
819 | } | 835 | } |