From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227wLdvQLmXuVdn+O1WZC+8aXUkL+myBq7UKeXZlrT5CnQO/bRLPhFDC6Jz1fJkJFhTm2FOM ARC-Seal: i=1; a=rsa-sha256; t=1517256385; cv=none; d=google.com; s=arc-20160816; b=Rj0Yz38G8NXPrWXtHT9CCj2lh8pLVWDsQXvD9cMlnPEYyHZUoMhSkUQx0BuyA/XgoX /F58E1u6TsAkAdow8pKisDEPC2Y5FfI8QlKPifQGZPgB3Nz7IsBNwRfxpr4LNn/AZHbZ sVP+3oi3zEZPPrL1zx83eR4zaVmcsAldnjK4e2byKYIGAIEYIyyTZ/Ul/d6Ct7fwtNgz whO/eccGMT0ZpGsA3oyOrZGDrMCohYhdBjb8jxqgjle9odMs/z9qLHctU/lVodLOInbg 8eCTT94nnfr0+Qon/dpXWlyggSuPOB2ZbIUYxYuqO9IKjJoZRfd24U76/x5TnitCkvt4 1udQ== 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=W9NSWtZQZz+ZWOer+/TTeqrCHuCL5DNQVFF4RNjQQb4=; b=u4w/P2cQk7JvDlFXWVXVAFqlRyhfgw6Bi/D9OgvSbzcinsz5OXWf1qjrQzEi6nfbBQ Vhz4+elB8enNfLRipcoDga8tjNWH5hntUuvZoCJtIZKYp282NSt0jDLOM7xVp7yUiH4G aQpUTYXpsJ/TELcMYxRpxaF+clnX4+TDg4m1os6qvmdjDeku0Twe3quX115PYC1urFfF Wv/4EZMe9s2V10ytSJQtxt3WLYtfLy5ABpQqPTj2IhQ5vmF9hAgsHen9s2ZM+atHsjQ8 PDPTHfu76d8WEc/Pse8X9EzTPxxLUa3D3sYeWv9iq3k3v2j7MFrnODM9thVVDmYNf3cW kKww== 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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958632156972052?= X-GMAIL-MSGID: =?utf-8?q?1590958632156972052?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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