From nobody Thu Apr 30 09:44:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B88BC433EF for ; Tue, 31 May 2022 14:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345374AbiEaOx5 (ORCPT ); Tue, 31 May 2022 10:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345358AbiEaOxw (ORCPT ); Tue, 31 May 2022 10:53:52 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EBA6E0BC; Tue, 31 May 2022 07:53:51 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id jx22so27075235ejb.12; Tue, 31 May 2022 07:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RnajSFs4DgNty7orDHrdOsB6V8V9bgUOexGBItj7yYs=; b=GBlM8XU0qqk8vyk41ayssiwNPIoeSPm+2C7ymoFOplfcpeTEoZGk4Lg80r4Fqgp121 YoCXvJqNiZjMb6irJ/9l2/gQmRWKZjL9QItxahSUlfVuNPAd4QZI26i+XWwFcU0NO3VV zooiinLqh35iJY4jxittDYK/FZAs4pCybdyrMd/kENTpZJOGPKUEBFNCM301/kr1rxW9 jaURHUb79an6UfYD4XykBrg80NYnHvyprT3q+U4sLq8OOE0QQUpNoVXlcZQ5G9oLGg6Q A9UPShsdvkgkNctAxa4edKhNpOZ0AaJy/f+q15YBWFU29jzolO96JdEh+erFwaLujxt1 /QwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RnajSFs4DgNty7orDHrdOsB6V8V9bgUOexGBItj7yYs=; b=dHk3nsXs03m57yg+Wju1aS4FhGvInCI+/EyHOw80BMgoqsT6+sVn+WFYkhln/47EFQ wdhNGHQ0wR00jro8CWsTEIDwzU0Je8FM8TQIL6FV0Xkp3yRGazQ/QG2jgEt9FCmzjlD7 NTmFK0xohxLzwduGuzgSiTW1EGKVsY79kS0ix/fHewuSrhMbM9/+iPB9LF05rWF4+4+m ktG7kQIQy4k/ctKOVKiY5vE5aUCW/IWoavCkM7yk33VvyOc+VpwReK6v9RpEgO+cr7nm z5dImQbuWVZ5zT3qJogUKK0Ex59EPFgPkMNTZOtqY3ri1F4rXKcFsfSq1l+LYIoBIBtK CM/w== X-Gm-Message-State: AOAM533HVo6JEqIfC6D7m3SuqP1kxBxDu4XiNKXqfjugL04dBHXbRBNz +buCW9jkbK+k0PwgpHmmaRc= X-Google-Smtp-Source: ABdhPJw64XzgP9z2G8cT5/Kennf/6dTzejX79K/0JkHCfm7gsLms53C8QzJH9B9IT5F9dRyd4NG9wA== X-Received: by 2002:a17:907:7291:b0:6f9:a3b5:7ce4 with SMTP id dt17-20020a170907729100b006f9a3b57ce4mr54645962ejc.642.1654008829486; Tue, 31 May 2022 07:53:49 -0700 (PDT) Received: from localhost.localdomain (host-79-55-12-155.retail.telecomitalia.it. [79.55.12.155]) by smtp.gmail.com with ESMTPSA id c2-20020a17090603c200b006fea59ef3a5sm5099779eja.32.2022.05.31.07.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 07:53:48 -0700 (PDT) From: "Fabio M. De Francesco" To: Chris Mason , Josef Bacik , David Sterba , Ira Weiny , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH 1/3] btrfs: Replace kmap() with kmap_local_page() in inode.c Date: Tue, 31 May 2022 16:53:33 +0200 Message-Id: <20220531145335.13954-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220531145335.13954-1-fmdefrancesco@gmail.com> References: <20220531145335.13954-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Fabio M. De Francesco Reviewed-by: Christoph Hellwig --- fs/btrfs/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 81737eff92f3..7d84d57a0653 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10779,15 +10779,15 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb= , struct iov_iter *from, ret =3D -ENOMEM; goto out_pages; } - kaddr =3D kmap(pages[i]); + kaddr =3D kmap_local_page(pages[i]); if (copy_from_iter(kaddr, bytes, from) !=3D bytes) { - kunmap(pages[i]); + kunmap_local(kaddr); ret =3D -EFAULT; goto out_pages; } if (bytes < PAGE_SIZE) memset(kaddr + bytes, 0, PAGE_SIZE - bytes); - kunmap(pages[i]); + kunmap_local(kaddr); } =20 for (;;) { --=20 2.36.1 From nobody Thu Apr 30 09:44:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B103FC433FE for ; Tue, 31 May 2022 14:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345390AbiEaOyA (ORCPT ); Tue, 31 May 2022 10:54:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345364AbiEaOxy (ORCPT ); Tue, 31 May 2022 10:53:54 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5246AE0BC; Tue, 31 May 2022 07:53:53 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id w27so11202808edl.7; Tue, 31 May 2022 07:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CK4EoL0eO3JAVfR/tGGITzcTWVmopSHu4SA20EXBoL4=; b=e9pOFT8pI0LVuJDcKzGp27du6GMOJMIT4IHspxByeu5fE8kG7sID5NFZQG6X8E201N fDl/yphyH4KqaG3k4lxLBWZMGy9FH9JxDQuTVOdu1Ut+S6aVFZjhQlTrFzeHxL+k0N0s JgvPHw6TSL/zV2CbiCM8Ur32sH+MW9tYLFjoJ8EH4/S59JOro7/V57HmhF6SefT+t5Lk P92netDr6ol48yiAftbWvVF/7bEgyScBpZBPIkbbQN16d9P9K/qmU0yKBnoGvgQW04yt N/AUGvpsQWKKstGnmvf2o8mtamzAfKgGvBrrg+wRkfdyVfXYmUDpwqJsfGkZJaLPCJCF zvsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CK4EoL0eO3JAVfR/tGGITzcTWVmopSHu4SA20EXBoL4=; b=4NzxluNhHi9UqNt2OsGXEmusBP6ZrAi8cFqqXwMJ7E6ueerA7L1O1muOHO6oYJ27i3 Mc7eUvswIhjJZOGdUsEWhXJeA+vahwO/672jn4SwFwME4aMUzTji13nMVXTopECfI5+2 uSXrSOTHLD+vaJhgkbvpQVBE3CutpRSwkJBRcDlx4IXkxf/x0f07oj8wjB1Uc27Uyz49 Qryu/3Tgo1IgAXDXssg8uvn+jWa3Lg6hJj9j78i6jXp8S0kK7nbfCkxbkvWvVd+zzDrE 8z8nFH4rrmjg1MCbcfhu2ocgyJFHhkkCRskMrnB00mBVKii4Ee2LwFweTjT7DyVnJXo1 Bm7w== X-Gm-Message-State: AOAM5333xaOL85R00LNy88Th87/wP1YuUUhxtL2aLMJyYscsetsVNPQB 2QI9JE3Ga1HoxdNuQz2RjEk= X-Google-Smtp-Source: ABdhPJy7NoEBxoXFG4DAUa0ObJAScQFVwz0HGQHCjHChXKWl8RjpueAlKg1anmPhAB1zT1C6W9mlrA== X-Received: by 2002:a05:6402:254e:b0:42b:4633:e53e with SMTP id l14-20020a056402254e00b0042b4633e53emr52402720edb.314.1654008831824; Tue, 31 May 2022 07:53:51 -0700 (PDT) Received: from localhost.localdomain (host-79-55-12-155.retail.telecomitalia.it. [79.55.12.155]) by smtp.gmail.com with ESMTPSA id c2-20020a17090603c200b006fea59ef3a5sm5099779eja.32.2022.05.31.07.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 07:53:50 -0700 (PDT) From: "Fabio M. De Francesco" To: Chris Mason , Josef Bacik , David Sterba , Ira Weiny , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH 2/3] btrfs: Replace kmap() with kmap_local_page() in lzo.c Date: Tue, 31 May 2022 16:53:34 +0200 Message-Id: <20220531145335.13954-3-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220531145335.13954-1-fmdefrancesco@gmail.com> References: <20220531145335.13954-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 lzo.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 Signed-off-by: Fabio M. De Francesco Reviewed-by: Christoph Hellwig --- fs/btrfs/lzo.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 430ad36b8b08..89bc5f825e0a 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -155,7 +155,7 @@ static int copy_compressed_data_to_page(char *compresse= d_data, out_pages[*cur_out / PAGE_SIZE] =3D cur_page; } =20 - kaddr =3D kmap(cur_page); + kaddr =3D kmap_local_page(cur_page); write_compress_length(kaddr + offset_in_page(*cur_out), compressed_size); *cur_out +=3D LZO_LEN; @@ -167,7 +167,7 @@ static int copy_compressed_data_to_page(char *compresse= d_data, u32 copy_len =3D min_t(u32, sectorsize - *cur_out % sectorsize, orig_out + compressed_size - *cur_out); =20 - kunmap(cur_page); + kunmap_local(kaddr); =20 if ((*cur_out / PAGE_SIZE) >=3D max_nr_page) return -E2BIG; @@ -180,7 +180,7 @@ static int copy_compressed_data_to_page(char *compresse= d_data, return -ENOMEM; out_pages[*cur_out / PAGE_SIZE] =3D cur_page; } - kaddr =3D kmap(cur_page); + kaddr =3D kmap_local_page(cur_page); =20 memcpy(kaddr + offset_in_page(*cur_out), compressed_data + *cur_out - orig_out, copy_len); @@ -202,7 +202,7 @@ static int copy_compressed_data_to_page(char *compresse= d_data, *cur_out +=3D sector_bytes_left; =20 out: - kunmap(cur_page); + kunmap_local(kaddr); return 0; } =20 @@ -248,12 +248,12 @@ int lzo_compress_pages(struct list_head *ws, struct a= ddress_space *mapping, /* Compress at most one sector of data each time */ in_len =3D min_t(u32, start + len - cur_in, sectorsize - sector_off); ASSERT(in_len); - data_in =3D kmap(page_in); + data_in =3D kmap_local_page(page_in); ret =3D lzo1x_1_compress(data_in + offset_in_page(cur_in), in_len, workspace->cbuf, &out_len, workspace->mem); - kunmap(page_in); + kunmap_local(data_in); if (ret < 0) { pr_debug("BTRFS: lzo in loop returned %d\n", ret); ret =3D -EIO; @@ -310,7 +310,6 @@ static void copy_compressed_segment(struct compressed_b= io *cb, u32 orig_in =3D *cur_in; =20 while (*cur_in < orig_in + len) { - char *kaddr; struct page *cur_page; u32 copy_len =3D min_t(u32, PAGE_SIZE - offset_in_page(*cur_in), orig_in + len - *cur_in); @@ -318,11 +317,8 @@ static void copy_compressed_segment(struct compressed_= bio *cb, ASSERT(copy_len); cur_page =3D cb->compressed_pages[*cur_in / PAGE_SIZE]; =20 - kaddr =3D kmap(cur_page); - memcpy(dest + *cur_in - orig_in, - kaddr + offset_in_page(*cur_in), - copy_len); - kunmap(cur_page); + memcpy_from_page(dest + *cur_in - orig_in, cur_page, + offset_in_page(*cur_in), copy_len); =20 *cur_in +=3D copy_len; } @@ -342,9 +338,9 @@ int lzo_decompress_bio(struct list_head *ws, struct com= pressed_bio *cb) /* Bytes decompressed so far */ u32 cur_out =3D 0; =20 - kaddr =3D kmap(cb->compressed_pages[0]); + kaddr =3D kmap_local_page(cb->compressed_pages[0]); len_in =3D read_compress_length(kaddr); - kunmap(cb->compressed_pages[0]); + kunmap_local(kaddr); cur_in +=3D LZO_LEN; =20 /* @@ -378,9 +374,9 @@ int lzo_decompress_bio(struct list_head *ws, struct com= pressed_bio *cb) (cur_in + LZO_LEN - 1) / sectorsize); cur_page =3D cb->compressed_pages[cur_in / PAGE_SIZE]; ASSERT(cur_page); - kaddr =3D kmap(cur_page); + kaddr =3D kmap_local_page(cur_page); seg_len =3D read_compress_length(kaddr + offset_in_page(cur_in)); - kunmap(cur_page); + kunmap_local(kaddr); cur_in +=3D LZO_LEN; =20 if (seg_len > WORKSPACE_CBUF_LENGTH) { --=20 2.36.1 From nobody Thu Apr 30 09:44:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6094AC433F5 for ; Tue, 31 May 2022 14:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345279AbiEaOyE (ORCPT ); Tue, 31 May 2022 10:54:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345372AbiEaOx4 (ORCPT ); Tue, 31 May 2022 10:53:56 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 465D111C1F; Tue, 31 May 2022 07:53:55 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id t5so17904494edc.2; Tue, 31 May 2022 07:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h6u/QxJKnZwln1iYjcv77c4i6gpgKvaB0L7K36sjt+A=; b=mMcGj/AIwwkZJ7/nVvrbkwzeWCyJrkU1xtJ1sSHt9NaW3pDdB54bycfU/H27R49bmX ZuLqdy0pmU9JUf0nh5h7Py62Fr7y2Jqd4NFAgK/7+FyIRtgvw9aQccqlzX4EQM9UcrpU fiyg4XCnTokY6DWtvuT4MRps/a91kvbfxcxph96qPhOUcpVxUKagEpqoFuj86nJqNgXC iLxq6Gbq9u53us1iiEBx0b3rSBjN4wPold9sQmKfOBRImR39z4PF8TO9W9FuRpkCP4rE msCsNJ9zq3FOeYYOdu8U1gQEPrttuxz9l2vqQZFHZ252jjsFuSsoKGlH6m/tkLlRFd7z l5XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h6u/QxJKnZwln1iYjcv77c4i6gpgKvaB0L7K36sjt+A=; b=BDef35pBomQ6pSiNYZekUiMGqlGCeD5GQtjiCHXtajOE3oum8TByYO19cQF0KuhlwR SmusiT3NyvTDdQFmrGVSGnxfekkaP3KseJ/rK6QQ8QB8D5CRBXtjuudEl0jAPiDtRHBm SJiXl5fcRA1mS7onksWZ3w2SBxv9cWOSQUzXglhmSD6h/NUuppZq4otZpAbZRg5Ehk3s rJ6OOBZ7/jPvFn02ORKr7xAC9kATeb67erZ0pkjF+6gx7qVG2KRa5MjMLdC2V/PahLrz rQhNPg7aSHqI4NADOK8qNZJn5j8dtA4Dh3+5SAbr9P+w8ag++Pw6M2p+DELcm0OF0j/l TXAg== X-Gm-Message-State: AOAM5330+8gIWpYyy8Td8PgQ/1vFzPLyOI15iWMciAOXjaozZXm1KdkL IUW9U9o32R2hzADIAjqvn+uOrS212jA= X-Google-Smtp-Source: ABdhPJys/H55/zOpGzAjyyuqldSEQIowZHeS9IPSdsSVWMguLYQYJiYjZCXFdODP8JumzjP9U53t2Q== X-Received: by 2002:a05:6402:3046:b0:42b:505a:4f26 with SMTP id bs6-20020a056402304600b0042b505a4f26mr50652108edb.183.1654008833809; Tue, 31 May 2022 07:53:53 -0700 (PDT) Received: from localhost.localdomain (host-79-55-12-155.retail.telecomitalia.it. [79.55.12.155]) by smtp.gmail.com with ESMTPSA id c2-20020a17090603c200b006fea59ef3a5sm5099779eja.32.2022.05.31.07.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 07:53:52 -0700 (PDT) From: "Fabio M. De Francesco" To: Chris Mason , Josef Bacik , David Sterba , Ira Weiny , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH 3/3] btrfs: Replace kmap() with kmap_local_page() in zlib.c Date: Tue, 31 May 2022 16:53:35 +0200 Message-Id: <20220531145335.13954-4-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220531145335.13954-1-fmdefrancesco@gmail.com> References: <20220531145335.13954-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 zlib.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 Signed-off-by: Fabio M. De Francesco Reported-by: Dan Carpenter Reported-by: kernel test robot Reviewed-by: Christoph Hellwig --- fs/btrfs/zlib.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index 767a0c6c9694..7c10e78bd3d4 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -126,7 +126,7 @@ int zlib_compress_pages(struct list_head *ws, struct ad= dress_space *mapping, ret =3D -ENOMEM; goto out; } - cpage_out =3D kmap(out_page); + cpage_out =3D kmap_local_page(out_page); pages[0] =3D out_page; nr_pages =3D 1; =20 @@ -148,26 +148,26 @@ int zlib_compress_pages(struct list_head *ws, struct = address_space *mapping, int i; =20 for (i =3D 0; i < in_buf_pages; i++) { - if (in_page) { - kunmap(in_page); + if (data_in) { + kunmap_local(data_in); put_page(in_page); } in_page =3D find_get_page(mapping, start >> PAGE_SHIFT); - data_in =3D kmap(in_page); + data_in =3D kmap_local_page(in_page); memcpy(workspace->buf + i * PAGE_SIZE, data_in, PAGE_SIZE); start +=3D PAGE_SIZE; } workspace->strm.next_in =3D workspace->buf; } else { - if (in_page) { - kunmap(in_page); + if (data_in) { + kunmap_local(data_in); put_page(in_page); } in_page =3D find_get_page(mapping, start >> PAGE_SHIFT); - data_in =3D kmap(in_page); + data_in =3D kmap_local_page(in_page); start +=3D PAGE_SIZE; workspace->strm.next_in =3D data_in; } @@ -196,7 +196,7 @@ int zlib_compress_pages(struct list_head *ws, struct ad= dress_space *mapping, * the stream end if required */ if (workspace->strm.avail_out =3D=3D 0) { - kunmap(out_page); + kunmap_local(cpage_out); if (nr_pages =3D=3D nr_dest_pages) { out_page =3D NULL; ret =3D -E2BIG; @@ -207,7 +207,7 @@ int zlib_compress_pages(struct list_head *ws, struct ad= dress_space *mapping, ret =3D -ENOMEM; goto out; } - cpage_out =3D kmap(out_page); + cpage_out =3D kmap_local_page(out_page); pages[nr_pages] =3D out_page; nr_pages++; workspace->strm.avail_out =3D PAGE_SIZE; @@ -234,7 +234,7 @@ int zlib_compress_pages(struct list_head *ws, struct ad= dress_space *mapping, goto out; } else if (workspace->strm.avail_out =3D=3D 0) { /* get another page for the stream end */ - kunmap(out_page); + kunmap_local(cpage_out); if (nr_pages =3D=3D nr_dest_pages) { out_page =3D NULL; ret =3D -E2BIG; @@ -245,7 +245,7 @@ int zlib_compress_pages(struct list_head *ws, struct ad= dress_space *mapping, ret =3D -ENOMEM; goto out; } - cpage_out =3D kmap(out_page); + cpage_out =3D kmap_local_page(out_page); pages[nr_pages] =3D out_page; nr_pages++; workspace->strm.avail_out =3D PAGE_SIZE; @@ -264,11 +264,11 @@ int zlib_compress_pages(struct list_head *ws, struct = address_space *mapping, *total_in =3D workspace->strm.total_in; out: *out_pages =3D nr_pages; - if (out_page) - kunmap(out_page); + if (cpage_out) + kunmap_local(cpage_out); =20 - if (in_page) { - kunmap(in_page); + if (data_in) { + kunmap_local(data_in); put_page(in_page); } return ret; @@ -287,7 +287,7 @@ int zlib_decompress_bio(struct list_head *ws, struct co= mpressed_bio *cb) unsigned long buf_start; struct page **pages_in =3D cb->compressed_pages; =20 - data_in =3D kmap(pages_in[page_in_index]); + data_in =3D kmap_local_page(pages_in[page_in_index]); workspace->strm.next_in =3D data_in; workspace->strm.avail_in =3D min_t(size_t, srclen, PAGE_SIZE); workspace->strm.total_in =3D 0; @@ -309,7 +309,7 @@ int zlib_decompress_bio(struct list_head *ws, struct co= mpressed_bio *cb) =20 if (Z_OK !=3D zlib_inflateInit2(&workspace->strm, wbits)) { pr_warn("BTRFS: inflateInit failed\n"); - kunmap(pages_in[page_in_index]); + kunmap_local(data_in); return -EIO; } while (workspace->strm.total_in < srclen) { @@ -336,13 +336,13 @@ int zlib_decompress_bio(struct list_head *ws, struct = compressed_bio *cb) =20 if (workspace->strm.avail_in =3D=3D 0) { unsigned long tmp; - kunmap(pages_in[page_in_index]); + kunmap_local(data_in); page_in_index++; if (page_in_index >=3D total_pages_in) { data_in =3D NULL; break; } - data_in =3D kmap(pages_in[page_in_index]); + data_in =3D kmap_local_page(pages_in[page_in_index]); workspace->strm.next_in =3D data_in; tmp =3D srclen - workspace->strm.total_in; workspace->strm.avail_in =3D min(tmp, PAGE_SIZE); @@ -355,7 +355,7 @@ int zlib_decompress_bio(struct list_head *ws, struct co= mpressed_bio *cb) done: zlib_inflateEnd(&workspace->strm); if (data_in) - kunmap(pages_in[page_in_index]); + kunmap_local(data_in); if (!ret) zero_fill_bio(cb->orig_bio); return ret; --=20 2.36.1