Skip to contentSkip to conversation

DAX Small clean ups

PATCH In review [email protected] 3 participants 7 messages May 25, 2021 – Jun 18, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover DAX Small clean ups

From: Ira Weiny <[email protected]>

The following are 3 unrelated small clean ups in the dax area. They were found while working on PMEM stray write protection.

Ira Weiny (3):
fs/fuse: Remove unneeded kaddr parameter fs/dax: Clarify nr_pages to dax_direct_access()
dax: Ensure errno is returned from dax_direct_access

 drivers/dax/super.c | 2 +-
 fs/dax.c            | 2 +-
 fs/fuse/dax.c       | 6 ++----
 3 files changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
#1 lore raw

PATCH 1/3 fs/fuse: Remove unneeded kaddr parameter

From: Ira Weiny <[email protected]>

fuse_dax_mem_range_init() does not need the address or the pfn of the memory requested in dax_direct_access(). It is only calling direct access to get the number of pages.

Remove the unused variables and stop requesting the kaddr and pfn from dax_direct_access().

---
 fs/fuse/dax.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/fuse/dax.c +2 -4
index ff99ab2a3c43..34f8a5635c7f 100644
@@ -1234,8 +1234,6 @@ void fuse_dax_conn_free(struct fuse_conn *fc)
 static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
 {
 	long nr_pages, nr_ranges;
-	void *kaddr;
-	pfn_t pfn;
 	struct fuse_dax_mapping *range;
 	int ret, id;
 	size_t dax_size = -1;
@@ -1247,8 +1245,8 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
 	INIT_DELAYED_WORK(&fcd->free_work, fuse_dax_free_mem_worker);
 
 	id = dax_read_lock();
-	nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), &kaddr,
-				     &pfn);
+	nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), NULL,
+				     NULL);
 	dax_read_unlock(id);
 	if (nr_pages < 0) {
 		pr_debug("dax_direct_access() returned %ld\n", nr_pages);
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
author
#2 lore raw

Re: [PATCH 1/3] fs/fuse: Remove unneeded kaddr parameter

Quoted 5 lines · Ira Weiny

From: Ira Weiny <[email protected]>

fuse_dax_mem_range_init() does not need the address or the pfn of the memory requested in dax_direct_access(). It is only calling direct access to get the number of pages.

In looking for feedback on this small series I realize that I failed to email Miklos for the fs/fuse patch.

I'm adding Miklos to the To line...

For the rest of the series is there any feedback?

Ira

Quoted 37 lines

Remove the unused variables and stop requesting the kaddr and pfn from dax_direct_access().

---
 fs/fuse/dax.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/fuse/dax.c +2 -4
index ff99ab2a3c43..34f8a5635c7f 100644
@@ -1234,8 +1234,6 @@ void fuse_dax_conn_free(struct fuse_conn *fc)
 static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
 {
 	long nr_pages, nr_ranges;
-	void *kaddr;
-	pfn_t pfn;
 	struct fuse_dax_mapping *range;
 	int ret, id;
 	size_t dax_size = -1;
@@ -1247,8 +1245,8 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
 	INIT_DELAYED_WORK(&fcd->free_work, fuse_dax_free_mem_worker);
 
 	id = dax_read_lock();
-	nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), &kaddr,
-				     &pfn);
+	nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), NULL,
+				     NULL);
 	dax_read_unlock(id);
 	if (nr_pages < 0) {
 		pr_debug("dax_direct_access() returned %ld\n", nr_pages);
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
maintainer
#3 lore raw

Re: [PATCH 1/3] fs/fuse: Remove unneeded kaddr parameter

Quoted 4 lines · Ira Weiny
Quoted 2 lines · Ira Weiny

From: Ira Weiny <[email protected]>

Quoted 8 lines
Quoted 3 lines

fuse_dax_mem_range_init() does not need the address or the pfn of the memory requested in dax_direct_access(). It is only calling direct access to get the number of pages.

In looking for feedback on this small series I realize that I failed to email Miklos for the fs/fuse patch.

I'm adding Miklos to the To line...

LGTM, but this is Vivek's code, so adding Cc.

Thanks,
Miklos

Quoted 42 lines

For the rest of the series is there any feedback?

Ira

Quoted 37 lines

Remove the unused variables and stop requesting the kaddr and pfn from dax_direct_access().

---
 fs/fuse/dax.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/fuse/dax.c +2 -5
index ff99ab2a3c43..34f8a5635c7f 100644
@@ -1234,8 +1234,6 @@ void fuse_dax_conn_free(struct fuse_conn *fc)
 static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
 {
      long nr_pages, nr_ranges;
-     void *kaddr;
-     pfn_t pfn;
      struct fuse_dax_mapping *range;
      int ret, id;
      size_t dax_size = -1;
@@ -1247,8 +1245,8 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
      INIT_DELAYED_WORK(&fcd->free_work, fuse_dax_free_mem_worker);
 
      id = dax_read_lock();
-     nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), &kaddr,
-                                  &pfn);
+     nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), NULL,
+                                  NULL);
      dax_read_unlock(id);
      if (nr_pages < 0) {
              pr_debug("dax_direct_access() returned %ld\n", nr_pages);
--

2.28.0.rc0.12.gb6a658bd00c9

Reviewed-by
#4 lore raw

Re: [PATCH 1/3] fs/fuse: Remove unneeded kaddr parameter

Quoted 9 lines · Miklos Szeredi
Quoted 8 lines · Ira Weiny
Quoted 5 lines · Ira Weiny

From: Ira Weiny <[email protected]>

fuse_dax_mem_range_init() does not need the address or the pfn of the memory requested in dax_direct_access(). It is only calling direct access to get the number of pages.

Quoted 7 lines
Quoted 4 lines

In looking for feedback on this small series I realize that I failed to email Miklos for the fs/fuse patch.

I'm adding Miklos to the To line...

LGTM, but this is Vivek's code, so adding Cc.

Looks good to me as well. We are not using pfn and kaddr in fuse_dax_mem_range_init().

Thanks
Vivek

Quoted 47 lines

Thanks,
Miklos

Quoted 42 lines

For the rest of the series is there any feedback?

Ira

Quoted 37 lines

Remove the unused variables and stop requesting the kaddr and pfn from dax_direct_access().

---
 fs/fuse/dax.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/fuse/dax.c +2 -5
index ff99ab2a3c43..34f8a5635c7f 100644
@@ -1234,8 +1234,6 @@ void fuse_dax_conn_free(struct fuse_conn *fc)
 static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
 {
      long nr_pages, nr_ranges;
-     void *kaddr;
-     pfn_t pfn;
      struct fuse_dax_mapping *range;
      int ret, id;
      size_t dax_size = -1;
@@ -1247,8 +1245,8 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd)
      INIT_DELAYED_WORK(&fcd->free_work, fuse_dax_free_mem_worker);
 
      id = dax_read_lock();
-     nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), &kaddr,
-                                  &pfn);
+     nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), NULL,
+                                  NULL);
      dax_read_unlock(id);
      if (nr_pages < 0) {
              pr_debug("dax_direct_access() returned %ld\n", nr_pages);
--

2.28.0.rc0.12.gb6a658bd00c9

#5 lore raw

PATCH 2/3 fs/dax: Clarify nr_pages to dax_direct_access()

In reply to [email protected]

From: Ira Weiny <[email protected]>

dax_direct_access() takes a number of pages. PHYS_PFN(PAGE_SIZE) is a very round about way to specify '1'.

Change the nr_pages parameter to the explicit value of '1'.

---
 fs/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dax.c +1 -1
index b3d27fdc6775..07621322aeee 100644
@@ -710,7 +710,7 @@ static int copy_cow_page_dax(struct block_device *bdev, struct dax_device *dax_d
 		return rc;
 
 	id = dax_read_lock();
-	rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(PAGE_SIZE), &kaddr, NULL);
+	rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL);
 	if (rc < 0) {
 		dax_read_unlock(id);
 		return rc;
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9
#6 lore raw

PATCH 3/3 dax: Ensure errno is returned from dax_direct_access

In reply to [email protected]

From: Ira Weiny <[email protected]>

If the caller specifies a negative nr_pages that is an invalid parameter.

Return -EINVAL to ensure callers get an errno if they want to check it.

---
 drivers/dax/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +1 -1
index 5fa6ae9dbc8b..44736cbd446e 100644
@@ -313,7 +313,7 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
 		return -ENXIO;
 
 	if (nr_pages < 0)
-		return nr_pages;
+		return -EINVAL;
 
 	avail = dax_dev->ops->direct_access(dax_dev, pgoff, nr_pages,
 			kaddr, pfn);
Signature · 1 line
2.28.0.rc0.12.gb6a658bd00c9