Skip to content

Commit ca0168e

Browse files
author
Al Viro
committed
alloc_super(): do ->s_umount initialization earlier
... so that failure exits could count on it having been done. Signed-off-by: Al Viro <[email protected]>
1 parent 4fbd8d1 commit ca0168e

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

fs/super.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
191191

192192
INIT_LIST_HEAD(&s->s_mounts);
193193
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);
194212

195213
if (security_sb_alloc(s))
196214
goto fail;
@@ -218,25 +236,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
218236
goto fail;
219237
if (list_lru_init_memcg(&s->s_inode_lru))
220238
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);
240239
s->s_count = 1;
241240
atomic_set(&s->s_active, 1);
242241
mutex_init(&s->s_vfs_rename_mutex);

0 commit comments

Comments
 (0)