23 #include <linux/export.h>
24 #include <linux/slab.h>
25 #include <linux/acct.h>
74 if (sb->
s_op && sb->
s_op->nr_cached_objects)
75 fs_objects = sb->
s_op->nr_cached_objects(sb);
99 if (fs_objects && sb->
s_op->free_cached_objects) {
100 sb->
s_op->free_cached_objects(sb, fs_objects);
101 fs_objects = sb->
s_op->nr_cached_objects(sb);
107 total_objects = (total_objects / 100) * sysctl_vfs_cache_pressure;
109 return total_objects;
118 err = percpu_counter_init(&s->
s_writers.counter[i], 0);
133 static void destroy_sb_writers(
struct super_block *s)
177 if (init_sb_writers(s, type))
214 s->
s_op = &default_op;
230 destroy_sb_writers(s);
242 static inline void destroy_super(
struct super_block *s)
247 destroy_sb_writers(s);
263 list_del_init(&sb->
s_list);
279 spin_unlock(&sb_lock);
298 cleancache_invalidate_fs(s);
322 if (!atomic_add_unless(&s->
s_active, -1, 1)) {
344 spin_unlock(&sb_lock);
349 spin_unlock(&sb_lock);
421 printk(
"VFS: Busy inodes after unmount of %s. "
422 "Self-destruct in 5 seconds. Have a nice day...\n",
458 if (!
test(old, data))
460 if (!grab_super(old))
477 s = alloc_super(type, flags);
684 if (sb->
s_dev == dev) {
724 if (flags & MS_RDONLY)
743 if (sb->
s_op->remount_fs) {
744 retval = sb->
s_op->remount_fs(sb, &flags, data);
747 goto cancel_readonly;
749 WARN(1,
"forced remount of a %s fs returned %i\n",
750 sb->
s_type->name, retval);
766 if (remount_ro && sb->
s_bdev)
784 spin_unlock(&sb_lock);
801 spin_unlock(&sb_lock);
803 printk(
"Emergency Remount complete\n");
824 static int unnamed_dev_start = 0;
834 spin_lock(&unnamed_dev_lock);
837 unnamed_dev_start = dev + 1;
838 spin_unlock(&unnamed_dev_lock);
846 spin_lock(&unnamed_dev_lock);
848 if (unnamed_dev_start > dev)
849 unnamed_dev_start =
dev;
850 spin_unlock(&unnamed_dev_lock);
861 spin_lock(&unnamed_dev_lock);
863 if (slot < unnamed_dev_start)
864 unnamed_dev_start =
slot;
865 spin_unlock(&unnamed_dev_lock);
913 sb =
sget(fs_type, ns_test_super, ns_set_super, flags, data);
919 err = fill_super(sb, data, flags &
MS_SILENT ? 1 : 0);
934 static int set_bdev_super(
struct super_block *s,
void *data)
943 s->
s_bdi = &bdev_get_queue(s->
s_bdev)->backing_dev_info;
947 static int test_bdev_super(
struct super_block *s,
void *data)
953 int flags,
const char *dev_name,
void *data,
954 int (*fill_super)(
struct super_block *,
void *,
int))
966 return ERR_CAST(bdev);
979 s =
sget(fs_type, test_bdev_super, set_bdev_super, flags |
MS_NOSEC,
986 if ((flags ^ s->
s_flags) & MS_RDONLY) {
1008 error = fill_super(s, data, flags &
MS_SILENT ? 1 : 0);
1025 return ERR_PTR(error);
1045 int flags,
void *data,
1046 int (*fill_super)(
struct super_block *,
void *,
int))
1054 error = fill_super(s, data, flags &
MS_SILENT ? 1 : 0);
1057 return ERR_PTR(error);
1064 static int compare_single(
struct super_block *s,
void *p)
1070 int flags,
void *data,
1071 int (*fill_super)(
struct super_block *,
void *,
int))
1080 error = fill_super(s, data, flags &
MS_SILENT ? 1 : 0);
1083 return ERR_PTR(error);
1098 char *secdata =
NULL;
1102 secdata = alloc_secdata();
1108 goto out_free_secdata;
1111 root = type->
mount(type, flags, name, data);
1113 error = PTR_ERR(root);
1114 goto out_free_secdata;
1136 free_secdata(secdata);
1142 free_secdata(secdata);
1144 return ERR_PTR(error);
1153 percpu_counter_dec(&sb->
s_writers.counter[level-1]);
1159 if (waitqueue_active(&sb->
s_writers.wait))
1165 #ifdef CONFIG_LOCKDEP
1175 static void acquire_freeze_lock(
struct super_block *sb,
int level,
bool trylock,
1181 for (i = 0; i < level - 1; i++)
1205 #ifdef CONFIG_LOCKDEP
1206 acquire_freeze_lock(sb, level, !wait,
_RET_IP_);
1208 percpu_counter_inc(&sb->
s_writers.counter[level-1]);
1232 static void sb_wait_write(
struct super_block *sb,
int level)
1253 writers = percpu_counter_sum(&sb->
s_writers.counter[level-1]);
1310 if (sb->
s_flags & MS_RDONLY) {
1341 if (sb->
s_op->freeze_fs) {
1342 ret = sb->
s_op->freeze_fs(sb);
1345 "VFS:Filesystem freeze failed\n");
1382 if (sb->
s_op->unfreeze_fs) {
1383 error = sb->
s_op->unfreeze_fs(sb);
1386 "VFS:Filesystem thaw failed\n");