Skip to content

Commit

Permalink
btrfs: fix unlocked access of delalloc_inodes
Browse files Browse the repository at this point in the history
list_splice_init will make delalloc_inodes empty, but without a spinlock
around, this may produce corrupted list head, accessed in many placess,
The race window is very tight and nobody seems to have hit it so far.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
David Sterba authored and Chris Mason committed Jun 10, 2011
1 parent 027ed2f commit 5be7675
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2911,9 +2911,8 @@ static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root)

INIT_LIST_HEAD(&splice);

list_splice_init(&root->fs_info->delalloc_inodes, &splice);

spin_lock(&root->fs_info->delalloc_lock);
list_splice_init(&root->fs_info->delalloc_inodes, &splice);

while (!list_empty(&splice)) {
btrfs_inode = list_entry(splice.next, struct btrfs_inode,
Expand Down

0 comments on commit 5be7675

Please sign in to comment.