Commit b10be47d authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] err1-40: sysvfs locking fix

Found by the new Stanford locking checker.

Minimal fix for a deadlock in sysvfs: get_branch() can take
read_lock(&pointers_lock), but one caller already has a write_lock.

Perhaps some of the "oh we raced, drop everything and try again" logic in
there can go away now, but this is enugh to fix the obvious deadlock.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 114a8aec
......@@ -81,6 +81,9 @@ static inline u32 *block_end(struct buffer_head *bh)
return (u32*)((char*)bh->b_data + bh->b_size);
}
/*
* Requires read_lock(&pointers_lock) or write_lock(&pointers_lock)
*/
static Indirect *get_branch(struct inode *inode,
int depth,
int offsets[],
......@@ -100,18 +103,15 @@ static Indirect *get_branch(struct inode *inode,
bh = sb_bread(sb, block);
if (!bh)
goto failure;
read_lock(&pointers_lock);
if (!verify_chain(chain, p))
goto changed;
add_chain(++p, bh, (u32*)bh->b_data + *++offsets);
read_unlock(&pointers_lock);
if (!p->key)
goto no_block;
}
return NULL;
changed:
read_unlock(&pointers_lock);
brelse(bh);
*err = -EAGAIN;
goto no_block;
......@@ -213,7 +213,9 @@ static int get_block(struct inode *inode, sector_t iblock, struct buffer_head *b
goto out;
reread:
read_lock(&pointers_lock);
partial = get_branch(inode, depth, offsets, chain, &err);
read_unlock(&pointers_lock);
/* Simplest case - block found, no allocation needed */
if (!partial) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment