* [PATCH] dm,dax: Make sure dm_dax_flush() is called if device supports it
@ 2017-07-25 19:43 Vivek Goyal
2017-07-25 20:43 ` Dan Williams
2017-07-25 20:46 ` Mike Snitzer
0 siblings, 2 replies; 5+ messages in thread
From: Vivek Goyal @ 2017-07-25 19:43 UTC (permalink / raw)
To: dm-devel, linux-nvdimm; +Cc: Mike Snitzer
Right now, dm_dax_flush() is not being called and I think it is not being
called becuase DAXDEV_WRITE_CACHE is not set on dm dax device.
If underlying dax device supports write cache, set DAXDEV_WRITE_CACHE on
dm dax device. This will get dm_dax_flush() being called.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
drivers/dax/super.c | 5 +++++
drivers/md/dm-table.c | 33 +++++++++++++++++++++++++++++++++
include/linux/dax.h | 1 +
3 files changed, 39 insertions(+)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index ce9e563e6e1d..5c5e7b9f6831 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -278,6 +278,11 @@ void dax_write_cache(struct dax_device *dax_dev, bool wc)
}
EXPORT_SYMBOL_GPL(dax_write_cache);
+bool dax_write_cache_enabled(struct dax_device *dax_dev)
+{
+ return test_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+}
+
bool dax_alive(struct dax_device *dax_dev)
{
lockdep_assert_held(&dax_srcu);
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a39bcd9b982a..3be0ab2a71c8 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -20,6 +20,7 @@
#include <linux/atomic.h>
#include <linux/blk-mq.h>
#include <linux/mount.h>
+#include <linux/dax.h>
#define DM_MSG_PREFIX "table"
@@ -1630,6 +1631,35 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned long flush)
return false;
}
+static int device_dax_flush_capable(struct dm_target *ti, struct dm_dev *dev,
+ sector_t start, sector_t len, void *data)
+{
+ struct dax_device *dax_dev = dev->dax_dev;
+
+ if (!dax_dev)
+ return false;
+
+ if (dax_write_cache_enabled(dax_dev))
+ return true;
+ return false;
+}
+
+static int dm_table_supports_dax_flush(struct dm_table *t)
+{
+ struct dm_target *ti;
+ unsigned i;
+
+ for (i = 0; i < dm_table_get_num_targets(t); i++) {
+ ti = dm_table_get_target(t, i);
+
+ if (ti->type->iterate_devices &&
+ ti->type->iterate_devices(ti, device_dax_flush_capable, NULL))
+ return true;
+ }
+
+ return false;
+}
+
static int device_is_nonrot(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
@@ -1785,6 +1815,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
}
blk_queue_write_cache(q, wc, fua);
+ if (dm_table_supports_dax_flush(t))
+ dax_write_cache(t->md->dax_dev, true);
+
/* Ensure that all underlying devices are non-rotational. */
if (dm_table_all_devices_attribute(t, device_is_nonrot))
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 794811875732..df97b7af7e2c 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -87,6 +87,7 @@ size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
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);
/*
* We use lowest available bit in exceptional entry for locking, one bit for
--
2.13.3
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] dm,dax: Make sure dm_dax_flush() is called if device supports it
2017-07-25 19:43 [PATCH] dm,dax: Make sure dm_dax_flush() is called if device supports it Vivek Goyal
@ 2017-07-25 20:43 ` Dan Williams
2017-07-25 20:51 ` Vivek Goyal
2017-07-25 20:46 ` Mike Snitzer
1 sibling, 1 reply; 5+ messages in thread
From: Dan Williams @ 2017-07-25 20:43 UTC (permalink / raw)
To: Vivek Goyal; +Cc: dm-devel, Mike Snitzer, linux-nvdimm@lists.01.org
On Tue, Jul 25, 2017 at 12:43 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> Right now, dm_dax_flush() is not being called and I think it is not being
> called becuase DAXDEV_WRITE_CACHE is not set on dm dax device.
>
> If underlying dax device supports write cache, set DAXDEV_WRITE_CACHE on
> dm dax device. This will get dm_dax_flush() being called.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> ---
> drivers/dax/super.c | 5 +++++
> drivers/md/dm-table.c | 33 +++++++++++++++++++++++++++++++++
> include/linux/dax.h | 1 +
> 3 files changed, 39 insertions(+)
>
> diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> index ce9e563e6e1d..5c5e7b9f6831 100644
> --- a/drivers/dax/super.c
> +++ b/drivers/dax/super.c
> @@ -278,6 +278,11 @@ void dax_write_cache(struct dax_device *dax_dev, bool wc)
> }
> EXPORT_SYMBOL_GPL(dax_write_cache);
>
> +bool dax_write_cache_enabled(struct dax_device *dax_dev)
> +{
> + return test_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
> +}
We need :
EXPORT_SYMBOL_GPL(dax_write_cache_enabled)
...but other than that, looks good to me.
Acked-by: Dan Williams <dan.j.williams@intel.com>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: dm,dax: Make sure dm_dax_flush() is called if device supports it
2017-07-25 19:43 [PATCH] dm,dax: Make sure dm_dax_flush() is called if device supports it Vivek Goyal
2017-07-25 20:43 ` Dan Williams
@ 2017-07-25 20:46 ` Mike Snitzer
2017-07-25 20:54 ` Vivek Goyal
1 sibling, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2017-07-25 20:46 UTC (permalink / raw)
To: Vivek Goyal; +Cc: dm-devel, linux-nvdimm
On Tue, Jul 25 2017 at 3:43pm -0400,
Vivek Goyal <vgoyal@redhat.com> wrote:
> Right now, dm_dax_flush() is not being called and I think it is not being
> called becuase DAXDEV_WRITE_CACHE is not set on dm dax device.
>
> If underlying dax device supports write cache, set DAXDEV_WRITE_CACHE on
> dm dax device. This will get dm_dax_flush() being called.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
In general this looks mostly OK.. but it seems a bit weird to on the one
hand: test if DAXDEV_WRITE_CACHE is set on underlying device. And on
the other: say it is a write cache because it is "flush_capable". Kind
of blurring things a bit.
Why not s/device_dax_flush_capable/device_dax_write_cache_enabled/ ?
Mike
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm,dax: Make sure dm_dax_flush() is called if device supports it
2017-07-25 20:43 ` Dan Williams
@ 2017-07-25 20:51 ` Vivek Goyal
0 siblings, 0 replies; 5+ messages in thread
From: Vivek Goyal @ 2017-07-25 20:51 UTC (permalink / raw)
To: Dan Williams; +Cc: dm-devel, Mike Snitzer, linux-nvdimm@lists.01.org
On Tue, Jul 25, 2017 at 01:43:27PM -0700, Dan Williams wrote:
> On Tue, Jul 25, 2017 at 12:43 PM, Vivek Goyal <vgoyal@redhat.com> wrote:
> > Right now, dm_dax_flush() is not being called and I think it is not being
> > called becuase DAXDEV_WRITE_CACHE is not set on dm dax device.
> >
> > If underlying dax device supports write cache, set DAXDEV_WRITE_CACHE on
> > dm dax device. This will get dm_dax_flush() being called.
> >
> > Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> > ---
> > drivers/dax/super.c | 5 +++++
> > drivers/md/dm-table.c | 33 +++++++++++++++++++++++++++++++++
> > include/linux/dax.h | 1 +
> > 3 files changed, 39 insertions(+)
> >
> > diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> > index ce9e563e6e1d..5c5e7b9f6831 100644
> > --- a/drivers/dax/super.c
> > +++ b/drivers/dax/super.c
> > @@ -278,6 +278,11 @@ void dax_write_cache(struct dax_device *dax_dev, bool wc)
> > }
> > EXPORT_SYMBOL_GPL(dax_write_cache);
> >
> > +bool dax_write_cache_enabled(struct dax_device *dax_dev)
> > +{
> > + return test_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
> > +}
>
> We need :
>
> EXPORT_SYMBOL_GPL(dax_write_cache_enabled)
>
> ...but other than that, looks good to me.
Aha, missed that. Will fix in next version.
Vivek
>
> Acked-by: Dan Williams <dan.j.williams@intel.com>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: dm,dax: Make sure dm_dax_flush() is called if device supports it
2017-07-25 20:46 ` Mike Snitzer
@ 2017-07-25 20:54 ` Vivek Goyal
0 siblings, 0 replies; 5+ messages in thread
From: Vivek Goyal @ 2017-07-25 20:54 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel, linux-nvdimm
On Tue, Jul 25, 2017 at 04:46:09PM -0400, Mike Snitzer wrote:
> On Tue, Jul 25 2017 at 3:43pm -0400,
> Vivek Goyal <vgoyal@redhat.com> wrote:
>
> > Right now, dm_dax_flush() is not being called and I think it is not being
> > called becuase DAXDEV_WRITE_CACHE is not set on dm dax device.
> >
> > If underlying dax device supports write cache, set DAXDEV_WRITE_CACHE on
> > dm dax device. This will get dm_dax_flush() being called.
> >
> > Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
>
> In general this looks mostly OK.. but it seems a bit weird to on the one
> hand: test if DAXDEV_WRITE_CACHE is set on underlying device. And on
> the other: say it is a write cache because it is "flush_capable". Kind
> of blurring things a bit.
>
> Why not s/device_dax_flush_capable/device_dax_write_cache_enabled/ ?
Sounds good. I will rename it in next version.
Vivek
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-25 20:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-25 19:43 [PATCH] dm,dax: Make sure dm_dax_flush() is called if device supports it Vivek Goyal
2017-07-25 20:43 ` Dan Williams
2017-07-25 20:51 ` Vivek Goyal
2017-07-25 20:46 ` Mike Snitzer
2017-07-25 20:54 ` Vivek Goyal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox