Skip to content

Commit 5f12c33

Browse files
qnap-dennisyanggregkh
authored andcommitted
dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6
commit 490ae01 upstream. For btree removal, there is a corner case that a single thread could takes 6 locks which is more than THIN_MAX_CONCURRENT_LOCKS(5) and leads to deadlock. A btree removal might eventually call rebalance_children()->rebalance3() to rebalance entries of three neighbor child nodes when shadow_spine has already acquired two write locks. In rebalance3(), it tries to shadow and acquire the write locks of all three child nodes. However, shadowing a child node requires acquiring a read lock of the original child node and a write lock of the new block. Although the read lock will be released after block shadowing, shadowing the third child node in rebalance3() could still take the sixth lock. (2 write locks for shadow_spine + 2 write locks for the first two child nodes's shadow + 1 write lock for the last child node's shadow + 1 read lock for the last child node) Signed-off-by: Dennis Yang <dennisyang@qnap.com> Acked-by: Joe Thornber <thornber@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9056370 commit 5f12c33

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/md/dm-thin-metadata.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@
8080
#define SECTOR_TO_BLOCK_SHIFT 3
8181

8282
/*
83+
* For btree insert:
8384
* 3 for btree insert +
8485
* 2 for btree lookup used within space map
86+
* For btree remove:
87+
* 2 for shadow spine +
88+
* 4 for rebalance 3 child node
8589
*/
86-
#define THIN_MAX_CONCURRENT_LOCKS 5
90+
#define THIN_MAX_CONCURRENT_LOCKS 6
8791

8892
/* This should be plenty */
8993
#define SPACE_MAP_ROOT_SIZE 128

0 commit comments

Comments
 (0)