Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9169149pxu; Mon, 28 Dec 2020 08:17:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAFJN9BTxZ7NQ9CPasNN1iqOayAgKNGSkaCfdul5lOLzv5oysD4TzNbB/Eyu3A8T/wnfaw X-Received: by 2002:a17:906:8693:: with SMTP id g19mr44251978ejx.111.1609172251675; Mon, 28 Dec 2020 08:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172251; cv=none; d=google.com; s=arc-20160816; b=hCMNvgUDpghn80Pz8/cnVdzwpwN+Lwk6wOpI18mFH79d59WA6rEkRwVeyxztY+Dm5U rXx1v9Tb2Tp6ybJFBSuFDRTEZc4XUgosG/c5LG5Y/rhKLA5gG5VR//D5DiUAP3K7f1RU UISk+uE+NPiBUxvd1WhkEnJ7ODbVkck+Su00hdNNXeA0GaLwG0colPXR79mhgcWL2HVy jFgYth2926JnZktbhezpeqonKCO1NnJHZlB7xln1dSOrjwhY7EZbm3h9UOSCTGxw3W5A aNB2wrz+VqIoyjMhRbwEMYpqv8HAcAJTxuL6+EVCEYvudglFSAzDJn/TA8l+1jQ0ZBPZ qttA== 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=vJqKac17XKxwBsGpG80FrZX5StUw1iF0OsZWszAjhcE=; b=SfR3Hla39gF277NmIoRv5dJpuRGEbY4d+WCJx9TnykY4Wid0Kk1B1VY7COfRR7Amwu v/e63+ZRJ7TBll/n1qGnJswcSvNoUo/r3xOoiPFZdsCNizlqne/+2/qOaPTKMVNuRiz5 h86fB88EbKJEKX4YEsxUuj3jusRwjp+KuBYM4At5rNOCmHpd4BGSqTyKsmGrusJfjFip RNwCztENpgbD7ouC/2iED3/EYE/JH+A6Gn02ox1ju3hcba/ZYvpzTSrmD9Z+KJZz+pkS ZFpeD8FASGWhuJn893uc9cB/ZRKIcvdQjc5pVTBjHhqHSwSV45n+Hzx/RfotC5lN+TIY gKcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zZWs7iCI; 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 gj13si17593393ejb.521.2020.12.28.08.17.06; Mon, 28 Dec 2020 08:17:31 -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=zZWs7iCI; 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 S1733011AbgL1NTx (ORCPT + 99 others); Mon, 28 Dec 2020 08:19:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:48352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732932AbgL1NTo (ORCPT ); Mon, 28 Dec 2020 08:19:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 54EA3207C9; Mon, 28 Dec 2020 13:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161543; bh=CP2b5ra7DAz0Q62CS5Q9Smn/aFgXZzFz6sp9jmRjcjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zZWs7iCI5Udu5mmKwpQzaQ38+4nf08POutZTCVFla9oXmAopknMvAog1dJOreLsoN rotoxb5BmQN1+eCbyCwQepcY08H9J5HD/HSgh9vzZEe8ceo/p/zg/8N77B1MVH54fi CnFkNsyLxeyl1kwp7R7WgBwioPXPmWl3MGbSNW58= 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 4.14 241/242] libnvdimm/namespace: Fix reaping of invalidated block-window-namespace labels Date: Mon, 28 Dec 2020 13:50:46 +0100 Message-Id: <20201228124916.554029416@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 @@ -852,6 +852,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.