Skip to content

Commit 7892f2f

Browse files
Ingo MolnarIngo Molnar
authored andcommitted
[PATCH] mutex subsystem, semaphore to mutex: VFS, sb->s_lock
This patch converts the superblock-lock semaphore to a mutex, affecting lock_super()/unlock_super(). Tested on ext3 and XFS. Signed-off-by: Ingo Molnar <[email protected]>
1 parent 1b1dcc1 commit 7892f2f

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

fs/ext3/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ int ext3_force_commit(struct super_block *sb)
21502150

21512151
static void ext3_write_super (struct super_block * sb)
21522152
{
2153-
if (down_trylock(&sb->s_lock) == 0)
2153+
if (mutex_trylock(&sb->s_lock) != 0)
21542154
BUG();
21552155
sb->s_dirt = 0;
21562156
}

fs/ocfs2/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static match_table_t tokens = {
169169
*/
170170
static void ocfs2_write_super(struct super_block *sb)
171171
{
172-
if (down_trylock(&sb->s_lock) == 0)
172+
if (mutex_trylock(&sb->s_lock) != 0)
173173
BUG();
174174
sb->s_dirt = 0;
175175
}

fs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static struct super_block *alloc_super(void)
7272
INIT_HLIST_HEAD(&s->s_anon);
7373
INIT_LIST_HEAD(&s->s_inodes);
7474
init_rwsem(&s->s_umount);
75-
sema_init(&s->s_lock, 1);
75+
mutex_init(&s->s_lock);
7676
down_write(&s->s_umount);
7777
s->s_count = S_BIAS;
7878
atomic_set(&s->s_active, 1);

include/linux/fs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ struct super_block {
821821
unsigned long s_magic;
822822
struct dentry *s_root;
823823
struct rw_semaphore s_umount;
824-
struct semaphore s_lock;
824+
struct mutex s_lock;
825825
int s_count;
826826
int s_syncing;
827827
int s_need_sync_fs;
@@ -893,13 +893,13 @@ static inline int has_fs_excl(void)
893893
static inline void lock_super(struct super_block * sb)
894894
{
895895
get_fs_excl();
896-
down(&sb->s_lock);
896+
mutex_lock(&sb->s_lock);
897897
}
898898

899899
static inline void unlock_super(struct super_block * sb)
900900
{
901901
put_fs_excl();
902-
up(&sb->s_lock);
902+
mutex_unlock(&sb->s_lock);
903903
}
904904

905905
/*

0 commit comments

Comments
 (0)