summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDennis Yang <dennisyang@qnap.com>2017-12-12 18:21:40 +0800
committerBen Hutchings <ben@decadent.org.uk>2018-03-03 15:51:00 +0000
commit181397fc16b72c4f7a0079a89022df817e99fa19 (patch)
tree9f3313e8fe300194bfcf40cd05d455dbca7570a8 /drivers
parent4a92df31aa9b79ebeca325ac9991bbca8d2bd5a6 (diff)
downloadlinux-181397fc16b72c4f7a0079a89022df817e99fa19.tar.gz
linux-181397fc16b72c4f7a0079a89022df817e99fa19.tar.bz2
linux-181397fc16b72c4f7a0079a89022df817e99fa19.zip
dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6
commit 490ae017f54e55bde382d45ea24bddfb6d1a0aaf 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: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-thin-metadata.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 525f560884a5..b2ad14e000dd 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -81,10 +81,14 @@
#define SECTOR_TO_BLOCK_SHIFT 3
/*
+ * For btree insert:
* 3 for btree insert +
* 2 for btree lookup used within space map
+ * For btree remove:
+ * 2 for shadow spine +
+ * 4 for rebalance 3 child node
*/
-#define THIN_MAX_CONCURRENT_LOCKS 5
+#define THIN_MAX_CONCURRENT_LOCKS 6
/* This should be plenty */
#define SPACE_MAP_ROOT_SIZE 128