summaryrefslogtreecommitdiffstats
path: root/drivers/dax/super.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-05-29 15:57:56 -0400
committerDan Williams <dan.j.williams@intel.com>2017-06-09 12:22:21 -0400
commit7e026c8c0a4200da86bc51edeaad79dcdccf78ca (patch)
treeb1e30796161a6b1696ce75c2098d2fb980cb6a44 /drivers/dax/super.c
parent0aed55af88345b5d673240f90e671d79662fb01e (diff)
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 @@
18#include <linux/cdev.h> 18#include <linux/cdev.h>
19#include <linux/hash.h> 19#include <linux/hash.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/uio.h>
21#include <linux/dax.h> 22#include <linux/dax.h>
22#include <linux/fs.h> 23#include <linux/fs.h>
23 24
@@ -172,6 +173,18 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
172} 173}
173EXPORT_SYMBOL_GPL(dax_direct_access); 174EXPORT_SYMBOL_GPL(dax_direct_access);
174 175
176size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
177 size_t bytes, struct iov_iter *i)
178{
179 if (!dax_alive(dax_dev))
180 return 0;
181
182 if (!dax_dev->ops->copy_from_iter)
183 return copy_from_iter(addr, bytes, i);
184 return dax_dev->ops->copy_from_iter(dax_dev, pgoff, addr, bytes, i);
185}
186EXPORT_SYMBOL_GPL(dax_copy_from_iter);
187
175bool dax_alive(struct dax_device *dax_dev) 188bool dax_alive(struct dax_device *dax_dev)
176{ 189{
177 lockdep_assert_held(&dax_srcu); 190 lockdep_assert_held(&dax_srcu);