summaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-12-05 09:32:25 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2017-12-05 09:32:25 -0500
commitca0168e8a77cf833f8c9ac1d26a3a4012bab4f72 (patch)
tree3f16a5a564345566d6356b60654c3578264a408b /fs/super.c
parent4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 (diff)
alloc_super(): do ->s_umount initialization earlier
... so that failure exits could count on it having been done. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/fs/super.c b/fs/super.c
index d4e33e8f1e6f..7ff1349609e4 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -191,6 +191,24 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
191 191
192 INIT_LIST_HEAD(&s->s_mounts); 192 INIT_LIST_HEAD(&s->s_mounts);
193 s->s_user_ns = get_user_ns(user_ns); 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 if (security_sb_alloc(s)) 213 if (security_sb_alloc(s))
196 goto fail; 214 goto fail;
@@ -218,25 +236,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
218 goto fail; 236 goto fail;
219 if (list_lru_init_memcg(&s->s_inode_lru)) 237 if (list_lru_init_memcg(&s->s_inode_lru))
220 goto fail; 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 s->s_count = 1; 239 s->s_count = 1;
241 atomic_set(&s->s_active, 1); 240 atomic_set(&s->s_active, 1);
242 mutex_init(&s->s_vfs_rename_mutex); 241 mutex_init(&s->s_vfs_rename_mutex);