From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225p0K/bZ8ta7v48hsV9yl2vtyV9cA9rZupU+TtTM7rPF1RC3Ft1G5mDwqG1TpBBgO/3b/IF ARC-Seal: i=1; a=rsa-sha256; t=1516611204; cv=none; d=google.com; s=arc-20160816; b=lW7X/GISnQXJzzia4scvB93kE5cc1Fk+QbLYdbIqjRlfrTsd2NkzrqQn8IEqcBCaRb ocouXXROJQBpgvEkFJ5WdcS7+oqRgoQJhiJkin+4xUraMperGeck2rNglX2l0IDQ+FgH cktwqHkYcLFcJ6g2SCkgEIRoYqKbH7X/PX2vd27Dd8hf2ElBpogJ+OHE4ELmlkyRcpC3 99CI/xHPu2WcGz+WfTuLpkM9rGUx9qS+cozB54z3WmRPF27/JKn3eUzwwjMSr6zCwT8p VBmRwpI53JTb1Lo7nOLIT/DxhIkv+MYkaFMvz27sbQuA8h4yCYBzt0GtZdO2OcZFkkkE R3cw== 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=vcdIP53qLu8KNub3tXxWvUVqTXOI7dPkcP/sb4oNXfw=; b=BkVRlCdccQSp+MMGbEbqbqKX8kx7tEkSIs6c4+qLqPmzQ92mTSmG9XOwhXZHgLhY5l U3sMPCrc6d+ue0twMOtktgwtXxZbN3WZRw2JL7A3+Mh3v00wKLJoJzQ0XWGOo/Ue5yRG YPojiVzSpPaQivxLaCFzWGONS59WW26JmQ9Q9KfZyBEWLx7m/ycIWuJPAAIP9YVZepN+ 5pElbo4JnuREbzKXl5vD/8EaYUP6ztSzne3Cvb31BzUaSe6D7xeTjVs48r189NnfMY4G w6iEjJJ2DXU4U9QKcQCWdOUbN3GVjKUjM+i9jEYUEArLMK2r6WPIOwAnaDJ7AbK2NG/t WJDA== 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.14 71/89] dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 Date: Mon, 22 Jan 2018 09:45:51 +0100 Message-Id: <20180122084001.517639713@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@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?1590282110979072434?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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 @@ -80,10 +80,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