提交 ed3ad79f 编写于 作者: F Fabian Frederick 提交者: Linus Torvalds

fs/ufs/super.c: fix potential race condition

Let locking subsystem decide on mutex management.  As reported by Andrew
Morton this patch fixes a bug:

: lock_ufs() is assuming that on non-preempt uniprocessor, the calling
: code will run atomically up to the matching unlock_ufs().
:
: But that isn't true. The very first site I looked at (ufs_frag_map)
: does sb_bread() under lock_ufs().  And sb_bread() will call schedule(),
: very commonly.
:
: The ->mutex_owner stuff is a bit hacky but should work OK.
Signed-off-by: NFabian Frederick <fabf@skynet.be>
Cc: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 61da3ae2
...@@ -95,22 +95,18 @@ ...@@ -95,22 +95,18 @@
void lock_ufs(struct super_block *sb) void lock_ufs(struct super_block *sb)
{ {
#if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT)
struct ufs_sb_info *sbi = UFS_SB(sb); struct ufs_sb_info *sbi = UFS_SB(sb);
mutex_lock(&sbi->mutex); mutex_lock(&sbi->mutex);
sbi->mutex_owner = current; sbi->mutex_owner = current;
#endif
} }
void unlock_ufs(struct super_block *sb) void unlock_ufs(struct super_block *sb)
{ {
#if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT)
struct ufs_sb_info *sbi = UFS_SB(sb); struct ufs_sb_info *sbi = UFS_SB(sb);
sbi->mutex_owner = NULL; sbi->mutex_owner = NULL;
mutex_unlock(&sbi->mutex); mutex_unlock(&sbi->mutex);
#endif
} }
static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation) static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册