From: Dan Williams <dan.j.williams@intel.com> To: snitzer@redhat.com Cc: kbuild test robot <lkp@intel.com>, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Bart Van Assche <Bart.VanAssche@wdc.com>, Alasdair Kergon <agk@redhat.com> Subject: [PATCH v3 2/2] dm: allow device-mapper to operate without dax support Date: Wed, 02 Aug 2017 10:58:10 -0700 [thread overview] Message-ID: <150169668989.39569.8174620146135008137.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <150169667935.39569.15808116323143633486.stgit@dwillia2-desk3.amr.corp.intel.com> Rather than have device-mapper directly 'select DAX', let the fact that BLK_DEV_PMEM selects dax act as a gate for the device-mapper dax support. We arrange for all the dax core routines to compile to nops when CONFIG_DAX=n. With that in place we can simply handle the alloc_dax() error as expected and ifdef out the other device-mapper-dax support code. Now, if dax is provided by a leaf driver that driver may only arrange to compile the dax core as a module. Since device-mapper dax support is consumed by the always-built-in portion of the device-mapper implementation we need to upgrade from DAX=m to DAX=y. Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/md/Kconfig | 2 +- drivers/md/dm-linear.c | 6 ++++++ drivers/md/dm-stripe.c | 6 ++++++ drivers/md/dm.c | 10 ++++++---- include/linux/dax.h | 30 ++++++++++++++++++++++++------ 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..8ebf09e99006 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -195,12 +195,12 @@ config MD_CLUSTER source "drivers/md/bcache/Kconfig" config BLK_DEV_DM_BUILTIN + select DAX if DAX_DRIVER bool 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 eb0bff6f1eab..59575b8e638e 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -27,16 +27,39 @@ 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); +void dax_write_cache(struct dax_device *dax_dev, bool wc); +bool dax_write_cache_enabled(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) +{ +} +static inline void dax_write_cache(struct dax_device *dax_dev, bool wc) +{ +} +static inline bool dax_write_cache_enabled(struct dax_device *dax_dev) +{ + return false; +} #endif int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); @@ -75,10 +98,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); @@ -86,8 +106,6 @@ size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); void dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t size); -void dax_write_cache(struct dax_device *dax_dev, bool wc); -bool dax_write_cache_enabled(struct dax_device *dax_dev); ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: snitzer@redhat.com Cc: kbuild test robot <lkp@intel.com>, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Bart Van Assche <Bart.VanAssche@wdc.com>, Alasdair Kergon <agk@redhat.com> Subject: [PATCH v3 2/2] dm: allow device-mapper to operate without dax support Date: Wed, 02 Aug 2017 10:58:10 -0700 [thread overview] Message-ID: <150169668989.39569.8174620146135008137.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <150169667935.39569.15808116323143633486.stgit@dwillia2-desk3.amr.corp.intel.com> Rather than have device-mapper directly 'select DAX', let the fact that BLK_DEV_PMEM selects dax act as a gate for the device-mapper dax support. We arrange for all the dax core routines to compile to nops when CONFIG_DAX=n. With that in place we can simply handle the alloc_dax() error as expected and ifdef out the other device-mapper-dax support code. Now, if dax is provided by a leaf driver that driver may only arrange to compile the dax core as a module. Since device-mapper dax support is consumed by the always-built-in portion of the device-mapper implementation we need to upgrade from DAX=m to DAX=y. Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com> Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/md/Kconfig | 2 +- drivers/md/dm-linear.c | 6 ++++++ drivers/md/dm-stripe.c | 6 ++++++ drivers/md/dm.c | 10 ++++++---- include/linux/dax.h | 30 ++++++++++++++++++++++++------ 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 4a249ee86364..8ebf09e99006 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -195,12 +195,12 @@ config MD_CLUSTER source "drivers/md/bcache/Kconfig" config BLK_DEV_DM_BUILTIN + select DAX if DAX_DRIVER bool 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 eb0bff6f1eab..59575b8e638e 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -27,16 +27,39 @@ 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); +void dax_write_cache(struct dax_device *dax_dev, bool wc); +bool dax_write_cache_enabled(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) +{ +} +static inline void dax_write_cache(struct dax_device *dax_dev, bool wc) +{ +} +static inline bool dax_write_cache_enabled(struct dax_device *dax_dev) +{ + return false; +} #endif int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); @@ -75,10 +98,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); @@ -86,8 +106,6 @@ size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); void dax_flush(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t size); -void dax_write_cache(struct dax_device *dax_dev, bool wc); -bool dax_write_cache_enabled(struct dax_device *dax_dev); ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops);
next prev parent reply other threads:[~2017-08-02 18:02 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-08-02 17:57 [PATCH v3 0/2] dax, dm: stop requiring dax for device-mapper Dan Williams 2017-08-02 17:57 ` Dan Williams 2017-08-02 17:58 ` [PATCH v3 1/2] dax: introduce CONFIG_DAX_DRIVER Dan Williams 2017-08-02 17:58 ` Dan Williams 2017-08-02 17:58 ` Dan Williams 2017-08-02 17:58 ` Dan Williams [this message] 2017-08-02 17:58 ` [PATCH v3 2/2] dm: allow device-mapper to operate without dax support Dan Williams 2017-09-11 14:41 ` Mike Snitzer 2017-09-11 14:41 ` Mike Snitzer 2017-09-11 15:56 ` Dan Williams 2017-09-11 15:56 ` Dan Williams 2017-09-11 15:56 ` Dan Williams 2017-08-02 18:55 ` [PATCH v3 0/2] dax, dm: stop requiring dax for device-mapper Mike Snitzer 2017-08-02 18:55 ` Mike Snitzer 2017-08-02 18:55 ` Mike Snitzer 2017-09-09 18:56 ` Dan Williams 2017-09-09 18:56 ` Dan Williams
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=150169668989.39569.8174620146135008137.stgit@dwillia2-desk3.amr.corp.intel.com \ --to=dan.j.williams@intel.com \ --cc=Bart.VanAssche@wdc.com \ --cc=agk@redhat.com \ --cc=dm-devel@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ --cc=lkp@intel.com \ --cc=snitzer@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.