btrfs: replace kmap_atomic() with kmap_local_page()
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Mon, 27 Jun 2022 17:48:49 +0000 (19:48 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Jul 2022 15:45:41 +0000 (17:45 +0200)
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: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index b04280a682316e9501e29f00f2da4572ec486af1..b26bb73d9b33c07e3ac8e3ad028d3c1db9809417 100644 (file)
@@ -333,9 +333,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
                        cur_size = min_t(unsigned long, compressed_size,
                                       PAGE_SIZE);
 
-                       kaddr = kmap_atomic(cpage);
+                       kaddr = kmap_local_page(cpage);
                        write_extent_buffer(leaf, kaddr, ptr, cur_size);
-                       kunmap_atomic(kaddr);
+                       kunmap_local(kaddr);
 
                        i++;
                        ptr += cur_size;
@@ -346,9 +346,9 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
        } else {
                page = find_get_page(inode->vfs_inode.i_mapping, 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);
-               kunmap_atomic(kaddr);
+               kunmap_local(kaddr);
                put_page(page);
        }
        btrfs_mark_buffer_dirty(leaf);