Commit 92bfc6e7c4eabbbd15e7d6d49123b296d05dcfd1

Authored by Christoph Hellwig
Committed by Niv Sardi
1 parent 94e1b69d1a

[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>

Showing 7 changed files with 33 additions and 71 deletions Side-by-side Diff

... ... @@ -40,7 +40,6 @@
40 40 #include "xfs_rtalloc.h"
41 41 #include "xfs_error.h"
42 42 #include "xfs_bmap.h"
43   -#include "xfs_imap.h"
44 43  
45 44  
46 45 /*
fs/xfs/xfs_imap.h
1   -/*
2   - * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3   - * All Rights Reserved.
4   - *
5   - * This program is free software; you can redistribute it and/or
6   - * modify it under the terms of the GNU General Public License as
7   - * published by the Free Software Foundation.
8   - *
9   - * This program is distributed in the hope that it would be useful,
10   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   - * GNU General Public License for more details.
13   - *
14   - * You should have received a copy of the GNU General Public License
15   - * along with this program; if not, write the Free Software Foundation,
16   - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17   - */
18   -#ifndef __XFS_IMAP_H__
19   -#define __XFS_IMAP_H__
20   -
21   -/*
22   - * This is the structure passed to xfs_imap() to map
23   - * an inode number to its on disk location.
24   - */
25   -typedef struct xfs_imap {
26   - xfs_daddr_t im_blkno; /* starting BB of inode chunk */
27   - uint im_len; /* length in BBs of inode chunk */
28   - ushort im_boffset; /* inode offset in block in bytes */
29   -} xfs_imap_t;
30   -
31   -#endif /* __XFS_IMAP_H__ */
... ... @@ -23,7 +23,6 @@
23 23 #include "xfs_bit.h"
24 24 #include "xfs_log.h"
25 25 #include "xfs_inum.h"
26   -#include "xfs_imap.h"
27 26 #include "xfs_trans.h"
28 27 #include "xfs_trans_priv.h"
29 28 #include "xfs_sb.h"
... ... @@ -134,7 +133,7 @@
134 133 xfs_imap_to_bp(
135 134 xfs_mount_t *mp,
136 135 xfs_trans_t *tp,
137   - xfs_imap_t *imap,
  136 + struct xfs_imap *imap,
138 137 xfs_buf_t **bpp,
139 138 uint buf_flags,
140 139 uint imap_flags)
... ... @@ -232,7 +231,7 @@
232 231 int *offset,
233 232 uint imap_flags)
234 233 {
235   - xfs_imap_t imap;
  234 + struct xfs_imap imap;
236 235 xfs_buf_t *bp;
237 236 int error;
238 237  
239 238  
240 239  
... ... @@ -277,17 +276,12 @@
277 276 xfs_buf_t **bpp,
278 277 uint buf_flags)
279 278 {
280   - xfs_imap_t imap;
281 279 xfs_buf_t *bp;
282 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;
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);
  284 + error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, buf_flags, 0);
291 285 if (error)
292 286 return error;
293 287  
... ... @@ -298,7 +292,7 @@
298 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 296 *bpp = bp;
303 297 return 0;
304 298 }
... ... @@ -799,9 +793,7 @@
799 793 /* initialise the xfs inode */
800 794 ip->i_ino = ino;
801 795 ip->i_mount = mp;
802   - ip->i_blkno = 0;
803   - ip->i_len = 0;
804   - ip->i_boffset =0;
  796 + memset(&ip->i_imap, 0, sizeof(struct xfs_imap));
805 797 ip->i_afp = NULL;
806 798 memset(&ip->i_df, 0, sizeof(xfs_ifork_t));
807 799 ip->i_flags = 0;
... ... @@ -857,7 +849,6 @@
857 849 xfs_buf_t *bp;
858 850 xfs_dinode_t *dip;
859 851 xfs_inode_t *ip;
860   - xfs_imap_t imap;
861 852 int error;
862 853  
863 854 ip = xfs_inode_alloc(mp, ino);
864 855  
865 856  
866 857  
867 858  
868 859  
... ... @@ -865,26 +856,22 @@
865 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;
871   - error = xfs_imap(mp, tp, ip->i_ino, &imap, imap_flags);
  861 + ip->i_imap.im_blkno = bno;
  862 + error = xfs_imap(mp, tp, ip->i_ino, &ip->i_imap, imap_flags);
872 863 if (error)
873 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
877   - * map the inode to its buffer from now on.
  868 + * Get pointers to the on-disk inode and the buffer containing it.
878 869 */
879   - ip->i_blkno = imap.im_blkno;
880   - ip->i_len = imap.im_len;
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);
  870 + error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp,
  871 + XFS_BUF_LOCK, imap_flags);
885 872 if (error)
886 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 877 * If we got something that isn't an inode it means someone
... ... @@ -1872,7 +1859,7 @@
1872 1859 ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO);
1873 1860 /* both on-disk, don't endian flip twice */
1874 1861 dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
1875   - offset = ip->i_boffset +
  1862 + offset = ip->i_imap.im_boffset +
1876 1863 offsetof(xfs_dinode_t, di_next_unlinked);
1877 1864 xfs_trans_inode_buf(tp, ibp);
1878 1865 xfs_trans_log_buf(tp, ibp, offset,
... ... @@ -1958,7 +1945,7 @@
1958 1945 ASSERT(next_agino != 0);
1959 1946 if (next_agino != NULLAGINO) {
1960 1947 dip->di_next_unlinked = cpu_to_be32(NULLAGINO);
1961   - offset = ip->i_boffset +
  1948 + offset = ip->i_imap.im_boffset +
1962 1949 offsetof(xfs_dinode_t, di_next_unlinked);
1963 1950 xfs_trans_inode_buf(tp, ibp);
1964 1951 xfs_trans_log_buf(tp, ibp, offset,
... ... @@ -2021,7 +2008,7 @@
2021 2008 ASSERT(next_agino != agino);
2022 2009 if (next_agino != NULLAGINO) {
2023 2010 dip->di_next_unlinked = cpu_to_be32(NULLAGINO);
2024   - offset = ip->i_boffset +
  2011 + offset = ip->i_imap.im_boffset +
2025 2012 offsetof(xfs_dinode_t, di_next_unlinked);
2026 2013 xfs_trans_inode_buf(tp, ibp);
2027 2014 xfs_trans_log_buf(tp, ibp, offset,
... ... @@ -3201,7 +3188,7 @@
3201 3188 }
3202 3189  
3203 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 3194 * Clear i_update_core before copying out the data.
... ... @@ -83,6 +83,16 @@
83 83 } xfs_ifork_t;
84 84  
85 85 /*
  86 + * Inode location information. Stored in the inode and passed to
  87 + * xfs_imap_to_bp() to get a buffer and dinode for a given inode.
  88 + */
  89 +struct xfs_imap {
  90 + xfs_daddr_t im_blkno; /* starting BB of inode chunk */
  91 + ushort im_len; /* length in BBs of inode chunk */
  92 + ushort im_boffset; /* inode offset in block in bytes */
  93 +};
  94 +
  95 +/*
86 96 * This is the xfs in-core inode structure.
87 97 * Most of the on-disk inode is embedded in the i_d field.
88 98 *
... ... @@ -238,9 +248,7 @@
238 248  
239 249 /* Inode location stuff */
240 250 xfs_ino_t i_ino; /* inode number (agno/agino)*/
241   - xfs_daddr_t i_blkno; /* blkno of inode buffer */
242   - ushort i_len; /* len of inode buffer */
243   - ushort i_boffset; /* off of inode in buffer */
  251 + struct xfs_imap i_imap; /* location for xfs_imap() */
244 252  
245 253 /* Extent information. */
246 254 xfs_ifork_t *i_afp; /* attribute fork pointer */
fs/xfs/xfs_inode_item.c
... ... @@ -942,9 +942,9 @@
942 942  
943 943 iip->ili_format.ilf_type = XFS_LI_INODE;
944 944 iip->ili_format.ilf_ino = ip->i_ino;
945   - iip->ili_format.ilf_blkno = ip->i_blkno;
946   - iip->ili_format.ilf_len = ip->i_len;
947   - iip->ili_format.ilf_boffset = ip->i_boffset;
  945 + iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
  946 + iip->ili_format.ilf_len = ip->i_imap.im_len;
  947 + iip->ili_format.ilf_boffset = ip->i_imap.im_boffset;
948 948 }
949 949  
950 950 /*
... ... @@ -69,7 +69,7 @@
69 69 }
70 70  
71 71 ASSERT(ip != NULL);
72   - ASSERT(ip->i_blkno != (xfs_daddr_t)0);
  72 + ASSERT(ip->i_imap.im_blkno != 0);
73 73  
74 74 dic = &ip->i_d;
75 75  
fs/xfs/xfs_log_recover.c
... ... @@ -36,7 +36,6 @@
36 36 #include "xfs_dinode.h"
37 37 #include "xfs_inode.h"
38 38 #include "xfs_inode_item.h"
39   -#include "xfs_imap.h"
40 39 #include "xfs_alloc.h"
41 40 #include "xfs_ialloc.h"
42 41 #include "xfs_log_priv.h"