From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225op3CljfX85oPmJ/kTOGrXI8dS8xxawgtGz82K4Ygd+gpJYMkBxypusPj+a6ZgWZCgxRFr ARC-Seal: i=1; a=rsa-sha256; t=1516610550; cv=none; d=google.com; s=arc-20160816; b=BNt1E20/aO6kXCsN73Ol1JNM0AwuUre7evIKSqO7Qpjs8KUKbj5tjcI78pHZpc84tY GGLa/o68HRnne32hNqvgJ9TkHjykj5g3FGx1XfSooOhkoRf6sEyySCFE8lVerZg1+9ow UxT0wngewCNez+IhDjxTqjTi0p3SZEYq0FE8merB2dvo2FEfBPals89kNnXtY3khNirO 3GLfwFjBXjV4Wq9BACgZEOHrYv0/LwMbcvazPP2ztXOBoOX0EXCi+uAcYWXbg16hz4BW RxN9aJH6r4qUMFZPEGv4usvZhTbO3Qjd5k4TMU2IceOa4UZ7snVbuMfVCfE+oTmy6E4C q81g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8mJqzKZFlQ6K5l4GYtn2NmnG6SXi4qd+9jXpjgwLc6Y=; b=0RPdns0QSqSmK975d186xIe4O2FGrxJLLzjLuBGGH8LXRjaHW2+Jjwbql53SfMhn2M YAKGSCAtjC4NUFiSB/Q/1F7auiVYvaLOw8HQUuoBMLePHKoB/O8g+pKJkO0PbiqDCT7T nNAW4wAmWpVIuVMns1qeWyLgNgfussp+VSZeUuWKEBsc5Sa+OJcsEkRw/4yaW+XuRkvR FE9LrR9PHr5AIdcgVJ6SYSWU7YlJeg+M7TLWQW5+U56+xvgHGkdN63salok/9KGNfFeh GX9rky0c6/xj0MPKW7fGgEXBp0b8Bu48W7Ydfek7MS2rjpzkOMGY5k4tJrE9XJRVaSOA iZFg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dennis Yang , Joe Thornber , Mike Snitzer Subject: [PATCH 4.4 44/53] dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 Date: Mon, 22 Jan 2018 09:40:36 +0100 Message-Id: <20180122083912.485134595@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083910.299610926@linuxfoundation.org> References: <20180122083910.299610926@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590281424493403566?= X-GMAIL-MSGID: =?utf-8?q?1590281424493403566?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dennis Yang 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 Acked-by: Joe Thornber Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-thin-metadata.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- 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