Re: [PATCH v2 1/3] block: add QUEUE_FLAG_DAX for devices to advertise their DAX support

From: Kani, Toshimitsu
Date: Thu Jun 23 2016 - 13:36:37 EST


On Thu, 2016-06-23 at 19:31 +0300, Yigal Korman wrote:
> On Thu, Jun 23, 2016 at 2:54 AM, Toshi Kani <toshi.kani@xxxxxxx> wrote:
> >
> >
> > Currently, presence of direct_access() in block_device_operations
> > indicates support of DAX on its block device.ÂÂBecause
> > block_device_operations is instantiated with 'const', this DAX
> > capablity may not be enabled conditinally.
> >
> > In preparation for supporting DAX to device-mapper devices, add
> > QUEUE_FLAG_DAX to request_queue flags to advertise their DAX
> > support.ÂÂThis will allow to set the DAX capability based on how
> > mapped device is composed.
>
> Hi Toshi,
> This patch is very helpful!
> I think QUEUE_FLAG_DAX can also help with identifying dax devices in
> userspace.
> Perhaps you'd be willing to squash the patch below with this one or
> add it to your submission?

Hi Yigal,

Good idea. ÂMike can probably take it into his tree, but I will include it
into the series if I needed to submit v3.

Acked-by: Toshi Kani <toshi.kani@xxxxxxx>

I have one minor comment below.

> [PATCH] block: expose QUEUE_FLAG_DAX in sysfs
>
> There's currently no way to identify DAX enabled devices in userspace.
>
> Signed-off-by: Yigal Korman <yigal@xxxxxxxxxxxxx>
> ---
> Âblock/blk-sysfs.c | 15 +++++++++++++++
> Â1 file changed, 15 insertions(+)
>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 9920596..d55126d 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -379,6 +379,15 @@ static ssize_t queue_wc_store(struct
> request_queue *q, const char *page,
> ÂÂÂÂÂÂÂÂreturn count;
> Â}
>
> +static ssize_t queue_dax_show(struct request_queue *q, char *page)
> +{
> +ÂÂÂÂÂÂÂint bit;
> +
> +ÂÂÂÂÂÂÂbit = test_bit(QUEUE_FLAG_DAX, &q->queue_flags);
> +
> +ÂÂÂÂÂÂÂreturn queue_var_show(bit, page);

This can be:
return queue_var_show(blk_queue_dax(q), page);

Thanks,
-Toshi

> +}
> +
> Âstatic struct queue_sysfs_entry queue_requests_entry = {
> ÂÂÂÂÂÂÂÂ.attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
> ÂÂÂÂÂÂÂÂ.show = queue_requests_show,
> @@ -516,6 +525,11 @@ static struct queue_sysfs_entry queue_wc_entry = {
> ÂÂÂÂÂÂÂÂ.store = queue_wc_store,
> Â};
>
> +static struct queue_sysfs_entry queue_dax_entry = {
> +ÂÂÂÂÂÂÂ.attr = {.name = "dax", .mode = S_IRUGO },
> +ÂÂÂÂÂÂÂ.show = queue_dax_show,
> +};
> +
> Âstatic struct attribute *default_attrs[] = {
> ÂÂÂÂÂÂÂÂ&queue_requests_entry.attr,
> ÂÂÂÂÂÂÂÂ&queue_ra_entry.attr,
> @@ -542,6 +556,7 @@ static struct attribute *default_attrs[] = {
> ÂÂÂÂÂÂÂÂ&queue_random_entry.attr,
> ÂÂÂÂÂÂÂÂ&queue_poll_entry.attr,
> ÂÂÂÂÂÂÂÂ&queue_wc_entry.attr,
> +ÂÂÂÂÂÂÂ&queue_dax_entry.attr,
> ÂÂÂÂÂÂÂÂNULL,
> Â};
>