summaryrefslogtreecommitdiffstats
path: root/drivers/dax/super.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-05-29 21:57:56 +0200
committerDan Williams <dan.j.williams@intel.com>2017-06-09 18:22:21 +0200
commit7e026c8c0a4200da86bc51edeaad79dcdccf78ca (patch)
treeb1e30796161a6b1696ce75c2098d2fb980cb6a44 /drivers/dax/super.c
parentx86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass ope... (diff)
downloadlinux-7e026c8c0a4200da86bc51edeaad79dcdccf78ca.tar.xz
linux-7e026c8c0a4200da86bc51edeaad79dcdccf78ca.zip
dm: add ->copy_from_iter() dax operation support
Allow device-mapper to route copy_from_iter operations to the per-target implementation. In order for the device stacking to work we need a dax_dev and a pgoff relative to that device. This gives each layer of the stack the information it needs to look up the operation pointer for the next level. This conceptually allows for an array of mixed device drivers with varying copy_from_iter implementations. Reviewed-by: Toshi Kani <toshi.kani@hpe.com> Reviewed-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dax/super.c')
-rw-r--r--drivers/dax/super.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 6ed32aac8bbe..dd299e55f65d 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -18,6 +18,7 @@
#include <linux/cdev.h>
#include <linux/hash.h>
#include <linux/slab.h>
+#include <linux/uio.h>
#include <linux/dax.h>
#include <linux/fs.h>
@@ -172,6 +173,18 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
}
EXPORT_SYMBOL_GPL(dax_direct_access);
+size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
+ size_t bytes, struct iov_iter *i)
+{
+ if (!dax_alive(dax_dev))
+ return 0;
+
+ if (!dax_dev->ops->copy_from_iter)
+ return copy_from_iter(addr, bytes, i);
+ return dax_dev->ops->copy_from_iter(dax_dev, pgoff, addr, bytes, i);
+}
+EXPORT_SYMBOL_GPL(dax_copy_from_iter);
+
bool dax_alive(struct dax_device *dax_dev)
{
lockdep_assert_held(&dax_srcu);