@@ -191,6 +191,24 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
191
191
192
192
INIT_LIST_HEAD (& s -> s_mounts );
193
193
s -> s_user_ns = get_user_ns (user_ns );
194
+ init_rwsem (& s -> s_umount );
195
+ lockdep_set_class (& s -> s_umount , & type -> s_umount_key );
196
+ /*
197
+ * sget() can have s_umount recursion.
198
+ *
199
+ * When it cannot find a suitable sb, it allocates a new
200
+ * one (this one), and tries again to find a suitable old
201
+ * one.
202
+ *
203
+ * In case that succeeds, it will acquire the s_umount
204
+ * lock of the old one. Since these are clearly distrinct
205
+ * locks, and this object isn't exposed yet, there's no
206
+ * risk of deadlocks.
207
+ *
208
+ * Annotate this by putting this lock in a different
209
+ * subclass.
210
+ */
211
+ down_write_nested (& s -> s_umount , SINGLE_DEPTH_NESTING );
194
212
195
213
if (security_sb_alloc (s ))
196
214
goto fail ;
@@ -218,25 +236,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
218
236
goto fail ;
219
237
if (list_lru_init_memcg (& s -> s_inode_lru ))
220
238
goto fail ;
221
-
222
- init_rwsem (& s -> s_umount );
223
- lockdep_set_class (& s -> s_umount , & type -> s_umount_key );
224
- /*
225
- * sget() can have s_umount recursion.
226
- *
227
- * When it cannot find a suitable sb, it allocates a new
228
- * one (this one), and tries again to find a suitable old
229
- * one.
230
- *
231
- * In case that succeeds, it will acquire the s_umount
232
- * lock of the old one. Since these are clearly distrinct
233
- * locks, and this object isn't exposed yet, there's no
234
- * risk of deadlocks.
235
- *
236
- * Annotate this by putting this lock in a different
237
- * subclass.
238
- */
239
- down_write_nested (& s -> s_umount , SINGLE_DEPTH_NESTING );
240
239
s -> s_count = 1 ;
241
240
atomic_set (& s -> s_active , 1 );
242
241
mutex_init (& s -> s_vfs_rename_mutex );
0 commit comments