Received: by 10.223.176.46 with SMTP id f43csp2692186wra; Mon, 22 Jan 2018 01:42:18 -0800 (PST) X-Google-Smtp-Source: AH8x225j3SPKO2WsV8SXLynWh+ucHGvzL2u7ljH7vrgeGMKKEiNxv0I/oi95cEp1eGF0GpRxlNXp X-Received: by 10.99.174.69 with SMTP id e5mr6915755pgp.263.1516614138699; Mon, 22 Jan 2018 01:42:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516614138; cv=none; d=google.com; s=arc-20160816; b=DpiPfHCFO7Epug/BpBI3T/J7EESUqrET18BbHzW9MqN2RrYT1TPMXrXiJZM1hU7pUF 8OTRZaZVd+346IM5TPUQi7bzRgGFC70z6h0Q9IwZ09+fasxntyMDxILcfUEIwiw6WpPO SGaZL0hOUYzR7kYt5VlwmYqjFZa+bRGT0lO/Xws+CsUwQwry3ajBgNUHhtHy2021R3iL ttMUIcRVA8TwmgglKHZEBQhk3guQP3ixYy/u6s2b+l5znnQ8BrdWepeoNBiYZlwJ27vU ps1w6mUKr4Ii7EwKgsxOM35LS24eW7YYaB0nECyPwxiJD+srvzJzxenvGOBK1D1dpwQi qkyA== 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=8mJqzKZFlQ6K5l4GYtn2NmnG6SXi4qd+9jXpjgwLc6Y=; b=urMYTBgqbkg5woMuMRPnInBzjvtGkHQaW0ZK/13gr/JHD/Pqv3OGrF0OAxStzr9Yvv eOGv9MjvuhihiexnGRDP40i4xDxb067Bi05Etcq/QnLztuwMlJHEYUuHo1TnbvPlUrOf 71zGyB56XCzZ0rk7vqOTtyHvYbCUgRYTA/xDqUOPiLyhZIJHZMi/2lH2DxOXpuwVQr+s mdbhH15bbyicTUpZT+UREDTaq+Hf4/1YECNtNh98gqzRgmVU8cY0SD7X5JJ/6yeqNqc6 uJOf4b10oYxZgvTm0sJLnLk1cbO5XqejcQhVYPzw37UjwF4skF/x8oWqRJiGXXebWznO 2X1g== 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 v79si13405167pgb.185.2018.01.22.01.42.04; Mon, 22 Jan 2018 01:42:18 -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 S1751591AbeAVJlU (ORCPT + 99 others); Mon, 22 Jan 2018 04:41:20 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58944 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751265AbeAVIm3 (ORCPT ); Mon, 22 Jan 2018 03:42:29 -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 EE574F33; Mon, 22 Jan 2018 08:42:28 +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 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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