diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-22 08:53:19 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 18:31:14 -0400 |
commit | b20bd1a5e78af267dc4b6e1ffed48d5d776302c5 (patch) | |
tree | d50982ee42500712d9add489435d4455580b9cac /fs/super.c | |
parent | 389b8be6ef419397e4f176652927ebad6ebb4b77 (diff) |
get rid of S_BIAS
use atomic_inc_not_zero(&sb->s_active) instead of playing games with
checking ->s_count > S_BIAS
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/fs/super.c b/fs/super.c index d8c8b1d2d010..bc734f8b3e18 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -93,7 +93,7 @@ static struct super_block *alloc_super(struct file_system_type *type) | |||
93 | * subclass. | 93 | * subclass. |
94 | */ | 94 | */ |
95 | down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING); | 95 | down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING); |
96 | s->s_count = S_BIAS; | 96 | s->s_count = 1; |
97 | atomic_set(&s->s_active, 1); | 97 | atomic_set(&s->s_active, 1); |
98 | mutex_init(&s->s_vfs_rename_mutex); | 98 | mutex_init(&s->s_vfs_rename_mutex); |
99 | mutex_init(&s->s_dquot.dqio_mutex); | 99 | mutex_init(&s->s_dquot.dqio_mutex); |
@@ -189,9 +189,7 @@ void put_super(struct super_block *sb) | |||
189 | void deactivate_super(struct super_block *s) | 189 | void deactivate_super(struct super_block *s) |
190 | { | 190 | { |
191 | struct file_system_type *fs = s->s_type; | 191 | struct file_system_type *fs = s->s_type; |
192 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { | 192 | if (atomic_dec_and_test(&s->s_active)) { |
193 | s->s_count -= S_BIAS-1; | ||
194 | spin_unlock(&sb_lock); | ||
195 | vfs_dq_off(s, 0); | 193 | vfs_dq_off(s, 0); |
196 | down_write(&s->s_umount); | 194 | down_write(&s->s_umount); |
197 | fs->kill_sb(s); | 195 | fs->kill_sb(s); |
@@ -216,9 +214,7 @@ EXPORT_SYMBOL(deactivate_super); | |||
216 | void deactivate_locked_super(struct super_block *s) | 214 | void deactivate_locked_super(struct super_block *s) |
217 | { | 215 | { |
218 | struct file_system_type *fs = s->s_type; | 216 | struct file_system_type *fs = s->s_type; |
219 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { | 217 | if (atomic_dec_and_test(&s->s_active)) { |
220 | s->s_count -= S_BIAS-1; | ||
221 | spin_unlock(&sb_lock); | ||
222 | vfs_dq_off(s, 0); | 218 | vfs_dq_off(s, 0); |
223 | fs->kill_sb(s); | 219 | fs->kill_sb(s); |
224 | put_filesystem(fs); | 220 | put_filesystem(fs); |
@@ -243,21 +239,19 @@ EXPORT_SYMBOL(deactivate_locked_super); | |||
243 | */ | 239 | */ |
244 | static int grab_super(struct super_block *s) __releases(sb_lock) | 240 | static int grab_super(struct super_block *s) __releases(sb_lock) |
245 | { | 241 | { |
242 | if (atomic_inc_not_zero(&s->s_active)) { | ||
243 | spin_unlock(&sb_lock); | ||
244 | down_write(&s->s_umount); | ||
245 | return 1; | ||
246 | } | ||
247 | /* it's going away */ | ||
246 | s->s_count++; | 248 | s->s_count++; |
247 | spin_unlock(&sb_lock); | 249 | spin_unlock(&sb_lock); |
250 | /* usually that'll be enough for it to die... */ | ||
248 | down_write(&s->s_umount); | 251 | down_write(&s->s_umount); |
249 | if (s->s_root) { | ||
250 | spin_lock(&sb_lock); | ||
251 | if (s->s_count > S_BIAS) { | ||
252 | atomic_inc(&s->s_active); | ||
253 | s->s_count--; | ||
254 | spin_unlock(&sb_lock); | ||
255 | return 1; | ||
256 | } | ||
257 | spin_unlock(&sb_lock); | ||
258 | } | ||
259 | up_write(&s->s_umount); | 252 | up_write(&s->s_umount); |
260 | put_super(s); | 253 | put_super(s); |
254 | /* ... but in case it wasn't, let's at least yield() */ | ||
261 | yield(); | 255 | yield(); |
262 | return 0; | 256 | return 0; |
263 | } | 257 | } |