Received: by 10.223.176.46 with SMTP id f43csp2658087wra; Mon, 22 Jan 2018 01:02:59 -0800 (PST) X-Google-Smtp-Source: AH8x227NUEOdUy/pF/9sVh84kVU2zzcZsyfSIkwPaMk1WaQqeySk4PTDOMe2OcWovBrjbIAha2kc X-Received: by 2002:a17:902:14d:: with SMTP id 71-v6mr3079659plb.42.1516611779727; Mon, 22 Jan 2018 01:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516611779; cv=none; d=google.com; s=arc-20160816; b=Pv6Ex4DF57qV6ima+rB3NcbosRQ02MC8+AfIwUEs+4J1MB9zHY99tYL9M5eMrhBrSU EPhkBxPehgWkFTobzEHGnGWERVKn3mugWM9LZbO634BXonpH5EON7+E7WfACwQUAIZ7X wRsh/ARkkO5719BhGTPst0DU2xZbpRGuuLfPObcK1Yg8Q94iu/Nt4N/rb/on5RSndMVH htBJLhIswqFxNdzGAWNodg3pN9FG3j4HWxmp0FtR3ntcAApUdTp4C6xvdGBvMBL/4xlq obMNNkNyfYQ/R1DCqVkZfdWZReQ4c8hqmyb0LmYTCosqF3TD9bVFiLCZzaVOaI0DcAs5 cgaQ== 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=vcdIP53qLu8KNub3tXxWvUVqTXOI7dPkcP/sb4oNXfw=; b=UrFGs1qBPOtXYU/rlETAR+lTTwXHHOM+ZpteiC9SvKJgN4PI9a6xM636Ud0ttjaAx3 aKywfVitTFMTkv9hg5zGNKulsJUocYj6CRKhIaVdpyWbtRDcEySiCxT2SCo4U3Aka5oP 7MG3k3tjTNOtVO+dSjMM4oSZPHjIIu4hZahLdfGuvoI1B4zz4clNKfKvg+i5IAtCGYn2 MVr3LlRLl25fRMvbD16HE0sTq2n1CsTyocF90pUIIt4tkIcVV1pU1KsD5xX44fipkSvc 7MnQOFEjYfxkitX6TXVyM4yxMPpOPBEc0UeYnrZxrXPEufiLlQ7ptTObiCE9jbj23BCV 9dng== 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 d63si13612151pgc.260.2018.01.22.01.02.45; Mon, 22 Jan 2018 01:02:59 -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 S1753709AbeAVJBk (ORCPT + 99 others); Mon, 22 Jan 2018 04:01:40 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33956 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753565AbeAVIxX (ORCPT ); Mon, 22 Jan 2018 03:53:23 -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 18068F0B; Mon, 22 Jan 2018 08:53:22 +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.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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