Re: [PATCH 02/13] block, dax: introduce dax_operations
From: Dan Williams
Date: Fri Jan 20 2017 - 12:28:33 EST
On Thu, Jan 19, 2017 at 7:50 PM, Dan Williams <dan.j.williams@xxxxxxxxx> wrote:
> Prepare for the removal of memcpy_to_pmem() and copy_from_iter_pmem() by
> introducing dax_ops. This allows for driver specific overrides for the
> routines that transfer data to a dax capable block device.
>
> Cc: <dm-devel@xxxxxxxxxx>
> Cc: Jan Kara <jack@xxxxxxx>
> Cc: Jens Axboe <axboe@xxxxxx>
> Cc: Jeff Moyer <jmoyer@xxxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> Cc: Toshi Kani <toshi.kani@xxxxxxx>
> Cc: Mike Snitzer <snitzer@xxxxxxxxxx>
> Cc: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx>
> Cc: Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> ---
> arch/powerpc/sysdev/axonram.c | 6 +++++-
> drivers/block/brd.c | 6 +++++-
> drivers/md/dm.c | 6 +++++-
> drivers/nvdimm/pmem.c | 6 +++++-
> drivers/s390/block/dcssblk.c | 6 +++++-
> fs/block_dev.c | 6 ++++--
> include/linux/blkdev.h | 8 ++++++--
> 7 files changed, 35 insertions(+), 9 deletions(-)
>
[..]
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 3086da5664f3..87920a379d20 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -2725,13 +2725,17 @@ static const struct pr_ops dm_pr_ops = {
> .pr_clear = dm_pr_clear,
> };
>
> +static const struct dax_operations dm_dax_ops = {
> + .direct_access = dm_blk_direct_access,
> +};
> +
> static const struct block_device_operations dm_blk_dops = {
> .open = dm_blk_open,
> .release = dm_blk_close,
> .ioctl = dm_blk_ioctl,
> - .direct_access = dm_blk_direct_access,
> .getgeo = dm_blk_getgeo,
> .pr_ops = &dm_pr_ops,
> + .dax_ops = &dm_dax_ops,
> .owner = THIS_MODULE
> };
I just realized we need to do a bit more plumbing to support the
device-mapper case. We need to implement all the dax_operations at the
dm_dax_ops level and pass in the physical sector so that device-mapper
can look up the backing block-device to call the real dax_operation if
it is implemented.