]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: convert kmap to kmap_local_page, simple cases
authorIra Weiny <ira.weiny@intel.com>
Wed, 17 Feb 2021 02:48:23 +0000 (18:48 -0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 6 Apr 2021 13:35:55 +0000 (15:35 +0200)
commit2c86fe22b41edea15ade7d2b456bfd98b870b70d
tree50577c2f08e9422d50f438f302e4eb9dc8bcfb79
parenta01f305823ecccebf51f243a02ed8aa2018a8920
btrfs: convert kmap to kmap_local_page, simple cases

Use a simple coccinelle script to help convert the most common
kmap()/kunmap() patterns to kmap_local_page()/kunmap_local().

Note that some kmaps which were caught by this script needed to be
handled by hand because of the strict unmapping order of kunmap_local()
so they are not included in this patch.  But this script got us started.

There's another temp variable added for the final length write to the
first page so it does not interfere with cpage_out that is used for
mapping other pages.

The development of this patch was aided by the follow script:

// <smpl>
// SPDX-License-Identifier: GPL-2.0-only
// Find kmap and replace with kmap_local_page then mark kunmap
//
// Confidence: Low
// Copyright: (C) 2021 Intel Corporation
// URL: http://coccinelle.lip6.fr/

@ catch_all @
expression e, e2;
@@

(
-kmap(e)
+kmap_local_page(e)
)
...
(
-kunmap(...)
+kunmap_local()
)

// </smpl>

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/inode.c
fs/btrfs/lzo.c
fs/btrfs/raid56.c