]> git.hungrycats.org Git - linux/commit
Btrfs: Fix misuse of chunk mutex
authorMiao Xie <miaox@cn.fujitsu.com>
Wed, 3 Sep 2014 13:35:41 +0000 (21:35 +0800)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Wed, 3 Dec 2014 15:16:56 +0000 (10:16 -0500)
commitb2e36c81e1094d19d3a49768294b6aea75150412
tree37c9172369e48b6840a4ed97a6a5c473b7e6f671
parent5958f27780f18645032ad499078050e59b3c9c59
Btrfs: Fix misuse of chunk mutex

There were several problems about chunk mutex usage:
- Lock chunk mutex when updating metadata. It would cause the nested
  deadlock because updating metadata might need allocate new chunks
  that need acquire chunk mutex. We remove chunk mutex at this case,
  because b-tree lock and other lock mechanism can help us.
- ABBA deadlock occured between device_list_mutex and chunk_mutex.
  When we update device status, we must acquire device_list_mutex at the
  beginning, and then we might get chunk_mutex during the device status
  update because we need allocate new chunks for metadata COW. But at
  most place, we acquire chunk_mutex at first and then acquire device list
  mutex. We need change the lock order.
- Some place we needn't acquire chunk_mutex. For example we needn't get
  chunk_mutex when we free a empty seed fs_devices structure.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 2196d6e8a71fc901e31c1d81581fc6cc6c64913e)
fs/btrfs/dev-replace.c
fs/btrfs/extent-tree.c
fs/btrfs/volumes.c