* [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-01 18:12 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 18:12 UTC (permalink / raw) To: snitzer-H+wXaHxf7aLQT0dZR+AlfA Cc: Bart Van Assche, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Alasdair Kergon, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw Now that dax is no longer a default property of a block-device, i.e. ->direct_access() is not a block-device operation, we optionally enable device-mapper dax support with a new CONFIG_DM_DAX option. All the dax operations helpers are moved to a new file, drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. Otherwise, we stub out all the operations with NULL function pointers and nop wrappers for the core dax routines. Cc: Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Reported-by: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org> Signed-off-by: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- drivers/md/Kconfig | 14 +++ drivers/md/Makefile | 1 drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/md/dm-dax.h | 73 +++++++++++++++ drivers/md/dm-linear.c | 56 ------------ drivers/md/dm-snap.c | 9 -- drivers/md/dm-stripe.c | 89 ------------------- drivers/md/dm-target.c | 7 - drivers/md/dm.c | 105 ++-------------------- drivers/md/dm.h | 34 +++++++ 10 files changed, 363 insertions(+), 252 deletions(-) create mode 100644 drivers/md/dm-dax.c create mode 100644 drivers/md/dm-dax.h diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..bf27b435f7cd 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN config BLK_DEV_DM tristate "Device mapper support" select BLK_DEV_DM_BUILTIN - select DAX ---help--- Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various @@ -214,6 +213,19 @@ config BLK_DEV_DM If unsure, say N. +config DM_DAX + bool "Direct access (DAX) support" + depends on BLK_DEV_DM + default BLK_DEV_PMEM + select DAX + ---help--- + Enable DAX support for the device-mapper linear and stripe + targets for use with DAX capable block devices like /dev/pmemN. + If you have a DAX capable block device and have enabled + filesystem DAX support (CONFIG_FS_DAX), then say Y. + + If unsure, say N. + config DM_MQ_DEFAULT bool "request-based DM: use blk-mq I/O path by default" depends on BLK_DEV_DM diff --git a/drivers/md/Makefile b/drivers/md/Makefile index 786ec9e86d65..4a2fd958a3d9 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -5,6 +5,7 @@ dm-mod-y += dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \ dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-stats.o \ dm-rq.o +dm-mod-$(CONFIG_DM_DAX) += dm-dax.o dm-multipath-y += dm-path-selector.o dm-mpath.o dm-snapshot-y += dm-snap.o dm-exception-store.o dm-snap-transient.o \ dm-snap-persistent.o diff --git a/drivers/md/dm-dax.c b/drivers/md/dm-dax.c new file mode 100644 index 000000000000..d48386fe2578 --- /dev/null +++ b/drivers/md/dm-dax.c @@ -0,0 +1,227 @@ +/* + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +#include <linux/device-mapper.h> +#include <linux/dax.h> +#include <linux/uio.h> + +#include "dm.h" + +extern sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector); +extern sector_t max_io_len(sector_t sector, struct dm_target *ti); + +long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + long ret; + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) + return; + dax_flush(dax_dev, pgoff, addr, size); +} + +long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ +#define DM_MSG_PREFIX "snapshots" + DMWARN("device does not support dax."); + return -EIO; +} +EXPORT_SYMBOL_GPL(origin_dax_direct_access); + +extern void stripe_map_sector(struct stripe_c *sc, sector_t sector, + uint32_t *stripe, sector_t *result); +long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + long ret; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) + return; + dax_flush(dax_dev, pgoff, addr, size); +} + +long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + return -EIO; +} + +static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, + sector_t sector, int *srcu_idx) +{ + struct dm_table *map; + struct dm_target *ti; + + map = dm_get_live_table(md, srcu_idx); + if (!map) + return NULL; + + ti = dm_table_find_target(map, sector); + if (!dm_target_is_valid(ti)) + return NULL; + + return ti; +} + +long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long len, ret = -EIO; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (!ti->type->direct_access) + goto out; + len = max_io_len(sector, ti) / PAGE_SECTORS; + if (len < 1) + goto out; + nr_pages = min(len, nr_pages); + if (ti->type->direct_access) + ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); + + out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + +size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long ret = 0; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (!ti->type->dax_copy_from_iter) { + ret = copy_from_iter(addr, bytes, i); + goto out; + } + ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); + out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + +void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t size) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (ti->type->dax_flush) + ti->type->dax_flush(ti, pgoff, addr, size); + out: + dm_put_live_table(md, srcu_idx); +} diff --git a/drivers/md/dm-dax.h b/drivers/md/dm-dax.h new file mode 100644 index 000000000000..02cd4589d05a --- /dev/null +++ b/drivers/md/dm-dax.h @@ -0,0 +1,73 @@ +#ifndef __DM_DAX_H__ +#define __DM_DAX_H__ +#include <linux/dax.h> +#if IS_ENABLED(CONFIG_DM_DAX) +/* dax helpers to allow compiling out dax support */ +long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size); +long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size); +long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +static inline struct dax_device *dm_dax_get_by_host(const char *host) +{ + return dax_get_by_host(host); +} +static inline void dm_put_dax(struct dax_device *dax_dev) +{ + put_dax(dax_dev); +} +static inline struct dax_device *dm_alloc_dax(void *p, const char *host, + const struct dax_operations *ops) +{ + return alloc_dax(p, host, ops); +} +static inline void dm_kill_dax(struct dax_device *dax_dev) +{ + kill_dax(dax_dev); +} +long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t size); +#else +#define linear_dax_direct_access NULL +#define linear_dax_copy_from_iter NULL +#define linear_dax_flush NULL +#define origin_dax_direct_access NULL +#define stripe_dax_direct_access NULL +#define stripe_dax_copy_from_iter NULL +#define stripe_dax_flush NULL +#define io_err_dax_direct_access NULL +static inline struct dax_device *dm_dax_get_by_host(const char *host) +{ + return NULL; +} +static inline void dm_put_dax(struct dax_device *dax_dev) +{ +} +static inline struct dax_device *dm_alloc_dax(void *private, const char *__host, + const struct dax_operations *ops) +{ + return NULL; +} +static inline void dm_kill_dax(struct dax_device *dax_dev) +{ +} +#define dm_dax_direct_access NULL +#define dm_dax_copy_from_iter NULL +#define dm_dax_flush NULL +#endif +#endif /* __DM_DAX_H__ */ diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 41971a090e34..184ae6e76ac4 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -5,25 +5,17 @@ */ #include "dm.h" +#include "dm-dax.h" #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/device-mapper.h> #define DM_MSG_PREFIX "linear" /* - * Linear: maps a linear range of a device. - */ -struct linear_c { - struct dm_dev *dev; - sector_t start; -}; - -/* * Construct a linear mapping: <dev_path> <offset> */ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) @@ -77,7 +69,7 @@ static void linear_dtr(struct dm_target *ti) kfree(lc); } -static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) +sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) { struct linear_c *lc = ti->private; @@ -154,50 +146,6 @@ static int linear_iterate_devices(struct dm_target *ti, return fn(ti, lc->dev, lc->start, ti->len, data); } -static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - long ret; - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); -} - -static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); -} - -static void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, - size_t size) -{ - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) - return; - dax_flush(dax_dev, pgoff, addr, size); -} - static struct target_type linear_target = { .name = "linear", .version = {1, 4, 0}, diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 1ba41048b438..fa31d9f5642d 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -21,7 +21,7 @@ #include <linux/dm-kcopyd.h> #include "dm.h" - +#include "dm-dax.h" #include "dm-exception-store.h" #define DM_MSG_PREFIX "snapshots" @@ -2303,13 +2303,6 @@ static int origin_map(struct dm_target *ti, struct bio *bio) return do_origin(o->dev, bio); } -static long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - DMWARN("device does not support dax."); - return -EIO; -} - /* * Set the target "max_io_len" field to the minimum of all the snapshots' * chunk sizes. diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a0375530b07f..a4720abac523 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -5,45 +5,19 @@ */ #include "dm.h" +#include "dm-dax.h" #include <linux/device-mapper.h> #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/log2.h> #define DM_MSG_PREFIX "striped" #define DM_IO_ERROR_THRESHOLD 15 -struct stripe { - struct dm_dev *dev; - sector_t physical_start; - - atomic_t error_count; -}; - -struct stripe_c { - uint32_t stripes; - int stripes_shift; - - /* The size of this target / num. stripes */ - sector_t stripe_width; - - uint32_t chunk_size; - int chunk_size_shift; - - /* Needed for handling events */ - struct dm_target *ti; - - /* Work struct used for triggering events*/ - struct work_struct trigger_event; - - struct stripe stripe[0]; -}; - /* * An event is triggered whenever a drive * drops out of a stripe volume. @@ -212,7 +186,7 @@ static void stripe_dtr(struct dm_target *ti) kfree(sc); } -static void stripe_map_sector(struct stripe_c *sc, sector_t sector, +void stripe_map_sector(struct stripe_c *sc, sector_t sector, uint32_t *stripe, sector_t *result) { sector_t chunk = dm_target_offset(sc->ti, sector); @@ -311,65 +285,6 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } -static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - long ret; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); -} - -static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); -} - -static void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, - size_t size) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) - return; - dax_flush(dax_dev, pgoff, addr, size); -} - /* * Stripe status: * diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index c0d7e60820c4..3d4130e2e1e9 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -5,6 +5,7 @@ */ #include "dm-core.h" +#include "dm-dax.h" #include <linux/module.h> #include <linux/init.h> @@ -142,12 +143,6 @@ static void io_err_release_clone_rq(struct request *clone) { } -static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - return -EIO; -} - static struct target_type error_target = { .name = "error", .version = {1, 5, 0}, diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2edbcc2d7d3f..73aca9ce5581 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -8,6 +8,7 @@ #include "dm-core.h" #include "dm-rq.h" #include "dm-uevent.h" +#include "dm-dax.h" #include <linux/init.h> #include <linux/module.h> @@ -16,7 +17,6 @@ #include <linux/blkpg.h> #include <linux/bio.h> #include <linux/mempool.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/idr.h> #include <linux/uio.h> @@ -634,7 +634,7 @@ static int open_table_device(struct table_device *td, dev_t dev, } td->dm_dev.bdev = bdev; - td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); + td->dm_dev.dax_dev = dm_dax_get_by_host(bdev->bd_disk->disk_name); return 0; } @@ -648,7 +648,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); - put_dax(td->dm_dev.dax_dev); + dm_put_dax(td->dm_dev.dax_dev); td->dm_dev.bdev = NULL; td->dm_dev.dax_dev = NULL; } @@ -890,7 +890,7 @@ static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti return ti->len - target_offset; } -static sector_t max_io_len(sector_t sector, struct dm_target *ti) +sector_t max_io_len(sector_t sector, struct dm_target *ti) { sector_t len = max_io_len_target_boundary(sector, ti); sector_t offset, max_len; @@ -928,93 +928,6 @@ int dm_set_target_max_io_len(struct dm_target *ti, sector_t len) } EXPORT_SYMBOL_GPL(dm_set_target_max_io_len); -static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, - sector_t sector, int *srcu_idx) -{ - struct dm_table *map; - struct dm_target *ti; - - map = dm_get_live_table(md, srcu_idx); - if (!map) - return NULL; - - ti = dm_table_find_target(map, sector); - if (!dm_target_is_valid(ti)) - return NULL; - - return ti; -} - -static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - long len, ret = -EIO; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (!ti->type->direct_access) - goto out; - len = max_io_len(sector, ti) / PAGE_SECTORS; - if (len < 1) - goto out; - nr_pages = min(len, nr_pages); - if (ti->type->direct_access) - ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); - - out: - dm_put_live_table(md, srcu_idx); - - return ret; -} - -static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - long ret = 0; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (!ti->type->dax_copy_from_iter) { - ret = copy_from_iter(addr, bytes, i); - goto out; - } - ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); - out: - dm_put_live_table(md, srcu_idx); - - return ret; -} - -static void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t size) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (ti->type->dax_flush) - ti->type->dax_flush(ti, pgoff, addr, size); - out: - dm_put_live_table(md, srcu_idx); -} - /* * A target may call dm_accept_partial_bio only from the map routine. It is * allowed for all bio types except REQ_PREFLUSH. @@ -1681,8 +1594,8 @@ static void cleanup_mapped_device(struct mapped_device *md) bioset_free(md->bs); if (md->dax_dev) { - kill_dax(md->dax_dev); - put_dax(md->dax_dev); + dm_kill_dax(md->dax_dev); + dm_put_dax(md->dax_dev); md->dax_dev = NULL; } @@ -1779,8 +1692,8 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); - if (!dax_dev) + dax_dev = dm_alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev && IS_ENABLED(CONFIG_DM_DAX)) goto bad; md->dax_dev = dax_dev; @@ -2999,7 +2912,7 @@ static const struct block_device_operations dm_blk_dops = { .owner = THIS_MODULE }; -static const struct dax_operations dm_dax_ops = { +static const __maybe_unused struct dax_operations dm_dax_ops = { .direct_access = dm_dax_direct_access, .copy_from_iter = dm_dax_copy_from_iter, .flush = dm_dax_flush, diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 38c84c0a35d4..2c9d94ec2391 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -174,6 +174,40 @@ int dm_stripe_init(void); void dm_stripe_exit(void); /* + * Linear: maps a linear range of a device. + */ +struct linear_c { + struct dm_dev *dev; + sector_t start; +}; + +struct stripe { + struct dm_dev *dev; + sector_t physical_start; + + atomic_t error_count; +}; + +struct stripe_c { + uint32_t stripes; + int stripes_shift; + + /* The size of this target / num. stripes */ + sector_t stripe_width; + + uint32_t chunk_size; + int chunk_size_shift; + + /* Needed for handling events */ + struct dm_target *ti; + + /* Work struct used for triggering events*/ + struct work_struct trigger_event; + + struct stripe stripe[0]; +}; + +/* * mapped_device operations */ void dm_destroy(struct mapped_device *md); ^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-01 18:12 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 18:12 UTC (permalink / raw) To: snitzer Cc: Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm Now that dax is no longer a default property of a block-device, i.e. ->direct_access() is not a block-device operation, we optionally enable device-mapper dax support with a new CONFIG_DM_DAX option. All the dax operations helpers are moved to a new file, drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. Otherwise, we stub out all the operations with NULL function pointers and nop wrappers for the core dax routines. Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/md/Kconfig | 14 +++ drivers/md/Makefile | 1 drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/md/dm-dax.h | 73 +++++++++++++++ drivers/md/dm-linear.c | 56 ------------ drivers/md/dm-snap.c | 9 -- drivers/md/dm-stripe.c | 89 ------------------- drivers/md/dm-target.c | 7 - drivers/md/dm.c | 105 ++-------------------- drivers/md/dm.h | 34 +++++++ 10 files changed, 363 insertions(+), 252 deletions(-) create mode 100644 drivers/md/dm-dax.c create mode 100644 drivers/md/dm-dax.h diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..bf27b435f7cd 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN config BLK_DEV_DM tristate "Device mapper support" select BLK_DEV_DM_BUILTIN - select DAX ---help--- Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various @@ -214,6 +213,19 @@ config BLK_DEV_DM If unsure, say N. +config DM_DAX + bool "Direct access (DAX) support" + depends on BLK_DEV_DM + default BLK_DEV_PMEM + select DAX + ---help--- + Enable DAX support for the device-mapper linear and stripe + targets for use with DAX capable block devices like /dev/pmemN. + If you have a DAX capable block device and have enabled + filesystem DAX support (CONFIG_FS_DAX), then say Y. + + If unsure, say N. + config DM_MQ_DEFAULT bool "request-based DM: use blk-mq I/O path by default" depends on BLK_DEV_DM diff --git a/drivers/md/Makefile b/drivers/md/Makefile index 786ec9e86d65..4a2fd958a3d9 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -5,6 +5,7 @@ dm-mod-y += dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \ dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-stats.o \ dm-rq.o +dm-mod-$(CONFIG_DM_DAX) += dm-dax.o dm-multipath-y += dm-path-selector.o dm-mpath.o dm-snapshot-y += dm-snap.o dm-exception-store.o dm-snap-transient.o \ dm-snap-persistent.o diff --git a/drivers/md/dm-dax.c b/drivers/md/dm-dax.c new file mode 100644 index 000000000000..d48386fe2578 --- /dev/null +++ b/drivers/md/dm-dax.c @@ -0,0 +1,227 @@ +/* + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +#include <linux/device-mapper.h> +#include <linux/dax.h> +#include <linux/uio.h> + +#include "dm.h" + +extern sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector); +extern sector_t max_io_len(sector_t sector, struct dm_target *ti); + +long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + long ret; + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) + return; + dax_flush(dax_dev, pgoff, addr, size); +} + +long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ +#define DM_MSG_PREFIX "snapshots" + DMWARN("device does not support dax."); + return -EIO; +} +EXPORT_SYMBOL_GPL(origin_dax_direct_access); + +extern void stripe_map_sector(struct stripe_c *sc, sector_t sector, + uint32_t *stripe, sector_t *result); +long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + long ret; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) + return; + dax_flush(dax_dev, pgoff, addr, size); +} + +long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + return -EIO; +} + +static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, + sector_t sector, int *srcu_idx) +{ + struct dm_table *map; + struct dm_target *ti; + + map = dm_get_live_table(md, srcu_idx); + if (!map) + return NULL; + + ti = dm_table_find_target(map, sector); + if (!dm_target_is_valid(ti)) + return NULL; + + return ti; +} + +long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long len, ret = -EIO; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (!ti->type->direct_access) + goto out; + len = max_io_len(sector, ti) / PAGE_SECTORS; + if (len < 1) + goto out; + nr_pages = min(len, nr_pages); + if (ti->type->direct_access) + ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); + + out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + +size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long ret = 0; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (!ti->type->dax_copy_from_iter) { + ret = copy_from_iter(addr, bytes, i); + goto out; + } + ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); + out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + +void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t size) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (ti->type->dax_flush) + ti->type->dax_flush(ti, pgoff, addr, size); + out: + dm_put_live_table(md, srcu_idx); +} diff --git a/drivers/md/dm-dax.h b/drivers/md/dm-dax.h new file mode 100644 index 000000000000..02cd4589d05a --- /dev/null +++ b/drivers/md/dm-dax.h @@ -0,0 +1,73 @@ +#ifndef __DM_DAX_H__ +#define __DM_DAX_H__ +#include <linux/dax.h> +#if IS_ENABLED(CONFIG_DM_DAX) +/* dax helpers to allow compiling out dax support */ +long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size); +long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size); +long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +static inline struct dax_device *dm_dax_get_by_host(const char *host) +{ + return dax_get_by_host(host); +} +static inline void dm_put_dax(struct dax_device *dax_dev) +{ + put_dax(dax_dev); +} +static inline struct dax_device *dm_alloc_dax(void *p, const char *host, + const struct dax_operations *ops) +{ + return alloc_dax(p, host, ops); +} +static inline void dm_kill_dax(struct dax_device *dax_dev) +{ + kill_dax(dax_dev); +} +long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t size); +#else +#define linear_dax_direct_access NULL +#define linear_dax_copy_from_iter NULL +#define linear_dax_flush NULL +#define origin_dax_direct_access NULL +#define stripe_dax_direct_access NULL +#define stripe_dax_copy_from_iter NULL +#define stripe_dax_flush NULL +#define io_err_dax_direct_access NULL +static inline struct dax_device *dm_dax_get_by_host(const char *host) +{ + return NULL; +} +static inline void dm_put_dax(struct dax_device *dax_dev) +{ +} +static inline struct dax_device *dm_alloc_dax(void *private, const char *__host, + const struct dax_operations *ops) +{ + return NULL; +} +static inline void dm_kill_dax(struct dax_device *dax_dev) +{ +} +#define dm_dax_direct_access NULL +#define dm_dax_copy_from_iter NULL +#define dm_dax_flush NULL +#endif +#endif /* __DM_DAX_H__ */ diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 41971a090e34..184ae6e76ac4 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -5,25 +5,17 @@ */ #include "dm.h" +#include "dm-dax.h" #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/device-mapper.h> #define DM_MSG_PREFIX "linear" /* - * Linear: maps a linear range of a device. - */ -struct linear_c { - struct dm_dev *dev; - sector_t start; -}; - -/* * Construct a linear mapping: <dev_path> <offset> */ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) @@ -77,7 +69,7 @@ static void linear_dtr(struct dm_target *ti) kfree(lc); } -static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) +sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) { struct linear_c *lc = ti->private; @@ -154,50 +146,6 @@ static int linear_iterate_devices(struct dm_target *ti, return fn(ti, lc->dev, lc->start, ti->len, data); } -static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - long ret; - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); -} - -static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); -} - -static void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, - size_t size) -{ - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) - return; - dax_flush(dax_dev, pgoff, addr, size); -} - static struct target_type linear_target = { .name = "linear", .version = {1, 4, 0}, diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 1ba41048b438..fa31d9f5642d 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -21,7 +21,7 @@ #include <linux/dm-kcopyd.h> #include "dm.h" - +#include "dm-dax.h" #include "dm-exception-store.h" #define DM_MSG_PREFIX "snapshots" @@ -2303,13 +2303,6 @@ static int origin_map(struct dm_target *ti, struct bio *bio) return do_origin(o->dev, bio); } -static long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - DMWARN("device does not support dax."); - return -EIO; -} - /* * Set the target "max_io_len" field to the minimum of all the snapshots' * chunk sizes. diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a0375530b07f..a4720abac523 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -5,45 +5,19 @@ */ #include "dm.h" +#include "dm-dax.h" #include <linux/device-mapper.h> #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/log2.h> #define DM_MSG_PREFIX "striped" #define DM_IO_ERROR_THRESHOLD 15 -struct stripe { - struct dm_dev *dev; - sector_t physical_start; - - atomic_t error_count; -}; - -struct stripe_c { - uint32_t stripes; - int stripes_shift; - - /* The size of this target / num. stripes */ - sector_t stripe_width; - - uint32_t chunk_size; - int chunk_size_shift; - - /* Needed for handling events */ - struct dm_target *ti; - - /* Work struct used for triggering events*/ - struct work_struct trigger_event; - - struct stripe stripe[0]; -}; - /* * An event is triggered whenever a drive * drops out of a stripe volume. @@ -212,7 +186,7 @@ static void stripe_dtr(struct dm_target *ti) kfree(sc); } -static void stripe_map_sector(struct stripe_c *sc, sector_t sector, +void stripe_map_sector(struct stripe_c *sc, sector_t sector, uint32_t *stripe, sector_t *result) { sector_t chunk = dm_target_offset(sc->ti, sector); @@ -311,65 +285,6 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } -static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - long ret; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); -} - -static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); -} - -static void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, - size_t size) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) - return; - dax_flush(dax_dev, pgoff, addr, size); -} - /* * Stripe status: * diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index c0d7e60820c4..3d4130e2e1e9 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -5,6 +5,7 @@ */ #include "dm-core.h" +#include "dm-dax.h" #include <linux/module.h> #include <linux/init.h> @@ -142,12 +143,6 @@ static void io_err_release_clone_rq(struct request *clone) { } -static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - return -EIO; -} - static struct target_type error_target = { .name = "error", .version = {1, 5, 0}, diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2edbcc2d7d3f..73aca9ce5581 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -8,6 +8,7 @@ #include "dm-core.h" #include "dm-rq.h" #include "dm-uevent.h" +#include "dm-dax.h" #include <linux/init.h> #include <linux/module.h> @@ -16,7 +17,6 @@ #include <linux/blkpg.h> #include <linux/bio.h> #include <linux/mempool.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/idr.h> #include <linux/uio.h> @@ -634,7 +634,7 @@ static int open_table_device(struct table_device *td, dev_t dev, } td->dm_dev.bdev = bdev; - td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); + td->dm_dev.dax_dev = dm_dax_get_by_host(bdev->bd_disk->disk_name); return 0; } @@ -648,7 +648,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); - put_dax(td->dm_dev.dax_dev); + dm_put_dax(td->dm_dev.dax_dev); td->dm_dev.bdev = NULL; td->dm_dev.dax_dev = NULL; } @@ -890,7 +890,7 @@ static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti return ti->len - target_offset; } -static sector_t max_io_len(sector_t sector, struct dm_target *ti) +sector_t max_io_len(sector_t sector, struct dm_target *ti) { sector_t len = max_io_len_target_boundary(sector, ti); sector_t offset, max_len; @@ -928,93 +928,6 @@ int dm_set_target_max_io_len(struct dm_target *ti, sector_t len) } EXPORT_SYMBOL_GPL(dm_set_target_max_io_len); -static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, - sector_t sector, int *srcu_idx) -{ - struct dm_table *map; - struct dm_target *ti; - - map = dm_get_live_table(md, srcu_idx); - if (!map) - return NULL; - - ti = dm_table_find_target(map, sector); - if (!dm_target_is_valid(ti)) - return NULL; - - return ti; -} - -static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - long len, ret = -EIO; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (!ti->type->direct_access) - goto out; - len = max_io_len(sector, ti) / PAGE_SECTORS; - if (len < 1) - goto out; - nr_pages = min(len, nr_pages); - if (ti->type->direct_access) - ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); - - out: - dm_put_live_table(md, srcu_idx); - - return ret; -} - -static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - long ret = 0; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (!ti->type->dax_copy_from_iter) { - ret = copy_from_iter(addr, bytes, i); - goto out; - } - ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); - out: - dm_put_live_table(md, srcu_idx); - - return ret; -} - -static void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t size) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (ti->type->dax_flush) - ti->type->dax_flush(ti, pgoff, addr, size); - out: - dm_put_live_table(md, srcu_idx); -} - /* * A target may call dm_accept_partial_bio only from the map routine. It is * allowed for all bio types except REQ_PREFLUSH. @@ -1681,8 +1594,8 @@ static void cleanup_mapped_device(struct mapped_device *md) bioset_free(md->bs); if (md->dax_dev) { - kill_dax(md->dax_dev); - put_dax(md->dax_dev); + dm_kill_dax(md->dax_dev); + dm_put_dax(md->dax_dev); md->dax_dev = NULL; } @@ -1779,8 +1692,8 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); - if (!dax_dev) + dax_dev = dm_alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev && IS_ENABLED(CONFIG_DM_DAX)) goto bad; md->dax_dev = dax_dev; @@ -2999,7 +2912,7 @@ static const struct block_device_operations dm_blk_dops = { .owner = THIS_MODULE }; -static const struct dax_operations dm_dax_ops = { +static const __maybe_unused struct dax_operations dm_dax_ops = { .direct_access = dm_dax_direct_access, .copy_from_iter = dm_dax_copy_from_iter, .flush = dm_dax_flush, diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 38c84c0a35d4..2c9d94ec2391 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -174,6 +174,40 @@ int dm_stripe_init(void); void dm_stripe_exit(void); /* + * Linear: maps a linear range of a device. + */ +struct linear_c { + struct dm_dev *dev; + sector_t start; +}; + +struct stripe { + struct dm_dev *dev; + sector_t physical_start; + + atomic_t error_count; +}; + +struct stripe_c { + uint32_t stripes; + int stripes_shift; + + /* The size of this target / num. stripes */ + sector_t stripe_width; + + uint32_t chunk_size; + int chunk_size_shift; + + /* Needed for handling events */ + struct dm_target *ti; + + /* Work struct used for triggering events*/ + struct work_struct trigger_event; + + struct stripe stripe[0]; +}; + +/* * mapped_device operations */ void dm_destroy(struct mapped_device *md); ^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-01 18:12 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 18:12 UTC (permalink / raw) To: snitzer Cc: Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm Now that dax is no longer a default property of a block-device, i.e. ->direct_access() is not a block-device operation, we optionally enable device-mapper dax support with a new CONFIG_DM_DAX option. All the dax operations helpers are moved to a new file, drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. Otherwise, we stub out all the operations with NULL function pointers and nop wrappers for the core dax routines. Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/md/Kconfig | 14 +++ drivers/md/Makefile | 1 drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/md/dm-dax.h | 73 +++++++++++++++ drivers/md/dm-linear.c | 56 ------------ drivers/md/dm-snap.c | 9 -- drivers/md/dm-stripe.c | 89 ------------------- drivers/md/dm-target.c | 7 - drivers/md/dm.c | 105 ++-------------------- drivers/md/dm.h | 34 +++++++ 10 files changed, 363 insertions(+), 252 deletions(-) create mode 100644 drivers/md/dm-dax.c create mode 100644 drivers/md/dm-dax.h diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..bf27b435f7cd 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN config BLK_DEV_DM tristate "Device mapper support" select BLK_DEV_DM_BUILTIN - select DAX ---help--- Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various @@ -214,6 +213,19 @@ config BLK_DEV_DM If unsure, say N. +config DM_DAX + bool "Direct access (DAX) support" + depends on BLK_DEV_DM + default BLK_DEV_PMEM + select DAX + ---help--- + Enable DAX support for the device-mapper linear and stripe + targets for use with DAX capable block devices like /dev/pmemN. + If you have a DAX capable block device and have enabled + filesystem DAX support (CONFIG_FS_DAX), then say Y. + + If unsure, say N. + config DM_MQ_DEFAULT bool "request-based DM: use blk-mq I/O path by default" depends on BLK_DEV_DM diff --git a/drivers/md/Makefile b/drivers/md/Makefile index 786ec9e86d65..4a2fd958a3d9 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -5,6 +5,7 @@ dm-mod-y += dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \ dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-stats.o \ dm-rq.o +dm-mod-$(CONFIG_DM_DAX) += dm-dax.o dm-multipath-y += dm-path-selector.o dm-mpath.o dm-snapshot-y += dm-snap.o dm-exception-store.o dm-snap-transient.o \ dm-snap-persistent.o diff --git a/drivers/md/dm-dax.c b/drivers/md/dm-dax.c new file mode 100644 index 000000000000..d48386fe2578 --- /dev/null +++ b/drivers/md/dm-dax.c @@ -0,0 +1,227 @@ +/* + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +#include <linux/device-mapper.h> +#include <linux/dax.h> +#include <linux/uio.h> + +#include "dm.h" + +extern sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector); +extern sector_t max_io_len(sector_t sector, struct dm_target *ti); + +long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + long ret; + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size) +{ + struct linear_c *lc = ti->private; + struct block_device *bdev = lc->dev->bdev; + struct dax_device *dax_dev = lc->dev->dax_dev; + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + + dev_sector = linear_map_sector(ti, sector); + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) + return; + dax_flush(dax_dev, pgoff, addr, size); +} + +long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ +#define DM_MSG_PREFIX "snapshots" + DMWARN("device does not support dax."); + return -EIO; +} +EXPORT_SYMBOL_GPL(origin_dax_direct_access); + +extern void stripe_map_sector(struct stripe_c *sc, sector_t sector, + uint32_t *stripe, sector_t *result); +long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + long ret; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size) +{ + sector_t dev_sector, sector = pgoff * PAGE_SECTORS; + struct stripe_c *sc = ti->private; + struct dax_device *dax_dev; + struct block_device *bdev; + uint32_t stripe; + + stripe_map_sector(sc, sector, &stripe, &dev_sector); + dev_sector += sc->stripe[stripe].physical_start; + dax_dev = sc->stripe[stripe].dev->dax_dev; + bdev = sc->stripe[stripe].dev->bdev; + + if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) + return; + dax_flush(dax_dev, pgoff, addr, size); +} + +long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + return -EIO; +} + +static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, + sector_t sector, int *srcu_idx) +{ + struct dm_table *map; + struct dm_target *ti; + + map = dm_get_live_table(md, srcu_idx); + if (!map) + return NULL; + + ti = dm_table_find_target(map, sector); + if (!dm_target_is_valid(ti)) + return NULL; + + return ti; +} + +long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long len, ret = -EIO; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (!ti->type->direct_access) + goto out; + len = max_io_len(sector, ti) / PAGE_SECTORS; + if (len < 1) + goto out; + nr_pages = min(len, nr_pages); + if (ti->type->direct_access) + ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); + + out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + +size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long ret = 0; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (!ti->type->dax_copy_from_iter) { + ret = copy_from_iter(addr, bytes, i); + goto out; + } + ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); + out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + +void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t size) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + if (ti->type->dax_flush) + ti->type->dax_flush(ti, pgoff, addr, size); + out: + dm_put_live_table(md, srcu_idx); +} diff --git a/drivers/md/dm-dax.h b/drivers/md/dm-dax.h new file mode 100644 index 000000000000..02cd4589d05a --- /dev/null +++ b/drivers/md/dm-dax.h @@ -0,0 +1,73 @@ +#ifndef __DM_DAX_H__ +#define __DM_DAX_H__ +#include <linux/dax.h> +#if IS_ENABLED(CONFIG_DM_DAX) +/* dax helpers to allow compiling out dax support */ +long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size); +long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, + size_t size); +long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +static inline struct dax_device *dm_dax_get_by_host(const char *host) +{ + return dax_get_by_host(host); +} +static inline void dm_put_dax(struct dax_device *dax_dev) +{ + put_dax(dax_dev); +} +static inline struct dax_device *dm_alloc_dax(void *p, const char *host, + const struct dax_operations *ops) +{ + return alloc_dax(p, host, ops); +} +static inline void dm_kill_dax(struct dax_device *dax_dev) +{ + kill_dax(dax_dev); +} +long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn); +size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); +void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t size); +#else +#define linear_dax_direct_access NULL +#define linear_dax_copy_from_iter NULL +#define linear_dax_flush NULL +#define origin_dax_direct_access NULL +#define stripe_dax_direct_access NULL +#define stripe_dax_copy_from_iter NULL +#define stripe_dax_flush NULL +#define io_err_dax_direct_access NULL +static inline struct dax_device *dm_dax_get_by_host(const char *host) +{ + return NULL; +} +static inline void dm_put_dax(struct dax_device *dax_dev) +{ +} +static inline struct dax_device *dm_alloc_dax(void *private, const char *__host, + const struct dax_operations *ops) +{ + return NULL; +} +static inline void dm_kill_dax(struct dax_device *dax_dev) +{ +} +#define dm_dax_direct_access NULL +#define dm_dax_copy_from_iter NULL +#define dm_dax_flush NULL +#endif +#endif /* __DM_DAX_H__ */ diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 41971a090e34..184ae6e76ac4 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -5,25 +5,17 @@ */ #include "dm.h" +#include "dm-dax.h" #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/device-mapper.h> #define DM_MSG_PREFIX "linear" /* - * Linear: maps a linear range of a device. - */ -struct linear_c { - struct dm_dev *dev; - sector_t start; -}; - -/* * Construct a linear mapping: <dev_path> <offset> */ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) @@ -77,7 +69,7 @@ static void linear_dtr(struct dm_target *ti) kfree(lc); } -static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) +sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) { struct linear_c *lc = ti->private; @@ -154,50 +146,6 @@ static int linear_iterate_devices(struct dm_target *ti, return fn(ti, lc->dev, lc->start, ti->len, data); } -static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - long ret; - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); -} - -static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); -} - -static void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, - size_t size) -{ - struct linear_c *lc = ti->private; - struct block_device *bdev = lc->dev->bdev; - struct dax_device *dax_dev = lc->dev->dax_dev; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - - dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) - return; - dax_flush(dax_dev, pgoff, addr, size); -} - static struct target_type linear_target = { .name = "linear", .version = {1, 4, 0}, diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 1ba41048b438..fa31d9f5642d 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -21,7 +21,7 @@ #include <linux/dm-kcopyd.h> #include "dm.h" - +#include "dm-dax.h" #include "dm-exception-store.h" #define DM_MSG_PREFIX "snapshots" @@ -2303,13 +2303,6 @@ static int origin_map(struct dm_target *ti, struct bio *bio) return do_origin(o->dev, bio); } -static long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - DMWARN("device does not support dax."); - return -EIO; -} - /* * Set the target "max_io_len" field to the minimum of all the snapshots' * chunk sizes. diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a0375530b07f..a4720abac523 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -5,45 +5,19 @@ */ #include "dm.h" +#include "dm-dax.h" #include <linux/device-mapper.h> #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/log2.h> #define DM_MSG_PREFIX "striped" #define DM_IO_ERROR_THRESHOLD 15 -struct stripe { - struct dm_dev *dev; - sector_t physical_start; - - atomic_t error_count; -}; - -struct stripe_c { - uint32_t stripes; - int stripes_shift; - - /* The size of this target / num. stripes */ - sector_t stripe_width; - - uint32_t chunk_size; - int chunk_size_shift; - - /* Needed for handling events */ - struct dm_target *ti; - - /* Work struct used for triggering events*/ - struct work_struct trigger_event; - - struct stripe stripe[0]; -}; - /* * An event is triggered whenever a drive * drops out of a stripe volume. @@ -212,7 +186,7 @@ static void stripe_dtr(struct dm_target *ti) kfree(sc); } -static void stripe_map_sector(struct stripe_c *sc, sector_t sector, +void stripe_map_sector(struct stripe_c *sc, sector_t sector, uint32_t *stripe, sector_t *result) { sector_t chunk = dm_target_offset(sc->ti, sector); @@ -311,65 +285,6 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } -static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - long ret; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); -} - -static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); -} - -static void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, - size_t size) -{ - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(size, PAGE_SIZE), &pgoff)) - return; - dax_flush(dax_dev, pgoff, addr, size); -} - /* * Stripe status: * diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index c0d7e60820c4..3d4130e2e1e9 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -5,6 +5,7 @@ */ #include "dm-core.h" +#include "dm-dax.h" #include <linux/module.h> #include <linux/init.h> @@ -142,12 +143,6 @@ static void io_err_release_clone_rq(struct request *clone) { } -static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - return -EIO; -} - static struct target_type error_target = { .name = "error", .version = {1, 5, 0}, diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2edbcc2d7d3f..73aca9ce5581 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -8,6 +8,7 @@ #include "dm-core.h" #include "dm-rq.h" #include "dm-uevent.h" +#include "dm-dax.h" #include <linux/init.h> #include <linux/module.h> @@ -16,7 +17,6 @@ #include <linux/blkpg.h> #include <linux/bio.h> #include <linux/mempool.h> -#include <linux/dax.h> #include <linux/slab.h> #include <linux/idr.h> #include <linux/uio.h> @@ -634,7 +634,7 @@ static int open_table_device(struct table_device *td, dev_t dev, } td->dm_dev.bdev = bdev; - td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); + td->dm_dev.dax_dev = dm_dax_get_by_host(bdev->bd_disk->disk_name); return 0; } @@ -648,7 +648,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); - put_dax(td->dm_dev.dax_dev); + dm_put_dax(td->dm_dev.dax_dev); td->dm_dev.bdev = NULL; td->dm_dev.dax_dev = NULL; } @@ -890,7 +890,7 @@ static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti return ti->len - target_offset; } -static sector_t max_io_len(sector_t sector, struct dm_target *ti) +sector_t max_io_len(sector_t sector, struct dm_target *ti) { sector_t len = max_io_len_target_boundary(sector, ti); sector_t offset, max_len; @@ -928,93 +928,6 @@ int dm_set_target_max_io_len(struct dm_target *ti, sector_t len) } EXPORT_SYMBOL_GPL(dm_set_target_max_io_len); -static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, - sector_t sector, int *srcu_idx) -{ - struct dm_table *map; - struct dm_target *ti; - - map = dm_get_live_table(md, srcu_idx); - if (!map) - return NULL; - - ti = dm_table_find_target(map, sector); - if (!dm_target_is_valid(ti)) - return NULL; - - return ti; -} - -static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - long len, ret = -EIO; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (!ti->type->direct_access) - goto out; - len = max_io_len(sector, ti) / PAGE_SECTORS; - if (len < 1) - goto out; - nr_pages = min(len, nr_pages); - if (ti->type->direct_access) - ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); - - out: - dm_put_live_table(md, srcu_idx); - - return ret; -} - -static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - long ret = 0; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (!ti->type->dax_copy_from_iter) { - ret = copy_from_iter(addr, bytes, i); - goto out; - } - ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); - out: - dm_put_live_table(md, srcu_idx); - - return ret; -} - -static void dm_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t size) -{ - struct mapped_device *md = dax_get_private(dax_dev); - sector_t sector = pgoff * PAGE_SECTORS; - struct dm_target *ti; - int srcu_idx; - - ti = dm_dax_get_live_target(md, sector, &srcu_idx); - - if (!ti) - goto out; - if (ti->type->dax_flush) - ti->type->dax_flush(ti, pgoff, addr, size); - out: - dm_put_live_table(md, srcu_idx); -} - /* * A target may call dm_accept_partial_bio only from the map routine. It is * allowed for all bio types except REQ_PREFLUSH. @@ -1681,8 +1594,8 @@ static void cleanup_mapped_device(struct mapped_device *md) bioset_free(md->bs); if (md->dax_dev) { - kill_dax(md->dax_dev); - put_dax(md->dax_dev); + dm_kill_dax(md->dax_dev); + dm_put_dax(md->dax_dev); md->dax_dev = NULL; } @@ -1779,8 +1692,8 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); - if (!dax_dev) + dax_dev = dm_alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev && IS_ENABLED(CONFIG_DM_DAX)) goto bad; md->dax_dev = dax_dev; @@ -2999,7 +2912,7 @@ static const struct block_device_operations dm_blk_dops = { .owner = THIS_MODULE }; -static const struct dax_operations dm_dax_ops = { +static const __maybe_unused struct dax_operations dm_dax_ops = { .direct_access = dm_dax_direct_access, .copy_from_iter = dm_dax_copy_from_iter, .flush = dm_dax_flush, diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 38c84c0a35d4..2c9d94ec2391 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -174,6 +174,40 @@ int dm_stripe_init(void); void dm_stripe_exit(void); /* + * Linear: maps a linear range of a device. + */ +struct linear_c { + struct dm_dev *dev; + sector_t start; +}; + +struct stripe { + struct dm_dev *dev; + sector_t physical_start; + + atomic_t error_count; +}; + +struct stripe_c { + uint32_t stripes; + int stripes_shift; + + /* The size of this target / num. stripes */ + sector_t stripe_width; + + uint32_t chunk_size; + int chunk_size_shift; + + /* Needed for handling events */ + struct dm_target *ti; + + /* Work struct used for triggering events*/ + struct work_struct trigger_event; + + struct stripe stripe[0]; +}; + +/* * mapped_device operations */ void dm_destroy(struct mapped_device *md); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 31+ messages in thread
[parent not found: <150161113411.34055.9762658795237184307.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: dm: enable opt-out of device-mapper dax support 2017-08-01 18:12 ` Dan Williams (?) @ 2017-08-01 19:02 ` Mike Snitzer -1 siblings, 0 replies; 31+ messages in thread From: Mike Snitzer @ 2017-08-01 19:02 UTC (permalink / raw) To: Dan Williams Cc: Bart Van Assche, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Alasdair Kergon, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw On Tue, Aug 01 2017 at 2:12pm -0400, Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote: > Now that dax is no longer a default property of a block-device, i.e. > ->direct_access() is not a block-device operation, we optionally enable > device-mapper dax support with a new CONFIG_DM_DAX option. > > All the dax operations helpers are moved to a new file, > drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. > Otherwise, we stub out all the operations with NULL function pointers > and nop wrappers for the core dax routines. > > Cc: Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > Cc: Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > Reported-by: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org> > Signed-off-by: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > drivers/md/Kconfig | 14 +++ > drivers/md/Makefile | 1 > drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/md/dm-dax.h | 73 +++++++++++++++ > drivers/md/dm-linear.c | 56 ------------ > drivers/md/dm-snap.c | 9 -- > drivers/md/dm-stripe.c | 89 ------------------- > drivers/md/dm-target.c | 7 - > drivers/md/dm.c | 105 ++-------------------- > drivers/md/dm.h | 34 +++++++ > 10 files changed, 363 insertions(+), 252 deletions(-) > create mode 100644 drivers/md/dm-dax.c > create mode 100644 drivers/md/dm-dax.h > > diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig > index 4a249ee86364..bf27b435f7cd 100644 > --- a/drivers/md/Kconfig > +++ b/drivers/md/Kconfig > @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN > config BLK_DEV_DM > tristate "Device mapper support" > select BLK_DEV_DM_BUILTIN > - select DAX > ---help--- > Device-mapper is a low level volume manager. It works by allowing > people to specify mappings for ranges of logical sectors. Various > @@ -214,6 +213,19 @@ config BLK_DEV_DM > > If unsure, say N. > > +config DM_DAX > + bool "Direct access (DAX) support" > + depends on BLK_DEV_DM > + default BLK_DEV_PMEM > + select DAX > + ---help--- > + Enable DAX support for the device-mapper linear and stripe > + targets for use with DAX capable block devices like /dev/pmemN. > + If you have a DAX capable block device and have enabled > + filesystem DAX support (CONFIG_FS_DAX), then say Y. > + > + If unsure, say N. > + I'm questioning the need to have yet another Kbuild CONFIG option. If the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just be enabled? Guess I'm just skeptical of: why do we want to move to a model where users need to opt-in to DM support for DAX? I also _really_ don't like each target's DAX support being colocated in drivers/md/dm-dax.c This all looks and feels like a serious step backwards. Mike ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 19:02 ` Mike Snitzer 0 siblings, 0 replies; 31+ messages in thread From: Mike Snitzer @ 2017-08-01 19:02 UTC (permalink / raw) To: Dan Williams Cc: Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm On Tue, Aug 01 2017 at 2:12pm -0400, Dan Williams <dan.j.williams@intel.com> wrote: > Now that dax is no longer a default property of a block-device, i.e. > ->direct_access() is not a block-device operation, we optionally enable > device-mapper dax support with a new CONFIG_DM_DAX option. > > All the dax operations helpers are moved to a new file, > drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. > Otherwise, we stub out all the operations with NULL function pointers > and nop wrappers for the core dax routines. > > Cc: Alasdair Kergon <agk@redhat.com> > Cc: Mike Snitzer <snitzer@redhat.com> > Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > drivers/md/Kconfig | 14 +++ > drivers/md/Makefile | 1 > drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/md/dm-dax.h | 73 +++++++++++++++ > drivers/md/dm-linear.c | 56 ------------ > drivers/md/dm-snap.c | 9 -- > drivers/md/dm-stripe.c | 89 ------------------- > drivers/md/dm-target.c | 7 - > drivers/md/dm.c | 105 ++-------------------- > drivers/md/dm.h | 34 +++++++ > 10 files changed, 363 insertions(+), 252 deletions(-) > create mode 100644 drivers/md/dm-dax.c > create mode 100644 drivers/md/dm-dax.h > > diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig > index 4a249ee86364..bf27b435f7cd 100644 > --- a/drivers/md/Kconfig > +++ b/drivers/md/Kconfig > @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN > config BLK_DEV_DM > tristate "Device mapper support" > select BLK_DEV_DM_BUILTIN > - select DAX > ---help--- > Device-mapper is a low level volume manager. It works by allowing > people to specify mappings for ranges of logical sectors. Various > @@ -214,6 +213,19 @@ config BLK_DEV_DM > > If unsure, say N. > > +config DM_DAX > + bool "Direct access (DAX) support" > + depends on BLK_DEV_DM > + default BLK_DEV_PMEM > + select DAX > + ---help--- > + Enable DAX support for the device-mapper linear and stripe > + targets for use with DAX capable block devices like /dev/pmemN. > + If you have a DAX capable block device and have enabled > + filesystem DAX support (CONFIG_FS_DAX), then say Y. > + > + If unsure, say N. > + I'm questioning the need to have yet another Kbuild CONFIG option. If the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just be enabled? Guess I'm just skeptical of: why do we want to move to a model where users need to opt-in to DM support for DAX? I also _really_ don't like each target's DAX support being colocated in drivers/md/dm-dax.c This all looks and feels like a serious step backwards. Mike ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 19:02 ` Mike Snitzer 0 siblings, 0 replies; 31+ messages in thread From: Mike Snitzer @ 2017-08-01 19:02 UTC (permalink / raw) To: Dan Williams Cc: Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm On Tue, Aug 01 2017 at 2:12pm -0400, Dan Williams <dan.j.williams@intel.com> wrote: > Now that dax is no longer a default property of a block-device, i.e. > ->direct_access() is not a block-device operation, we optionally enable > device-mapper dax support with a new CONFIG_DM_DAX option. > > All the dax operations helpers are moved to a new file, > drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. > Otherwise, we stub out all the operations with NULL function pointers > and nop wrappers for the core dax routines. > > Cc: Alasdair Kergon <agk@redhat.com> > Cc: Mike Snitzer <snitzer@redhat.com> > Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > drivers/md/Kconfig | 14 +++ > drivers/md/Makefile | 1 > drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/md/dm-dax.h | 73 +++++++++++++++ > drivers/md/dm-linear.c | 56 ------------ > drivers/md/dm-snap.c | 9 -- > drivers/md/dm-stripe.c | 89 ------------------- > drivers/md/dm-target.c | 7 - > drivers/md/dm.c | 105 ++-------------------- > drivers/md/dm.h | 34 +++++++ > 10 files changed, 363 insertions(+), 252 deletions(-) > create mode 100644 drivers/md/dm-dax.c > create mode 100644 drivers/md/dm-dax.h > > diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig > index 4a249ee86364..bf27b435f7cd 100644 > --- a/drivers/md/Kconfig > +++ b/drivers/md/Kconfig > @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN > config BLK_DEV_DM > tristate "Device mapper support" > select BLK_DEV_DM_BUILTIN > - select DAX > ---help--- > Device-mapper is a low level volume manager. It works by allowing > people to specify mappings for ranges of logical sectors. Various > @@ -214,6 +213,19 @@ config BLK_DEV_DM > > If unsure, say N. > > +config DM_DAX > + bool "Direct access (DAX) support" > + depends on BLK_DEV_DM > + default BLK_DEV_PMEM > + select DAX > + ---help--- > + Enable DAX support for the device-mapper linear and stripe > + targets for use with DAX capable block devices like /dev/pmemN. > + If you have a DAX capable block device and have enabled > + filesystem DAX support (CONFIG_FS_DAX), then say Y. > + > + If unsure, say N. > + I'm questioning the need to have yet another Kbuild CONFIG option. If the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just be enabled? Guess I'm just skeptical of: why do we want to move to a model where users need to opt-in to DM support for DAX? I also _really_ don't like each target's DAX support being colocated in drivers/md/dm-dax.c This all looks and feels like a serious step backwards. Mike _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
[parent not found: <20170801190257.GA10033-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: dm: enable opt-out of device-mapper dax support 2017-08-01 19:02 ` Mike Snitzer (?) @ 2017-08-01 19:45 ` Dan Williams -1 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 19:45 UTC (permalink / raw) To: Mike Snitzer Cc: Bart Van Assche, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Alasdair Kergon, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > On Tue, Aug 01 2017 at 2:12pm -0400, > Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote: > >> Now that dax is no longer a default property of a block-device, i.e. >> ->direct_access() is not a block-device operation, we optionally enable >> device-mapper dax support with a new CONFIG_DM_DAX option. >> >> All the dax operations helpers are moved to a new file, >> drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. >> Otherwise, we stub out all the operations with NULL function pointers >> and nop wrappers for the core dax routines. >> >> Cc: Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> Cc: Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >> Reported-by: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org> >> Signed-off-by: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> >> --- >> drivers/md/Kconfig | 14 +++ >> drivers/md/Makefile | 1 >> drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ >> drivers/md/dm-dax.h | 73 +++++++++++++++ >> drivers/md/dm-linear.c | 56 ------------ >> drivers/md/dm-snap.c | 9 -- >> drivers/md/dm-stripe.c | 89 ------------------- >> drivers/md/dm-target.c | 7 - >> drivers/md/dm.c | 105 ++-------------------- >> drivers/md/dm.h | 34 +++++++ >> 10 files changed, 363 insertions(+), 252 deletions(-) >> create mode 100644 drivers/md/dm-dax.c >> create mode 100644 drivers/md/dm-dax.h >> >> diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig >> index 4a249ee86364..bf27b435f7cd 100644 >> --- a/drivers/md/Kconfig >> +++ b/drivers/md/Kconfig >> @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN >> config BLK_DEV_DM >> tristate "Device mapper support" >> select BLK_DEV_DM_BUILTIN >> - select DAX >> ---help--- >> Device-mapper is a low level volume manager. It works by allowing >> people to specify mappings for ranges of logical sectors. Various >> @@ -214,6 +213,19 @@ config BLK_DEV_DM >> >> If unsure, say N. >> >> +config DM_DAX >> + bool "Direct access (DAX) support" >> + depends on BLK_DEV_DM >> + default BLK_DEV_PMEM >> + select DAX >> + ---help--- >> + Enable DAX support for the device-mapper linear and stripe >> + targets for use with DAX capable block devices like /dev/pmemN. >> + If you have a DAX capable block device and have enabled >> + filesystem DAX support (CONFIG_FS_DAX), then say Y. >> + >> + If unsure, say N. >> + > > I'm questioning the need to have yet another Kbuild CONFIG option. If > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just > be enabled? > > Guess I'm just skeptical of: why do we want to move to a model where > users need to opt-in to DM support for DAX? > > I also _really_ don't like each target's DAX support being colocated in > drivers/md/dm-dax.c > > This all looks and feels like a serious step backwards. Ok, you want ifdef'd sections of DAX code in each target and make DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything else? ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 19:45 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 19:45 UTC (permalink / raw) To: Mike Snitzer Cc: Bart Van Assche, dm-devel, linux-kernel@vger.kernel.org, Alasdair Kergon, linux-nvdimm@lists.01.org On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: > On Tue, Aug 01 2017 at 2:12pm -0400, > Dan Williams <dan.j.williams@intel.com> wrote: > >> Now that dax is no longer a default property of a block-device, i.e. >> ->direct_access() is not a block-device operation, we optionally enable >> device-mapper dax support with a new CONFIG_DM_DAX option. >> >> All the dax operations helpers are moved to a new file, >> drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. >> Otherwise, we stub out all the operations with NULL function pointers >> and nop wrappers for the core dax routines. >> >> Cc: Alasdair Kergon <agk@redhat.com> >> Cc: Mike Snitzer <snitzer@redhat.com> >> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> >> Signed-off-by: Dan Williams <dan.j.williams@intel.com> >> --- >> drivers/md/Kconfig | 14 +++ >> drivers/md/Makefile | 1 >> drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ >> drivers/md/dm-dax.h | 73 +++++++++++++++ >> drivers/md/dm-linear.c | 56 ------------ >> drivers/md/dm-snap.c | 9 -- >> drivers/md/dm-stripe.c | 89 ------------------- >> drivers/md/dm-target.c | 7 - >> drivers/md/dm.c | 105 ++-------------------- >> drivers/md/dm.h | 34 +++++++ >> 10 files changed, 363 insertions(+), 252 deletions(-) >> create mode 100644 drivers/md/dm-dax.c >> create mode 100644 drivers/md/dm-dax.h >> >> diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig >> index 4a249ee86364..bf27b435f7cd 100644 >> --- a/drivers/md/Kconfig >> +++ b/drivers/md/Kconfig >> @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN >> config BLK_DEV_DM >> tristate "Device mapper support" >> select BLK_DEV_DM_BUILTIN >> - select DAX >> ---help--- >> Device-mapper is a low level volume manager. It works by allowing >> people to specify mappings for ranges of logical sectors. Various >> @@ -214,6 +213,19 @@ config BLK_DEV_DM >> >> If unsure, say N. >> >> +config DM_DAX >> + bool "Direct access (DAX) support" >> + depends on BLK_DEV_DM >> + default BLK_DEV_PMEM >> + select DAX >> + ---help--- >> + Enable DAX support for the device-mapper linear and stripe >> + targets for use with DAX capable block devices like /dev/pmemN. >> + If you have a DAX capable block device and have enabled >> + filesystem DAX support (CONFIG_FS_DAX), then say Y. >> + >> + If unsure, say N. >> + > > I'm questioning the need to have yet another Kbuild CONFIG option. If > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just > be enabled? > > Guess I'm just skeptical of: why do we want to move to a model where > users need to opt-in to DM support for DAX? > > I also _really_ don't like each target's DAX support being colocated in > drivers/md/dm-dax.c > > This all looks and feels like a serious step backwards. Ok, you want ifdef'd sections of DAX code in each target and make DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything else? ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 19:45 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 19:45 UTC (permalink / raw) To: Mike Snitzer Cc: Bart Van Assche, dm-devel, linux-kernel@vger.kernel.org, Alasdair Kergon, linux-nvdimm@lists.01.org On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: > On Tue, Aug 01 2017 at 2:12pm -0400, > Dan Williams <dan.j.williams@intel.com> wrote: > >> Now that dax is no longer a default property of a block-device, i.e. >> ->direct_access() is not a block-device operation, we optionally enable >> device-mapper dax support with a new CONFIG_DM_DAX option. >> >> All the dax operations helpers are moved to a new file, >> drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. >> Otherwise, we stub out all the operations with NULL function pointers >> and nop wrappers for the core dax routines. >> >> Cc: Alasdair Kergon <agk@redhat.com> >> Cc: Mike Snitzer <snitzer@redhat.com> >> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> >> Signed-off-by: Dan Williams <dan.j.williams@intel.com> >> --- >> drivers/md/Kconfig | 14 +++ >> drivers/md/Makefile | 1 >> drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ >> drivers/md/dm-dax.h | 73 +++++++++++++++ >> drivers/md/dm-linear.c | 56 ------------ >> drivers/md/dm-snap.c | 9 -- >> drivers/md/dm-stripe.c | 89 ------------------- >> drivers/md/dm-target.c | 7 - >> drivers/md/dm.c | 105 ++-------------------- >> drivers/md/dm.h | 34 +++++++ >> 10 files changed, 363 insertions(+), 252 deletions(-) >> create mode 100644 drivers/md/dm-dax.c >> create mode 100644 drivers/md/dm-dax.h >> >> diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig >> index 4a249ee86364..bf27b435f7cd 100644 >> --- a/drivers/md/Kconfig >> +++ b/drivers/md/Kconfig >> @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN >> config BLK_DEV_DM >> tristate "Device mapper support" >> select BLK_DEV_DM_BUILTIN >> - select DAX >> ---help--- >> Device-mapper is a low level volume manager. It works by allowing >> people to specify mappings for ranges of logical sectors. Various >> @@ -214,6 +213,19 @@ config BLK_DEV_DM >> >> If unsure, say N. >> >> +config DM_DAX >> + bool "Direct access (DAX) support" >> + depends on BLK_DEV_DM >> + default BLK_DEV_PMEM >> + select DAX >> + ---help--- >> + Enable DAX support for the device-mapper linear and stripe >> + targets for use with DAX capable block devices like /dev/pmemN. >> + If you have a DAX capable block device and have enabled >> + filesystem DAX support (CONFIG_FS_DAX), then say Y. >> + >> + If unsure, say N. >> + > > I'm questioning the need to have yet another Kbuild CONFIG option. If > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just > be enabled? > > Guess I'm just skeptical of: why do we want to move to a model where > users need to opt-in to DM support for DAX? > > I also _really_ don't like each target's DAX support being colocated in > drivers/md/dm-dax.c > > This all looks and feels like a serious step backwards. Ok, you want ifdef'd sections of DAX code in each target and make DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything else? _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
[parent not found: <CAPcyv4jxTQhHANEBmObwhvWW7JHnSmHfCqv3JL3xEm0YFamvrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: dm: enable opt-out of device-mapper dax support 2017-08-01 19:45 ` Dan Williams (?) @ 2017-08-01 20:59 ` Dan Williams -1 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 20:59 UTC (permalink / raw) To: Mike Snitzer Cc: Bart Van Assche, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Alasdair Kergon, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote: > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: >> On Tue, Aug 01 2017 at 2:12pm -0400, >> Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote: >> >>> Now that dax is no longer a default property of a block-device, i.e. >>> ->direct_access() is not a block-device operation, we optionally enable >>> device-mapper dax support with a new CONFIG_DM_DAX option. >>> >>> All the dax operations helpers are moved to a new file, >>> drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. >>> Otherwise, we stub out all the operations with NULL function pointers >>> and nop wrappers for the core dax routines. >>> >>> Cc: Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >>> Cc: Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> >>> Reported-by: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org> >>> Signed-off-by: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> >>> --- >>> drivers/md/Kconfig | 14 +++ >>> drivers/md/Makefile | 1 >>> drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ >>> drivers/md/dm-dax.h | 73 +++++++++++++++ >>> drivers/md/dm-linear.c | 56 ------------ >>> drivers/md/dm-snap.c | 9 -- >>> drivers/md/dm-stripe.c | 89 ------------------- >>> drivers/md/dm-target.c | 7 - >>> drivers/md/dm.c | 105 ++-------------------- >>> drivers/md/dm.h | 34 +++++++ >>> 10 files changed, 363 insertions(+), 252 deletions(-) >>> create mode 100644 drivers/md/dm-dax.c >>> create mode 100644 drivers/md/dm-dax.h >>> >>> diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig >>> index 4a249ee86364..bf27b435f7cd 100644 >>> --- a/drivers/md/Kconfig >>> +++ b/drivers/md/Kconfig >>> @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN >>> config BLK_DEV_DM >>> tristate "Device mapper support" >>> select BLK_DEV_DM_BUILTIN >>> - select DAX >>> ---help--- >>> Device-mapper is a low level volume manager. It works by allowing >>> people to specify mappings for ranges of logical sectors. Various >>> @@ -214,6 +213,19 @@ config BLK_DEV_DM >>> >>> If unsure, say N. >>> >>> +config DM_DAX >>> + bool "Direct access (DAX) support" >>> + depends on BLK_DEV_DM >>> + default BLK_DEV_PMEM >>> + select DAX >>> + ---help--- >>> + Enable DAX support for the device-mapper linear and stripe >>> + targets for use with DAX capable block devices like /dev/pmemN. >>> + If you have a DAX capable block device and have enabled >>> + filesystem DAX support (CONFIG_FS_DAX), then say Y. >>> + >>> + If unsure, say N. >>> + >> >> I'm questioning the need to have yet another Kbuild CONFIG option. If >> the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already >> gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just >> be enabled? >> >> Guess I'm just skeptical of: why do we want to move to a model where >> users need to opt-in to DM support for DAX? >> >> I also _really_ don't like each target's DAX support being colocated in >> drivers/md/dm-dax.c >> >> This all looks and feels like a serious step backwards. > > Ok, you want ifdef'd sections of DAX code in each target and make > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything > else? Actually, no, I was thrown off by Bart's suggestion to move code around. I can handle this all by deleting "select DAX" and adding more stubbed out dax helpers. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 20:59 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 20:59 UTC (permalink / raw) To: Mike Snitzer Cc: Bart Van Assche, dm-devel, linux-kernel@vger.kernel.org, Alasdair Kergon, linux-nvdimm@lists.01.org On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams@intel.com> wrote: > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: >> On Tue, Aug 01 2017 at 2:12pm -0400, >> Dan Williams <dan.j.williams@intel.com> wrote: >> >>> Now that dax is no longer a default property of a block-device, i.e. >>> ->direct_access() is not a block-device operation, we optionally enable >>> device-mapper dax support with a new CONFIG_DM_DAX option. >>> >>> All the dax operations helpers are moved to a new file, >>> drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. >>> Otherwise, we stub out all the operations with NULL function pointers >>> and nop wrappers for the core dax routines. >>> >>> Cc: Alasdair Kergon <agk@redhat.com> >>> Cc: Mike Snitzer <snitzer@redhat.com> >>> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> >>> Signed-off-by: Dan Williams <dan.j.williams@intel.com> >>> --- >>> drivers/md/Kconfig | 14 +++ >>> drivers/md/Makefile | 1 >>> drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ >>> drivers/md/dm-dax.h | 73 +++++++++++++++ >>> drivers/md/dm-linear.c | 56 ------------ >>> drivers/md/dm-snap.c | 9 -- >>> drivers/md/dm-stripe.c | 89 ------------------- >>> drivers/md/dm-target.c | 7 - >>> drivers/md/dm.c | 105 ++-------------------- >>> drivers/md/dm.h | 34 +++++++ >>> 10 files changed, 363 insertions(+), 252 deletions(-) >>> create mode 100644 drivers/md/dm-dax.c >>> create mode 100644 drivers/md/dm-dax.h >>> >>> diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig >>> index 4a249ee86364..bf27b435f7cd 100644 >>> --- a/drivers/md/Kconfig >>> +++ b/drivers/md/Kconfig >>> @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN >>> config BLK_DEV_DM >>> tristate "Device mapper support" >>> select BLK_DEV_DM_BUILTIN >>> - select DAX >>> ---help--- >>> Device-mapper is a low level volume manager. It works by allowing >>> people to specify mappings for ranges of logical sectors. Various >>> @@ -214,6 +213,19 @@ config BLK_DEV_DM >>> >>> If unsure, say N. >>> >>> +config DM_DAX >>> + bool "Direct access (DAX) support" >>> + depends on BLK_DEV_DM >>> + default BLK_DEV_PMEM >>> + select DAX >>> + ---help--- >>> + Enable DAX support for the device-mapper linear and stripe >>> + targets for use with DAX capable block devices like /dev/pmemN. >>> + If you have a DAX capable block device and have enabled >>> + filesystem DAX support (CONFIG_FS_DAX), then say Y. >>> + >>> + If unsure, say N. >>> + >> >> I'm questioning the need to have yet another Kbuild CONFIG option. If >> the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already >> gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just >> be enabled? >> >> Guess I'm just skeptical of: why do we want to move to a model where >> users need to opt-in to DM support for DAX? >> >> I also _really_ don't like each target's DAX support being colocated in >> drivers/md/dm-dax.c >> >> This all looks and feels like a serious step backwards. > > Ok, you want ifdef'd sections of DAX code in each target and make > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything > else? Actually, no, I was thrown off by Bart's suggestion to move code around. I can handle this all by deleting "select DAX" and adding more stubbed out dax helpers. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 20:59 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 20:59 UTC (permalink / raw) To: Mike Snitzer Cc: Bart Van Assche, dm-devel, linux-kernel@vger.kernel.org, Alasdair Kergon, linux-nvdimm@lists.01.org On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams@intel.com> wrote: > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: >> On Tue, Aug 01 2017 at 2:12pm -0400, >> Dan Williams <dan.j.williams@intel.com> wrote: >> >>> Now that dax is no longer a default property of a block-device, i.e. >>> ->direct_access() is not a block-device operation, we optionally enable >>> device-mapper dax support with a new CONFIG_DM_DAX option. >>> >>> All the dax operations helpers are moved to a new file, >>> drivers/md/dm-dax.c, that is optionally compiled when CONFIG_DM_DAX=y. >>> Otherwise, we stub out all the operations with NULL function pointers >>> and nop wrappers for the core dax routines. >>> >>> Cc: Alasdair Kergon <agk@redhat.com> >>> Cc: Mike Snitzer <snitzer@redhat.com> >>> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> >>> Signed-off-by: Dan Williams <dan.j.williams@intel.com> >>> --- >>> drivers/md/Kconfig | 14 +++ >>> drivers/md/Makefile | 1 >>> drivers/md/dm-dax.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ >>> drivers/md/dm-dax.h | 73 +++++++++++++++ >>> drivers/md/dm-linear.c | 56 ------------ >>> drivers/md/dm-snap.c | 9 -- >>> drivers/md/dm-stripe.c | 89 ------------------- >>> drivers/md/dm-target.c | 7 - >>> drivers/md/dm.c | 105 ++-------------------- >>> drivers/md/dm.h | 34 +++++++ >>> 10 files changed, 363 insertions(+), 252 deletions(-) >>> create mode 100644 drivers/md/dm-dax.c >>> create mode 100644 drivers/md/dm-dax.h >>> >>> diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig >>> index 4a249ee86364..bf27b435f7cd 100644 >>> --- a/drivers/md/Kconfig >>> +++ b/drivers/md/Kconfig >>> @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN >>> config BLK_DEV_DM >>> tristate "Device mapper support" >>> select BLK_DEV_DM_BUILTIN >>> - select DAX >>> ---help--- >>> Device-mapper is a low level volume manager. It works by allowing >>> people to specify mappings for ranges of logical sectors. Various >>> @@ -214,6 +213,19 @@ config BLK_DEV_DM >>> >>> If unsure, say N. >>> >>> +config DM_DAX >>> + bool "Direct access (DAX) support" >>> + depends on BLK_DEV_DM >>> + default BLK_DEV_PMEM >>> + select DAX >>> + ---help--- >>> + Enable DAX support for the device-mapper linear and stripe >>> + targets for use with DAX capable block devices like /dev/pmemN. >>> + If you have a DAX capable block device and have enabled >>> + filesystem DAX support (CONFIG_FS_DAX), then say Y. >>> + >>> + If unsure, say N. >>> + >> >> I'm questioning the need to have yet another Kbuild CONFIG option. If >> the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already >> gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just >> be enabled? >> >> Guess I'm just skeptical of: why do we want to move to a model where >> users need to opt-in to DM support for DAX? >> >> I also _really_ don't like each target's DAX support being colocated in >> drivers/md/dm-dax.c >> >> This all looks and feels like a serious step backwards. > > Ok, you want ifdef'd sections of DAX code in each target and make > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything > else? Actually, no, I was thrown off by Bart's suggestion to move code around. I can handle this all by deleting "select DAX" and adding more stubbed out dax helpers. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
[parent not found: <CAPcyv4hLP98cap0cgWWw_FOeh9yzLJVSaZURntsB0t2D24nF9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: dm: enable opt-out of device-mapper dax support 2017-08-01 20:59 ` Dan Williams (?) @ 2017-08-01 21:04 ` Bart Van Assche -1 siblings, 0 replies; 31+ messages in thread From: Bart Van Assche @ 2017-08-01 21:04 UTC (permalink / raw) To: dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Cc: dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org On Tue, 2017-08-01 at 13:59 -0700, Dan Williams wrote: > On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote: > > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > > > On Tue, Aug 01 2017 at 2:12pm -0400, > > > Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote: > > > > [ ... ] > > > > > > I'm questioning the need to have yet another Kbuild CONFIG option. If > > > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already > > > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just > > > be enabled? > > > > > > Guess I'm just skeptical of: why do we want to move to a model where > > > users need to opt-in to DM support for DAX? > > > > > > I also _really_ don't like each target's DAX support being colocated in > > > drivers/md/dm-dax.c > > > > > > This all looks and feels like a serious step backwards. > > > > Ok, you want ifdef'd sections of DAX code in each target and make > > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything > > else? > > Actually, no, I was thrown off by Bart's suggestion to move code > around. I can handle this all by deleting "select DAX" and adding more > stubbed out dax helpers. Hello Mike and Dan, How about one *-dax.c file per *.c dm file that has to be modified to add DAX support? I think that approach would avoid collocation of code for different targets in a single dm-dax.c file and would also avoid that #ifdef CONFIG_DAX statements have to be added. This approach is orthogonal to removal of CONFIG_DM_DAX. Thanks, Bart. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 21:04 ` Bart Van Assche 0 siblings, 0 replies; 31+ messages in thread From: Bart Van Assche @ 2017-08-01 21:04 UTC (permalink / raw) To: dan.j.williams@intel.com, snitzer@redhat.com Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, agk@redhat.com On Tue, 2017-08-01 at 13:59 -0700, Dan Williams wrote: > On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams@intel.com> wrote: > > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: > > > On Tue, Aug 01 2017 at 2:12pm -0400, > > > Dan Williams <dan.j.williams@intel.com> wrote: > > > > [ ... ] > > > > > > I'm questioning the need to have yet another Kbuild CONFIG option. If > > > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already > > > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just > > > be enabled? > > > > > > Guess I'm just skeptical of: why do we want to move to a model where > > > users need to opt-in to DM support for DAX? > > > > > > I also _really_ don't like each target's DAX support being colocated in > > > drivers/md/dm-dax.c > > > > > > This all looks and feels like a serious step backwards. > > > > Ok, you want ifdef'd sections of DAX code in each target and make > > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything > > else? > > Actually, no, I was thrown off by Bart's suggestion to move code > around. I can handle this all by deleting "select DAX" and adding more > stubbed out dax helpers. Hello Mike and Dan, How about one *-dax.c file per *.c dm file that has to be modified to add DAX support? I think that approach would avoid collocation of code for different targets in a single dm-dax.c file and would also avoid that #ifdef CONFIG_DAX statements have to be added. This approach is orthogonal to removal of CONFIG_DM_DAX. Thanks, Bart. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 21:04 ` Bart Van Assche 0 siblings, 0 replies; 31+ messages in thread From: Bart Van Assche @ 2017-08-01 21:04 UTC (permalink / raw) To: dan.j.williams@intel.com, snitzer@redhat.com Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, agk@redhat.com, linux-nvdimm@lists.01.org On Tue, 2017-08-01 at 13:59 -0700, Dan Williams wrote: > On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams@intel.com> wrote: > > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: > > > On Tue, Aug 01 2017 at 2:12pm -0400, > > > Dan Williams <dan.j.williams@intel.com> wrote: > > > > [ ... ] > > > > > > I'm questioning the need to have yet another Kbuild CONFIG option. If > > > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already > > > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just > > > be enabled? > > > > > > Guess I'm just skeptical of: why do we want to move to a model where > > > users need to opt-in to DM support for DAX? > > > > > > I also _really_ don't like each target's DAX support being colocated in > > > drivers/md/dm-dax.c > > > > > > This all looks and feels like a serious step backwards. > > > > Ok, you want ifdef'd sections of DAX code in each target and make > > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything > > else? > > Actually, no, I was thrown off by Bart's suggestion to move code > around. I can handle this all by deleting "select DAX" and adding more > stubbed out dax helpers. Hello Mike and Dan, How about one *-dax.c file per *.c dm file that has to be modified to add DAX support? I think that approach would avoid collocation of code for different targets in a single dm-dax.c file and would also avoid that #ifdef CONFIG_DAX statements have to be added. This approach is orthogonal to removal of CONFIG_DM_DAX. Thanks, Bart. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support 2017-08-01 21:04 ` Bart Van Assche @ 2017-08-01 21:19 ` Dan Williams -1 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 21:19 UTC (permalink / raw) To: Bart Van Assche Cc: snitzer@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, agk@redhat.com On Tue, Aug 1, 2017 at 2:04 PM, Bart Van Assche <Bart.VanAssche@wdc.com> wrote: > On Tue, 2017-08-01 at 13:59 -0700, Dan Williams wrote: >> On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams@intel.com> wrote: >> > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: >> > > On Tue, Aug 01 2017 at 2:12pm -0400, >> > > Dan Williams <dan.j.williams@intel.com> wrote: >> > > > [ ... ] >> > > >> > > I'm questioning the need to have yet another Kbuild CONFIG option. If >> > > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already >> > > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just >> > > be enabled? >> > > >> > > Guess I'm just skeptical of: why do we want to move to a model where >> > > users need to opt-in to DM support for DAX? >> > > >> > > I also _really_ don't like each target's DAX support being colocated in >> > > drivers/md/dm-dax.c >> > > >> > > This all looks and feels like a serious step backwards. >> > >> > Ok, you want ifdef'd sections of DAX code in each target and make >> > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything >> > else? >> >> Actually, no, I was thrown off by Bart's suggestion to move code >> around. I can handle this all by deleting "select DAX" and adding more >> stubbed out dax helpers. > > Hello Mike and Dan, > > How about one *-dax.c file per *.c dm file that has to be modified to add DAX support? > I think that approach would avoid collocation of code for different targets in a > single dm-dax.c file and would also avoid that #ifdef CONFIG_DAX statements have to > be added. This approach is orthogonal to removal of CONFIG_DM_DAX. You're free to send an alternative approach, but the new ifdefs in include/linux/dax.h seem to be the cleanest option to remove dax text size when the device-mapper dax support is not needed. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: dm: enable opt-out of device-mapper dax support @ 2017-08-01 21:19 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 21:19 UTC (permalink / raw) To: Bart Van Assche Cc: dm-devel@redhat.com, agk@redhat.com, linux-kernel@vger.kernel.org, snitzer@redhat.com, linux-nvdimm@lists.01.org On Tue, Aug 1, 2017 at 2:04 PM, Bart Van Assche <Bart.VanAssche@wdc.com> wrote: > On Tue, 2017-08-01 at 13:59 -0700, Dan Williams wrote: >> On Tue, Aug 1, 2017 at 12:45 PM, Dan Williams <dan.j.williams@intel.com> wrote: >> > On Tue, Aug 1, 2017 at 12:02 PM, Mike Snitzer <snitzer@redhat.com> wrote: >> > > On Tue, Aug 01 2017 at 2:12pm -0400, >> > > Dan Williams <dan.j.williams@intel.com> wrote: >> > > > [ ... ] >> > > >> > > I'm questioning the need to have yet another Kbuild CONFIG option. If >> > > the user has enabled CONFIG_BLK_DEV_PMEM and CONFIG_FS_DAX (DAX already >> > > gets selected by CONFIG_FS_DAX) then shouldn't the DM capabilities just >> > > be enabled? >> > > >> > > Guess I'm just skeptical of: why do we want to move to a model where >> > > users need to opt-in to DM support for DAX? >> > > >> > > I also _really_ don't like each target's DAX support being colocated in >> > > drivers/md/dm-dax.c >> > > >> > > This all looks and feels like a serious step backwards. >> > >> > Ok, you want ifdef'd sections of DAX code in each target and make >> > DM_DAX a silent option that gets enabled with BLK_DEV_PMEM, anything >> > else? >> >> Actually, no, I was thrown off by Bart's suggestion to move code >> around. I can handle this all by deleting "select DAX" and adding more >> stubbed out dax helpers. > > Hello Mike and Dan, > > How about one *-dax.c file per *.c dm file that has to be modified to add DAX support? > I think that approach would avoid collocation of code for different targets in a > single dm-dax.c file and would also avoid that #ifdef CONFIG_DAX statements have to > be added. This approach is orthogonal to removal of CONFIG_DM_DAX. You're free to send an alternative approach, but the new ifdefs in include/linux/dax.h seem to be the cleanest option to remove dax text size when the device-mapper dax support is not needed. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2] dm: allow device-mapper to operate without dax support 2017-08-01 18:12 ` Dan Williams (?) @ 2017-08-01 22:47 ` Dan Williams -1 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 22:47 UTC (permalink / raw) To: snitzer-H+wXaHxf7aLQT0dZR+AlfA Cc: Bart Van Assche, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Alasdair Kergon, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw Rather than 'select dax', let the fact that BLK_DEV_PMEM selects dax act as a gate for the device-mapper dax support. Given that all the dax core routines compile to nops when CONFIG_DAX=n, we can simply handle the alloc_dax() error as expected and ifdef out the other dax support code. Cc: Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Reported-by: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org> Signed-off-by: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- drivers/md/Kconfig | 1 - drivers/md/dm-linear.c | 6 ++++++ drivers/md/dm-stripe.c | 6 ++++++ drivers/md/dm.c | 10 ++++++---- include/linux/dax.h | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..8ed48ff351cc 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN config BLK_DEV_DM tristate "Device mapper support" select BLK_DEV_DM_BUILTIN - select DAX ---help--- Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 41971a090e34..8804e278e834 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -154,6 +154,7 @@ static int linear_iterate_devices(struct dm_target *ti, return fn(ti, lc->dev, lc->start, ti->len, data); } +#if IS_ENABLED(CONFIG_DAX) static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { @@ -197,6 +198,11 @@ static void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, return; dax_flush(dax_dev, pgoff, addr, size); } +#else +#define linear_dax_direct_access NULL +#define linear_dax_copy_from_iter NULL +#define linear_dax_flush NULL +#endif static struct target_type linear_target = { .name = "linear", diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a0375530b07f..eeb6c784dc4f 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -311,6 +311,7 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } +#if IS_ENABLED(CONFIG_DAX) static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { @@ -369,6 +370,11 @@ static void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, return; dax_flush(dax_dev, pgoff, addr, size); } +#else +#define stripe_dax_direct_access NULL +#define stripe_dax_copy_from_iter NULL +#define stripe_dax_flush NULL +#endif /* * Stripe status: diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2edbcc2d7d3f..70fa48f4d3a3 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1713,7 +1713,7 @@ static void cleanup_mapped_device(struct mapped_device *md) static struct mapped_device *alloc_dev(int minor) { int r, numa_node_id = dm_get_numa_node(); - struct dax_device *dax_dev; + struct dax_device *dax_dev = NULL; struct mapped_device *md; void *old_md; @@ -1779,9 +1779,11 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); - if (!dax_dev) - goto bad; + if (IS_ENABLED(CONFIG_DAX)) { + dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev) + goto bad; + } md->dax_dev = dax_dev; add_disk(md->disk); diff --git a/include/linux/dax.h b/include/linux/dax.h index 794811875732..5d51c5ef678b 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -27,16 +27,30 @@ extern struct attribute_group dax_attribute_group; #if IS_ENABLED(CONFIG_DAX) struct dax_device *dax_get_by_host(const char *host); +struct dax_device *alloc_dax(void *private, const char *host, + const struct dax_operations *ops); void put_dax(struct dax_device *dax_dev); +void kill_dax(struct dax_device *dax_dev); #else static inline struct dax_device *dax_get_by_host(const char *host) { return NULL; } - +static inline struct dax_device *alloc_dax(void *private, const char *host, + const struct dax_operations *ops) +{ + /* + * Callers should check IS_ENABLED(CONFIG_DAX) to know if this + * NULL is an error or expected. + */ + return NULL; +} static inline void put_dax(struct dax_device *dax_dev) { } +static inline void kill_dax(struct dax_device *dax_dev) +{ +} #endif int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); @@ -75,10 +89,7 @@ static inline void fs_put_dax(struct dax_device *dax_dev) int dax_read_lock(void); void dax_read_unlock(int id); -struct dax_device *alloc_dax(void *private, const char *host, - const struct dax_operations *ops); bool dax_alive(struct dax_device *dax_dev); -void kill_dax(struct dax_device *dax_dev); void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn); ^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2] dm: allow device-mapper to operate without dax support @ 2017-08-01 22:47 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 22:47 UTC (permalink / raw) To: snitzer Cc: Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm Rather than 'select dax', let the fact that BLK_DEV_PMEM selects dax act as a gate for the device-mapper dax support. Given that all the dax core routines compile to nops when CONFIG_DAX=n, we can simply handle the alloc_dax() error as expected and ifdef out the other dax support code. Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/md/Kconfig | 1 - drivers/md/dm-linear.c | 6 ++++++ drivers/md/dm-stripe.c | 6 ++++++ drivers/md/dm.c | 10 ++++++---- include/linux/dax.h | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..8ed48ff351cc 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN config BLK_DEV_DM tristate "Device mapper support" select BLK_DEV_DM_BUILTIN - select DAX ---help--- Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 41971a090e34..8804e278e834 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -154,6 +154,7 @@ static int linear_iterate_devices(struct dm_target *ti, return fn(ti, lc->dev, lc->start, ti->len, data); } +#if IS_ENABLED(CONFIG_DAX) static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { @@ -197,6 +198,11 @@ static void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, return; dax_flush(dax_dev, pgoff, addr, size); } +#else +#define linear_dax_direct_access NULL +#define linear_dax_copy_from_iter NULL +#define linear_dax_flush NULL +#endif static struct target_type linear_target = { .name = "linear", diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a0375530b07f..eeb6c784dc4f 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -311,6 +311,7 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } +#if IS_ENABLED(CONFIG_DAX) static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { @@ -369,6 +370,11 @@ static void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, return; dax_flush(dax_dev, pgoff, addr, size); } +#else +#define stripe_dax_direct_access NULL +#define stripe_dax_copy_from_iter NULL +#define stripe_dax_flush NULL +#endif /* * Stripe status: diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2edbcc2d7d3f..70fa48f4d3a3 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1713,7 +1713,7 @@ static void cleanup_mapped_device(struct mapped_device *md) static struct mapped_device *alloc_dev(int minor) { int r, numa_node_id = dm_get_numa_node(); - struct dax_device *dax_dev; + struct dax_device *dax_dev = NULL; struct mapped_device *md; void *old_md; @@ -1779,9 +1779,11 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); - if (!dax_dev) - goto bad; + if (IS_ENABLED(CONFIG_DAX)) { + dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev) + goto bad; + } md->dax_dev = dax_dev; add_disk(md->disk); diff --git a/include/linux/dax.h b/include/linux/dax.h index 794811875732..5d51c5ef678b 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -27,16 +27,30 @@ extern struct attribute_group dax_attribute_group; #if IS_ENABLED(CONFIG_DAX) struct dax_device *dax_get_by_host(const char *host); +struct dax_device *alloc_dax(void *private, const char *host, + const struct dax_operations *ops); void put_dax(struct dax_device *dax_dev); +void kill_dax(struct dax_device *dax_dev); #else static inline struct dax_device *dax_get_by_host(const char *host) { return NULL; } - +static inline struct dax_device *alloc_dax(void *private, const char *host, + const struct dax_operations *ops) +{ + /* + * Callers should check IS_ENABLED(CONFIG_DAX) to know if this + * NULL is an error or expected. + */ + return NULL; +} static inline void put_dax(struct dax_device *dax_dev) { } +static inline void kill_dax(struct dax_device *dax_dev) +{ +} #endif int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); @@ -75,10 +89,7 @@ static inline void fs_put_dax(struct dax_device *dax_dev) int dax_read_lock(void); void dax_read_unlock(int id); -struct dax_device *alloc_dax(void *private, const char *host, - const struct dax_operations *ops); bool dax_alive(struct dax_device *dax_dev); -void kill_dax(struct dax_device *dax_dev); void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn); ^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2] dm: allow device-mapper to operate without dax support @ 2017-08-01 22:47 ` Dan Williams 0 siblings, 0 replies; 31+ messages in thread From: Dan Williams @ 2017-08-01 22:47 UTC (permalink / raw) To: snitzer Cc: Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm Rather than 'select dax', let the fact that BLK_DEV_PMEM selects dax act as a gate for the device-mapper dax support. Given that all the dax core routines compile to nops when CONFIG_DAX=n, we can simply handle the alloc_dax() error as expected and ifdef out the other dax support code. Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/md/Kconfig | 1 - drivers/md/dm-linear.c | 6 ++++++ drivers/md/dm-stripe.c | 6 ++++++ drivers/md/dm.c | 10 ++++++---- include/linux/dax.h | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..8ed48ff351cc 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -200,7 +200,6 @@ config BLK_DEV_DM_BUILTIN config BLK_DEV_DM tristate "Device mapper support" select BLK_DEV_DM_BUILTIN - select DAX ---help--- Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 41971a090e34..8804e278e834 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -154,6 +154,7 @@ static int linear_iterate_devices(struct dm_target *ti, return fn(ti, lc->dev, lc->start, ti->len, data); } +#if IS_ENABLED(CONFIG_DAX) static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { @@ -197,6 +198,11 @@ static void linear_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, return; dax_flush(dax_dev, pgoff, addr, size); } +#else +#define linear_dax_direct_access NULL +#define linear_dax_copy_from_iter NULL +#define linear_dax_flush NULL +#endif static struct target_type linear_target = { .name = "linear", diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a0375530b07f..eeb6c784dc4f 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -311,6 +311,7 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_REMAPPED; } +#if IS_ENABLED(CONFIG_DAX) static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { @@ -369,6 +370,11 @@ static void stripe_dax_flush(struct dm_target *ti, pgoff_t pgoff, void *addr, return; dax_flush(dax_dev, pgoff, addr, size); } +#else +#define stripe_dax_direct_access NULL +#define stripe_dax_copy_from_iter NULL +#define stripe_dax_flush NULL +#endif /* * Stripe status: diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2edbcc2d7d3f..70fa48f4d3a3 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1713,7 +1713,7 @@ static void cleanup_mapped_device(struct mapped_device *md) static struct mapped_device *alloc_dev(int minor) { int r, numa_node_id = dm_get_numa_node(); - struct dax_device *dax_dev; + struct dax_device *dax_dev = NULL; struct mapped_device *md; void *old_md; @@ -1779,9 +1779,11 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); - if (!dax_dev) - goto bad; + if (IS_ENABLED(CONFIG_DAX)) { + dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); + if (!dax_dev) + goto bad; + } md->dax_dev = dax_dev; add_disk(md->disk); diff --git a/include/linux/dax.h b/include/linux/dax.h index 794811875732..5d51c5ef678b 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -27,16 +27,30 @@ extern struct attribute_group dax_attribute_group; #if IS_ENABLED(CONFIG_DAX) struct dax_device *dax_get_by_host(const char *host); +struct dax_device *alloc_dax(void *private, const char *host, + const struct dax_operations *ops); void put_dax(struct dax_device *dax_dev); +void kill_dax(struct dax_device *dax_dev); #else static inline struct dax_device *dax_get_by_host(const char *host) { return NULL; } - +static inline struct dax_device *alloc_dax(void *private, const char *host, + const struct dax_operations *ops) +{ + /* + * Callers should check IS_ENABLED(CONFIG_DAX) to know if this + * NULL is an error or expected. + */ + return NULL; +} static inline void put_dax(struct dax_device *dax_dev) { } +static inline void kill_dax(struct dax_device *dax_dev) +{ +} #endif int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); @@ -75,10 +89,7 @@ static inline void fs_put_dax(struct dax_device *dax_dev) int dax_read_lock(void); void dax_read_unlock(int id); -struct dax_device *alloc_dax(void *private, const char *host, - const struct dax_operations *ops); bool dax_alive(struct dax_device *dax_dev); -void kill_dax(struct dax_device *dax_dev); void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v2] dm: allow device-mapper to operate without dax support 2017-08-01 22:47 ` Dan Williams @ 2017-08-02 16:02 ` kbuild test robot -1 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 16:02 UTC (permalink / raw) To: Dan Williams Cc: kbuild-all, snitzer, Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm [-- Attachment #1: Type: text/plain, Size: 14422 bytes --] Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170802] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-allow-device-mapper-to-operate-without-dax-support/20170802-155255 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: s390-defconfig (attached as .config) compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=s390 All errors (new ones prefixed by >>): drivers/md/dm.o: In function `cleanup_mapped_device': >> drivers/md/dm.c:1684: undefined reference to `kill_dax' >> drivers/md/dm.c:1685: undefined reference to `put_dax' drivers/md/dm.o: In function `close_table_device': drivers/md/dm.c:651: undefined reference to `put_dax' drivers/md/dm.o: In function `open_table_device': >> drivers/md/dm.c:637: undefined reference to `dax_get_by_host' drivers/md/dm.o: In function `dm_dax_flush': >> drivers/md/dm.c:1003: undefined reference to `dax_get_private' drivers/md/dm.o: In function `dm_dax_copy_from_iter': drivers/md/dm.c:979: undefined reference to `dax_get_private' drivers/md/dm.o: In function `dm_dax_direct_access': drivers/md/dm.c:951: undefined reference to `dax_get_private' drivers/md/dm.o: In function `alloc_dev': >> drivers/md/dm.c:1783: undefined reference to `alloc_dax' drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': drivers/md/dm-table.c:1644: undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': drivers/md/dm-table.c:1822: undefined reference to `dax_write_cache' drivers/md/dm-linear.o: In function `linear_dax_flush': >> drivers/md/dm-linear.c:197: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-linear.c:199: undefined reference to `dax_flush' drivers/md/dm-linear.o: In function `linear_dax_copy_from_iter': drivers/md/dm-linear.c:183: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-linear.c:185: undefined reference to `dax_copy_from_iter' drivers/md/dm-linear.o: In function `linear_dax_direct_access': drivers/md/dm-linear.c:168: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-linear.c:171: undefined reference to `dax_direct_access' drivers/md/dm-stripe.o: In function `stripe_dax_flush': >> drivers/md/dm-stripe.c:369: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-stripe.c:371: undefined reference to `dax_flush' drivers/md/dm-stripe.o: In function `stripe_dax_copy_from_iter': drivers/md/dm-stripe.c:350: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-stripe.c:352: undefined reference to `dax_copy_from_iter' drivers/md/dm-stripe.o: In function `stripe_dax_direct_access': drivers/md/dm-stripe.c:330: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-stripe.c:333: undefined reference to `dax_direct_access' vim +1684 drivers/md/dm.c 4a0b4ddf2 Mike Snitzer 2010-08-12 1672 0f20972f7 Mike Snitzer 2015-04-28 1673 static void cleanup_mapped_device(struct mapped_device *md) 0f20972f7 Mike Snitzer 2015-04-28 1674 { 0f20972f7 Mike Snitzer 2015-04-28 1675 if (md->wq) 0f20972f7 Mike Snitzer 2015-04-28 1676 destroy_workqueue(md->wq); 0f20972f7 Mike Snitzer 2015-04-28 1677 if (md->kworker_task) 0f20972f7 Mike Snitzer 2015-04-28 1678 kthread_stop(md->kworker_task); 0f20972f7 Mike Snitzer 2015-04-28 1679 mempool_destroy(md->io_pool); 0f20972f7 Mike Snitzer 2015-04-28 1680 if (md->bs) 0f20972f7 Mike Snitzer 2015-04-28 1681 bioset_free(md->bs); 0f20972f7 Mike Snitzer 2015-04-28 1682 f26c5719b Dan Williams 2017-04-12 1683 if (md->dax_dev) { f26c5719b Dan Williams 2017-04-12 @1684 kill_dax(md->dax_dev); f26c5719b Dan Williams 2017-04-12 @1685 put_dax(md->dax_dev); f26c5719b Dan Williams 2017-04-12 1686 md->dax_dev = NULL; f26c5719b Dan Williams 2017-04-12 1687 } f26c5719b Dan Williams 2017-04-12 1688 0f20972f7 Mike Snitzer 2015-04-28 1689 if (md->disk) { 0f20972f7 Mike Snitzer 2015-04-28 1690 spin_lock(&_minor_lock); 0f20972f7 Mike Snitzer 2015-04-28 1691 md->disk->private_data = NULL; 0f20972f7 Mike Snitzer 2015-04-28 1692 spin_unlock(&_minor_lock); 0f20972f7 Mike Snitzer 2015-04-28 1693 del_gendisk(md->disk); 0f20972f7 Mike Snitzer 2015-04-28 1694 put_disk(md->disk); 0f20972f7 Mike Snitzer 2015-04-28 1695 } 0f20972f7 Mike Snitzer 2015-04-28 1696 0f20972f7 Mike Snitzer 2015-04-28 1697 if (md->queue) 0f20972f7 Mike Snitzer 2015-04-28 1698 blk_cleanup_queue(md->queue); 0f20972f7 Mike Snitzer 2015-04-28 1699 d09960b00 Tahsin Erdogan 2016-10-10 1700 cleanup_srcu_struct(&md->io_barrier); d09960b00 Tahsin Erdogan 2016-10-10 1701 0f20972f7 Mike Snitzer 2015-04-28 1702 if (md->bdev) { 0f20972f7 Mike Snitzer 2015-04-28 1703 bdput(md->bdev); 0f20972f7 Mike Snitzer 2015-04-28 1704 md->bdev = NULL; 0f20972f7 Mike Snitzer 2015-04-28 1705 } 4cc96131a Mike Snitzer 2016-05-12 1706 4cc96131a Mike Snitzer 2016-05-12 1707 dm_mq_cleanup_mapped_device(md); 0f20972f7 Mike Snitzer 2015-04-28 1708 } 0f20972f7 Mike Snitzer 2015-04-28 1709 ^1da177e4 Linus Torvalds 2005-04-16 1710 /* ^1da177e4 Linus Torvalds 2005-04-16 1711 * Allocate and initialise a blank device with a given minor. ^1da177e4 Linus Torvalds 2005-04-16 1712 */ 2b06cfff1 Alasdair G Kergon 2006-06-26 1713 static struct mapped_device *alloc_dev(int minor) ^1da177e4 Linus Torvalds 2005-04-16 1714 { 115485e83 Mike Snitzer 2016-02-22 1715 int r, numa_node_id = dm_get_numa_node(); 74f22ed6b Dan Williams 2017-08-01 1716 struct dax_device *dax_dev = NULL; 115485e83 Mike Snitzer 2016-02-22 1717 struct mapped_device *md; ba61fdd17 Jeff Mahoney 2006-06-26 1718 void *old_md; ^1da177e4 Linus Torvalds 2005-04-16 1719 115485e83 Mike Snitzer 2016-02-22 1720 md = kzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id); ^1da177e4 Linus Torvalds 2005-04-16 1721 if (!md) { ^1da177e4 Linus Torvalds 2005-04-16 1722 DMWARN("unable to allocate device, out of memory."); ^1da177e4 Linus Torvalds 2005-04-16 1723 return NULL; ^1da177e4 Linus Torvalds 2005-04-16 1724 } ^1da177e4 Linus Torvalds 2005-04-16 1725 10da4f795 Jeff Mahoney 2006-06-26 1726 if (!try_module_get(THIS_MODULE)) 6ed7ade89 Milan Broz 2008-02-08 1727 goto bad_module_get; 10da4f795 Jeff Mahoney 2006-06-26 1728 ^1da177e4 Linus Torvalds 2005-04-16 1729 /* get a minor number for the dev */ 2b06cfff1 Alasdair G Kergon 2006-06-26 1730 if (minor == DM_ANY_MINOR) cf13ab8e0 Frederik Deweerdt 2008-04-24 1731 r = next_free_minor(&minor); 2b06cfff1 Alasdair G Kergon 2006-06-26 1732 else cf13ab8e0 Frederik Deweerdt 2008-04-24 1733 r = specific_minor(minor); ^1da177e4 Linus Torvalds 2005-04-16 1734 if (r < 0) 6ed7ade89 Milan Broz 2008-02-08 1735 goto bad_minor; ^1da177e4 Linus Torvalds 2005-04-16 1736 83d5e5b0a Mikulas Patocka 2013-07-10 1737 r = init_srcu_struct(&md->io_barrier); 83d5e5b0a Mikulas Patocka 2013-07-10 1738 if (r < 0) 83d5e5b0a Mikulas Patocka 2013-07-10 1739 goto bad_io_barrier; 83d5e5b0a Mikulas Patocka 2013-07-10 1740 115485e83 Mike Snitzer 2016-02-22 1741 md->numa_node_id = numa_node_id; 4cc96131a Mike Snitzer 2016-05-12 1742 md->use_blk_mq = dm_use_blk_mq_default(); 591ddcfc4 Mike Snitzer 2016-01-31 1743 md->init_tio_pdu = false; a5664dad7 Mike Snitzer 2010-08-12 1744 md->type = DM_TYPE_NONE; e61290a4a Daniel Walker 2008-02-08 1745 mutex_init(&md->suspend_lock); a5664dad7 Mike Snitzer 2010-08-12 1746 mutex_init(&md->type_lock); 86f1152b1 Benjamin Marzinski 2014-08-13 1747 mutex_init(&md->table_devices_lock); 022c26110 Mikulas Patocka 2009-04-02 1748 spin_lock_init(&md->deferred_lock); ^1da177e4 Linus Torvalds 2005-04-16 1749 atomic_set(&md->holders, 1); 5c6bd75d0 Alasdair G Kergon 2006-06-26 1750 atomic_set(&md->open_count, 0); ^1da177e4 Linus Torvalds 2005-04-16 1751 atomic_set(&md->event_nr, 0); 7a8c3d3b9 Mike Anderson 2007-10-19 1752 atomic_set(&md->uevent_seq, 0); 7a8c3d3b9 Mike Anderson 2007-10-19 1753 INIT_LIST_HEAD(&md->uevent_list); 86f1152b1 Benjamin Marzinski 2014-08-13 1754 INIT_LIST_HEAD(&md->table_devices); 7a8c3d3b9 Mike Anderson 2007-10-19 1755 spin_lock_init(&md->uevent_lock); ^1da177e4 Linus Torvalds 2005-04-16 1756 115485e83 Mike Snitzer 2016-02-22 1757 md->queue = blk_alloc_queue_node(GFP_KERNEL, numa_node_id); ^1da177e4 Linus Torvalds 2005-04-16 1758 if (!md->queue) 0f20972f7 Mike Snitzer 2015-04-28 1759 goto bad; ^1da177e4 Linus Torvalds 2005-04-16 1760 4a0b4ddf2 Mike Snitzer 2010-08-12 1761 dm_init_md_queue(md); 9faf400f7 Stefan Bader 2006-10-03 1762 115485e83 Mike Snitzer 2016-02-22 1763 md->disk = alloc_disk_node(1, numa_node_id); ^1da177e4 Linus Torvalds 2005-04-16 1764 if (!md->disk) 0f20972f7 Mike Snitzer 2015-04-28 1765 goto bad; ^1da177e4 Linus Torvalds 2005-04-16 1766 316d315bf Nikanth Karthikesan 2009-10-06 1767 atomic_set(&md->pending[0], 0); 316d315bf Nikanth Karthikesan 2009-10-06 1768 atomic_set(&md->pending[1], 0); f0b041153 Jeff Mahoney 2006-06-26 1769 init_waitqueue_head(&md->wait); 53d5914f2 Mikulas Patocka 2009-04-02 1770 INIT_WORK(&md->work, dm_wq_work); f0b041153 Jeff Mahoney 2006-06-26 1771 init_waitqueue_head(&md->eventq); 2995fa78e Mikulas Patocka 2014-01-13 1772 init_completion(&md->kobj_holder.completion); 2eb6e1e3a Keith Busch 2014-10-17 1773 md->kworker_task = NULL; f0b041153 Jeff Mahoney 2006-06-26 1774 ^1da177e4 Linus Torvalds 2005-04-16 1775 md->disk->major = _major; ^1da177e4 Linus Torvalds 2005-04-16 1776 md->disk->first_minor = minor; ^1da177e4 Linus Torvalds 2005-04-16 1777 md->disk->fops = &dm_blk_dops; ^1da177e4 Linus Torvalds 2005-04-16 1778 md->disk->queue = md->queue; ^1da177e4 Linus Torvalds 2005-04-16 1779 md->disk->private_data = md; ^1da177e4 Linus Torvalds 2005-04-16 1780 sprintf(md->disk->disk_name, "dm-%d", minor); f26c5719b Dan Williams 2017-04-12 1781 74f22ed6b Dan Williams 2017-08-01 1782 if (IS_ENABLED(CONFIG_DAX)) { f26c5719b Dan Williams 2017-04-12 @1783 dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); f26c5719b Dan Williams 2017-04-12 1784 if (!dax_dev) f26c5719b Dan Williams 2017-04-12 1785 goto bad; 74f22ed6b Dan Williams 2017-08-01 1786 } f26c5719b Dan Williams 2017-04-12 1787 md->dax_dev = dax_dev; f26c5719b Dan Williams 2017-04-12 1788 ^1da177e4 Linus Torvalds 2005-04-16 1789 add_disk(md->disk); 7e51f257e Mike Anderson 2006-03-27 1790 format_dev_t(md->name, MKDEV(_major, minor)); ^1da177e4 Linus Torvalds 2005-04-16 1791 670368a8d Tejun Heo 2013-07-30 1792 md->wq = alloc_workqueue("kdmflush", WQ_MEM_RECLAIM, 0); 304f3f6a5 Milan Broz 2008-02-08 1793 if (!md->wq) 0f20972f7 Mike Snitzer 2015-04-28 1794 goto bad; 304f3f6a5 Milan Broz 2008-02-08 1795 32a926da5 Mikulas Patocka 2009-06-22 1796 md->bdev = bdget_disk(md->disk, 0); 32a926da5 Mikulas Patocka 2009-06-22 1797 if (!md->bdev) 0f20972f7 Mike Snitzer 2015-04-28 1798 goto bad; 32a926da5 Mikulas Patocka 2009-06-22 1799 3a83f4677 Ming Lei 2016-11-22 1800 bio_init(&md->flush_bio, NULL, 0); 6a8736d10 Tejun Heo 2010-09-08 1801 md->flush_bio.bi_bdev = md->bdev; ff0361b34 Jan Kara 2017-05-31 1802 md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC; 6a8736d10 Tejun Heo 2010-09-08 1803 fd2ed4d25 Mikulas Patocka 2013-08-16 1804 dm_stats_init(&md->stats); fd2ed4d25 Mikulas Patocka 2013-08-16 1805 ba61fdd17 Jeff Mahoney 2006-06-26 1806 /* Populate the mapping, nobody knows we exist yet */ f32c10b09 Jeff Mahoney 2006-06-26 1807 spin_lock(&_minor_lock); ba61fdd17 Jeff Mahoney 2006-06-26 1808 old_md = idr_replace(&_minor_idr, md, minor); f32c10b09 Jeff Mahoney 2006-06-26 1809 spin_unlock(&_minor_lock); ba61fdd17 Jeff Mahoney 2006-06-26 1810 ba61fdd17 Jeff Mahoney 2006-06-26 1811 BUG_ON(old_md != MINOR_ALLOCED); ba61fdd17 Jeff Mahoney 2006-06-26 1812 ^1da177e4 Linus Torvalds 2005-04-16 1813 return md; ^1da177e4 Linus Torvalds 2005-04-16 1814 0f20972f7 Mike Snitzer 2015-04-28 1815 bad: 0f20972f7 Mike Snitzer 2015-04-28 1816 cleanup_mapped_device(md); 83d5e5b0a Mikulas Patocka 2013-07-10 1817 bad_io_barrier: ^1da177e4 Linus Torvalds 2005-04-16 1818 free_minor(minor); 6ed7ade89 Milan Broz 2008-02-08 1819 bad_minor: 10da4f795 Jeff Mahoney 2006-06-26 1820 module_put(THIS_MODULE); 6ed7ade89 Milan Broz 2008-02-08 1821 bad_module_get: ^1da177e4 Linus Torvalds 2005-04-16 1822 kfree(md); ^1da177e4 Linus Torvalds 2005-04-16 1823 return NULL; ^1da177e4 Linus Torvalds 2005-04-16 1824 } ^1da177e4 Linus Torvalds 2005-04-16 1825 :::::: The code at line 1684 was first introduced by commit :::::: f26c5719b2d7b00de69eb83eb1c1c831759fdc9b dm: add dax_device and dax_operations support :::::: TO: Dan Williams <dan.j.williams@intel.com> :::::: CC: Dan Williams <dan.j.williams@intel.com> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 10958 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2] dm: allow device-mapper to operate without dax support @ 2017-08-02 16:02 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 16:02 UTC (permalink / raw) To: Dan Williams Cc: snitzer, linux-nvdimm, linux-kernel, dm-devel, kbuild-all, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170802] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-allow-device-mapper-to-operate-without-dax-support/20170802-155255 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: s390-defconfig (attached as .config) compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=s390 All errors (new ones prefixed by >>): drivers/md/dm.o: In function `cleanup_mapped_device': >> drivers/md/dm.c:1684: undefined reference to `kill_dax' >> drivers/md/dm.c:1685: undefined reference to `put_dax' drivers/md/dm.o: In function `close_table_device': drivers/md/dm.c:651: undefined reference to `put_dax' drivers/md/dm.o: In function `open_table_device': >> drivers/md/dm.c:637: undefined reference to `dax_get_by_host' drivers/md/dm.o: In function `dm_dax_flush': >> drivers/md/dm.c:1003: undefined reference to `dax_get_private' drivers/md/dm.o: In function `dm_dax_copy_from_iter': drivers/md/dm.c:979: undefined reference to `dax_get_private' drivers/md/dm.o: In function `dm_dax_direct_access': drivers/md/dm.c:951: undefined reference to `dax_get_private' drivers/md/dm.o: In function `alloc_dev': >> drivers/md/dm.c:1783: undefined reference to `alloc_dax' drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': drivers/md/dm-table.c:1644: undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': drivers/md/dm-table.c:1822: undefined reference to `dax_write_cache' drivers/md/dm-linear.o: In function `linear_dax_flush': >> drivers/md/dm-linear.c:197: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-linear.c:199: undefined reference to `dax_flush' drivers/md/dm-linear.o: In function `linear_dax_copy_from_iter': drivers/md/dm-linear.c:183: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-linear.c:185: undefined reference to `dax_copy_from_iter' drivers/md/dm-linear.o: In function `linear_dax_direct_access': drivers/md/dm-linear.c:168: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-linear.c:171: undefined reference to `dax_direct_access' drivers/md/dm-stripe.o: In function `stripe_dax_flush': >> drivers/md/dm-stripe.c:369: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-stripe.c:371: undefined reference to `dax_flush' drivers/md/dm-stripe.o: In function `stripe_dax_copy_from_iter': drivers/md/dm-stripe.c:350: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-stripe.c:352: undefined reference to `dax_copy_from_iter' drivers/md/dm-stripe.o: In function `stripe_dax_direct_access': drivers/md/dm-stripe.c:330: undefined reference to `bdev_dax_pgoff' >> drivers/md/dm-stripe.c:333: undefined reference to `dax_direct_access' vim +1684 drivers/md/dm.c 4a0b4ddf2 Mike Snitzer 2010-08-12 1672 0f20972f7 Mike Snitzer 2015-04-28 1673 static void cleanup_mapped_device(struct mapped_device *md) 0f20972f7 Mike Snitzer 2015-04-28 1674 { 0f20972f7 Mike Snitzer 2015-04-28 1675 if (md->wq) 0f20972f7 Mike Snitzer 2015-04-28 1676 destroy_workqueue(md->wq); 0f20972f7 Mike Snitzer 2015-04-28 1677 if (md->kworker_task) 0f20972f7 Mike Snitzer 2015-04-28 1678 kthread_stop(md->kworker_task); 0f20972f7 Mike Snitzer 2015-04-28 1679 mempool_destroy(md->io_pool); 0f20972f7 Mike Snitzer 2015-04-28 1680 if (md->bs) 0f20972f7 Mike Snitzer 2015-04-28 1681 bioset_free(md->bs); 0f20972f7 Mike Snitzer 2015-04-28 1682 f26c5719b Dan Williams 2017-04-12 1683 if (md->dax_dev) { f26c5719b Dan Williams 2017-04-12 @1684 kill_dax(md->dax_dev); f26c5719b Dan Williams 2017-04-12 @1685 put_dax(md->dax_dev); f26c5719b Dan Williams 2017-04-12 1686 md->dax_dev = NULL; f26c5719b Dan Williams 2017-04-12 1687 } f26c5719b Dan Williams 2017-04-12 1688 0f20972f7 Mike Snitzer 2015-04-28 1689 if (md->disk) { 0f20972f7 Mike Snitzer 2015-04-28 1690 spin_lock(&_minor_lock); 0f20972f7 Mike Snitzer 2015-04-28 1691 md->disk->private_data = NULL; 0f20972f7 Mike Snitzer 2015-04-28 1692 spin_unlock(&_minor_lock); 0f20972f7 Mike Snitzer 2015-04-28 1693 del_gendisk(md->disk); 0f20972f7 Mike Snitzer 2015-04-28 1694 put_disk(md->disk); 0f20972f7 Mike Snitzer 2015-04-28 1695 } 0f20972f7 Mike Snitzer 2015-04-28 1696 0f20972f7 Mike Snitzer 2015-04-28 1697 if (md->queue) 0f20972f7 Mike Snitzer 2015-04-28 1698 blk_cleanup_queue(md->queue); 0f20972f7 Mike Snitzer 2015-04-28 1699 d09960b00 Tahsin Erdogan 2016-10-10 1700 cleanup_srcu_struct(&md->io_barrier); d09960b00 Tahsin Erdogan 2016-10-10 1701 0f20972f7 Mike Snitzer 2015-04-28 1702 if (md->bdev) { 0f20972f7 Mike Snitzer 2015-04-28 1703 bdput(md->bdev); 0f20972f7 Mike Snitzer 2015-04-28 1704 md->bdev = NULL; 0f20972f7 Mike Snitzer 2015-04-28 1705 } 4cc96131a Mike Snitzer 2016-05-12 1706 4cc96131a Mike Snitzer 2016-05-12 1707 dm_mq_cleanup_mapped_device(md); 0f20972f7 Mike Snitzer 2015-04-28 1708 } 0f20972f7 Mike Snitzer 2015-04-28 1709 ^1da177e4 Linus Torvalds 2005-04-16 1710 /* ^1da177e4 Linus Torvalds 2005-04-16 1711 * Allocate and initialise a blank device with a given minor. ^1da177e4 Linus Torvalds 2005-04-16 1712 */ 2b06cfff1 Alasdair G Kergon 2006-06-26 1713 static struct mapped_device *alloc_dev(int minor) ^1da177e4 Linus Torvalds 2005-04-16 1714 { 115485e83 Mike Snitzer 2016-02-22 1715 int r, numa_node_id = dm_get_numa_node(); 74f22ed6b Dan Williams 2017-08-01 1716 struct dax_device *dax_dev = NULL; 115485e83 Mike Snitzer 2016-02-22 1717 struct mapped_device *md; ba61fdd17 Jeff Mahoney 2006-06-26 1718 void *old_md; ^1da177e4 Linus Torvalds 2005-04-16 1719 115485e83 Mike Snitzer 2016-02-22 1720 md = kzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id); ^1da177e4 Linus Torvalds 2005-04-16 1721 if (!md) { ^1da177e4 Linus Torvalds 2005-04-16 1722 DMWARN("unable to allocate device, out of memory."); ^1da177e4 Linus Torvalds 2005-04-16 1723 return NULL; ^1da177e4 Linus Torvalds 2005-04-16 1724 } ^1da177e4 Linus Torvalds 2005-04-16 1725 10da4f795 Jeff Mahoney 2006-06-26 1726 if (!try_module_get(THIS_MODULE)) 6ed7ade89 Milan Broz 2008-02-08 1727 goto bad_module_get; 10da4f795 Jeff Mahoney 2006-06-26 1728 ^1da177e4 Linus Torvalds 2005-04-16 1729 /* get a minor number for the dev */ 2b06cfff1 Alasdair G Kergon 2006-06-26 1730 if (minor == DM_ANY_MINOR) cf13ab8e0 Frederik Deweerdt 2008-04-24 1731 r = next_free_minor(&minor); 2b06cfff1 Alasdair G Kergon 2006-06-26 1732 else cf13ab8e0 Frederik Deweerdt 2008-04-24 1733 r = specific_minor(minor); ^1da177e4 Linus Torvalds 2005-04-16 1734 if (r < 0) 6ed7ade89 Milan Broz 2008-02-08 1735 goto bad_minor; ^1da177e4 Linus Torvalds 2005-04-16 1736 83d5e5b0a Mikulas Patocka 2013-07-10 1737 r = init_srcu_struct(&md->io_barrier); 83d5e5b0a Mikulas Patocka 2013-07-10 1738 if (r < 0) 83d5e5b0a Mikulas Patocka 2013-07-10 1739 goto bad_io_barrier; 83d5e5b0a Mikulas Patocka 2013-07-10 1740 115485e83 Mike Snitzer 2016-02-22 1741 md->numa_node_id = numa_node_id; 4cc96131a Mike Snitzer 2016-05-12 1742 md->use_blk_mq = dm_use_blk_mq_default(); 591ddcfc4 Mike Snitzer 2016-01-31 1743 md->init_tio_pdu = false; a5664dad7 Mike Snitzer 2010-08-12 1744 md->type = DM_TYPE_NONE; e61290a4a Daniel Walker 2008-02-08 1745 mutex_init(&md->suspend_lock); a5664dad7 Mike Snitzer 2010-08-12 1746 mutex_init(&md->type_lock); 86f1152b1 Benjamin Marzinski 2014-08-13 1747 mutex_init(&md->table_devices_lock); 022c26110 Mikulas Patocka 2009-04-02 1748 spin_lock_init(&md->deferred_lock); ^1da177e4 Linus Torvalds 2005-04-16 1749 atomic_set(&md->holders, 1); 5c6bd75d0 Alasdair G Kergon 2006-06-26 1750 atomic_set(&md->open_count, 0); ^1da177e4 Linus Torvalds 2005-04-16 1751 atomic_set(&md->event_nr, 0); 7a8c3d3b9 Mike Anderson 2007-10-19 1752 atomic_set(&md->uevent_seq, 0); 7a8c3d3b9 Mike Anderson 2007-10-19 1753 INIT_LIST_HEAD(&md->uevent_list); 86f1152b1 Benjamin Marzinski 2014-08-13 1754 INIT_LIST_HEAD(&md->table_devices); 7a8c3d3b9 Mike Anderson 2007-10-19 1755 spin_lock_init(&md->uevent_lock); ^1da177e4 Linus Torvalds 2005-04-16 1756 115485e83 Mike Snitzer 2016-02-22 1757 md->queue = blk_alloc_queue_node(GFP_KERNEL, numa_node_id); ^1da177e4 Linus Torvalds 2005-04-16 1758 if (!md->queue) 0f20972f7 Mike Snitzer 2015-04-28 1759 goto bad; ^1da177e4 Linus Torvalds 2005-04-16 1760 4a0b4ddf2 Mike Snitzer 2010-08-12 1761 dm_init_md_queue(md); 9faf400f7 Stefan Bader 2006-10-03 1762 115485e83 Mike Snitzer 2016-02-22 1763 md->disk = alloc_disk_node(1, numa_node_id); ^1da177e4 Linus Torvalds 2005-04-16 1764 if (!md->disk) 0f20972f7 Mike Snitzer 2015-04-28 1765 goto bad; ^1da177e4 Linus Torvalds 2005-04-16 1766 316d315bf Nikanth Karthikesan 2009-10-06 1767 atomic_set(&md->pending[0], 0); 316d315bf Nikanth Karthikesan 2009-10-06 1768 atomic_set(&md->pending[1], 0); f0b041153 Jeff Mahoney 2006-06-26 1769 init_waitqueue_head(&md->wait); 53d5914f2 Mikulas Patocka 2009-04-02 1770 INIT_WORK(&md->work, dm_wq_work); f0b041153 Jeff Mahoney 2006-06-26 1771 init_waitqueue_head(&md->eventq); 2995fa78e Mikulas Patocka 2014-01-13 1772 init_completion(&md->kobj_holder.completion); 2eb6e1e3a Keith Busch 2014-10-17 1773 md->kworker_task = NULL; f0b041153 Jeff Mahoney 2006-06-26 1774 ^1da177e4 Linus Torvalds 2005-04-16 1775 md->disk->major = _major; ^1da177e4 Linus Torvalds 2005-04-16 1776 md->disk->first_minor = minor; ^1da177e4 Linus Torvalds 2005-04-16 1777 md->disk->fops = &dm_blk_dops; ^1da177e4 Linus Torvalds 2005-04-16 1778 md->disk->queue = md->queue; ^1da177e4 Linus Torvalds 2005-04-16 1779 md->disk->private_data = md; ^1da177e4 Linus Torvalds 2005-04-16 1780 sprintf(md->disk->disk_name, "dm-%d", minor); f26c5719b Dan Williams 2017-04-12 1781 74f22ed6b Dan Williams 2017-08-01 1782 if (IS_ENABLED(CONFIG_DAX)) { f26c5719b Dan Williams 2017-04-12 @1783 dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops); f26c5719b Dan Williams 2017-04-12 1784 if (!dax_dev) f26c5719b Dan Williams 2017-04-12 1785 goto bad; 74f22ed6b Dan Williams 2017-08-01 1786 } f26c5719b Dan Williams 2017-04-12 1787 md->dax_dev = dax_dev; f26c5719b Dan Williams 2017-04-12 1788 ^1da177e4 Linus Torvalds 2005-04-16 1789 add_disk(md->disk); 7e51f257e Mike Anderson 2006-03-27 1790 format_dev_t(md->name, MKDEV(_major, minor)); ^1da177e4 Linus Torvalds 2005-04-16 1791 670368a8d Tejun Heo 2013-07-30 1792 md->wq = alloc_workqueue("kdmflush", WQ_MEM_RECLAIM, 0); 304f3f6a5 Milan Broz 2008-02-08 1793 if (!md->wq) 0f20972f7 Mike Snitzer 2015-04-28 1794 goto bad; 304f3f6a5 Milan Broz 2008-02-08 1795 32a926da5 Mikulas Patocka 2009-06-22 1796 md->bdev = bdget_disk(md->disk, 0); 32a926da5 Mikulas Patocka 2009-06-22 1797 if (!md->bdev) 0f20972f7 Mike Snitzer 2015-04-28 1798 goto bad; 32a926da5 Mikulas Patocka 2009-06-22 1799 3a83f4677 Ming Lei 2016-11-22 1800 bio_init(&md->flush_bio, NULL, 0); 6a8736d10 Tejun Heo 2010-09-08 1801 md->flush_bio.bi_bdev = md->bdev; ff0361b34 Jan Kara 2017-05-31 1802 md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC; 6a8736d10 Tejun Heo 2010-09-08 1803 fd2ed4d25 Mikulas Patocka 2013-08-16 1804 dm_stats_init(&md->stats); fd2ed4d25 Mikulas Patocka 2013-08-16 1805 ba61fdd17 Jeff Mahoney 2006-06-26 1806 /* Populate the mapping, nobody knows we exist yet */ f32c10b09 Jeff Mahoney 2006-06-26 1807 spin_lock(&_minor_lock); ba61fdd17 Jeff Mahoney 2006-06-26 1808 old_md = idr_replace(&_minor_idr, md, minor); f32c10b09 Jeff Mahoney 2006-06-26 1809 spin_unlock(&_minor_lock); ba61fdd17 Jeff Mahoney 2006-06-26 1810 ba61fdd17 Jeff Mahoney 2006-06-26 1811 BUG_ON(old_md != MINOR_ALLOCED); ba61fdd17 Jeff Mahoney 2006-06-26 1812 ^1da177e4 Linus Torvalds 2005-04-16 1813 return md; ^1da177e4 Linus Torvalds 2005-04-16 1814 0f20972f7 Mike Snitzer 2015-04-28 1815 bad: 0f20972f7 Mike Snitzer 2015-04-28 1816 cleanup_mapped_device(md); 83d5e5b0a Mikulas Patocka 2013-07-10 1817 bad_io_barrier: ^1da177e4 Linus Torvalds 2005-04-16 1818 free_minor(minor); 6ed7ade89 Milan Broz 2008-02-08 1819 bad_minor: 10da4f795 Jeff Mahoney 2006-06-26 1820 module_put(THIS_MODULE); 6ed7ade89 Milan Broz 2008-02-08 1821 bad_module_get: ^1da177e4 Linus Torvalds 2005-04-16 1822 kfree(md); ^1da177e4 Linus Torvalds 2005-04-16 1823 return NULL; ^1da177e4 Linus Torvalds 2005-04-16 1824 } ^1da177e4 Linus Torvalds 2005-04-16 1825 :::::: The code at line 1684 was first introduced by commit :::::: f26c5719b2d7b00de69eb83eb1c1c831759fdc9b dm: add dax_device and dax_operations support :::::: TO: Dan Williams <dan.j.williams@intel.com> :::::: CC: Dan Williams <dan.j.williams@intel.com> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
[parent not found: <150162766102.27319.10043964535977848237.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2] dm: allow device-mapper to operate without dax support 2017-08-01 22:47 ` Dan Williams (?) @ 2017-08-02 20:44 ` kbuild test robot -1 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 20:44 UTC (permalink / raw) To: Dan Williams Cc: snitzer-H+wXaHxf7aLQT0dZR+AlfA, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, kbuild-all-JC7UmRfGjtg, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170802] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-allow-device-mapper-to-operate-without-dax-support/20170802-155255 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: sh-sdk7786_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': dm-table.c:(.text+0xab4): undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': >> (.text+0x23d0): undefined reference to `dax_write_cache' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2] dm: allow device-mapper to operate without dax support @ 2017-08-02 20:44 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 20:44 UTC (permalink / raw) To: Dan Williams Cc: kbuild-all, snitzer, Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm [-- Attachment #1: Type: text/plain, Size: 1247 bytes --] Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170802] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-allow-device-mapper-to-operate-without-dax-support/20170802-155255 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: sh-sdk7786_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': dm-table.c:(.text+0xab4): undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': >> (.text+0x23d0): undefined reference to `dax_write_cache' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 18571 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2] dm: allow device-mapper to operate without dax support @ 2017-08-02 20:44 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 20:44 UTC (permalink / raw) To: Dan Williams Cc: snitzer, linux-nvdimm, linux-kernel, dm-devel, kbuild-all, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170802] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-allow-device-mapper-to-operate-without-dax-support/20170802-155255 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: sh-sdk7786_defconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': dm-table.c:(.text+0xab4): undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': >> (.text+0x23d0): undefined reference to `dax_write_cache' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] dm: enable opt-out of device-mapper dax support 2017-08-01 18:12 ` Dan Williams (?) @ 2017-08-02 1:40 ` kbuild test robot -1 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 1:40 UTC (permalink / raw) To: Dan Williams Cc: snitzer-H+wXaHxf7aLQT0dZR+AlfA, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, kbuild-all-JC7UmRfGjtg, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170801] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-enable-opt-out-of-device-mapper-dax-support/20170802-063827 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: sparc64-defconfig (attached as .config) compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sparc64 All errors (new ones prefixed by >>): >> ERROR: "dax_write_cache" [drivers/md/dm-mod.ko] undefined! >> ERROR: "dax_write_cache_enabled" [drivers/md/dm-mod.ko] undefined! --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-02 1:40 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 1:40 UTC (permalink / raw) To: Dan Williams Cc: kbuild-all, snitzer, Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm [-- Attachment #1: Type: text/plain, Size: 1101 bytes --] Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170801] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-enable-opt-out-of-device-mapper-dax-support/20170802-063827 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: sparc64-defconfig (attached as .config) compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sparc64 All errors (new ones prefixed by >>): >> ERROR: "dax_write_cache" [drivers/md/dm-mod.ko] undefined! >> ERROR: "dax_write_cache_enabled" [drivers/md/dm-mod.ko] undefined! --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 17828 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-02 1:40 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 1:40 UTC (permalink / raw) To: Dan Williams Cc: snitzer, linux-nvdimm, linux-kernel, dm-devel, kbuild-all, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170801] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-enable-opt-out-of-device-mapper-dax-support/20170802-063827 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: sparc64-defconfig (attached as .config) compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sparc64 All errors (new ones prefixed by >>): >> ERROR: "dax_write_cache" [drivers/md/dm-mod.ko] undefined! >> ERROR: "dax_write_cache_enabled" [drivers/md/dm-mod.ko] undefined! --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] dm: enable opt-out of device-mapper dax support 2017-08-01 18:12 ` Dan Williams (?) @ 2017-08-02 1:48 ` kbuild test robot -1 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 1:48 UTC (permalink / raw) To: Dan Williams Cc: snitzer-H+wXaHxf7aLQT0dZR+AlfA, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, linux-kernel-u79uwXL29TY76Z2rM5mHXA, dm-devel-H+wXaHxf7aLQT0dZR+AlfA, kbuild-all-JC7UmRfGjtg, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170801] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-enable-opt-out-of-device-mapper-dax-support/20170802-063827 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: x86_64-allyesdebian (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': >> dm-table.c:(.text+0x568): undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': >> dm-table.c:(.text+0x1e40): undefined reference to `dax_write_cache' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-02 1:48 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 1:48 UTC (permalink / raw) To: Dan Williams Cc: kbuild-all, snitzer, Bart Van Assche, dm-devel, linux-kernel, Alasdair Kergon, linux-nvdimm [-- Attachment #1: Type: text/plain, Size: 1096 bytes --] Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170801] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-enable-opt-out-of-device-mapper-dax-support/20170802-063827 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: x86_64-allyesdebian (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': >> dm-table.c:(.text+0x568): undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': >> dm-table.c:(.text+0x1e40): undefined reference to `dax_write_cache' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 39258 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] dm: enable opt-out of device-mapper dax support @ 2017-08-02 1:48 ` kbuild test robot 0 siblings, 0 replies; 31+ messages in thread From: kbuild test robot @ 2017-08-02 1:48 UTC (permalink / raw) To: Dan Williams Cc: snitzer, linux-nvdimm, linux-kernel, dm-devel, kbuild-all, Bart Van Assche, Alasdair Kergon Hi Dan, [auto build test ERROR on dm/for-next] [also build test ERROR on v4.13-rc3 next-20170801] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Dan-Williams/dm-enable-opt-out-of-device-mapper-dax-support/20170802-063827 base: https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next config: x86_64-allyesdebian (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/md/dm-table.o: In function `device_dax_write_cache_enabled': >> dm-table.c:(.text+0x568): undefined reference to `dax_write_cache_enabled' drivers/md/dm-table.o: In function `dm_table_set_restrictions': >> dm-table.c:(.text+0x1e40): undefined reference to `dax_write_cache' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm ^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2017-08-02 20:45 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 18:12 [PATCH] dm: enable opt-out of device-mapper dax support Dan Williams
2017-08-01 18:12 ` Dan Williams
2017-08-01 18:12 ` Dan Williams
[not found] ` <150161113411.34055.9762658795237184307.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-01 19:02 ` Mike Snitzer
2017-08-01 19:02 ` Mike Snitzer
2017-08-01 19:02 ` Mike Snitzer
[not found] ` <20170801190257.GA10033-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-08-01 19:45 ` Dan Williams
2017-08-01 19:45 ` Dan Williams
2017-08-01 19:45 ` Dan Williams
[not found] ` <CAPcyv4jxTQhHANEBmObwhvWW7JHnSmHfCqv3JL3xEm0YFamvrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-01 20:59 ` Dan Williams
2017-08-01 20:59 ` Dan Williams
2017-08-01 20:59 ` Dan Williams
[not found] ` <CAPcyv4hLP98cap0cgWWw_FOeh9yzLJVSaZURntsB0t2D24nF9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-01 21:04 ` Bart Van Assche
2017-08-01 21:04 ` Bart Van Assche
2017-08-01 21:04 ` Bart Van Assche
2017-08-01 21:19 ` Dan Williams
2017-08-01 21:19 ` Dan Williams
2017-08-01 22:47 ` [PATCH v2] dm: allow device-mapper to operate without " Dan Williams
2017-08-01 22:47 ` Dan Williams
2017-08-01 22:47 ` Dan Williams
2017-08-02 16:02 ` kbuild test robot
2017-08-02 16:02 ` kbuild test robot
[not found] ` <150162766102.27319.10043964535977848237.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-02 20:44 ` kbuild test robot
2017-08-02 20:44 ` kbuild test robot
2017-08-02 20:44 ` kbuild test robot
2017-08-02 1:40 ` [PATCH] dm: enable opt-out of device-mapper " kbuild test robot
2017-08-02 1:40 ` kbuild test robot
2017-08-02 1:40 ` kbuild test robot
2017-08-02 1:48 ` kbuild test robot
2017-08-02 1:48 ` kbuild test robot
2017-08-02 1:48 ` kbuild test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.