Lines Matching refs:s
283 struct super_block *s = container_of(work, struct super_block, in destroy_super_work() local
288 percpu_free_rwsem(&s->s_writers.rw_sem[i]); in destroy_super_work()
289 kfree(s); in destroy_super_work()
294 struct super_block *s = container_of(head, struct super_block, rcu); in destroy_super_rcu() local
295 INIT_WORK(&s->destroy_work, destroy_super_work); in destroy_super_rcu()
296 schedule_work(&s->destroy_work); in destroy_super_rcu()
300 static void destroy_unused_super(struct super_block *s) in destroy_unused_super() argument
302 if (!s) in destroy_unused_super()
304 super_unlock_excl(s); in destroy_unused_super()
305 list_lru_destroy(&s->s_dentry_lru); in destroy_unused_super()
306 list_lru_destroy(&s->s_inode_lru); in destroy_unused_super()
307 security_sb_free(s); in destroy_unused_super()
308 put_user_ns(s->s_user_ns); in destroy_unused_super()
309 kfree(s->s_subtype); in destroy_unused_super()
310 free_prealloced_shrinker(&s->s_shrink); in destroy_unused_super()
312 destroy_super_work(&s->destroy_work); in destroy_unused_super()
327 struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); in alloc_super() local
331 if (!s) in alloc_super()
334 INIT_LIST_HEAD(&s->s_mounts); in alloc_super()
335 s->s_user_ns = get_user_ns(user_ns); in alloc_super()
336 init_rwsem(&s->s_umount); in alloc_super()
337 lockdep_set_class(&s->s_umount, &type->s_umount_key); in alloc_super()
353 down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING); in alloc_super()
355 if (security_sb_alloc(s)) in alloc_super()
359 if (__percpu_init_rwsem(&s->s_writers.rw_sem[i], in alloc_super()
364 s->s_bdi = &noop_backing_dev_info; in alloc_super()
365 s->s_flags = flags; in alloc_super()
366 if (s->s_user_ns != &init_user_ns) in alloc_super()
367 s->s_iflags |= SB_I_NODEV; in alloc_super()
368 INIT_HLIST_NODE(&s->s_instances); in alloc_super()
369 INIT_HLIST_BL_HEAD(&s->s_roots); in alloc_super()
370 mutex_init(&s->s_sync_lock); in alloc_super()
371 INIT_LIST_HEAD(&s->s_inodes); in alloc_super()
372 spin_lock_init(&s->s_inode_list_lock); in alloc_super()
373 INIT_LIST_HEAD(&s->s_inodes_wb); in alloc_super()
374 spin_lock_init(&s->s_inode_wblist_lock); in alloc_super()
376 s->s_count = 1; in alloc_super()
377 atomic_set(&s->s_active, 1); in alloc_super()
378 mutex_init(&s->s_vfs_rename_mutex); in alloc_super()
379 lockdep_set_class(&s->s_vfs_rename_mutex, &type->s_vfs_rename_key); in alloc_super()
380 init_rwsem(&s->s_dquot.dqio_sem); in alloc_super()
381 s->s_maxbytes = MAX_NON_LFS; in alloc_super()
382 s->s_op = &default_op; in alloc_super()
383 s->s_time_gran = 1000000000; in alloc_super()
384 s->s_time_min = TIME64_MIN; in alloc_super()
385 s->s_time_max = TIME64_MAX; in alloc_super()
386 s->cleancache_poolid = CLEANCACHE_NO_POOL; in alloc_super()
388 s->s_shrink.seeks = DEFAULT_SEEKS; in alloc_super()
389 s->s_shrink.scan_objects = super_cache_scan; in alloc_super()
390 s->s_shrink.count_objects = super_cache_count; in alloc_super()
391 s->s_shrink.batch = 1024; in alloc_super()
392 s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE; in alloc_super()
393 if (prealloc_shrinker(&s->s_shrink, "sb-%s", type->name)) in alloc_super()
395 if (list_lru_init_memcg(&s->s_dentry_lru, &s->s_shrink)) in alloc_super()
397 if (list_lru_init_memcg(&s->s_inode_lru, &s->s_shrink)) in alloc_super()
399 return s; in alloc_super()
402 destroy_unused_super(s); in alloc_super()
411 static void __put_super(struct super_block *s) in __put_super() argument
413 if (!--s->s_count) { in __put_super()
414 list_del_init(&s->s_list); in __put_super()
415 WARN_ON(s->s_dentry_lru.node); in __put_super()
416 WARN_ON(s->s_inode_lru.node); in __put_super()
417 WARN_ON(!list_empty(&s->s_mounts)); in __put_super()
418 security_sb_free(s); in __put_super()
419 put_user_ns(s->s_user_ns); in __put_super()
420 kfree(s->s_subtype); in __put_super()
421 call_rcu(&s->rcu, destroy_super_rcu); in __put_super()
478 void deactivate_locked_super(struct super_block *s) in deactivate_locked_super() argument
480 struct file_system_type *fs = s->s_type; in deactivate_locked_super()
481 if (atomic_dec_and_test(&s->s_active)) { in deactivate_locked_super()
482 cleancache_invalidate_fs(s); in deactivate_locked_super()
483 unregister_shrinker(&s->s_shrink); in deactivate_locked_super()
484 fs->kill_sb(s); in deactivate_locked_super()
486 kill_super_notify(s); in deactivate_locked_super()
493 list_lru_destroy(&s->s_dentry_lru); in deactivate_locked_super()
494 list_lru_destroy(&s->s_inode_lru); in deactivate_locked_super()
497 put_super(s); in deactivate_locked_super()
499 super_unlock_excl(s); in deactivate_locked_super()
513 void deactivate_super(struct super_block *s) in deactivate_super() argument
515 if (!atomic_add_unless(&s->s_active, -1, 1)) { in deactivate_super()
516 __super_lock_excl(s); in deactivate_super()
517 deactivate_locked_super(s); in deactivate_super()
536 static int grab_super(struct super_block *s) __releases(sb_lock) in grab_super() argument
540 s->s_count++; in grab_super()
542 born = super_lock_excl(s); in grab_super()
543 if (born && atomic_inc_not_zero(&s->s_active)) { in grab_super()
544 put_super(s); in grab_super()
547 super_unlock_excl(s); in grab_super()
548 put_super(s); in grab_super()
782 struct super_block *s = NULL; in sget_fc() local
806 if (!s) { in sget_fc()
808 s = alloc_super(fc->fs_type, fc->sb_flags, user_ns); in sget_fc()
809 if (!s) in sget_fc()
814 s->s_fs_info = fc->s_fs_info; in sget_fc()
815 err = set(s, fc); in sget_fc()
817 s->s_fs_info = NULL; in sget_fc()
819 destroy_unused_super(s); in sget_fc()
823 s->s_type = fc->fs_type; in sget_fc()
824 s->s_iflags |= fc->s_iflags; in sget_fc()
825 strscpy(s->s_id, s->s_type->name, sizeof(s->s_id)); in sget_fc()
831 list_add_tail(&s->s_list, &super_blocks); in sget_fc()
832 hlist_add_head(&s->s_instances, &s->s_type->fs_supers); in sget_fc()
834 get_filesystem(s->s_type); in sget_fc()
835 register_shrinker_prepared(&s->s_shrink); in sget_fc()
836 return s; in sget_fc()
841 destroy_unused_super(s); in sget_fc()
850 destroy_unused_super(s); in sget_fc()
870 struct super_block *s = NULL; in sget() local
889 destroy_unused_super(s); in sget()
894 destroy_unused_super(s); in sget()
898 if (!s) { in sget()
900 s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns); in sget()
901 if (!s) in sget()
906 err = set(s, data); in sget()
909 destroy_unused_super(s); in sget()
912 s->s_type = type; in sget()
913 strscpy(s->s_id, type->name, sizeof(s->s_id)); in sget()
914 list_add_tail(&s->s_list, &super_blocks); in sget()
915 hlist_add_head(&s->s_instances, &type->fs_supers); in sget()
918 register_shrinker_prepared(&s->s_shrink); in sget()
919 return s; in sget()
1297 int set_anon_super(struct super_block *s, void *data) in set_anon_super() argument
1299 return get_anon_bdev(&s->s_dev); in set_anon_super()
1331 static int test_single_super(struct super_block *s, struct fs_context *fc) in test_single_super() argument
1390 static int set_bdev_super(struct super_block *s, void *data) in set_bdev_super() argument
1392 s->s_dev = *(dev_t *)data; in set_bdev_super()
1396 static int super_s_dev_set(struct super_block *s, struct fs_context *fc) in super_s_dev_set() argument
1398 return set_bdev_super(s, fc->sget_key); in super_s_dev_set()
1401 static int super_s_dev_test(struct super_block *s, struct fs_context *fc) in super_s_dev_test() argument
1403 return !(s->s_iflags & SB_I_RETIRED) && in super_s_dev_test()
1404 s->s_dev == *(dev_t *)fc->sget_key; in super_s_dev_test()
1555 struct super_block *s; in get_tree_bdev() local
1569 s = sget_dev(fc, dev); in get_tree_bdev()
1570 if (IS_ERR(s)) in get_tree_bdev()
1571 return PTR_ERR(s); in get_tree_bdev()
1573 if (s->s_root) { in get_tree_bdev()
1575 if ((fc->sb_flags ^ s->s_flags) & SB_RDONLY) { in get_tree_bdev()
1576 warnf(fc, "%pg: Can't mount, would change RO state", s->s_bdev); in get_tree_bdev()
1577 deactivate_locked_super(s); in get_tree_bdev()
1587 super_unlock_excl(s); in get_tree_bdev()
1588 error = setup_bdev_super(s, fc->sb_flags, fc); in get_tree_bdev()
1589 __super_lock_excl(s); in get_tree_bdev()
1591 error = fill_super(s, fc); in get_tree_bdev()
1593 deactivate_locked_super(s); in get_tree_bdev()
1596 s->s_flags |= SB_ACTIVE; in get_tree_bdev()
1600 fc->root = dget(s->s_root); in get_tree_bdev()
1605 static int test_bdev_super(struct super_block *s, void *data) in test_bdev_super() argument
1607 return !(s->s_iflags & SB_I_RETIRED) && s->s_dev == *(dev_t *)data; in test_bdev_super()
1614 struct super_block *s; in mount_bdev() local
1623 s = sget(fs_type, test_bdev_super, set_bdev_super, flags, &dev); in mount_bdev()
1624 if (IS_ERR(s)) in mount_bdev()
1625 return ERR_CAST(s); in mount_bdev()
1627 if (s->s_root) { in mount_bdev()
1628 if ((flags ^ s->s_flags) & SB_RDONLY) { in mount_bdev()
1629 deactivate_locked_super(s); in mount_bdev()
1639 super_unlock_excl(s); in mount_bdev()
1640 error = setup_bdev_super(s, flags, NULL); in mount_bdev()
1641 __super_lock_excl(s); in mount_bdev()
1643 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0); in mount_bdev()
1645 deactivate_locked_super(s); in mount_bdev()
1649 s->s_flags |= SB_ACTIVE; in mount_bdev()
1652 return dget(s->s_root); in mount_bdev()
1675 struct super_block *s = sget(fs_type, NULL, set_anon_super, flags, NULL); in mount_nodev() local
1677 if (IS_ERR(s)) in mount_nodev()
1678 return ERR_CAST(s); in mount_nodev()
1680 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0); in mount_nodev()
1682 deactivate_locked_super(s); in mount_nodev()
1685 s->s_flags |= SB_ACTIVE; in mount_nodev()
1686 return dget(s->s_root); in mount_nodev()
1690 int reconfigure_single(struct super_block *s, in reconfigure_single() argument
1701 fc = fs_context_for_reconfigure(s->s_root, flags, MS_RMT_MASK); in reconfigure_single()
1715 static int compare_single(struct super_block *s, void *p) in compare_single() argument
1724 struct super_block *s; in mount_single() local
1727 s = sget(fs_type, compare_single, set_anon_super, flags, NULL); in mount_single()
1728 if (IS_ERR(s)) in mount_single()
1729 return ERR_CAST(s); in mount_single()
1730 if (!s->s_root) { in mount_single()
1731 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0); in mount_single()
1733 s->s_flags |= SB_ACTIVE; in mount_single()
1735 error = reconfigure_single(s, flags, data); in mount_single()
1738 deactivate_locked_super(s); in mount_single()
1741 return dget(s->s_root); in mount_single()