diff options
author | Christoph Hellwig <hch@lst.de> | 2008-11-27 22:23:41 -0500 |
---|---|---|
committer | Niv Sardi <xaiki@sgi.com> | 2008-11-30 19:38:08 -0500 |
commit | 92bfc6e7c4eabbbd15e7d6d49123b296d05dcfd1 (patch) | |
tree | 4b409ecbc4b0704189b05989fae0a423bb557efd /fs/xfs/xfs_inode.c | |
parent | 94e1b69d1abd108d306e926c3012ec89e481c0da (diff) |
[XFS] embededd struct xfs_imap into xfs_inode
Most uses of struct xfs_imap are to map and inode to a buffer. To avoid
copying around the inode location information we should just embedd a
strcut xfs_imap into the xfs_inode. To make sure it doesn't bloat an
inode the im_len is changed to a ushort, which is fine as that's what
the users exepect anyway.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Niv Sardi <xaiki@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index bf528b725ae1..72dc7a87a14b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "xfs_bit.h" | 23 | #include "xfs_bit.h" |
24 | #include "xfs_log.h" | 24 | #include "xfs_log.h" |
25 | #include "xfs_inum.h" | 25 | #include "xfs_inum.h" |
26 | #include "xfs_imap.h" | ||
27 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
28 | #include "xfs_trans_priv.h" | 27 | #include "xfs_trans_priv.h" |
29 | #include "xfs_sb.h" | 28 | #include "xfs_sb.h" |
@@ -134,7 +133,7 @@ STATIC int | |||
134 | xfs_imap_to_bp( | 133 | xfs_imap_to_bp( |
135 | xfs_mount_t *mp, | 134 | xfs_mount_t *mp, |
136 | xfs_trans_t *tp, | 135 | xfs_trans_t *tp, |
137 | xfs_imap_t *imap, | 136 | struct xfs_imap *imap, |
138 | xfs_buf_t **bpp, | 137 | xfs_buf_t **bpp, |
139 | uint buf_flags, | 138 | uint buf_flags, |
140 | uint imap_flags) | 139 | uint imap_flags) |
@@ -232,7 +231,7 @@ xfs_inotobp( | |||
232 | int *offset, | 231 | int *offset, |
233 | uint imap_flags) | 232 | uint imap_flags) |
234 | { | 233 | { |
235 | xfs_imap_t imap; | 234 | struct xfs_imap imap; |
236 | xfs_buf_t *bp; | 235 | xfs_buf_t *bp; |
237 | int error; | 236 | int error; |
238 | 237 | ||
@@ -277,17 +276,12 @@ xfs_itobp( | |||
277 | xfs_buf_t **bpp, | 276 | xfs_buf_t **bpp, |
278 | uint buf_flags) | 277 | uint buf_flags) |
279 | { | 278 | { |
280 | xfs_imap_t imap; | ||
281 | xfs_buf_t *bp; | 279 | xfs_buf_t *bp; |
282 | int error; | 280 | int error; |
283 | 281 | ||
284 | ASSERT(ip->i_blkno != 0); | 282 | ASSERT(ip->i_imap.im_blkno != 0); |
285 | 283 | ||
286 | imap.im_blkno = ip->i_blkno; | 284 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, buf_flags, 0); |
287 | imap.im_len = ip->i_len; | ||
288 | imap.im_boffset = ip->i_boffset; | ||
289 | |||
290 | error = xfs_imap_to_bp(mp, tp, &imap, &bp, buf_flags, 0); | ||
291 | if (error) | 285 | if (error) |
292 | return error; | 286 | return error; |
293 | 287 | ||
@@ -298,7 +292,7 @@ xfs_itobp( | |||
298 | return EAGAIN; | 292 | return EAGAIN; |
299 | } | 293 | } |
300 | 294 | ||
301 | *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, imap.im_boffset); | 295 | *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); |
302 | *bpp = bp; | 296 | *bpp = bp; |
303 | return 0; | 297 | return 0; |
304 | } | 298 | } |
@@ -799,9 +793,7 @@ xfs_inode_alloc( | |||
799 | /* initialise the xfs inode */ | 793 | /* initialise the xfs inode */ |
800 | ip->i_ino = ino; | 794 | ip->i_ino = ino; |
801 | ip->i_mount = mp; | 795 | ip->i_mount = mp; |
802 | ip->i_blkno = 0; | 796 | memset(&ip->i_imap, 0, sizeof(struct xfs_imap)); |
803 | ip->i_len = 0; | ||
804 | ip->i_boffset =0; | ||
805 | ip->i_afp = NULL; | 797 | ip->i_afp = NULL; |
806 | memset(&ip->i_df, 0, sizeof(xfs_ifork_t)); | 798 | memset(&ip->i_df, 0, sizeof(xfs_ifork_t)); |
807 | ip->i_flags = 0; | 799 | ip->i_flags = 0; |
@@ -857,7 +849,6 @@ xfs_iread( | |||
857 | xfs_buf_t *bp; | 849 | xfs_buf_t *bp; |
858 | xfs_dinode_t *dip; | 850 | xfs_dinode_t *dip; |
859 | xfs_inode_t *ip; | 851 | xfs_inode_t *ip; |
860 | xfs_imap_t imap; | ||
861 | int error; | 852 | int error; |
862 | 853 | ||
863 | ip = xfs_inode_alloc(mp, ino); | 854 | ip = xfs_inode_alloc(mp, ino); |
@@ -865,26 +856,22 @@ xfs_iread( | |||
865 | return ENOMEM; | 856 | return ENOMEM; |
866 | 857 | ||
867 | /* | 858 | /* |
868 | * Get pointers to the on-disk inode and the buffer containing it. | 859 | * Fill in the location information in the in-core inode. |
869 | */ | 860 | */ |
870 | imap.im_blkno = bno; | 861 | ip->i_imap.im_blkno = bno; |
871 | error = xfs_imap(mp, tp, ip->i_ino, &imap, imap_flags); | 862 | error = xfs_imap(mp, tp, ip->i_ino, &ip->i_imap, imap_flags); |
872 | if (error) | 863 | if (error) |
873 | goto out_destroy_inode; | 864 | goto out_destroy_inode; |
865 | ASSERT(bno == 0 || bno == ip->i_imap.im_blkno); | ||
874 | 866 | ||
875 | /* | 867 | /* |
876 | * Fill in the fields in the inode that will be used to | 868 | * Get pointers to the on-disk inode and the buffer containing it. |
877 | * map the inode to its buffer from now on. | ||
878 | */ | 869 | */ |
879 | ip->i_blkno = imap.im_blkno; | 870 | error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, |
880 | ip->i_len = imap.im_len; | 871 | XFS_BUF_LOCK, imap_flags); |
881 | ip->i_boffset = imap.im_boffset; | ||
882 | ASSERT(bno == 0 || bno == imap.im_blkno); | ||
883 | |||
884 | error = xfs_imap_to_bp(mp, tp, &imap, &bp, XFS_BUF_LOCK, imap_flags); | ||
885 | if (error) | 872 | if (error) |
886 | goto out_destroy_inode; | 873 | goto out_destroy_inode; |
887 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, imap.im_boffset); | 874 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); |
888 | 875 | ||
889 | /* | 876 | /* |
890 | * If we got something that isn't an inode it means someone | 877 | * If we got something that isn't an inode it means someone |
@@ -1872,7 +1859,7 @@ xfs_iunlink( | |||
1872 | ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); | 1859 | ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); |
1873 | /* both on-disk, don't endian flip twice */ | 1860 | /* both on-disk, don't endian flip twice */ |
1874 | dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; | 1861 | dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; |
1875 | offset = ip->i_boffset + | 1862 | offset = ip->i_imap.im_boffset + |
1876 | offsetof(xfs_dinode_t, di_next_unlinked); | 1863 | offsetof(xfs_dinode_t, di_next_unlinked); |
1877 | xfs_trans_inode_buf(tp, ibp); | 1864 | xfs_trans_inode_buf(tp, ibp); |
1878 | xfs_trans_log_buf(tp, ibp, offset, | 1865 | xfs_trans_log_buf(tp, ibp, offset, |
@@ -1958,7 +1945,7 @@ xfs_iunlink_remove( | |||
1958 | ASSERT(next_agino != 0); | 1945 | ASSERT(next_agino != 0); |
1959 | if (next_agino != NULLAGINO) { | 1946 | if (next_agino != NULLAGINO) { |
1960 | dip->di_next_unlinked = cpu_to_be32(NULLAGINO); | 1947 | dip->di_next_unlinked = cpu_to_be32(NULLAGINO); |
1961 | offset = ip->i_boffset + | 1948 | offset = ip->i_imap.im_boffset + |
1962 | offsetof(xfs_dinode_t, di_next_unlinked); | 1949 | offsetof(xfs_dinode_t, di_next_unlinked); |
1963 | xfs_trans_inode_buf(tp, ibp); | 1950 | xfs_trans_inode_buf(tp, ibp); |
1964 | xfs_trans_log_buf(tp, ibp, offset, | 1951 | xfs_trans_log_buf(tp, ibp, offset, |
@@ -2021,7 +2008,7 @@ xfs_iunlink_remove( | |||
2021 | ASSERT(next_agino != agino); | 2008 | ASSERT(next_agino != agino); |
2022 | if (next_agino != NULLAGINO) { | 2009 | if (next_agino != NULLAGINO) { |
2023 | dip->di_next_unlinked = cpu_to_be32(NULLAGINO); | 2010 | dip->di_next_unlinked = cpu_to_be32(NULLAGINO); |
2024 | offset = ip->i_boffset + | 2011 | offset = ip->i_imap.im_boffset + |
2025 | offsetof(xfs_dinode_t, di_next_unlinked); | 2012 | offsetof(xfs_dinode_t, di_next_unlinked); |
2026 | xfs_trans_inode_buf(tp, ibp); | 2013 | xfs_trans_inode_buf(tp, ibp); |
2027 | xfs_trans_log_buf(tp, ibp, offset, | 2014 | xfs_trans_log_buf(tp, ibp, offset, |
@@ -3201,7 +3188,7 @@ xfs_iflush_int( | |||
3201 | } | 3188 | } |
3202 | 3189 | ||
3203 | /* set *dip = inode's place in the buffer */ | 3190 | /* set *dip = inode's place in the buffer */ |
3204 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_boffset); | 3191 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); |
3205 | 3192 | ||
3206 | /* | 3193 | /* |
3207 | * Clear i_update_core before copying out the data. | 3194 | * Clear i_update_core before copying out the data. |