Skip to content

Commit 551de6f

Browse files
author
Al Viro
committed
Leave superblocks on s_list until the end
We used to remove from s_list and s_instances at the same time. So let's *not* do the former and skip superblocks that have empty s_instances in the loops over s_list. The next step, of course, will be to get rid of rescan logics in those loops. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 1712ac8 commit 551de6f

6 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎fs/buffer.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ static void do_thaw_all(struct work_struct *work)
568568
spin_lock(&sb_lock);
569569
restart:
570570
list_for_each_entry(sb, &super_blocks, s_list) {
571+
if (list_empty(&sb->s_instances))
572+
continue;
571573
sb->s_count++;
572574
spin_unlock(&sb_lock);
573575
down_read(&sb->s_umount);

‎fs/dcache.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ static void prune_dcache(int count)
552552
prune_ratio = unused / count;
553553
spin_lock(&sb_lock);
554554
list_for_each_entry(sb, &super_blocks, s_list) {
555+
if (list_empty(&sb->s_instances))
556+
continue;
555557
if (sb->s_nr_dentry_unused == 0)
556558
continue;
557559
sb->s_count++;

‎fs/drop_caches.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ static void drop_pagecache(void)
4040
spin_lock(&sb_lock);
4141
restart:
4242
list_for_each_entry(sb, &super_blocks, s_list) {
43+
if (list_empty(&sb->s_instances))
44+
continue;
4345
sb->s_count++;
4446
spin_unlock(&sb_lock);
4547
down_read(&sb->s_umount);

‎fs/quota/quota.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static int quota_sync_all(int type)
5959
spin_lock(&sb_lock);
6060
restart:
6161
list_for_each_entry(sb, &super_blocks, s_list) {
62+
if (list_empty(&sb->s_instances))
63+
continue;
6264
if (!sb->s_qcop || !sb->s_qcop->quota_sync)
6365
continue;
6466

‎fs/super.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static int __put_super(struct super_block *sb)
135135
int ret = 0;
136136

137137
if (!--sb->s_count) {
138+
list_del_init(&sb->s_list);
138139
destroy_super(sb);
139140
ret = 1;
140141
}
@@ -151,7 +152,7 @@ static int __put_super(struct super_block *sb)
151152
int __put_super_and_need_restart(struct super_block *sb)
152153
{
153154
/* check for race with generic_shutdown_super() */
154-
if (list_empty(&sb->s_list)) {
155+
if (list_empty(&sb->s_instances)) {
155156
/* super block is removed, need to restart... */
156157
__put_super(sb);
157158
return 1;
@@ -308,8 +309,7 @@ void generic_shutdown_super(struct super_block *sb)
308309
}
309310
spin_lock(&sb_lock);
310311
/* should be initialized for __put_super_and_need_restart() */
311-
list_del_init(&sb->s_list);
312-
list_del(&sb->s_instances);
312+
list_del_init(&sb->s_instances);
313313
spin_unlock(&sb_lock);
314314
up_write(&sb->s_umount);
315315
}
@@ -400,6 +400,8 @@ void sync_supers(void)
400400
spin_lock(&sb_lock);
401401
restart:
402402
list_for_each_entry(sb, &super_blocks, s_list) {
403+
if (list_empty(&sb->s_instances))
404+
continue;
403405
if (sb->s_op->write_super && sb->s_dirt) {
404406
sb->s_count++;
405407
spin_unlock(&sb_lock);
@@ -435,6 +437,8 @@ struct super_block * get_super(struct block_device *bdev)
435437
spin_lock(&sb_lock);
436438
rescan:
437439
list_for_each_entry(sb, &super_blocks, s_list) {
440+
if (list_empty(&sb->s_instances))
441+
continue;
438442
if (sb->s_bdev == bdev) {
439443
sb->s_count++;
440444
spin_unlock(&sb_lock);
@@ -471,6 +475,8 @@ struct super_block *get_active_super(struct block_device *bdev)
471475

472476
spin_lock(&sb_lock);
473477
list_for_each_entry(sb, &super_blocks, s_list) {
478+
if (list_empty(&sb->s_instances))
479+
continue;
474480
if (sb->s_bdev != bdev)
475481
continue;
476482

@@ -490,6 +496,8 @@ struct super_block * user_get_super(dev_t dev)
490496
spin_lock(&sb_lock);
491497
rescan:
492498
list_for_each_entry(sb, &super_blocks, s_list) {
499+
if (list_empty(&sb->s_instances))
500+
continue;
493501
if (sb->s_dev == dev) {
494502
sb->s_count++;
495503
spin_unlock(&sb_lock);
@@ -600,6 +608,8 @@ static void do_emergency_remount(struct work_struct *work)
600608

601609
spin_lock(&sb_lock);
602610
list_for_each_entry(sb, &super_blocks, s_list) {
611+
if (list_empty(&sb->s_instances))
612+
continue;
603613
sb->s_count++;
604614
spin_unlock(&sb_lock);
605615
down_write(&sb->s_umount);

‎fs/sync.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@ static void sync_filesystems(int wait)
9999
mutex_lock(&mutex); /* Could be down_interruptible */
100100
spin_lock(&sb_lock);
101101
list_for_each_entry(sb, &super_blocks, s_list)
102-
sb->s_need_sync = 1;
102+
if (!list_empty(&sb->s_instances))
103+
sb->s_need_sync = 1;
103104

104105
restart:
105106
list_for_each_entry(sb, &super_blocks, s_list) {
107+
if (list_empty(&sb->s_instances))
108+
continue;
106109
if (!sb->s_need_sync)
107110
continue;
108111
sb->s_need_sync = 0;

0 commit comments

Comments
 (0)