Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9418408pxu; Mon, 28 Dec 2020 15:52:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAFacLbuOpmISVZCNChPJFdlk9IuOF34ij2/tyxorCHgr/hgj5JM0vCe99ITTv3rd/eCe4 X-Received: by 2002:a17:906:408f:: with SMTP id u15mr44347549ejj.84.1609199532576; Mon, 28 Dec 2020 15:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609199532; cv=none; d=google.com; s=arc-20160816; b=tRfO5/7djtCdjlvRizPHFV70k5wKGHZ+Ip1xNi0VswucxsenSBA4XxhJzhmjz/vm3+ 85k+VW8K+y5ff/AroMrK3WGl/GN/g6EqAkSez76cKDFNaQU65Ozpqp8X1c2NaN0sjoGy hvUn3OSuMg3j9Q9AsG7VSRP1KU5qcj5rsUmnbw94KaTD89WpjGxmRueua2aduKzpPRYU E8Qwo/M6kMIxxPUTu7Lkh+hK8RplMOWitnNetcM7ylR65s9uV8paGGOU28FAp4axvihH GJh/pqNeV7MvbtcrKk9hDkBOfVt6G4zXiCIgiap2EKwk5Q7O6nhhAwoXah2fiLfEwTf6 BazQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K7caXdl4/lwA90YlvTQhjm7Q8WyScvDXZeQJ8YAG6fQ=; b=eC7xQ8Qx7H7wv2yVa7Eksd7SN31W6rSlnWgEFkiXR/V+PXeh6Y5wPN5c8lqd9pRQAk XvUvkOAxxOYUF/Htvcotq+n8TYSjrOVOPp7vA8PIcqsj/QspcsTb1+XWHrk14RE9Hi4p VHPQtocCXSyOQl5sMHo91mvk37qpFOnDNpVO84lAUlscLUNteLGgLnduYpOVXttn4LCd C//pz+Z99l1Cd1+gbWaGPxGmWYcFN/yS27qT7LJ3ae4LAkD9wuUUcb9LTyeYhmOY3J4T rZUaAfQnGUthwANEX6b0lHQzs/0gvbvo1mL41+hH66D61mFEinITXd0pIZodmWNFgKkZ nzPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YbqTJWfa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si21327495edq.169.2020.12.28.15.51.51; Mon, 28 Dec 2020 15:52:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YbqTJWfa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392271AbgL1Ohs (ORCPT + 99 others); Mon, 28 Dec 2020 09:37:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:40238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504696AbgL1Oc2 (ORCPT ); Mon, 28 Dec 2020 09:32:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFDD82063A; Mon, 28 Dec 2020 14:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165933; bh=bFujeQTmkX8voB3Hyv3mHFA2PPAjBxbnp9aIl6G7r7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YbqTJWfaK1FCN5Z5RcGwp3ahLmpqT2dqvPZFnHIWrkACO/5yUZVfozrAt+pWNAtP9 /5zkcgFNjwcQR/Tjjoica4hn8kN+pDtKjoLZKyfdzk0d4ZcEB5C4AyhSJ/HsSAAPY2 dn+18+KLgS9CNueubHdh0zSgr0Z+L1yU551b9ZgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vishal Verma , Dave Jiang , Ira Weiny , Dan Williams Subject: [PATCH 5.10 705/717] libnvdimm/namespace: Fix reaping of invalidated block-window-namespace labels Date: Mon, 28 Dec 2020 13:51:43 +0100 Message-Id: <20201228125054.765775171@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams commit 2dd2a1740ee19cd2636d247276cf27bfa434b0e2 upstream. A recent change to ndctl to attempt to reconfigure namespaces in place uncovered a label accounting problem in block-window-type namespaces. The ndctl "create.sh" test is able to trigger this signature: WARNING: CPU: 34 PID: 9167 at drivers/nvdimm/label.c:1100 __blk_label_update+0x9a3/0xbc0 [libnvdimm] [..] RIP: 0010:__blk_label_update+0x9a3/0xbc0 [libnvdimm] [..] Call Trace: uuid_store+0x21b/0x2f0 [libnvdimm] kernfs_fop_write+0xcf/0x1c0 vfs_write+0xcc/0x380 ksys_write+0x68/0xe0 When allocated capacity for a namespace is renamed (new UUID) the labels with the old UUID need to be deleted. The ndctl behavior to always destroy namespaces on reconfiguration hid this problem. The immediate impact of this bug is limited since block-window-type namespaces only seem to exist in the specification and not in any shipping products. However, the label handling code is being reused for other technologies like CXL region labels, so there is a benefit to making sure both vertical labels sets (block-window) and horizontal label sets (pmem) have a functional reference implementation in libnvdimm. Fixes: c4703ce11c23 ("libnvdimm/namespace: Fix label tracking error") Cc: Cc: Vishal Verma Cc: Dave Jiang Cc: Ira Weiny Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/label.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/nvdimm/label.c +++ b/drivers/nvdimm/label.c @@ -980,6 +980,15 @@ static int __blk_label_update(struct nd_ } } + /* release slots associated with any invalidated UUIDs */ + mutex_lock(&nd_mapping->lock); + list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) + if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags)) { + reap_victim(nd_mapping, label_ent); + list_move(&label_ent->list, &list); + } + mutex_unlock(&nd_mapping->lock); + /* * Find the resource associated with the first label in the set * per the v1.2 namespace specification.