Received: by 10.223.176.5 with SMTP id f5csp3437323wra; Mon, 29 Jan 2018 13:10:02 -0800 (PST) X-Google-Smtp-Source: AH8x227pNeaKiyLOW3PZd2UN4UE9wNC9FqWftqTbN2sTVV740GfVh1n+V4aHmCCXGNKKvLwutouU X-Received: by 10.98.54.71 with SMTP id d68mr27820900pfa.173.1517260202520; Mon, 29 Jan 2018 13:10:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517260202; cv=none; d=google.com; s=arc-20160816; b=Q0Ee+pK4gWT/kVfu7+92akibluN4PrGX6Dr12zkgP23RHWB32NGuGElYyQPAimFHCe BKq3oY0RJAhWKGN0yRUAHhW7OVwmkPPMch/u832XAb+2qrAeH434ZkoqjB9rCZob9WhR svEUh5a3jz0tBpFBzGZbGnLoO7HBe456Dw7HSSiwIkeSyBhxIpXrPPOjm0lUJDKFK1at shjFL/wLbDAh0aSP70BP8xXfUJjT5EIljrrhL1i+R2CnieOoD9yXe4xdzA9oJOEH5JdA V0aoUhR1dYTs7Eo+D85x7+b1Y6w23AQJDWAk62Dx77Cpfwhz37lr9m1uZBjSLzHoFNhE c1Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=W9NSWtZQZz+ZWOer+/TTeqrCHuCL5DNQVFF4RNjQQb4=; b=JSb24OCD3goFZFZRFsUGxDNRwtZwldzj2nl1KPRWcwMKMC6BErOipHjkaljvZ1RI0Q 98fau3Qq4gGopy3D4JygifRNxnZ31M3CUCre2buKY5bz0t/vjWcSd46LolUQZ/klmUOp A9M3YBsUGgsAlFONhT54y54h2MFL508bsF66a4M4M2v66x007Sb9ca3gLuFQNEcp4lIy 1TJ63rVQh81svlFSrZSu/7lhinBI/IoH3JAb+x1PC5Zb0lU9qA09XkdXOxp6XLro6Gb/ 6Xw9Q2qFR+S0OnDJlrmRjWqomJMuIAGTVw2t2eVlRV/Gtyh2W7VxaxdQQgrsl2qPWJtG IcIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18-v6si298800pll.186.2018.01.29.13.09.47; Mon, 29 Jan 2018 13:10:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbeA2VJZ (ORCPT + 99 others); Mon, 29 Jan 2018 16:09:25 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48112 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752680AbeA2UGY (ORCPT ); Mon, 29 Jan 2018 15:06:24 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 029452EC7; Mon, 29 Jan 2018 13:00:09 +0000 (UTC) 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 3.18 17/52] dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 Date: Mon, 29 Jan 2018 13:56:35 +0100 Message-Id: <20180129123628.953073824@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123628.168904217@linuxfoundation.org> References: <20180129123628.168904217@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-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