dax: Kill DEV_DAX_PMEM_COMPAT
authorDan Williams <dan.j.williams@intel.com>
Mon, 15 Nov 2021 21:20:57 +0000 (13:20 -0800)
committerDan Williams <dan.j.williams@intel.com>
Thu, 25 Nov 2021 03:21:35 +0000 (19:21 -0800)
The /sys/class/dax compatibility option has shipped in the kernel for 4
years now which should be sufficient time for tools to abandon the old
ABI in favor of the /sys/bus/dax device-model. Delete it now and see if
anyone screams.

Since this compatibility option shipped there has been more reports of
users being surprised by the compat ABI than surprised by the "new", so
the compat infrastructure has outlived its usefulness. Recall that
/sys/bus/dax device-model is required for the dax kmem driver which
allows PMEM to be used as "System RAM".

The following projects were known to have a dependency on /sys/class/dax
and have dropped their dependency as of the listed version:

- ndctl (including libndctl, daxctl, and libdaxctl): v64+
- fio: v3.13+
- pmdk: v1.5.2+

As further evidence this option is no longer needed some distributions
have already stopped enabling CONFIG_DEV_DAX_PMEM_COMPAT.

Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Jane Chu <jane.chu@oracle.com>
Link: https://lore.kernel.org/r/163701116195.3784476.726128179293466337.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
16 files changed:
Documentation/ABI/obsolete/sysfs-class-dax [deleted file]
drivers/dax/Kconfig
drivers/dax/Makefile
drivers/dax/bus.c
drivers/dax/bus.h
drivers/dax/device.c
drivers/dax/pmem.c [new file with mode: 0644]
drivers/dax/pmem/Makefile
drivers/dax/pmem/compat.c [deleted file]
drivers/dax/pmem/core.c [deleted file]
drivers/dax/pmem/pmem.c
tools/testing/nvdimm/Kbuild
tools/testing/nvdimm/dax_pmem_compat_test.c [deleted file]
tools/testing/nvdimm/dax_pmem_core_test.c [deleted file]
tools/testing/nvdimm/test/ndtest.c
tools/testing/nvdimm/test/nfit.c

diff --git a/Documentation/ABI/obsolete/sysfs-class-dax b/Documentation/ABI/obsolete/sysfs-class-dax
deleted file mode 100644 (file)
index 5bcce27..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-What:           /sys/class/dax/
-Date:           May, 2016
-KernelVersion:  v4.7
-Contact:        nvdimm@lists.linux.dev
-Description:   Device DAX is the device-centric analogue of Filesystem
-               DAX (CONFIG_FS_DAX).  It allows memory ranges to be
-               allocated and mapped without need of an intervening file
-               system.  Device DAX is strict, precise and predictable.
-               Specifically this interface:
-
-               1. Guarantees fault granularity with respect to a given
-                  page size (pte, pmd, or pud) set at configuration time.
-
-               2. Enforces deterministic behavior by being strict about
-                  what fault scenarios are supported.
-
-               The /sys/class/dax/ interface enumerates all the
-               device-dax instances in the system. The ABI is
-               deprecated and will be removed after 2020. It is
-               replaced with the DAX bus interface /sys/bus/dax/ where
-               device-dax instances can be found under
-               /sys/bus/dax/devices/
index d2834c2cfa10deaaafc4acfdc25043840597ccec..15b442ef7b9342dcdeb7fb502d3bda84799798c8 100644 (file)
@@ -70,13 +70,4 @@ config DEV_DAX_KMEM
 
          Say N if unsure.
 
-config DEV_DAX_PMEM_COMPAT
-       tristate "PMEM DAX: support the deprecated /sys/class/dax interface"
-       depends on m && DEV_DAX_PMEM=m
-       default DEV_DAX_PMEM
-       help
-         Older versions of the libdaxctl library expect to find all
-         device-dax instances under /sys/class/dax. If libdaxctl in
-         your distribution is older than v58 say M, otherwise say N.
-
 endif
index 9d4ba672d305937bdec68b9e7eab7c64ad2be2f7..90a56ca3b345468a719c457161bdf1a63de7673a 100644 (file)
@@ -2,10 +2,11 @@
 obj-$(CONFIG_DAX) += dax.o
 obj-$(CONFIG_DEV_DAX) += device_dax.o
 obj-$(CONFIG_DEV_DAX_KMEM) += kmem.o
+obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o
 
 dax-y := super.o
 dax-y += bus.o
 device_dax-y := device.o
+dax_pmem-y := pmem.o
 
-obj-y += pmem/
 obj-y += hmem/
index 6cc4da4c713d903fde149e40ca03b44ae5988e86..452cf7860926223912342fb1609785a9e4396cc1 100644 (file)
@@ -10,8 +10,6 @@
 #include "dax-private.h"
 #include "bus.h"
 
-static struct class *dax_class;
-
 static DEFINE_MUTEX(dax_bus_lock);
 
 #define DAX_NAME_LEN 30
@@ -1343,10 +1341,7 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
 
        inode = dax_inode(dax_dev);
        dev->devt = inode->i_rdev;
-       if (data->subsys == DEV_DAX_BUS)
-               dev->bus = &dax_bus_type;
-       else
-               dev->class = dax_class;
+       dev->bus = &dax_bus_type;
        dev->parent = parent;
        dev->type = &dev_dax_type;
 
@@ -1445,22 +1440,10 @@ EXPORT_SYMBOL_GPL(dax_driver_unregister);
 
 int __init dax_bus_init(void)
 {
-       int rc;
-
-       if (IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT)) {
-               dax_class = class_create(THIS_MODULE, "dax");
-               if (IS_ERR(dax_class))
-                       return PTR_ERR(dax_class);
-       }
-
-       rc = bus_register(&dax_bus_type);
-       if (rc)
-               class_destroy(dax_class);
-       return rc;
+       return bus_register(&dax_bus_type);
 }
 
 void __exit dax_bus_exit(void)
 {
        bus_unregister(&dax_bus_type);
-       class_destroy(dax_class);
 }
index 1e946ad7780a82b40f6ccdc472429c41005ee960..381cec9ff05c4f92e6be660ccdf685c71322e81a 100644 (file)
@@ -16,24 +16,15 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
                struct range *range, int target_node, unsigned int align,
                unsigned long flags);
 
-enum dev_dax_subsys {
-       DEV_DAX_BUS = 0, /* zeroed dev_dax_data picks this by default */
-       DEV_DAX_CLASS,
-};
-
 struct dev_dax_data {
        struct dax_region *dax_region;
        struct dev_pagemap *pgmap;
-       enum dev_dax_subsys subsys;
        resource_size_t size;
        int id;
 };
 
 struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
 
-/* to be deleted when DEV_DAX_CLASS is removed */
-struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys);
-
 struct dax_device_driver {
        struct device_driver drv;
        struct list_head ids;
@@ -49,10 +40,6 @@ int __dax_driver_register(struct dax_device_driver *dax_drv,
 void dax_driver_unregister(struct dax_device_driver *dax_drv);
 void kill_dev_dax(struct dev_dax *dev_dax);
 
-#if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT)
-int dev_dax_probe(struct dev_dax *dev_dax);
-#endif
-
 /*
  * While run_dax() is potentially a generic operation that could be
  * defined in include/linux/dax.h we don't want to grow any users
index dd8222a42808d64aa465887ab87210f58fe6f6d7..e58d597f0415a049e64149bc9f92552aad04fed2 100644 (file)
@@ -433,11 +433,7 @@ int dev_dax_probe(struct dev_dax *dev_dax)
        inode = dax_inode(dax_dev);
        cdev = inode->i_cdev;
        cdev_init(cdev, &dax_fops);
-       if (dev->class) {
-               /* for the CONFIG_DEV_DAX_PMEM_COMPAT case */
-               cdev->owner = dev->parent->driver->owner;
-       } else
-               cdev->owner = dev->driver->owner;
+       cdev->owner = dev->driver->owner;
        cdev_set_parent(cdev, &dev->kobj);
        rc = cdev_add(cdev, dev->devt, 1);
        if (rc)
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
new file mode 100644 (file)
index 0000000..f050ea7
--- /dev/null
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
+#include <linux/memremap.h>
+#include <linux/module.h>
+#include <linux/pfn_t.h>
+#include "../nvdimm/pfn.h"
+#include "../nvdimm/nd.h"
+#include "bus.h"
+
+static struct dev_dax *__dax_pmem_probe(struct device *dev)
+{
+       struct range range;
+       int rc, id, region_id;
+       resource_size_t offset;
+       struct nd_pfn_sb *pfn_sb;
+       struct dev_dax *dev_dax;
+       struct dev_dax_data data;
+       struct nd_namespace_io *nsio;
+       struct dax_region *dax_region;
+       struct dev_pagemap pgmap = { };
+       struct nd_namespace_common *ndns;
+       struct nd_dax *nd_dax = to_nd_dax(dev);
+       struct nd_pfn *nd_pfn = &nd_dax->nd_pfn;
+       struct nd_region *nd_region = to_nd_region(dev->parent);
+
+       ndns = nvdimm_namespace_common_probe(dev);
+       if (IS_ERR(ndns))
+               return ERR_CAST(ndns);
+
+       /* parse the 'pfn' info block via ->rw_bytes */
+       rc = devm_namespace_enable(dev, ndns, nd_info_block_reserve());
+       if (rc)
+               return ERR_PTR(rc);
+       rc = nvdimm_setup_pfn(nd_pfn, &pgmap);
+       if (rc)
+               return ERR_PTR(rc);
+       devm_namespace_disable(dev, ndns);
+
+       /* reserve the metadata area, device-dax will reserve the data */
+       pfn_sb = nd_pfn->pfn_sb;
+       offset = le64_to_cpu(pfn_sb->dataoff);
+       nsio = to_nd_namespace_io(&ndns->dev);
+       if (!devm_request_mem_region(dev, nsio->res.start, offset,
+                               dev_name(&ndns->dev))) {
+               dev_warn(dev, "could not reserve metadata\n");
+               return ERR_PTR(-EBUSY);
+       }
+
+       rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", &region_id, &id);
+       if (rc != 2)
+               return ERR_PTR(-EINVAL);
+
+       /* adjust the dax_region range to the start of data */
+       range = pgmap.range;
+       range.start += offset;
+       dax_region = alloc_dax_region(dev, region_id, &range,
+                       nd_region->target_node, le32_to_cpu(pfn_sb->align),
+                       IORESOURCE_DAX_STATIC);
+       if (!dax_region)
+               return ERR_PTR(-ENOMEM);
+
+       data = (struct dev_dax_data) {
+               .dax_region = dax_region,
+               .id = id,
+               .pgmap = &pgmap,
+               .size = range_len(&range),
+       };
+       dev_dax = devm_create_dev_dax(&data);
+
+       /* child dev_dax instances now own the lifetime of the dax_region */
+       dax_region_put(dax_region);
+
+       return dev_dax;
+}
+
+static int dax_pmem_probe(struct device *dev)
+{
+       return PTR_ERR_OR_ZERO(__dax_pmem_probe(dev));
+}
+
+static struct nd_device_driver dax_pmem_driver = {
+       .probe = dax_pmem_probe,
+       .drv = {
+               .name = "dax_pmem",
+       },
+       .type = ND_DRIVER_DAX_PMEM,
+};
+
+static int __init dax_pmem_init(void)
+{
+       return nd_driver_register(&dax_pmem_driver);
+}
+module_init(dax_pmem_init);
+
+static void __exit dax_pmem_exit(void)
+{
+       driver_unregister(&dax_pmem_driver.drv);
+}
+module_exit(dax_pmem_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Intel Corporation");
+MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_PMEM);
index 010269f61d416c5d40851372bc7ec51625ad9d76..191c31f0d4f00831a0a21100ebacf8527ed1ddf9 100644 (file)
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o
 obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem_core.o
-obj-$(CONFIG_DEV_DAX_PMEM_COMPAT) += dax_pmem_compat.o
 
 dax_pmem-y := pmem.o
 dax_pmem_core-y := core.o
diff --git a/drivers/dax/pmem/compat.c b/drivers/dax/pmem/compat.c
deleted file mode 100644 (file)
index d81dc35..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
-#include <linux/percpu-refcount.h>
-#include <linux/memremap.h>
-#include <linux/module.h>
-#include <linux/pfn_t.h>
-#include <linux/nd.h>
-#include "../bus.h"
-
-/* we need the private definitions to implement compat suport */
-#include "../dax-private.h"
-
-static int dax_pmem_compat_probe(struct device *dev)
-{
-       struct dev_dax *dev_dax = __dax_pmem_probe(dev, DEV_DAX_CLASS);
-       int rc;
-
-       if (IS_ERR(dev_dax))
-               return PTR_ERR(dev_dax);
-
-        if (!devres_open_group(&dev_dax->dev, dev_dax, GFP_KERNEL))
-               return -ENOMEM;
-
-       device_lock(&dev_dax->dev);
-       rc = dev_dax_probe(dev_dax);
-       device_unlock(&dev_dax->dev);
-
-       devres_close_group(&dev_dax->dev, dev_dax);
-       if (rc)
-               devres_release_group(&dev_dax->dev, dev_dax);
-
-       return rc;
-}
-
-static int dax_pmem_compat_release(struct device *dev, void *data)
-{
-       device_lock(dev);
-       devres_release_group(dev, to_dev_dax(dev));
-       device_unlock(dev);
-
-       return 0;
-}
-
-static void dax_pmem_compat_remove(struct device *dev)
-{
-       device_for_each_child(dev, NULL, dax_pmem_compat_release);
-}
-
-static struct nd_device_driver dax_pmem_compat_driver = {
-       .probe = dax_pmem_compat_probe,
-       .remove = dax_pmem_compat_remove,
-       .drv = {
-               .name = "dax_pmem_compat",
-       },
-       .type = ND_DRIVER_DAX_PMEM,
-};
-
-static int __init dax_pmem_compat_init(void)
-{
-       return nd_driver_register(&dax_pmem_compat_driver);
-}
-module_init(dax_pmem_compat_init);
-
-static void __exit dax_pmem_compat_exit(void)
-{
-       driver_unregister(&dax_pmem_compat_driver.drv);
-}
-module_exit(dax_pmem_compat_exit);
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Intel Corporation");
-MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_PMEM);
diff --git a/drivers/dax/pmem/core.c b/drivers/dax/pmem/core.c
deleted file mode 100644 (file)
index 062e8bc..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
-#include <linux/memremap.h>
-#include <linux/module.h>
-#include <linux/pfn_t.h>
-#include "../../nvdimm/pfn.h"
-#include "../../nvdimm/nd.h"
-#include "../bus.h"
-
-struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys)
-{
-       struct range range;
-       int rc, id, region_id;
-       resource_size_t offset;
-       struct nd_pfn_sb *pfn_sb;
-       struct dev_dax *dev_dax;
-       struct dev_dax_data data;
-       struct nd_namespace_io *nsio;
-       struct dax_region *dax_region;
-       struct dev_pagemap pgmap = { };
-       struct nd_namespace_common *ndns;
-       struct nd_dax *nd_dax = to_nd_dax(dev);
-       struct nd_pfn *nd_pfn = &nd_dax->nd_pfn;
-       struct nd_region *nd_region = to_nd_region(dev->parent);
-
-       ndns = nvdimm_namespace_common_probe(dev);
-       if (IS_ERR(ndns))
-               return ERR_CAST(ndns);
-
-       /* parse the 'pfn' info block via ->rw_bytes */
-       rc = devm_namespace_enable(dev, ndns, nd_info_block_reserve());
-       if (rc)
-               return ERR_PTR(rc);
-       rc = nvdimm_setup_pfn(nd_pfn, &pgmap);
-       if (rc)
-               return ERR_PTR(rc);
-       devm_namespace_disable(dev, ndns);
-
-       /* reserve the metadata area, device-dax will reserve the data */
-       pfn_sb = nd_pfn->pfn_sb;
-       offset = le64_to_cpu(pfn_sb->dataoff);
-       nsio = to_nd_namespace_io(&ndns->dev);
-       if (!devm_request_mem_region(dev, nsio->res.start, offset,
-                               dev_name(&ndns->dev))) {
-               dev_warn(dev, "could not reserve metadata\n");
-               return ERR_PTR(-EBUSY);
-       }
-
-       rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", &region_id, &id);
-       if (rc != 2)
-               return ERR_PTR(-EINVAL);
-
-       /* adjust the dax_region range to the start of data */
-       range = pgmap.range;
-       range.start += offset;
-       dax_region = alloc_dax_region(dev, region_id, &range,
-                       nd_region->target_node, le32_to_cpu(pfn_sb->align),
-                       IORESOURCE_DAX_STATIC);
-       if (!dax_region)
-               return ERR_PTR(-ENOMEM);
-
-       data = (struct dev_dax_data) {
-               .dax_region = dax_region,
-               .id = id,
-               .pgmap = &pgmap,
-               .subsys = subsys,
-               .size = range_len(&range),
-       };
-       dev_dax = devm_create_dev_dax(&data);
-
-       /* child dev_dax instances now own the lifetime of the dax_region */
-       dax_region_put(dax_region);
-
-       return dev_dax;
-}
-EXPORT_SYMBOL_GPL(__dax_pmem_probe);
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Intel Corporation");
index 0ae4238a0ef88dd9be32dcea7bef9b2abd8a8331..dfe91a2990fec46cdba6a782ca71817f94f58419 100644 (file)
@@ -7,34 +7,4 @@
 #include <linux/nd.h>
 #include "../bus.h"
 
-static int dax_pmem_probe(struct device *dev)
-{
-       return PTR_ERR_OR_ZERO(__dax_pmem_probe(dev, DEV_DAX_BUS));
-}
 
-static struct nd_device_driver dax_pmem_driver = {
-       .probe = dax_pmem_probe,
-       .drv = {
-               .name = "dax_pmem",
-       },
-       .type = ND_DRIVER_DAX_PMEM,
-};
-
-static int __init dax_pmem_init(void)
-{
-       return nd_driver_register(&dax_pmem_driver);
-}
-module_init(dax_pmem_init);
-
-static void __exit dax_pmem_exit(void)
-{
-       driver_unregister(&dax_pmem_driver.drv);
-}
-module_exit(dax_pmem_exit);
-
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Intel Corporation");
-#if !IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT)
-/* For compat builds, don't load this module by default */
-MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_PMEM);
-#endif
index 47f9cc9dcd94b560e7f520d0f56f1284840c535c..c57d9e9d448039db265c0179aa584ba1b33375ce 100644 (file)
@@ -35,8 +35,6 @@ obj-$(CONFIG_DAX) += dax.o
 endif
 obj-$(CONFIG_DEV_DAX) += device_dax.o
 obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o
-obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem_core.o
-obj-$(CONFIG_DEV_DAX_PMEM_COMPAT) += dax_pmem_compat.o
 
 nfit-y := $(ACPI_SRC)/core.o
 nfit-y += $(ACPI_SRC)/intel.o
@@ -67,12 +65,8 @@ device_dax-y += dax-dev.o
 device_dax-y += device_dax_test.o
 device_dax-y += config_check.o
 
-dax_pmem-y := $(DAX_SRC)/pmem/pmem.o
+dax_pmem-y := $(DAX_SRC)/pmem.o
 dax_pmem-y += dax_pmem_test.o
-dax_pmem_core-y := $(DAX_SRC)/pmem/core.o
-dax_pmem_core-y += dax_pmem_core_test.o
-dax_pmem_compat-y := $(DAX_SRC)/pmem/compat.o
-dax_pmem_compat-y += dax_pmem_compat_test.o
 dax_pmem-y += config_check.o
 
 libnvdimm-y := $(NVDIMM_SRC)/core.o
diff --git a/tools/testing/nvdimm/dax_pmem_compat_test.c b/tools/testing/nvdimm/dax_pmem_compat_test.c
deleted file mode 100644 (file)
index 7cd1877..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-// Copyright(c) 2019 Intel Corporation. All rights reserved.
-
-#include <linux/module.h>
-#include <linux/printk.h>
-#include "watermark.h"
-
-nfit_test_watermark(dax_pmem_compat);
diff --git a/tools/testing/nvdimm/dax_pmem_core_test.c b/tools/testing/nvdimm/dax_pmem_core_test.c
deleted file mode 100644 (file)
index a4249cd..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-// Copyright(c) 2019 Intel Corporation. All rights reserved.
-
-#include <linux/module.h>
-#include <linux/printk.h>
-#include "watermark.h"
-
-nfit_test_watermark(dax_pmem_core);
index 6862915f1fb0c7be5f4eac7bdf1f17a94e33e94d..3ca7c32e936266e7d2f035837332408020ed5979 100644 (file)
@@ -1054,10 +1054,6 @@ static __init int ndtest_init(void)
        libnvdimm_test();
        device_dax_test();
        dax_pmem_test();
-       dax_pmem_core_test();
-#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
-       dax_pmem_compat_test();
-#endif
 
        nfit_test_setup(ndtest_resource_lookup, NULL);
 
index b1bff5fb0f65db91a9f638553758444fdcd2a100..0bc91ffee2577c241d2728364719409e6b6d8823 100644 (file)
@@ -3300,10 +3300,6 @@ static __init int nfit_test_init(void)
        acpi_nfit_test();
        device_dax_test();
        dax_pmem_test();
-       dax_pmem_core_test();
-#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
-       dax_pmem_compat_test();
-#endif
 
        nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);