@@ -40,37 +40,6 @@ static const struct inode_operations gfs2_file_iops;
40
40
static const struct inode_operations gfs2_dir_iops ;
41
41
static const struct inode_operations gfs2_symlink_iops ;
42
42
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
-
74
43
/**
75
44
* gfs2_set_iop - Sets inode operations
76
45
* @inode: The inode with correct i_mode filled in
@@ -104,6 +73,22 @@ static void gfs2_set_iop(struct inode *inode)
104
73
}
105
74
}
106
75
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
+
107
92
/**
108
93
* gfs2_inode_lookup - Lookup an inode
109
94
* @sb: The super block
@@ -132,35 +117,28 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
132
117
{
133
118
struct inode * inode ;
134
119
struct gfs2_inode * ip ;
135
- struct gfs2_glock * io_gl = NULL ;
136
120
struct gfs2_holder i_gh ;
137
121
int error ;
138
122
139
123
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 );
141
125
if (!inode )
142
126
return ERR_PTR (- ENOMEM );
143
127
144
128
ip = GFS2_I (inode );
145
129
146
130
if (inode -> i_state & I_NEW ) {
147
131
struct gfs2_sbd * sdp = GFS2_SB (inode );
132
+ struct gfs2_glock * io_gl ;
148
133
149
134
error = gfs2_glock_get (sdp , no_addr , & gfs2_inode_glops , CREATE , & ip -> i_gl );
150
135
if (unlikely (error ))
151
136
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 );
159
137
160
138
if (type == DT_UNKNOWN || blktype != GFS2_BLKST_FREE ) {
161
139
/*
162
140
* 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
164
142
* after possibly checking the block type.
165
143
*/
166
144
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,
181
159
}
182
160
}
183
161
184
- glock_set_object (ip -> i_gl , ip );
185
162
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 );
187
165
if (unlikely (error ))
188
166
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 );
190
170
gfs2_glock_put (io_gl );
191
- io_gl = NULL ;
171
+ if (unlikely (error ))
172
+ goto fail ;
192
173
193
174
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
194
175
inode -> i_atime .tv_sec = 1LL << (8 * sizeof (inode -> i_atime .tv_sec ) - 1 );
195
176
inode -> i_atime .tv_nsec = 0 ;
196
177
178
+ glock_set_object (ip -> i_gl , ip );
179
+
197
180
if (type == DT_UNKNOWN ) {
198
181
/* Inode glock must be locked already */
199
182
error = gfs2_instantiate (& i_gh );
200
- if (error )
183
+ if (error ) {
184
+ glock_clear_object (ip -> i_gl , ip );
201
185
goto fail ;
186
+ }
202
187
} else {
203
188
ip -> i_no_formal_ino = no_formal_ino ;
204
189
inode -> i_mode = DT2IF (type );
205
190
}
206
191
207
192
if (gfs2_holder_initialized (& i_gh ))
208
193
gfs2_glock_dq_uninit (& i_gh );
194
+ glock_set_object (ip -> i_iopen_gh .gh_gl , ip );
209
195
210
196
gfs2_set_iop (inode );
211
197
unlock_new_inode (inode );
@@ -220,12 +206,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
220
206
return inode ;
221
207
222
208
fail :
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 ))
225
210
gfs2_glock_dq_uninit (& ip -> i_iopen_gh );
226
- }
227
- if (io_gl )
228
- gfs2_glock_put (io_gl );
229
211
if (gfs2_holder_initialized (& i_gh ))
230
212
gfs2_glock_dq_uninit (& i_gh );
231
213
iget_failed (inode );
0 commit comments