提交 dca33252 编写于 作者: A Al Viro

no need for list_for_each_entry_safe()/resetting with superblock list

just delay __put_super() a bit
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 7a4dec53
...@@ -536,7 +536,7 @@ static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags) ...@@ -536,7 +536,7 @@ static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags)
*/ */
static void prune_dcache(int count) static void prune_dcache(int count)
{ {
struct super_block *sb, *n; struct super_block *sb, *p = NULL;
int w_count; int w_count;
int unused = dentry_stat.nr_unused; int unused = dentry_stat.nr_unused;
int prune_ratio; int prune_ratio;
...@@ -550,7 +550,7 @@ static void prune_dcache(int count) ...@@ -550,7 +550,7 @@ static void prune_dcache(int count)
else else
prune_ratio = unused / count; prune_ratio = unused / count;
spin_lock(&sb_lock); spin_lock(&sb_lock);
list_for_each_entry_safe(sb, n, &super_blocks, s_list) { list_for_each_entry(sb, &super_blocks, s_list) {
if (list_empty(&sb->s_instances)) if (list_empty(&sb->s_instances))
continue; continue;
if (sb->s_nr_dentry_unused == 0) if (sb->s_nr_dentry_unused == 0)
...@@ -590,14 +590,16 @@ static void prune_dcache(int count) ...@@ -590,14 +590,16 @@ static void prune_dcache(int count)
up_read(&sb->s_umount); up_read(&sb->s_umount);
} }
spin_lock(&sb_lock); spin_lock(&sb_lock);
/* lock was dropped, must reset next */ if (p)
list_safe_reset_next(sb, n, s_list); __put_super(p);
count -= pruned; count -= pruned;
__put_super(sb); p = sb;
/* more work left to do? */ /* more work left to do? */
if (count <= 0) if (count <= 0)
break; break;
} }
if (p)
__put_super(p);
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
} }
......
...@@ -363,10 +363,10 @@ EXPORT_SYMBOL(drop_super); ...@@ -363,10 +363,10 @@ EXPORT_SYMBOL(drop_super);
*/ */
void sync_supers(void) void sync_supers(void)
{ {
struct super_block *sb, *n; struct super_block *sb, *p = NULL;
spin_lock(&sb_lock); spin_lock(&sb_lock);
list_for_each_entry_safe(sb, n, &super_blocks, s_list) { list_for_each_entry(sb, &super_blocks, s_list) {
if (list_empty(&sb->s_instances)) if (list_empty(&sb->s_instances))
continue; continue;
if (sb->s_op->write_super && sb->s_dirt) { if (sb->s_op->write_super && sb->s_dirt) {
...@@ -379,11 +379,13 @@ void sync_supers(void) ...@@ -379,11 +379,13 @@ void sync_supers(void)
up_read(&sb->s_umount); up_read(&sb->s_umount);
spin_lock(&sb_lock); spin_lock(&sb_lock);
/* lock was dropped, must reset next */ if (p)
list_safe_reset_next(sb, n, s_list); __put_super(p);
__put_super(sb); p = sb;
} }
} }
if (p)
__put_super(p);
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
} }
...@@ -397,10 +399,10 @@ void sync_supers(void) ...@@ -397,10 +399,10 @@ void sync_supers(void)
*/ */
void iterate_supers(void (*f)(struct super_block *, void *), void *arg) void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
{ {
struct super_block *sb, *n; struct super_block *sb, *p = NULL;
spin_lock(&sb_lock); spin_lock(&sb_lock);
list_for_each_entry_safe(sb, n, &super_blocks, s_list) { list_for_each_entry(sb, &super_blocks, s_list) {
if (list_empty(&sb->s_instances)) if (list_empty(&sb->s_instances))
continue; continue;
sb->s_count++; sb->s_count++;
...@@ -412,10 +414,12 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) ...@@ -412,10 +414,12 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
up_read(&sb->s_umount); up_read(&sb->s_umount);
spin_lock(&sb_lock); spin_lock(&sb_lock);
/* lock was dropped, must reset next */ if (p)
list_safe_reset_next(sb, n, s_list); __put_super(p);
__put_super(sb); p = sb;
} }
if (p)
__put_super(p);
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
} }
...@@ -577,10 +581,10 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) ...@@ -577,10 +581,10 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
static void do_emergency_remount(struct work_struct *work) static void do_emergency_remount(struct work_struct *work)
{ {
struct super_block *sb, *n; struct super_block *sb, *p = NULL;
spin_lock(&sb_lock); spin_lock(&sb_lock);
list_for_each_entry_safe(sb, n, &super_blocks, s_list) { list_for_each_entry(sb, &super_blocks, s_list) {
if (list_empty(&sb->s_instances)) if (list_empty(&sb->s_instances))
continue; continue;
sb->s_count++; sb->s_count++;
...@@ -594,10 +598,12 @@ static void do_emergency_remount(struct work_struct *work) ...@@ -594,10 +598,12 @@ static void do_emergency_remount(struct work_struct *work)
} }
up_write(&sb->s_umount); up_write(&sb->s_umount);
spin_lock(&sb_lock); spin_lock(&sb_lock);
/* lock was dropped, must reset next */ if (p)
list_safe_reset_next(sb, n, s_list); __put_super(p);
__put_super(sb); p = sb;
} }
if (p)
__put_super(p);
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
kfree(work); kfree(work);
printk("Emergency Remount complete\n"); printk("Emergency Remount complete\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册