nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] dax: add missing address_space_operations for device dax
@ 2018-09-10 23:18 Dave Jiang
  2018-09-13 18:25 ` Jeff Moyer
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jiang @ 2018-09-10 23:18 UTC (permalink / raw)
  To: dan.j.williams; +Cc: linux-nvdimm

With address_space_operations missing for device dax, namely the
.set_page_dirty, we hit a kernel warning when running destructive
ndctl unit test: make TESTS=device-dax check

WARNING: CPU: 3 PID: 7380 at fs/buffer.c:581 __set_page_dirty+0xb1/0xc0

Setting address_space_operations to noop_set_page_dirty and
noop_invalidatepage for device dax to prevent fallback to
__set_page_dirty_buffers() and block_invalidatepage() respectively.

Fixes: 2232c6382a ("device-dax: Enable page_mapping()")

Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/dax/device.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/dax/device.c b/drivers/dax/device.c
index 6fd46083e629..079f6811eca6 100644
--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@ -534,6 +534,11 @@ static unsigned long dax_get_unmapped_area(struct file *filp,
 	return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
 }
 
+static const struct address_space_operations dev_dax_aops = {
+	.set_page_dirty		= noop_set_page_dirty,
+	.invalidatepage		= noop_invalidatepage,
+};
+
 static int dax_open(struct inode *inode, struct file *filp)
 {
 	struct dax_device *dax_dev = inode_dax(inode);
@@ -543,6 +548,7 @@ static int dax_open(struct inode *inode, struct file *filp)
 	dev_dbg(&dev_dax->dev, "trace\n");
 	inode->i_mapping = __dax_inode->i_mapping;
 	inode->i_mapping->host = __dax_inode;
+	inode->i_mapping->a_ops = &dev_dax_aops;
 	filp->f_mapping = inode->i_mapping;
 	filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
 	filp->private_data = dev_dax;

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dax: add missing address_space_operations for device dax
  2018-09-10 23:18 [PATCH] dax: add missing address_space_operations for device dax Dave Jiang
@ 2018-09-13 18:25 ` Jeff Moyer
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Moyer @ 2018-09-13 18:25 UTC (permalink / raw)
  To: Dave Jiang; +Cc: linux-nvdimm

Dave Jiang <dave.jiang@intel.com> writes:

> With address_space_operations missing for device dax, namely the
> .set_page_dirty, we hit a kernel warning when running destructive
> ndctl unit test: make TESTS=device-dax check
>
> WARNING: CPU: 3 PID: 7380 at fs/buffer.c:581 __set_page_dirty+0xb1/0xc0
>
> Setting address_space_operations to noop_set_page_dirty and
> noop_invalidatepage for device dax to prevent fallback to
> __set_page_dirty_buffers() and block_invalidatepage() respectively.
>
> Fixes: 2232c6382a ("device-dax: Enable page_mapping()")
>
> Reported-by: Vishal Verma <vishal.l.verma@intel.com>
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>

I looked over the other aops, and I think this covers the fallback
paths.

Acked-by: Jeff Moyer <jmoyer@redhat.com>

> ---
>  drivers/dax/device.c |    6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> index 6fd46083e629..079f6811eca6 100644
> --- a/drivers/dax/device.c
> +++ b/drivers/dax/device.c
> @@ -534,6 +534,11 @@ static unsigned long dax_get_unmapped_area(struct file *filp,
>  	return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
>  }
>  
> +static const struct address_space_operations dev_dax_aops = {
> +	.set_page_dirty		= noop_set_page_dirty,
> +	.invalidatepage		= noop_invalidatepage,
> +};
> +
>  static int dax_open(struct inode *inode, struct file *filp)
>  {
>  	struct dax_device *dax_dev = inode_dax(inode);
> @@ -543,6 +548,7 @@ static int dax_open(struct inode *inode, struct file *filp)
>  	dev_dbg(&dev_dax->dev, "trace\n");
>  	inode->i_mapping = __dax_inode->i_mapping;
>  	inode->i_mapping->host = __dax_inode;
> +	inode->i_mapping->a_ops = &dev_dax_aops;
>  	filp->f_mapping = inode->i_mapping;
>  	filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
>  	filp->private_data = dev_dax;
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-13 18:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 23:18 [PATCH] dax: add missing address_space_operations for device dax Dave Jiang
2018-09-13 18:25 ` Jeff Moyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).