Skip to contentSkip to conversation

NFS: Convert kmap_atomic() to kmap_local_folio()

PATCH In review Fabio M. De Francesco 2 participants 2 messages May 3, 2023

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

PATCH 1/1 NFS: Convert kmap_atomic() to kmap_local_folio()

kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().

Therefore, replace kmap_atomic() with kmap_local_folio() in nfs_readdir_folio_array_append().

kmap_atomic() disables page-faults and preemption (the latter only for !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in nfs_readdir_folio_array_append() does not depend on the above-mentioned side effects.

Therefore, a mere replacement of the old API with the new one is all that is required (i.e., there is no need to explicitly add any calls to pagefault_disable() and/or preempt_disable()).

Tested with (x)fstests in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled.

---

"./check -nfs -g quick", with or without this patch, always fails the same 12 tests of 559: generic/053 generic/099 generic/105 generic/193 generic/294 generic/318 generic/319 generic/444 generic/465 generic/528 generic/529 generic/531.

Therefore, I think I can say that this patch does not introduce any regressions.

 fs/nfs/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +2 -2
index 8257de6dba45..8fa8ae49d6cd 100644
@@ -317,7 +317,7 @@ static int nfs_readdir_folio_array_append(struct folio *folio,
 
 	name = nfs_readdir_copy_name(entry->name, entry->len);
 
-	array = kmap_atomic(folio_page(folio, 0));
+	array = kmap_local_folio(folio, 0);
 	if (!name)
 		goto out;
 	ret = nfs_readdir_array_can_expand(array);
@@ -340,7 +340,7 @@ static int nfs_readdir_folio_array_append(struct folio *folio,
 		nfs_readdir_array_set_eof(array);
 out:
 	*cookie = array->last_cookie;
-	kunmap_atomic(array);
+	kunmap_local(array);
 	return ret;
 }
 
Signature · 1 line
2.40.0
maintainer
#1 lore raw
Quoted 11 lines · Fabio M. De Francesco

kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().

Therefore, replace kmap_atomic() with kmap_local_folio() in nfs_readdir_folio_array_append().

kmap_atomic() disables page-faults and preemption (the latter only for !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in nfs_readdir_folio_array_append() does not depend on the above-mentioned side effects.

Quoted 6 lines

Therefore, a mere replacement of the old API with the new one is all that is required (i.e., there is no need to explicitly add any calls to pagefault_disable() and/or preempt_disable()).

Tested with (x)fstests in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled.

Thanks Fabio! Looks like I missed this when I wrote: ec108d3cc766 ("NFS: Convert readdir page array functions to use a folio")

I have it applied now.

Anna

Quoted 41 lines

---

"./check -nfs -g quick", with or without this patch, always fails the same 12 tests of 559: generic/053 generic/099 generic/105 generic/193 generic/294 generic/318 generic/319 generic/444 generic/465 generic/528 generic/529 generic/531.

Therefore, I think I can say that this patch does not introduce any regressions.

 fs/nfs/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +2 -3
index 8257de6dba45..8fa8ae49d6cd 100644
@@ -317,7 +317,7 @@ static int nfs_readdir_folio_array_append(struct folio *folio,
 
        name = nfs_readdir_copy_name(entry->name, entry->len);
 
-       array = kmap_atomic(folio_page(folio, 0));
+       array = kmap_local_folio(folio, 0);
        if (!name)
                goto out;
        ret = nfs_readdir_array_can_expand(array);
@@ -340,7 +340,7 @@ static int nfs_readdir_folio_array_append(struct folio *folio,
                nfs_readdir_array_set_eof(array);
 out:
        *cookie = array->last_cookie;
-       kunmap_atomic(array);
+       kunmap_local(array);
        return ret;
 }
 
--

2.40.0