Change dm-linear to implement direct_access function,
linear_direct_access(), which maps sector and calls
direct_access function of its target device.

Signed-off-by: Toshi Kani <toshi.k...@hpe.com>
Cc: Alasdair Kergon <a...@redhat.com>
Cc: Mike Snitzer <snit...@redhat.com>
Cc: Dan Williams <dan.j.willi...@intel.com>
Cc: Ross Zwisler <ross.zwis...@linux.intel.com>
---
 drivers/md/dm-linear.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 05c35aa..49bd7d2 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -141,6 +141,22 @@ static int linear_iterate_devices(struct dm_target *ti,
        return fn(ti, lc->dev, lc->start, ti->len, data);
 }
 
+static long linear_direct_access(struct dm_target *ti, sector_t sector,
+               void __pmem **kaddr, pfn_t *pfn, long size)
+{
+       struct linear_c *lc;
+       struct block_device *tbdev;
+       const struct block_device_operations *tops;
+       sector_t tsector;
+
+       lc = ti->private;
+       tbdev = lc->dev->bdev;
+       tops = tbdev->bd_disk->fops;
+       tsector = linear_map_sector(ti, sector);
+
+       return tops->direct_access(tbdev, tsector, kaddr, pfn, size);
+}
+
 static struct target_type linear_target = {
        .name   = "linear",
        .version = {1, 2, 1},
@@ -151,6 +167,7 @@ static struct target_type linear_target = {
        .status = linear_status,
        .prepare_ioctl = linear_prepare_ioctl,
        .iterate_devices = linear_iterate_devices,
+       .direct_access = linear_direct_access,
 };
 
 int __init dm_linear_init(void)

Reply via email to