From patchwork Thu Feb 15 14:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 201503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp449088dyb; Thu, 15 Feb 2024 06:48:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU/DEAab8bu1A+5PJrGd+HwrpEcx+CJlQDwRmxK+2skDppxcSQRxBabGECu8G8b1LEZB69Zb8C0v028JtvVlRPMQxK7nA== X-Google-Smtp-Source: AGHT+IE2tOKIP9VREGd65A0dBdtr7MsYJx0518bs6nRZu/GhiaW3TGNgFRe2c3KUvQHC1svLe7Av X-Received: by 2002:a17:906:254e:b0:a3d:ab64:7524 with SMTP id j14-20020a170906254e00b00a3dab647524mr792483ejb.36.1708008531440; Thu, 15 Feb 2024 06:48:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708008531; cv=pass; d=google.com; s=arc-20160816; b=x9HJvGbSpO+00ccgG58eY6rEHzF3a/Ytb7Hh1QRym4b6vEN1UIE1V8QW26TUXPijIq bQnOpXYB8l06RgqhUmQLcAunPEIuJNKB6td9hEa72kIMZXQcZzcBH1KaCKt1pXZVmu0N 92VUm9A9lMvwgwBPvd2Ha4znyJXF5njkwFqQz08Hzo9b5KQAxUIDsq9Kep6KDNhuE79v B8obNwTna6j1H3qqfJ/wT/qWProOp59o40J7GFFh99NuNae6mcZyQCVfW5nZ9/rFW+cQ 7mPnnjs6sId1OasxUrosWyW0Kembq57Z3FsB6jsSeRCI9QbP//fwY1ywtFx5PmYbAh+d bbDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=B4ilFMr2eFF794YdWWw0DjFvkMffunaWzt7kSkCawqA=; fh=vB3mjx618UEkjhkr0KlPmbcjzb/dBtVqarMo/Lep1XI=; b=E3cITA2d89ua1l6zfNf2OdhvO6GJl4PWzXpVgdji2v28NUV/M31QY8VMkHJZuq4AH0 yxOPocJxMo8TMwlR82HfQ8VMJB6Qu5VMlLreygwJLggMN9p1Q+NIOxOw7vW3rAO9V2Wt YPhpcVUJiE3D2RQ0YUuiuWp/5uQqIZjwp8p7bqON2unjQzfA4+0SWnkOs6ZLmR+sHRY+ 4roca1+dmfGuHNlXIwCWQpTq0GuEma29NZFK9EYG+MHzhuVjkvFgDYjqvHcHm69+Alh5 tNUJ8BMLcubKpdkeI0IeqlZhlHHQLIlod7sMNAUcOdOAES4UYmFt0r9L5HpWnmXgRzHW xuiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=BnQ8gALW; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-67097-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67097-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o19-20020a1709061d5300b00a3d4ee98b11si679823ejh.740.2024.02.15.06.48.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:48:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67097-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=BnQ8gALW; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-67097-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67097-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 100BE1F279DB for ; Thu, 15 Feb 2024 14:48:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BF0B134CDA; Thu, 15 Feb 2024 14:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="BnQ8gALW" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D091132475; Thu, 15 Feb 2024 14:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008402; cv=none; b=JpuzccT0MHMNA3pHJaj+n9wC7v9VsU72PaNIyFk4643CziJmgicWbZEQ8yPFPam/hlWY4l6WQxopGft4BLZmyT5/2zPGYjuD8oBB205NA0irU8dBlhUBYYgjJVf2vqEJ7qiT0JqNDtaQgPOSv/kh8HA2i2F3KDZvggsIX9JI+SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008402; c=relaxed/simple; bh=ecUyvilxXmAuEa6CVYKrKIA8K8l2tVUUJHjpsI0Te00=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZEjVBYupDPwcKur4dQJQMOhjUtFE3zl6qni7m4W6iLf+2IZUWvfuOQToK8ttxya+G3TSMS8dnXwWxOcTjTGQwPxzDB7EM+kwhGaN30Gtlk5wsB4l0Kt4xNSGmHixWhxqbgZg2/DTYL7i2+RVvOBTjMXd2G3/PlHM4SuY+e4mULM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=BnQ8gALW; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1708008400; bh=ecUyvilxXmAuEa6CVYKrKIA8K8l2tVUUJHjpsI0Te00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnQ8gALWRG0w08WHE18FXz/gmkcBs+yrQ55MT0cKd97EICKIovqMo4kVDLrKcH8bh YQI6fZljO24zHkyqsBzPTcvX20Vmg1ap8c8Tut+BU0Ci57M0gEpwtLnH+URQUAtmmg 76+jmRJI3BJZlPVr+gtSamRkZubkS4p6ZAiRoPVMrfSWx4HichoBiZJGLDkgrUvm+H 3BOlrHqxHEUVhYGYgEgu5uP0I6z8XFlAkekIdXkSRk81RBemq+K4JJyRUPbB2q5zqA kStS73njuquarYVVqiJKuZr+R21XtlJhj0W1tdwj08C9j7a2ZkXN80Oc/GHeo+rxH5 /2vMn1vOE7jHg== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TbHvN0F0TzZS6; Thu, 15 Feb 2024 09:46:40 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [PATCH v6 3/9] nvdimm/pmem: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal Date: Thu, 15 Feb 2024 09:46:27 -0500 Message-Id: <20240215144633.96437-4-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> References: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790976753674685418 X-GMAIL-MSGID: 1790976753674685418 In preparation for checking whether the architecture has data cache aliasing within alloc_dax(), modify the error handling of nvdimm/pmem pmem_attach_disk() to treat alloc_dax() -EOPNOTSUPP failure as non-fatal. [ Based on commit "nvdimm/pmem: Fix leak on dax_add_host() failure". ] Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/nvdimm/pmem.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9fe358090720..e9898457a7bd 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -560,17 +560,19 @@ static int pmem_attach_disk(struct device *dev, dax_dev = alloc_dax(pmem, &pmem_dax_ops); if (IS_ERR(dax_dev)) { rc = PTR_ERR(dax_dev); - goto out; + if (rc != -EOPNOTSUPP) + goto out; + } else { + set_dax_nocache(dax_dev); + set_dax_nomc(dax_dev); + if (is_nvdimm_sync(nd_region)) + set_dax_synchronous(dax_dev); + pmem->dax_dev = dax_dev; + rc = dax_add_host(dax_dev, disk); + if (rc) + goto out_cleanup_dax; + dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); } - set_dax_nocache(dax_dev); - set_dax_nomc(dax_dev); - if (is_nvdimm_sync(nd_region)) - set_dax_synchronous(dax_dev); - pmem->dax_dev = dax_dev; - rc = dax_add_host(dax_dev, disk); - if (rc) - goto out_cleanup_dax; - dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); rc = device_add_disk(dev, disk, pmem_attribute_groups); if (rc) goto out_remove_host;