Commit 4cb2e5e8 authored by Fabio M. De Francesco's avatar Fabio M. De Francesco Committed by David Sterba

btrfs: replace kmap_atomic() with kmap_local_page()

kmap_atomic() is being deprecated in favor of kmap_local_page() where it
is feasible. With kmap_local_page() mappings are per thread, CPU local,
and not globally visible.

The last use of kmap_atomic is in inode.c where the context is atomic [1]
and can be safely replaced by kmap_local_page.

Tested with xfstests on a QEMU + KVM 32-bits VM with 4GB RAM and booting a
kernel with HIGHMEM64GB enabled.

[1] https://lore.kernel.org/linux-btrfs/20220601132545.GM20633@twin.jikos.cz/Suggested-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarFabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 5a6e6e7c
...@@ -333,9 +333,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, ...@@ -333,9 +333,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
cur_size = min_t(unsigned long, compressed_size, cur_size = min_t(unsigned long, compressed_size,
PAGE_SIZE); PAGE_SIZE);
kaddr = kmap_atomic(cpage); kaddr = kmap_local_page(cpage);
write_extent_buffer(leaf, kaddr, ptr, cur_size); write_extent_buffer(leaf, kaddr, ptr, cur_size);
kunmap_atomic(kaddr); kunmap_local(kaddr);
i++; i++;
ptr += cur_size; ptr += cur_size;
...@@ -346,9 +346,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, ...@@ -346,9 +346,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
} else { } else {
page = find_get_page(inode->vfs_inode.i_mapping, 0); page = find_get_page(inode->vfs_inode.i_mapping, 0);
btrfs_set_file_extent_compression(leaf, ei, 0); btrfs_set_file_extent_compression(leaf, ei, 0);
kaddr = kmap_atomic(page); kaddr = kmap_local_page(page);
write_extent_buffer(leaf, kaddr, ptr, size); write_extent_buffer(leaf, kaddr, ptr, size);
kunmap_atomic(kaddr); kunmap_local(kaddr);
put_page(page); put_page(page);
} }
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment