Thread (30 messages) 30 messages, 3 authors, 2020-07-14
STALE2177d
Revisions (2)
  1. rfc current
  2. v2 [diff vs current]

[RFC PATCH 13/15] dax: Stray write protection for dax_direct_access()

From: <hidden>
Date: 2020-07-14 07:04:52
Also in: linux-fsdevel, linux-kselftest, linux-mm, lkml, nvdimm
Subsystem: device direct access (dax), the rest · Maintainers: Dan Williams, Vishal Verma, Dave Jiang, Alison Schofield, Linus Torvalds

From: Ira Weiny <redacted>

dax_direct_access() is a special case of accessing pmem via a page
offset and without a struct page.

Because the dax driver is well aware of the special protections it has
mapped memory with, call dev_access_[en|dis]able() directly instead of
the unnecessary overhead of trying to get a page to kmap.

Like kmap though, leverage the existing dax_read[un]lock() functions
because they are already required to surround the use of the memory
returned from dax_direct_access().

Signed-off-by: Ira Weiny <redacted>
---
 drivers/dax/super.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 021739768093..e8d0a28e6ed2 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -30,12 +30,14 @@ static DEFINE_SPINLOCK(dax_host_lock);
 
 int dax_read_lock(void)
 {
+	dev_access_enable();
 	return srcu_read_lock(&dax_srcu);
 }
 EXPORT_SYMBOL_GPL(dax_read_lock);
 
 void dax_read_unlock(int id)
 {
+	dev_access_disable();
 	srcu_read_unlock(&dax_srcu, id);
 }
 EXPORT_SYMBOL_GPL(dax_read_unlock);
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help