]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
dax: introduce dax_operations
authorDan Williams <dan.j.williams@intel.com>
Wed, 25 Jan 2017 02:44:18 +0000 (18:44 -0800)
committerDan Williams <dan.j.williams@intel.com>
Wed, 19 Apr 2017 22:14:35 +0000 (15:14 -0700)
Track a set of dax_operations per dax_device that can be set at
alloc_dax() time. These operations will be used to stop the abuse of
block_device_operations for communicating dax capabilities to
filesystems. It will also be used to replace the "pmem api" and move
pmem-specific cache maintenance, and other dax-driver-specific
filesystem-dax operations, to dax device methods. In particular this
allows us to stop abusing __copy_user_nocache(), via memcpy_to_pmem(),
with a driver specific replacement.

This is a standalone introduction of the operations. Follow on patches
convert each dax-driver and teach fs/dax.c to use ->direct_access() from
dax_operations instead of block_device_operations.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/dax/dax.h
drivers/dax/device.c
drivers/dax/super.c
include/linux/dax.h

index 246a24d68d4c92dc70f6376ada74607f0d2ff58b..617bbc24be2b378bc852642bb3454babbd4ce058 100644 (file)
@@ -13,7 +13,9 @@
 #ifndef __DAX_H__
 #define __DAX_H__
 struct dax_device;
-struct dax_device *alloc_dax(void *private, const char *host);
+struct dax_operations;
+struct dax_device *alloc_dax(void *private, const char *host,
+               const struct dax_operations *ops);
 void put_dax(struct dax_device *dax_dev);
 bool dax_alive(struct dax_device *dax_dev);
 void kill_dax(struct dax_device *dax_dev);
index db68f4fa8ce0e2b25190257c9c407b4803fb5828..a0db055054a45dca61360b710072134f7ea89081 100644 (file)
@@ -645,7 +645,11 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
                goto err_id;
        }
 
-       dax_dev = alloc_dax(dev_dax, NULL);
+       /*
+        * No 'host' or dax_operations since there is no access to this
+        * device outside of mmap of the resulting character device.
+        */
+       dax_dev = alloc_dax(dev_dax, NULL, NULL);
        if (!dax_dev)
                goto err_dax;
 
index 8d446674c1da247c133bd1b332c7a44eee22a1a3..1a58542ee8fd15f281de621f8a7f5daa1057acaf 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/cdev.h>
 #include <linux/hash.h>
 #include <linux/slab.h>
+#include <linux/dax.h>
 #include <linux/fs.h>
 
 static int nr_dax = CONFIG_NR_DEV_DAX;
@@ -61,6 +62,7 @@ struct dax_device {
        const char *host;
        void *private;
        bool alive;
+       const struct dax_operations *ops;
 };
 
 bool dax_alive(struct dax_device *dax_dev)
@@ -208,7 +210,8 @@ static void dax_add_host(struct dax_device *dax_dev, const char *host)
        spin_unlock(&dax_host_lock);
 }
 
-struct dax_device *alloc_dax(void *private, const char *__host)
+struct dax_device *alloc_dax(void *private, const char *__host,
+               const struct dax_operations *ops)
 {
        struct dax_device *dax_dev;
        const char *host;
@@ -229,6 +232,7 @@ struct dax_device *alloc_dax(void *private, const char *__host)
                goto err_dev;
 
        dax_add_host(dax_dev, host);
+       dax_dev->ops = ops;
        dax_dev->private = private;
        return dax_dev;
 
index 9b2d5ba10d7dd161d86a3502c5c908e5ca0af8d7..74ebb92b625ad35d39ca12cf22067d69a1796c22 100644 (file)
@@ -7,6 +7,16 @@
 #include <asm/pgtable.h>
 
 struct iomap_ops;
+struct dax_device;
+struct dax_operations {
+       /*
+        * direct_access: translate a device-relative
+        * logical-page-offset into an absolute physical pfn. Return the
+        * number of pages available for DAX at that pfn.
+        */
+       long (*direct_access)(struct dax_device *, pgoff_t, long,
+                       void **, pfn_t *);
+};
 
 int dax_read_lock(void);
 void dax_read_unlock(int id);