aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_ialloc.c1
-rw-r--r--fs/xfs/xfs_imap.h31
-rw-r--r--fs/xfs/xfs_inode.c49
-rw-r--r--fs/xfs/xfs_inode.h14
-rw-r--r--fs/xfs/xfs_inode_item.c6
-rw-r--r--fs/xfs/xfs_itable.c2
-rw-r--r--fs/xfs/xfs_log_recover.c1
7 files changed, 33 insertions, 71 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 348ac30174c5..4f4557262d9f 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -40,7 +40,6 @@
40#include "xfs_rtalloc.h" 40#include "xfs_rtalloc.h"
41#include "xfs_error.h" 41#include "xfs_error.h"
42#include "xfs_bmap.h" 42#include "xfs_bmap.h"
43#include "xfs_imap.h"
44 43
45 44
46/* 45/*
diff --git a/fs/xfs/xfs_imap.h b/fs/xfs/xfs_imap.h
deleted file mode 100644
index 08690005739e..000000000000
--- a/fs/xfs/xfs_imap.h
+++ /dev/null
@@ -1,31 +0,0 @@
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 */
25typedef 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__ */
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
134xfs_imap_to_bp( 133xfs_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.
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 0a9ad1c56a87..d5c3aa1b18ef 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -83,6 +83,16 @@ typedef struct xfs_ifork {
83} xfs_ifork_t; 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 */
89struct 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 * This is the xfs in-core inode structure. 96 * This is the xfs in-core inode structure.
87 * Most of the on-disk inode is embedded in the i_d field. 97 * Most of the on-disk inode is embedded in the i_d field.
88 * 98 *
@@ -238,9 +248,7 @@ typedef struct xfs_inode {
238 248
239 /* Inode location stuff */ 249 /* Inode location stuff */
240 xfs_ino_t i_ino; /* inode number (agno/agino)*/ 250 xfs_ino_t i_ino; /* inode number (agno/agino)*/
241 xfs_daddr_t i_blkno; /* blkno of inode buffer */ 251 struct xfs_imap i_imap; /* location for xfs_imap() */
242 ushort i_len; /* len of inode buffer */
243 ushort i_boffset; /* off of inode in buffer */
244 252
245 /* Extent information. */ 253 /* Extent information. */
246 xfs_ifork_t *i_afp; /* attribute fork pointer */ 254 xfs_ifork_t *i_afp; /* attribute fork pointer */
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index c43118148e6c..977c4aec587e 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -942,9 +942,9 @@ xfs_inode_item_init(
942 942
943 iip->ili_format.ilf_type = XFS_LI_INODE; 943 iip->ili_format.ilf_type = XFS_LI_INODE;
944 iip->ili_format.ilf_ino = ip->i_ino; 944 iip->ili_format.ilf_ino = ip->i_ino;
945 iip->ili_format.ilf_blkno = ip->i_blkno; 945 iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
946 iip->ili_format.ilf_len = ip->i_len; 946 iip->ili_format.ilf_len = ip->i_imap.im_len;
947 iip->ili_format.ilf_boffset = ip->i_boffset; 947 iip->ili_format.ilf_boffset = ip->i_imap.im_boffset;
948} 948}
949 949
950/* 950/*
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 2cf16f4695ea..4315ce642b4e 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -69,7 +69,7 @@ xfs_bulkstat_one_iget(
69 } 69 }
70 70
71 ASSERT(ip != NULL); 71 ASSERT(ip != NULL);
72 ASSERT(ip->i_blkno != (xfs_daddr_t)0); 72 ASSERT(ip->i_imap.im_blkno != 0);
73 73
74 dic = &ip->i_d; 74 dic = &ip->i_d;
75 75
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index bf8573b5a7d8..ce6e907bec62 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -36,7 +36,6 @@
36#include "xfs_dinode.h" 36#include "xfs_dinode.h"
37#include "xfs_inode.h" 37#include "xfs_inode.h"
38#include "xfs_inode_item.h" 38#include "xfs_inode_item.h"
39#include "xfs_imap.h"
40#include "xfs_alloc.h" 39#include "xfs_alloc.h"
41#include "xfs_ialloc.h" 40#include "xfs_ialloc.h"
42#include "xfs_log_priv.h" 41#include "xfs_log_priv.h"