Received: by 10.223.176.46 with SMTP id f43csp2678187wra; Mon, 22 Jan 2018 01:25:40 -0800 (PST) X-Google-Smtp-Source: AH8x227re37oGO7ITeIT7N0Ko5w5U11ZicXuVh2m2BCRtoVj5yvJUIgO2nVjmwjyMxjAYmXHA5/r X-Received: by 10.101.65.205 with SMTP id b13mr6849674pgq.280.1516613140575; Mon, 22 Jan 2018 01:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516613140; cv=none; d=google.com; s=arc-20160816; b=FfY+9V+jgfF5jObYLl1JoELYBR2n50riE5MjSMnj7KTHTID9SrQbgHK8JiwDpEyPhC lphV27mCUWq957kUXbcB9MO6N5iHtjA98ywM/TEMwUF6bS+vJGoJf/iEFFpmK9uSJnor vPqov1o/8AvTNUM1dTRt7L5H4RwwgKrkjhWNfXfc2rkco8zBOdOxgvabcBwAVoFWsafP vOm4XTTW9tquIKZzsjvNBMzJ0wHCgG2i3Rxf+EN4uOmvztjic0LtgruXY+YT6qqi4owu mwgBQAnCLEMQG55J2hnFDg38eoZkiLK2mv1yrZix+f8/XlkAEh9iwacfO3b0XgF+E9g3 SlKw== 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=9Myb6HqLLUp/JPwf0dd1f4plPwiuoAGjfku0KFMH3AQ=; b=xiC+qkix8Es3xYmszd8hi7y0TfghanyPILSw31M4JyDxq1rv2187ZwrIr+MKwDafbi sqUKQf2mQ9Qs7gZ1yoqBFGWkWu2w2g/clyUU5+r+HTil7dO6BPhX5D8XBXb0hL88NJ6Z HCKvARrzuash7Qk0NX23Kq9hi0us9A3Um4fWRwinAUmEFQh3fmHhcfv6evfD9QDX50/J nFN7QjkHM4IhiE2mpV2cslv6+Q8LsridcCEpyoxIV5hrl2NRE3XdXTHt6hkxUOLi7kpq O29S7gkjSS5+bGXzCwsWHlePSlqCst4ySPe/uOc/hnWz9LBM+6wXqUbbvQ6dnZGkqdBG R1BQ== 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 d25si15174265pfl.211.2018.01.22.01.25.26; Mon, 22 Jan 2018 01:25:40 -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 S1752445AbeAVItG (ORCPT + 99 others); Mon, 22 Jan 2018 03:49:06 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60584 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425AbeAVItE (ORCPT ); Mon, 22 Jan 2018 03:49:04 -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 979B9E10; Mon, 22 Jan 2018 08:49:03 +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.9 38/47] dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 Date: Mon, 22 Jan 2018 09:45:49 +0100 Message-Id: <20180122083928.490296684@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083925.568134913@linuxfoundation.org> References: <20180122083925.568134913@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.9-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