aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iget.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2008-11-27 22:23:42 -0500
committerNiv Sardi <xaiki@sgi.com>2008-11-30 19:38:17 -0500
commit24f211bad09a31f19dda0c3faffe0244f4f235f5 (patch)
tree3554243712a41729df866e348a3925ffdf950b8c /fs/xfs/xfs_iget.c
parentb48d8d64377f39913663a06f4757f3b8c6fc6d87 (diff)
[XFS] move inode allocation out xfs_iread
Allocate the inode in xfs_iget_cache_miss and pass it into xfs_iread. This simplifies the error handling and allows xfs_iread to be shared with userspace which already uses these semantics. 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_iget.c')
-rw-r--r--fs/xfs/xfs_iget.c88
1 files changed, 82 insertions, 6 deletions
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index d60522a73a17..27ec2417b852 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -40,6 +40,82 @@
40#include "xfs_utils.h" 40#include "xfs_utils.h"
41#include "xfs_trans_priv.h" 41#include "xfs_trans_priv.h"
42#include "xfs_inode_item.h" 42#include "xfs_inode_item.h"
43#include "xfs_bmap.h"
44#include "xfs_btree_trace.h"
45#include "xfs_dir2_trace.h"
46
47
48/*
49 * Allocate and initialise an xfs_inode.
50 */
51STATIC struct xfs_inode *
52xfs_inode_alloc(
53 struct xfs_mount *mp,
54 xfs_ino_t ino)
55{
56 struct xfs_inode *ip;
57
58 /*
59 * if this didn't occur in transactions, we could use
60 * KM_MAYFAIL and return NULL here on ENOMEM. Set the
61 * code up to do this anyway.
62 */
63 ip = kmem_zone_alloc(xfs_inode_zone, KM_SLEEP);
64 if (!ip)
65 return NULL;
66
67 ASSERT(atomic_read(&ip->i_iocount) == 0);
68 ASSERT(atomic_read(&ip->i_pincount) == 0);
69 ASSERT(!spin_is_locked(&ip->i_flags_lock));
70 ASSERT(completion_done(&ip->i_flush));
71
72 /*
73 * initialise the VFS inode here to get failures
74 * out of the way early.
75 */
76 if (!inode_init_always(mp->m_super, VFS_I(ip))) {
77 kmem_zone_free(xfs_inode_zone, ip);
78 return NULL;
79 }
80
81 /* initialise the xfs inode */
82 ip->i_ino = ino;
83 ip->i_mount = mp;
84 memset(&ip->i_imap, 0, sizeof(struct xfs_imap));
85 ip->i_afp = NULL;
86 memset(&ip->i_df, 0, sizeof(xfs_ifork_t));
87 ip->i_flags = 0;
88 ip->i_update_core = 0;
89 ip->i_update_size = 0;
90 ip->i_delayed_blks = 0;
91 memset(&ip->i_d, 0, sizeof(xfs_icdinode_t));
92 ip->i_size = 0;
93 ip->i_new_size = 0;
94
95 /*
96 * Initialize inode's trace buffers.
97 */
98#ifdef XFS_INODE_TRACE
99 ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_NOFS);
100#endif
101#ifdef XFS_BMAP_TRACE
102 ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS);
103#endif
104#ifdef XFS_BTREE_TRACE
105 ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS);
106#endif
107#ifdef XFS_RW_TRACE
108 ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_NOFS);
109#endif
110#ifdef XFS_ILOCK_TRACE
111 ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_NOFS);
112#endif
113#ifdef XFS_DIR2_TRACE
114 ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS);
115#endif
116
117 return ip;
118}
43 119
44/* 120/*
45 * Check the validity of the inode we just found it the cache 121 * Check the validity of the inode we just found it the cache
@@ -155,13 +231,13 @@ xfs_iget_cache_miss(
155 unsigned long first_index, mask; 231 unsigned long first_index, mask;
156 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino); 232 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino);
157 233
158 /* 234 ip = xfs_inode_alloc(mp, ino);
159 * Read the disk inode attributes into a new inode structure and get 235 if (!ip)
160 * a new vnode for it. This should also initialize i_ino and i_mount. 236 return ENOMEM;
161 */ 237
162 error = xfs_iread(mp, tp, ino, &ip, bno, flags); 238 error = xfs_iread(mp, tp, ip, bno, flags);
163 if (error) 239 if (error)
164 return error; 240 goto out_destroy;
165 241
166 xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); 242 xfs_itrace_exit_tag(ip, "xfs_iget.alloc");
167 243