@@ -40,37 +40,6 @@ static const struct inode_operations gfs2_file_iops;
4040static const struct inode_operations gfs2_dir_iops ;
4141static const struct inode_operations gfs2_symlink_iops ;
4242
43- static int iget_test (struct inode * inode , void * opaque )
44- {
45- u64 no_addr = * (u64 * )opaque ;
46-
47- return GFS2_I (inode )-> i_no_addr == no_addr ;
48- }
49-
50- static int iget_set (struct inode * inode , void * opaque )
51- {
52- u64 no_addr = * (u64 * )opaque ;
53-
54- GFS2_I (inode )-> i_no_addr = no_addr ;
55- inode -> i_ino = no_addr ;
56- return 0 ;
57- }
58-
59- static struct inode * gfs2_iget (struct super_block * sb , u64 no_addr )
60- {
61- struct inode * inode ;
62-
63- repeat :
64- inode = iget5_locked (sb , no_addr , iget_test , iget_set , & no_addr );
65- if (!inode )
66- return inode ;
67- if (is_bad_inode (inode )) {
68- iput (inode );
69- goto repeat ;
70- }
71- return inode ;
72- }
73-
7443/**
7544 * gfs2_set_iop - Sets inode operations
7645 * @inode: The inode with correct i_mode filled in
@@ -104,6 +73,22 @@ static void gfs2_set_iop(struct inode *inode)
10473 }
10574}
10675
76+ static int iget_test (struct inode * inode , void * opaque )
77+ {
78+ u64 no_addr = * (u64 * )opaque ;
79+
80+ return GFS2_I (inode )-> i_no_addr == no_addr ;
81+ }
82+
83+ static int iget_set (struct inode * inode , void * opaque )
84+ {
85+ u64 no_addr = * (u64 * )opaque ;
86+
87+ GFS2_I (inode )-> i_no_addr = no_addr ;
88+ inode -> i_ino = no_addr ;
89+ return 0 ;
90+ }
91+
10792/**
10893 * gfs2_inode_lookup - Lookup an inode
10994 * @sb: The super block
@@ -132,35 +117,28 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
132117{
133118 struct inode * inode ;
134119 struct gfs2_inode * ip ;
135- struct gfs2_glock * io_gl = NULL ;
136120 struct gfs2_holder i_gh ;
137121 int error ;
138122
139123 gfs2_holder_mark_uninitialized (& i_gh );
140- inode = gfs2_iget (sb , no_addr );
124+ inode = iget5_locked (sb , no_addr , iget_test , iget_set , & no_addr );
141125 if (!inode )
142126 return ERR_PTR (- ENOMEM );
143127
144128 ip = GFS2_I (inode );
145129
146130 if (inode -> i_state & I_NEW ) {
147131 struct gfs2_sbd * sdp = GFS2_SB (inode );
132+ struct gfs2_glock * io_gl ;
148133
149134 error = gfs2_glock_get (sdp , no_addr , & gfs2_inode_glops , CREATE , & ip -> i_gl );
150135 if (unlikely (error ))
151136 goto fail ;
152- flush_delayed_work (& ip -> i_gl -> gl_work );
153-
154- error = gfs2_glock_get (sdp , no_addr , & gfs2_iopen_glops , CREATE , & io_gl );
155- if (unlikely (error ))
156- goto fail ;
157- if (blktype != GFS2_BLKST_UNLINKED )
158- gfs2_cancel_delete_work (io_gl );
159137
160138 if (type == DT_UNKNOWN || blktype != GFS2_BLKST_FREE ) {
161139 /*
162140 * The GL_SKIP flag indicates to skip reading the inode
163- * block. We read the inode with gfs2_inode_refresh
141+ * block. We read the inode when instantiating it
164142 * after possibly checking the block type.
165143 */
166144 error = gfs2_glock_nq_init (ip -> i_gl , LM_ST_EXCLUSIVE ,
@@ -181,31 +159,39 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
181159 }
182160 }
183161
184- glock_set_object (ip -> i_gl , ip );
185162 set_bit (GLF_INSTANTIATE_NEEDED , & ip -> i_gl -> gl_flags );
186- error = gfs2_glock_nq_init (io_gl , LM_ST_SHARED , GL_EXACT , & ip -> i_iopen_gh );
163+
164+ error = gfs2_glock_get (sdp , no_addr , & gfs2_iopen_glops , CREATE , & io_gl );
187165 if (unlikely (error ))
188166 goto fail ;
189- glock_set_object (ip -> i_iopen_gh .gh_gl , ip );
167+ if (blktype != GFS2_BLKST_UNLINKED )
168+ gfs2_cancel_delete_work (io_gl );
169+ error = gfs2_glock_nq_init (io_gl , LM_ST_SHARED , GL_EXACT , & ip -> i_iopen_gh );
190170 gfs2_glock_put (io_gl );
191- io_gl = NULL ;
171+ if (unlikely (error ))
172+ goto fail ;
192173
193174 /* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
194175 inode -> i_atime .tv_sec = 1LL << (8 * sizeof (inode -> i_atime .tv_sec ) - 1 );
195176 inode -> i_atime .tv_nsec = 0 ;
196177
178+ glock_set_object (ip -> i_gl , ip );
179+
197180 if (type == DT_UNKNOWN ) {
198181 /* Inode glock must be locked already */
199182 error = gfs2_instantiate (& i_gh );
200- if (error )
183+ if (error ) {
184+ glock_clear_object (ip -> i_gl , ip );
201185 goto fail ;
186+ }
202187 } else {
203188 ip -> i_no_formal_ino = no_formal_ino ;
204189 inode -> i_mode = DT2IF (type );
205190 }
206191
207192 if (gfs2_holder_initialized (& i_gh ))
208193 gfs2_glock_dq_uninit (& i_gh );
194+ glock_set_object (ip -> i_iopen_gh .gh_gl , ip );
209195
210196 gfs2_set_iop (inode );
211197 unlock_new_inode (inode );
@@ -220,12 +206,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
220206 return inode ;
221207
222208fail :
223- if (gfs2_holder_initialized (& ip -> i_iopen_gh )) {
224- glock_clear_object (ip -> i_iopen_gh .gh_gl , ip );
209+ if (gfs2_holder_initialized (& ip -> i_iopen_gh ))
225210 gfs2_glock_dq_uninit (& ip -> i_iopen_gh );
226- }
227- if (io_gl )
228- gfs2_glock_put (io_gl );
229211 if (gfs2_holder_initialized (& i_gh ))
230212 gfs2_glock_dq_uninit (& i_gh );
231213 iget_failed (inode );
0 commit comments