diff options
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 4f201656d2d9..202ce37e66cb 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -786,6 +786,7 @@ xfs_iformat_btree( | |||
786 | xfs_dinode_t *dip, | 786 | xfs_dinode_t *dip, |
787 | int whichfork) | 787 | int whichfork) |
788 | { | 788 | { |
789 | struct xfs_mount *mp = ip->i_mount; | ||
789 | xfs_bmdr_block_t *dfp; | 790 | xfs_bmdr_block_t *dfp; |
790 | xfs_ifork_t *ifp; | 791 | xfs_ifork_t *ifp; |
791 | /* REFERENCED */ | 792 | /* REFERENCED */ |
@@ -794,7 +795,7 @@ xfs_iformat_btree( | |||
794 | 795 | ||
795 | ifp = XFS_IFORK_PTR(ip, whichfork); | 796 | ifp = XFS_IFORK_PTR(ip, whichfork); |
796 | dfp = (xfs_bmdr_block_t *)XFS_DFORK_PTR(dip, whichfork); | 797 | dfp = (xfs_bmdr_block_t *)XFS_DFORK_PTR(dip, whichfork); |
797 | size = XFS_BMAP_BROOT_SPACE(dfp); | 798 | size = XFS_BMAP_BROOT_SPACE(mp, dfp); |
798 | nrecs = be16_to_cpu(dfp->bb_numrecs); | 799 | nrecs = be16_to_cpu(dfp->bb_numrecs); |
799 | 800 | ||
800 | /* | 801 | /* |
@@ -805,14 +806,14 @@ xfs_iformat_btree( | |||
805 | * blocks. | 806 | * blocks. |
806 | */ | 807 | */ |
807 | if (unlikely(XFS_IFORK_NEXTENTS(ip, whichfork) <= | 808 | if (unlikely(XFS_IFORK_NEXTENTS(ip, whichfork) <= |
808 | XFS_IFORK_MAXEXT(ip, whichfork) || | 809 | XFS_IFORK_MAXEXT(ip, whichfork) || |
809 | XFS_BMDR_SPACE_CALC(nrecs) > | 810 | XFS_BMDR_SPACE_CALC(nrecs) > |
810 | XFS_DFORK_SIZE(dip, ip->i_mount, whichfork) || | 811 | XFS_DFORK_SIZE(dip, mp, whichfork) || |
811 | XFS_IFORK_NEXTENTS(ip, whichfork) > ip->i_d.di_nblocks)) { | 812 | XFS_IFORK_NEXTENTS(ip, whichfork) > ip->i_d.di_nblocks)) { |
812 | xfs_warn(ip->i_mount, "corrupt inode %Lu (btree).", | 813 | xfs_warn(mp, "corrupt inode %Lu (btree).", |
813 | (unsigned long long) ip->i_ino); | 814 | (unsigned long long) ip->i_ino); |
814 | XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW, | 815 | XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW, |
815 | ip->i_mount, dip); | 816 | mp, dip); |
816 | return XFS_ERROR(EFSCORRUPTED); | 817 | return XFS_ERROR(EFSCORRUPTED); |
817 | } | 818 | } |
818 | 819 | ||
@@ -823,8 +824,7 @@ xfs_iformat_btree( | |||
823 | * Copy and convert from the on-disk structure | 824 | * Copy and convert from the on-disk structure |
824 | * to the in-memory structure. | 825 | * to the in-memory structure. |
825 | */ | 826 | */ |
826 | xfs_bmdr_to_bmbt(ip->i_mount, dfp, | 827 | xfs_bmdr_to_bmbt(ip, dfp, XFS_DFORK_SIZE(dip, ip->i_mount, whichfork), |
827 | XFS_DFORK_SIZE(dip, ip->i_mount, whichfork), | ||
828 | ifp->if_broot, size); | 828 | ifp->if_broot, size); |
829 | ifp->if_flags &= ~XFS_IFEXTENTS; | 829 | ifp->if_flags &= ~XFS_IFEXTENTS; |
830 | ifp->if_flags |= XFS_IFBROOT; | 830 | ifp->if_flags |= XFS_IFBROOT; |
@@ -2037,7 +2037,7 @@ xfs_iroot_realloc( | |||
2037 | * allocate it now and get out. | 2037 | * allocate it now and get out. |
2038 | */ | 2038 | */ |
2039 | if (ifp->if_broot_bytes == 0) { | 2039 | if (ifp->if_broot_bytes == 0) { |
2040 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(rec_diff); | 2040 | new_size = XFS_BMAP_BROOT_SPACE_CALC(mp, rec_diff); |
2041 | ifp->if_broot = kmem_alloc(new_size, KM_SLEEP | KM_NOFS); | 2041 | ifp->if_broot = kmem_alloc(new_size, KM_SLEEP | KM_NOFS); |
2042 | ifp->if_broot_bytes = (int)new_size; | 2042 | ifp->if_broot_bytes = (int)new_size; |
2043 | return; | 2043 | return; |
@@ -2051,9 +2051,9 @@ xfs_iroot_realloc( | |||
2051 | */ | 2051 | */ |
2052 | cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0); | 2052 | cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0); |
2053 | new_max = cur_max + rec_diff; | 2053 | new_max = cur_max + rec_diff; |
2054 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(new_max); | 2054 | new_size = XFS_BMAP_BROOT_SPACE_CALC(mp, new_max); |
2055 | ifp->if_broot = kmem_realloc(ifp->if_broot, new_size, | 2055 | ifp->if_broot = kmem_realloc(ifp->if_broot, new_size, |
2056 | (size_t)XFS_BMAP_BROOT_SPACE_CALC(cur_max), /* old size */ | 2056 | XFS_BMAP_BROOT_SPACE_CALC(mp, cur_max), |
2057 | KM_SLEEP | KM_NOFS); | 2057 | KM_SLEEP | KM_NOFS); |
2058 | op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, | 2058 | op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, |
2059 | ifp->if_broot_bytes); | 2059 | ifp->if_broot_bytes); |
@@ -2061,7 +2061,7 @@ xfs_iroot_realloc( | |||
2061 | (int)new_size); | 2061 | (int)new_size); |
2062 | ifp->if_broot_bytes = (int)new_size; | 2062 | ifp->if_broot_bytes = (int)new_size; |
2063 | ASSERT(ifp->if_broot_bytes <= | 2063 | ASSERT(ifp->if_broot_bytes <= |
2064 | XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ); | 2064 | XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ(ip)); |
2065 | memmove(np, op, cur_max * (uint)sizeof(xfs_dfsbno_t)); | 2065 | memmove(np, op, cur_max * (uint)sizeof(xfs_dfsbno_t)); |
2066 | return; | 2066 | return; |
2067 | } | 2067 | } |
@@ -2076,7 +2076,7 @@ xfs_iroot_realloc( | |||
2076 | new_max = cur_max + rec_diff; | 2076 | new_max = cur_max + rec_diff; |
2077 | ASSERT(new_max >= 0); | 2077 | ASSERT(new_max >= 0); |
2078 | if (new_max > 0) | 2078 | if (new_max > 0) |
2079 | new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(new_max); | 2079 | new_size = XFS_BMAP_BROOT_SPACE_CALC(mp, new_max); |
2080 | else | 2080 | else |
2081 | new_size = 0; | 2081 | new_size = 0; |
2082 | if (new_size > 0) { | 2082 | if (new_size > 0) { |
@@ -2084,7 +2084,8 @@ xfs_iroot_realloc( | |||
2084 | /* | 2084 | /* |
2085 | * First copy over the btree block header. | 2085 | * First copy over the btree block header. |
2086 | */ | 2086 | */ |
2087 | memcpy(new_broot, ifp->if_broot, XFS_BTREE_LBLOCK_LEN); | 2087 | memcpy(new_broot, ifp->if_broot, |
2088 | XFS_BMBT_BLOCK_LEN(ip->i_mount)); | ||
2088 | } else { | 2089 | } else { |
2089 | new_broot = NULL; | 2090 | new_broot = NULL; |
2090 | ifp->if_flags &= ~XFS_IFBROOT; | 2091 | ifp->if_flags &= ~XFS_IFBROOT; |
@@ -2114,7 +2115,7 @@ xfs_iroot_realloc( | |||
2114 | ifp->if_broot = new_broot; | 2115 | ifp->if_broot = new_broot; |
2115 | ifp->if_broot_bytes = (int)new_size; | 2116 | ifp->if_broot_bytes = (int)new_size; |
2116 | ASSERT(ifp->if_broot_bytes <= | 2117 | ASSERT(ifp->if_broot_bytes <= |
2117 | XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ); | 2118 | XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ(ip)); |
2118 | return; | 2119 | return; |
2119 | } | 2120 | } |
2120 | 2121 | ||
@@ -2427,7 +2428,7 @@ xfs_iflush_fork( | |||
2427 | ASSERT(ifp->if_broot != NULL); | 2428 | ASSERT(ifp->if_broot != NULL); |
2428 | ASSERT(ifp->if_broot_bytes <= | 2429 | ASSERT(ifp->if_broot_bytes <= |
2429 | (XFS_IFORK_SIZE(ip, whichfork) + | 2430 | (XFS_IFORK_SIZE(ip, whichfork) + |
2430 | XFS_BROOT_SIZE_ADJ)); | 2431 | XFS_BROOT_SIZE_ADJ(ip))); |
2431 | xfs_bmbt_to_bmdr(mp, ifp->if_broot, ifp->if_broot_bytes, | 2432 | xfs_bmbt_to_bmdr(mp, ifp->if_broot, ifp->if_broot_bytes, |
2432 | (xfs_bmdr_block_t *)cp, | 2433 | (xfs_bmdr_block_t *)cp, |
2433 | XFS_DFORK_SIZE(dip, mp, whichfork)); | 2434 | XFS_DFORK_SIZE(dip, mp, whichfork)); |