Lines Matching refs:s
159 struct super_block *s = container_of(work, struct super_block, in destroy_super_work() local
164 percpu_free_rwsem(&s->s_writers.rw_sem[i]); in destroy_super_work()
165 kfree(s); in destroy_super_work()
170 struct super_block *s = container_of(head, struct super_block, rcu); in destroy_super_rcu() local
171 INIT_WORK(&s->destroy_work, destroy_super_work); in destroy_super_rcu()
172 schedule_work(&s->destroy_work); in destroy_super_rcu()
176 static void destroy_unused_super(struct super_block *s) in destroy_unused_super() argument
178 if (!s) in destroy_unused_super()
180 up_write(&s->s_umount); in destroy_unused_super()
181 list_lru_destroy(&s->s_dentry_lru); in destroy_unused_super()
182 list_lru_destroy(&s->s_inode_lru); in destroy_unused_super()
183 security_sb_free(s); in destroy_unused_super()
184 put_user_ns(s->s_user_ns); in destroy_unused_super()
185 kfree(s->s_subtype); in destroy_unused_super()
186 free_prealloced_shrinker(&s->s_shrink); in destroy_unused_super()
188 destroy_super_work(&s->destroy_work); in destroy_unused_super()
203 struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); in alloc_super() local
207 if (!s) in alloc_super()
210 INIT_LIST_HEAD(&s->s_mounts); in alloc_super()
211 s->s_user_ns = get_user_ns(user_ns); in alloc_super()
212 init_rwsem(&s->s_umount); in alloc_super()
213 lockdep_set_class(&s->s_umount, &type->s_umount_key); in alloc_super()
229 down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING); in alloc_super()
231 if (security_sb_alloc(s)) in alloc_super()
235 if (__percpu_init_rwsem(&s->s_writers.rw_sem[i], in alloc_super()
240 init_waitqueue_head(&s->s_writers.wait_unfrozen); in alloc_super()
241 s->s_bdi = &noop_backing_dev_info; in alloc_super()
242 s->s_flags = flags; in alloc_super()
243 if (s->s_user_ns != &init_user_ns) in alloc_super()
244 s->s_iflags |= SB_I_NODEV; in alloc_super()
245 INIT_HLIST_NODE(&s->s_instances); in alloc_super()
246 INIT_HLIST_BL_HEAD(&s->s_roots); in alloc_super()
247 mutex_init(&s->s_sync_lock); in alloc_super()
248 INIT_LIST_HEAD(&s->s_inodes); in alloc_super()
249 spin_lock_init(&s->s_inode_list_lock); in alloc_super()
250 INIT_LIST_HEAD(&s->s_inodes_wb); in alloc_super()
251 spin_lock_init(&s->s_inode_wblist_lock); in alloc_super()
253 s->s_count = 1; in alloc_super()
254 atomic_set(&s->s_active, 1); in alloc_super()
255 mutex_init(&s->s_vfs_rename_mutex); in alloc_super()
256 lockdep_set_class(&s->s_vfs_rename_mutex, &type->s_vfs_rename_key); in alloc_super()
257 init_rwsem(&s->s_dquot.dqio_sem); in alloc_super()
258 s->s_maxbytes = MAX_NON_LFS; in alloc_super()
259 s->s_op = &default_op; in alloc_super()
260 s->s_time_gran = 1000000000; in alloc_super()
261 s->s_time_min = TIME64_MIN; in alloc_super()
262 s->s_time_max = TIME64_MAX; in alloc_super()
263 s->cleancache_poolid = CLEANCACHE_NO_POOL; in alloc_super()
265 s->s_shrink.seeks = DEFAULT_SEEKS; in alloc_super()
266 s->s_shrink.scan_objects = super_cache_scan; in alloc_super()
267 s->s_shrink.count_objects = super_cache_count; in alloc_super()
268 s->s_shrink.batch = 1024; in alloc_super()
269 s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE; in alloc_super()
270 if (prealloc_shrinker(&s->s_shrink)) in alloc_super()
272 if (list_lru_init_memcg(&s->s_dentry_lru, &s->s_shrink)) in alloc_super()
274 if (list_lru_init_memcg(&s->s_inode_lru, &s->s_shrink)) in alloc_super()
276 return s; in alloc_super()
279 destroy_unused_super(s); in alloc_super()
288 static void __put_super(struct super_block *s) in __put_super() argument
290 if (!--s->s_count) { in __put_super()
291 list_del_init(&s->s_list); in __put_super()
292 WARN_ON(s->s_dentry_lru.node); in __put_super()
293 WARN_ON(s->s_inode_lru.node); in __put_super()
294 WARN_ON(!list_empty(&s->s_mounts)); in __put_super()
295 security_sb_free(s); in __put_super()
296 fscrypt_sb_free(s); in __put_super()
297 put_user_ns(s->s_user_ns); in __put_super()
298 kfree(s->s_subtype); in __put_super()
299 call_rcu(&s->rcu, destroy_super_rcu); in __put_super()
329 void deactivate_locked_super(struct super_block *s) in deactivate_locked_super() argument
331 struct file_system_type *fs = s->s_type; in deactivate_locked_super()
332 if (atomic_dec_and_test(&s->s_active)) { in deactivate_locked_super()
333 cleancache_invalidate_fs(s); in deactivate_locked_super()
334 unregister_shrinker(&s->s_shrink); in deactivate_locked_super()
335 fs->kill_sb(s); in deactivate_locked_super()
342 list_lru_destroy(&s->s_dentry_lru); in deactivate_locked_super()
343 list_lru_destroy(&s->s_inode_lru); in deactivate_locked_super()
346 put_super(s); in deactivate_locked_super()
348 up_write(&s->s_umount); in deactivate_locked_super()
362 void deactivate_super(struct super_block *s) in deactivate_super() argument
364 if (!atomic_add_unless(&s->s_active, -1, 1)) { in deactivate_super()
365 down_write(&s->s_umount); in deactivate_super()
366 deactivate_locked_super(s); in deactivate_super()
385 static int grab_super(struct super_block *s) __releases(sb_lock) in grab_super() argument
387 s->s_count++; in grab_super()
389 down_write(&s->s_umount); in grab_super()
390 if ((s->s_flags & SB_BORN) && atomic_inc_not_zero(&s->s_active)) { in grab_super()
391 put_super(s); in grab_super()
394 up_write(&s->s_umount); in grab_super()
395 put_super(s); in grab_super()
515 struct super_block *s = NULL; in sget_fc() local
528 if (!s) { in sget_fc()
530 s = alloc_super(fc->fs_type, fc->sb_flags, user_ns); in sget_fc()
531 if (!s) in sget_fc()
536 s->s_fs_info = fc->s_fs_info; in sget_fc()
537 err = set(s, fc); in sget_fc()
539 s->s_fs_info = NULL; in sget_fc()
541 destroy_unused_super(s); in sget_fc()
545 s->s_type = fc->fs_type; in sget_fc()
546 s->s_iflags |= fc->s_iflags; in sget_fc()
547 strlcpy(s->s_id, s->s_type->name, sizeof(s->s_id)); in sget_fc()
548 list_add_tail(&s->s_list, &super_blocks); in sget_fc()
549 hlist_add_head(&s->s_instances, &s->s_type->fs_supers); in sget_fc()
551 get_filesystem(s->s_type); in sget_fc()
552 register_shrinker_prepared(&s->s_shrink); in sget_fc()
553 return s; in sget_fc()
558 destroy_unused_super(s); in sget_fc()
563 destroy_unused_super(s); in sget_fc()
583 struct super_block *s = NULL; in sget() local
602 destroy_unused_super(s); in sget()
607 destroy_unused_super(s); in sget()
611 if (!s) { in sget()
613 s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns); in sget()
614 if (!s) in sget()
619 err = set(s, data); in sget()
622 destroy_unused_super(s); in sget()
625 s->s_type = type; in sget()
626 strlcpy(s->s_id, type->name, sizeof(s->s_id)); in sget()
627 list_add_tail(&s->s_list, &super_blocks); in sget()
628 hlist_add_head(&s->s_instances, &type->fs_supers); in sget()
631 register_shrinker_prepared(&s->s_shrink); in sget()
632 return s; in sget()
796 struct super_block *s = __get_super(bdev, excl); in __get_super_thawed() local
797 if (!s || s->s_writers.frozen == SB_UNFROZEN) in __get_super_thawed()
798 return s; in __get_super_thawed()
800 up_read(&s->s_umount); in __get_super_thawed()
802 up_write(&s->s_umount); in __get_super_thawed()
803 wait_event(s->s_writers.wait_unfrozen, in __get_super_thawed()
804 s->s_writers.frozen == SB_UNFROZEN); in __get_super_thawed()
805 put_super(s); in __get_super_thawed()
1099 int set_anon_super(struct super_block *s, void *data) in set_anon_super() argument
1101 return get_anon_bdev(&s->s_dev); in set_anon_super()
1132 static int test_single_super(struct super_block *s, struct fs_context *fc) in test_single_super() argument
1253 static int set_bdev_super(struct super_block *s, void *data) in set_bdev_super() argument
1255 s->s_bdev = data; in set_bdev_super()
1256 s->s_dev = s->s_bdev->bd_dev; in set_bdev_super()
1257 s->s_bdi = bdi_get(s->s_bdev->bd_bdi); in set_bdev_super()
1262 static int set_bdev_super_fc(struct super_block *s, struct fs_context *fc) in set_bdev_super_fc() argument
1264 return set_bdev_super(s, fc->sget_key); in set_bdev_super_fc()
1267 static int test_bdev_super_fc(struct super_block *s, struct fs_context *fc) in test_bdev_super_fc() argument
1269 return s->s_bdev == fc->sget_key; in test_bdev_super_fc()
1282 struct super_block *s; in get_tree_bdev() local
1312 s = sget_fc(fc, test_bdev_super_fc, set_bdev_super_fc); in get_tree_bdev()
1314 if (IS_ERR(s)) { in get_tree_bdev()
1316 return PTR_ERR(s); in get_tree_bdev()
1319 if (s->s_root) { in get_tree_bdev()
1321 if ((fc->sb_flags ^ s->s_flags) & SB_RDONLY) { in get_tree_bdev()
1323 deactivate_locked_super(s); in get_tree_bdev()
1335 up_write(&s->s_umount); in get_tree_bdev()
1337 down_write(&s->s_umount); in get_tree_bdev()
1339 s->s_mode = mode; in get_tree_bdev()
1340 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); in get_tree_bdev()
1341 sb_set_blocksize(s, block_size(bdev)); in get_tree_bdev()
1342 error = fill_super(s, fc); in get_tree_bdev()
1344 deactivate_locked_super(s); in get_tree_bdev()
1348 s->s_flags |= SB_ACTIVE; in get_tree_bdev()
1349 bdev->bd_super = s; in get_tree_bdev()
1353 fc->root = dget(s->s_root); in get_tree_bdev()
1358 static int test_bdev_super(struct super_block *s, void *data) in test_bdev_super() argument
1360 return (void *)s->s_bdev == data; in test_bdev_super()
1368 struct super_block *s; in mount_bdev() local
1390 s = sget(fs_type, test_bdev_super, set_bdev_super, flags | SB_NOSEC, in mount_bdev()
1393 if (IS_ERR(s)) in mount_bdev()
1396 if (s->s_root) { in mount_bdev()
1397 if ((flags ^ s->s_flags) & SB_RDONLY) { in mount_bdev()
1398 deactivate_locked_super(s); in mount_bdev()
1410 up_write(&s->s_umount); in mount_bdev()
1412 down_write(&s->s_umount); in mount_bdev()
1414 s->s_mode = mode; in mount_bdev()
1415 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); in mount_bdev()
1416 sb_set_blocksize(s, block_size(bdev)); in mount_bdev()
1417 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0); in mount_bdev()
1419 deactivate_locked_super(s); in mount_bdev()
1423 s->s_flags |= SB_ACTIVE; in mount_bdev()
1424 bdev->bd_super = s; in mount_bdev()
1427 return dget(s->s_root); in mount_bdev()
1430 error = PTR_ERR(s); in mount_bdev()
1458 struct super_block *s = sget(fs_type, NULL, set_anon_super, flags, NULL); in mount_nodev() local
1460 if (IS_ERR(s)) in mount_nodev()
1461 return ERR_CAST(s); in mount_nodev()
1463 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0); in mount_nodev()
1465 deactivate_locked_super(s); in mount_nodev()
1468 s->s_flags |= SB_ACTIVE; in mount_nodev()
1469 return dget(s->s_root); in mount_nodev()
1473 static int reconfigure_single(struct super_block *s, in reconfigure_single() argument
1484 fc = fs_context_for_reconfigure(s->s_root, flags, MS_RMT_MASK); in reconfigure_single()
1498 static int compare_single(struct super_block *s, void *p) in compare_single() argument
1507 struct super_block *s; in mount_single() local
1510 s = sget(fs_type, compare_single, set_anon_super, flags, NULL); in mount_single()
1511 if (IS_ERR(s)) in mount_single()
1512 return ERR_CAST(s); in mount_single()
1513 if (!s->s_root) { in mount_single()
1514 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0); in mount_single()
1516 s->s_flags |= SB_ACTIVE; in mount_single()
1518 error = reconfigure_single(s, flags, data); in mount_single()
1521 deactivate_locked_super(s); in mount_single()
1524 return dget(s->s_root); in mount_single()