Skip to content

Commit 1683ed1

Browse files
xp4ns3amschuma-ntap
authored andcommitted
fs/nfs: Replace kmap_atomic() with kmap_local_page() in dir.c
kmap_atomic() is deprecated in favor of kmap_local_page(). With kmap_local_page() the mappings are per thread, CPU local, can take page-faults, and can be called from any context (including interrupts). Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels, otherwise it only disables migration). The code within the mappings/un-mappings in the functions of dir.c don't depend on the above-mentioned side effects of kmap_atomic(), so that mere replacements of the old API with the new one is all that is required (i.e., there is no need to explicitly add calls to pagefault_disable() and/or preempt_disable()). Therefore, replace kmap_atomic() with kmap_local_page() in fs/nfs/dir.c. Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled. Suggested-by: Ira Weiny <[email protected]> Signed-off-by: Fabio M. De Francesco <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 28d4411 commit 1683ed1

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

fs/nfs/dir.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ static void nfs_readdir_page_init_array(struct page *page, u64 last_cookie,
203203
{
204204
struct nfs_cache_array *array;
205205

206-
array = kmap_atomic(page);
206+
array = kmap_local_page(page);
207207
array->change_attr = change_attr;
208208
array->last_cookie = last_cookie;
209209
array->size = 0;
210210
array->page_full = 0;
211211
array->page_is_eof = 0;
212212
array->cookies_are_ordered = 1;
213-
kunmap_atomic(array);
213+
kunmap_local(array);
214214
}
215215

216216
/*
@@ -221,11 +221,11 @@ static void nfs_readdir_clear_array(struct page *page)
221221
struct nfs_cache_array *array;
222222
unsigned int i;
223223

224-
array = kmap_atomic(page);
224+
array = kmap_local_page(page);
225225
for (i = 0; i < array->size; i++)
226226
kfree(array->array[i].name);
227227
array->size = 0;
228-
kunmap_atomic(array);
228+
kunmap_local(array);
229229
}
230230

231231
static void nfs_readdir_free_folio(struct folio *folio)
@@ -371,14 +371,14 @@ static pgoff_t nfs_readdir_page_cookie_hash(u64 cookie)
371371
static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie,
372372
u64 change_attr)
373373
{
374-
struct nfs_cache_array *array = kmap_atomic(page);
374+
struct nfs_cache_array *array = kmap_local_page(page);
375375
int ret = true;
376376

377377
if (array->change_attr != change_attr)
378378
ret = false;
379379
if (nfs_readdir_array_index_cookie(array) != last_cookie)
380380
ret = false;
381-
kunmap_atomic(array);
381+
kunmap_local(array);
382382
return ret;
383383
}
384384

@@ -418,9 +418,9 @@ static u64 nfs_readdir_page_last_cookie(struct page *page)
418418
struct nfs_cache_array *array;
419419
u64 ret;
420420

421-
array = kmap_atomic(page);
421+
array = kmap_local_page(page);
422422
ret = array->last_cookie;
423-
kunmap_atomic(array);
423+
kunmap_local(array);
424424
return ret;
425425
}
426426

@@ -429,19 +429,19 @@ static bool nfs_readdir_page_needs_filling(struct page *page)
429429
struct nfs_cache_array *array;
430430
bool ret;
431431

432-
array = kmap_atomic(page);
432+
array = kmap_local_page(page);
433433
ret = !nfs_readdir_array_is_full(array);
434-
kunmap_atomic(array);
434+
kunmap_local(array);
435435
return ret;
436436
}
437437

438438
static void nfs_readdir_page_set_eof(struct page *page)
439439
{
440440
struct nfs_cache_array *array;
441441

442-
array = kmap_atomic(page);
442+
array = kmap_local_page(page);
443443
nfs_readdir_array_set_eof(array);
444-
kunmap_atomic(array);
444+
kunmap_local(array);
445445
}
446446

447447
static struct page *nfs_readdir_page_get_next(struct address_space *mapping,
@@ -568,14 +568,14 @@ static int nfs_readdir_search_array(struct nfs_readdir_descriptor *desc)
568568
struct nfs_cache_array *array;
569569
int status;
570570

571-
array = kmap_atomic(desc->page);
571+
array = kmap_local_page(desc->page);
572572

573573
if (desc->dir_cookie == 0)
574574
status = nfs_readdir_search_for_pos(array, desc);
575575
else
576576
status = nfs_readdir_search_for_cookie(array, desc);
577577

578-
kunmap_atomic(array);
578+
kunmap_local(array);
579579
return status;
580580
}
581581

0 commit comments

Comments
 (0)