@@ -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,56 +159,55 @@ 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 );
197
+ unlock_new_inode (inode );
211
198
}
212
199
213
200
if (no_formal_ino && ip -> i_no_formal_ino &&
214
201
no_formal_ino != ip -> i_no_formal_ino ) {
215
- error = - ESTALE ;
216
- if (inode -> i_state & I_NEW )
217
- goto fail ;
218
202
iput (inode );
219
- return ERR_PTR (error );
203
+ return ERR_PTR (- ESTALE );
220
204
}
221
205
222
- if (inode -> i_state & I_NEW )
223
- unlock_new_inode (inode );
224
-
225
206
return inode ;
226
207
227
208
fail :
228
- if (gfs2_holder_initialized (& ip -> i_iopen_gh )) {
229
- glock_clear_object (ip -> i_iopen_gh .gh_gl , ip );
209
+ if (gfs2_holder_initialized (& ip -> i_iopen_gh ))
230
210
gfs2_glock_dq_uninit (& ip -> i_iopen_gh );
231
- }
232
- if (io_gl )
233
- gfs2_glock_put (io_gl );
234
211
if (gfs2_holder_initialized (& i_gh ))
235
212
gfs2_glock_dq_uninit (& i_gh );
236
213
iget_failed (inode );
@@ -730,18 +707,19 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
730
707
error = gfs2_glock_get (sdp , ip -> i_no_addr , & gfs2_inode_glops , CREATE , & ip -> i_gl );
731
708
if (error )
732
709
goto fail_free_inode ;
733
- flush_delayed_work (& ip -> i_gl -> gl_work );
734
710
735
711
error = gfs2_glock_get (sdp , ip -> i_no_addr , & gfs2_iopen_glops , CREATE , & io_gl );
736
712
if (error )
737
713
goto fail_free_inode ;
738
714
gfs2_cancel_delete_work (io_gl );
739
715
716
+ error = insert_inode_locked4 (inode , ip -> i_no_addr , iget_test , & ip -> i_no_addr );
717
+ BUG_ON (error );
718
+
740
719
error = gfs2_glock_nq_init (ip -> i_gl , LM_ST_EXCLUSIVE , GL_SKIP , ghs + 1 );
741
720
if (error )
742
721
goto fail_gunlock2 ;
743
722
744
- glock_set_object (ip -> i_gl , ip );
745
723
error = gfs2_trans_begin (sdp , blocks , 0 );
746
724
if (error )
747
725
goto fail_gunlock2 ;
@@ -757,9 +735,9 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
757
735
if (error )
758
736
goto fail_gunlock2 ;
759
737
738
+ glock_set_object (ip -> i_gl , ip );
760
739
glock_set_object (io_gl , ip );
761
740
gfs2_set_iop (inode );
762
- insert_inode_hash (inode );
763
741
764
742
free_vfs_inode = 0 ; /* After this point, the inode is no longer
765
743
considered free. Any failures need to undo
@@ -801,17 +779,17 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
801
779
gfs2_glock_dq_uninit (ghs + 1 );
802
780
gfs2_glock_put (io_gl );
803
781
gfs2_qa_put (dip );
782
+ unlock_new_inode (inode );
804
783
return error ;
805
784
806
785
fail_gunlock3 :
786
+ glock_clear_object (ip -> i_gl , ip );
807
787
glock_clear_object (io_gl , ip );
808
788
gfs2_glock_dq_uninit (& ip -> i_iopen_gh );
809
789
fail_gunlock2 :
810
- glock_clear_object (io_gl , ip );
811
790
gfs2_glock_put (io_gl );
812
791
fail_free_inode :
813
792
if (ip -> i_gl ) {
814
- glock_clear_object (ip -> i_gl , ip );
815
793
if (free_vfs_inode ) /* else evict will do the put for us */
816
794
gfs2_glock_put (ip -> i_gl );
817
795
}
@@ -829,7 +807,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
829
807
mark_inode_dirty (inode );
830
808
set_bit (free_vfs_inode ? GIF_FREE_VFS_INODE : GIF_ALLOC_FAILED ,
831
809
& GFS2_I (inode )-> i_flags );
832
- iput (inode );
810
+ if (inode -> i_state & I_NEW )
811
+ iget_failed (inode );
812
+ else
813
+ iput (inode );
833
814
}
834
815
if (gfs2_holder_initialized (ghs + 1 ))
835
816
gfs2_glock_dq_uninit (ghs + 1 );
0 commit comments