Re: [PATCH 4/5] dax: remove the copy_from_iter and copy_to_iter methods

Dan Williams
2021-12-12T14:39:28Z

On Wed, Dec 8, 2021 at 10:38 PM Christoph Hellwig <hch@lst.de> wrote:
>
> These methods indirect the actual DAX read/write path. In the end pmem
> uses magic flush and mc safe variants and fuse and dcssblk use plain ones
> while device mapper picks redirects to the underlying device.
>
> Add set_dax_virtual() and set_dax_nomcsafe() APIs for fuse to skip these
> special variants, then use them everywhere as they fall back to the plain
> ones on s390 anyway and remove an indirect call from the read/write path
> as well as a lot of boilerplate code.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/dax/super.c | 36 ++++++++++++++--
> drivers/md/dm-linear.c | 20 ---------
> drivers/md/dm-log-writes.c | 80 -----------------------------------
> drivers/md/dm-stripe.c | 20 ---------
> drivers/md/dm.c | 50 ----------------------
> drivers/nvdimm/pmem.c | 20 ---------
> drivers/s390/block/dcssblk.c | 14 ------
> fs/dax.c | 5 ---
> fs/fuse/virtio_fs.c | 19 +--------
> include/linux/dax.h | 9 ++--
> include/linux/device-mapper.h | 4 --
> 11 files changed, 37 insertions(+), 240 deletions(-)
>
> diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> index e81d5ee57390f..ff676a07480c8 100644
> --- a/drivers/dax/super.c
> +++ b/drivers/dax/super.c
> @@ -105,6 +105,10 @@ enum dax_device_flags {
> DAXDEV_WRITE_CACHE,
> /* flag to check if device supports synchronous flush */
> DAXDEV_SYNC,
> + /* do not use uncached operations to write data */
> + DAXDEV_CACHED,
> + /* do not use mcsafe operations to read data */
> + DAXDEV_NOMCSAFE,

Linus did not like the mcsafe name, and this brings it back. Let's
flip the polarity to positively indicate which routine to use, and to
match the 'nofault' style which says "copy and handle faults".

/* do not leave the caches dirty after writes */
DAXDEV_NOCACHE

/* handle CPU fetch exceptions during reads */
DAXDEV_NOMC

...and then flip the use cases around.

Otherwise, nice cleanup. In retrospect I took the feedback to push
this decision to a driver a bit too literally, this is much better.