From: Fabio M. De Francesco Date: Tue, 31 May 2022 14:53:33 +0000 (+0200) Subject: btrfs: replace kmap() with kmap_local_page() in inode.c X-Git-Tag: baikal/mips/sdk6.1~5160^2~110 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=ceb419860e8cc6a0a77a9ba9d8ab32031039255f;p=kernel.git btrfs: replace kmap() with kmap_local_page() in inode.c The use of kmap() is being deprecated in favor of kmap_local_page() where it is feasible. With kmap_local_page(), the mapping is per thread, CPU local and not globally visible. Therefore, use kmap_local_page() / kunmap_local() in inode.c wherever the mappings are per thread and not globally visible. Tested on QEMU + KVM 32 bits VM with 4GB of RAM and HIGHMEM64G enabled. Suggested-by: Ira Weiny Reviewed-by: Christoph Hellwig Signed-off-by: Fabio M. De Francesco Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9cce0a3228f83..92dca0e0d2073 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10760,15 +10760,15 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from, ret = -ENOMEM; goto out_pages; } - kaddr = kmap(pages[i]); + kaddr = kmap_local_page(pages[i]); if (copy_from_iter(kaddr, bytes, from) != bytes) { - kunmap(pages[i]); + kunmap_local(kaddr); ret = -EFAULT; goto out_pages; } if (bytes < PAGE_SIZE) memset(kaddr + bytes, 0, PAGE_SIZE - bytes); - kunmap(pages[i]); + kunmap_local(kaddr); } for (;;) {