Skip to content

Commit

Permalink
Btrfs: fix block_rsv and space_info lock ordering
Browse files Browse the repository at this point in the history
may_commit_transaction() calls
        spin_lock(&space_info->lock);
        spin_lock(&delayed_rsv->lock);
and update_global_block_rsv() calls
        spin_lock(&block_rsv->lock);
        spin_lock(&sinfo->lock);

Lockdep complains about this at run time.
Everywhere except in update_global_block_rsv(), the space_info lock is
the outer lock, therefore the locking order in update_global_block_rsv()
is changed.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Stefan Behrens authored and Chris Mason committed Apr 27, 2012
1 parent 1daf354 commit 1f699d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4214,8 +4214,8 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)

num_bytes = calc_global_metadata_size(fs_info);

spin_lock(&block_rsv->lock);
spin_lock(&sinfo->lock);
spin_lock(&block_rsv->lock);

block_rsv->size = num_bytes;

Expand All @@ -4241,8 +4241,8 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
block_rsv->full = 1;
}

spin_unlock(&sinfo->lock);
spin_unlock(&block_rsv->lock);
spin_unlock(&sinfo->lock);
}

static void init_global_block_rsv(struct btrfs_fs_info *fs_info)
Expand Down

0 comments on commit 1f699d3

Please sign in to comment.