From patchwork Tue Aug 9 15:20:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fabio M. De Francesco" X-Patchwork-Id: 12939683 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 DEA56C19F2D for ; Tue, 9 Aug 2022 15:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244827AbiHIPUX (ORCPT ); Tue, 9 Aug 2022 11:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244835AbiHIPUT (ORCPT ); Tue, 9 Aug 2022 11:20:19 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A0E8C66; Tue, 9 Aug 2022 08:20:17 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id j8so22779549ejx.9; Tue, 09 Aug 2022 08:20:17 -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=DrjfGz/NaZQxMhh3hlQHeDNyMbOnbKG2/DNRFkKmXb0=; b=jCB2IOAdMlXzVuzrxy2Yo2ch/+fbK1OtPXpMRQFeg+nXavwSHWbWZeZbx3ddM4JPF+ 7ETH/5O3LT9aZ7OR9JuNTj07X0I2sbJJ8haeNWHHPAx/aFVLp5y9+UTHLAO8pJmEPURi pAV/IhVmfwzIN4t09xfTZft3rtCma4fOnV3i5ED66WAUDV7laRgRyeqKGDMYjj+xJNSq TNUaeZjaNZ5Kq0AZMmLfvl+LpbzO5fIh9KV9MbV5h1v95UU+f+M/WUsXqVlGI8EQJyPP RfAii03/5qakDnZHfkIqLDzTsoUvfIpV2HQETDuM72jqBJZZ73GV+nunfqGRVleZJX3i yHfQ== 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=DrjfGz/NaZQxMhh3hlQHeDNyMbOnbKG2/DNRFkKmXb0=; b=t5XEve/DuYCI1L5beDuYHIJSXZAV9wfAuz3Sf9iHAmoaOI1fmc/yxmdEfBnaxLZyDf TKAVxyd3XRzWtzJdRE/hCxHgxkKPf9V77wsCnHR40VQDwfnH3Xa2tna6SGzCp7q5QbTi BtJ2yPM414RKTvvlPsqp7pdpEf+zSJrHfuPWvkjBNUW4J/X1ILIUMTLejUyjQtrxPj0V hq90M+z39Z/HuGeYDN9tWbkWQmAJi/eI113HqE9kqoSXTXD6/gSMeEMfxO/ffFvdI5vO 1GY875leVSfB76g2bexUxIAxr0pdHsO459WUIrxxGaEtSA7r7ZAWGyPAAzs7f+pYjP+9 unKQ== X-Gm-Message-State: ACgBeo1Dx0GyqSzwTqD1dHSOGz4QP2GfS3iPm4imvkdfCnSz4uUIikz2 pdMQnT9cI27sBsUzgqUNqreaVQFBEko= X-Google-Smtp-Source: AA6agR5jrBcz3sqlDOfIbd0YJDEr+G9QbyAvfoMR+Ym2M/ZGOUVOuUXypC4nMIYuCEvqavH/3JMOZg== X-Received: by 2002:a17:907:94ca:b0:731:8395:d526 with SMTP id dn10-20020a17090794ca00b007318395d526mr4112301ejc.389.1660058415920; Tue, 09 Aug 2022 08:20:15 -0700 (PDT) Received: from localhost.localdomain (host-79-27-108-198.retail.telecomitalia.it. [79.27.108.198]) by smtp.gmail.com with ESMTPSA id m21-20020a170906721500b0073093eaf53esm1222162ejk.131.2022.08.09.08.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 08:20:14 -0700 (PDT) From: "Fabio M. De Francesco" To: "Matthew Wilcox (Oracle)" , "Fabio M. De Francesco" , Andrew Morton , Damien Le Moal , Jeff Layton , Arnd Bergmann , Muchun Song , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ira Weiny Subject: [PATCH 1/3] hfs: Unmap the page in the "fail_page" label Date: Tue, 9 Aug 2022 17:20:02 +0200 Message-Id: <20220809152004.9223-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809152004.9223-1-fmdefrancesco@gmail.com> References: <20220809152004.9223-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Several paths within hfs_btree_open() jump to the "fail_page" label where put_page() is called while the page is still mapped. Call kunmap() to unmap the page soon before put_page(). Reviewed-by: Ira Weiny Signed-off-by: Fabio M. De Francesco Reviewed-by: Viacheslav Dubeyko --- fs/hfs/btree.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c index 19017d296173..56c6782436e9 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -124,6 +124,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke return tree; fail_page: + kunmap(page); put_page(page); free_inode: tree->inode->i_mapping->a_ops = &hfs_aops; From patchwork Tue Aug 9 15:20:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Fabio M. De Francesco" X-Patchwork-Id: 12939684 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 CE72EC19F2D for ; Tue, 9 Aug 2022 15:20:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244803AbiHIPU2 (ORCPT ); Tue, 9 Aug 2022 11:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243505AbiHIPUV (ORCPT ); Tue, 9 Aug 2022 11:20:21 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA745DF8; Tue, 9 Aug 2022 08:20:19 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id uj29so22919084ejc.0; Tue, 09 Aug 2022 08:20:19 -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=pC0OF0AjNsXgSTVwqSglN9wjX2Yvl3xwZ360yloval8=; b=YShFCzczr8rVFsopDHAs3m3b02Qzc0k10OMegHVryz7M9Ek0lJh9zlG9kLjWspm9jc vfPOx8yFHOQBaGYPVoaRYchiizkiICPxQRFnOheD1NjdCwKeHX1u7dPeHtwtyNUwZD6i 8WYm2sooCw95qAzCShpZxQ9nZsoGrebYGy1KpFRqSQQwe5TbiJLKAHfvzT5QYNFP0kW/ CRaP++Aa8OEpfNQeluJQsOKJm0xPO04uLkAWKmjTXLNUJRFvjyyIe5MY4YfWzhlV8Vkg 0o47ej2qj4ZdJ7aXFG/Db7fNd+/ilZ8DKEH4XdVEaBI+HXj/EizO0GtFE7obYjkPftsI S28A== 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=pC0OF0AjNsXgSTVwqSglN9wjX2Yvl3xwZ360yloval8=; b=w4L46EMgZBYzTGbXXDeu6sLpZuGlClInIm9fL/4N5H/T2OIFyca3fyyLPivdiZpHHc tRnwvB0oK3yqc9qQyryk8U5w/1K5lLDKC0EYQV9evt8hMZobmWP/xI+k0ryRgin3Yua5 h3urcke5HjAVVd8t0inNwg0h8Z7EQ0XgH3peA3hDyu04NzpygiCFKBV+1SyfZACF2i5w CnNSnK3JZe4s3/ZZLLzCHeVoX5LMPAUW8K8uB74JD5Wt07pGmZDoomJmp+wIw8dYK4Us cFZoiZCI3numD3yTjNuQmmgmrdyhT7N8WHyiWcCqqnbyT24gGsN8jwRnUvHwNruokmGO 04kg== X-Gm-Message-State: ACgBeo2MaQWJ4auOcoKdOnnNhGaCUEKDjlv71yB+UzvPLjL0YQrRlb// UI5/o0+6lZQ8z5Mfg6P3ugA= X-Google-Smtp-Source: AA6agR6YsEEC7pc6ZbIgWfQqy/IxlAdSlmWSf5loKdES2e0ihuNJ80w6bVz2eLoWZ1n16Dn07zd6ZQ== X-Received: by 2002:a17:907:2722:b0:731:201a:df9c with SMTP id d2-20020a170907272200b00731201adf9cmr11586077ejl.149.1660058418213; Tue, 09 Aug 2022 08:20:18 -0700 (PDT) Received: from localhost.localdomain (host-79-27-108-198.retail.telecomitalia.it. [79.27.108.198]) by smtp.gmail.com with ESMTPSA id m21-20020a170906721500b0073093eaf53esm1222162ejk.131.2022.08.09.08.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 08:20:16 -0700 (PDT) From: "Fabio M. De Francesco" To: "Matthew Wilcox (Oracle)" , "Fabio M. De Francesco" , Andrew Morton , Damien Le Moal , Jeff Layton , Arnd Bergmann , Muchun Song , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ira Weiny Subject: [PATCH 2/3] hfs: Replace kmap() with kmap_local_page() in bnode.c Date: Tue, 9 Aug 2022 17:20:03 +0200 Message-Id: <20220809152004.9223-3-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809152004.9223-1-fmdefrancesco@gmail.com> References: <20220809152004.9223-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org kmap() is being deprecated in favor of kmap_local_page(). Two main problems with kmap(): (1) It comes with an overhead as mapping space is restricted and protected by a global lock for synchronization and (2) it also requires global TLB invalidation when the kmap’s pool wraps and it might block when the mapping space is fully utilized until a slot becomes available. With kmap_local_page() the mappings are per thread, CPU local, can take page faults, and can be called from any context (including interrupts). It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. Since its use in bnode.c is safe everywhere, it should be preferred. Therefore, replace kmap() with kmap_local_page() in bnode.c. Where possible, use the suited standard helpers (memzero_page(), memcpy_page()) instead of open coding kmap_local_page() plus memset() or memcpy(). Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled. Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco Reviewed-by: Viacheslav Dubeyko --- fs/hfs/bnode.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c index c83fd0e8404d..2015e42e752a 100644 --- a/fs/hfs/bnode.c +++ b/fs/hfs/bnode.c @@ -21,7 +21,6 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len) int pagenum; int bytes_read; int bytes_to_read; - void *vaddr; off += node->page_offset; pagenum = off >> PAGE_SHIFT; @@ -33,9 +32,7 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len) page = node->page[pagenum]; bytes_to_read = min_t(int, len - bytes_read, PAGE_SIZE - off); - vaddr = kmap_atomic(page); - memcpy(buf + bytes_read, vaddr + off, bytes_to_read); - kunmap_atomic(vaddr); + memcpy_from_page(buf + bytes_read, page, off, bytes_to_read); pagenum++; off = 0; /* page offset only applies to the first page */ @@ -80,8 +77,7 @@ void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len) off += node->page_offset; page = node->page[0]; - memcpy(kmap(page) + off, buf, len); - kunmap(page); + memcpy_to_page(page, off, buf, len); set_page_dirty(page); } @@ -105,8 +101,7 @@ void hfs_bnode_clear(struct hfs_bnode *node, int off, int len) off += node->page_offset; page = node->page[0]; - memset(kmap(page) + off, 0, len); - kunmap(page); + memzero_page(page, off, len); set_page_dirty(page); } @@ -123,9 +118,7 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst, src_page = src_node->page[0]; dst_page = dst_node->page[0]; - memcpy(kmap(dst_page) + dst, kmap(src_page) + src, len); - kunmap(src_page); - kunmap(dst_page); + memcpy_page(dst_page, dst, src_page, src, len); set_page_dirty(dst_page); } @@ -140,9 +133,9 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len) src += node->page_offset; dst += node->page_offset; page = node->page[0]; - ptr = kmap(page); + ptr = kmap_local_page(page); memmove(ptr + dst, ptr + src, len); - kunmap(page); + kunmap_local(ptr); set_page_dirty(page); } @@ -346,13 +339,14 @@ struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree, u32 num) if (!test_bit(HFS_BNODE_NEW, &node->flags)) return node; - desc = (struct hfs_bnode_desc *)(kmap(node->page[0]) + node->page_offset); + desc = (struct hfs_bnode_desc *)(kmap_local_page(node->page[0]) + + node->page_offset); node->prev = be32_to_cpu(desc->prev); node->next = be32_to_cpu(desc->next); node->num_recs = be16_to_cpu(desc->num_recs); node->type = desc->type; node->height = desc->height; - kunmap(node->page[0]); + kunmap_local(desc); switch (node->type) { case HFS_NODE_HEADER: @@ -436,14 +430,12 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num) } pagep = node->page; - memset(kmap(*pagep) + node->page_offset, 0, - min((int)PAGE_SIZE, (int)tree->node_size)); + memzero_page(*pagep, node->page_offset, + min((int)PAGE_SIZE, (int)tree->node_size)); set_page_dirty(*pagep); - kunmap(*pagep); for (i = 1; i < tree->pages_per_bnode; i++) { - memset(kmap(*++pagep), 0, PAGE_SIZE); + memzero_page(*++pagep, 0, PAGE_SIZE); set_page_dirty(*pagep); - kunmap(*pagep); } clear_bit(HFS_BNODE_NEW, &node->flags); wake_up(&node->lock_wq); From patchwork Tue Aug 9 15:20:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Fabio M. De Francesco" X-Patchwork-Id: 12939685 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 30098C25B0C for ; Tue, 9 Aug 2022 15:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244844AbiHIPUy (ORCPT ); Tue, 9 Aug 2022 11:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244096AbiHIPU1 (ORCPT ); Tue, 9 Aug 2022 11:20:27 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CED7389C; Tue, 9 Aug 2022 08:20:22 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id y13so22734265ejp.13; Tue, 09 Aug 2022 08:20:22 -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=jQq+vc9W06TACReKN0ej1GNxH6Z/P1l4L8dXBTGxx58=; b=YFyGTEzokrq07wvnt615JIoeAIkmfy5rslQjqsafwKzG+QJLBU+72qzez243xVVytB N1z42Kt37qCWJLYLd3sfwvEEGU1R0nPTsbUCEHOZ39f3SSJDcPEtChmkdHqpYSb7Qzf7 +Rd7YXzGB38laZ/OgtW179F+L82dhMowsgHS5hPhDQPRNeZcf5W6Eb60eY1j282E+t3B IBPKQUnh4lKtzAL9t3YDwFfH+lZSikQPjQgBGUoLvSS0OqgWUUkDDwfJW+FGbwi8W9Ew hk2+7SVv0cTPSYwKlXtpjpWm8xpnkgxDYeeHxSlShdCNImGG9LoPxFWLRe33eJGXscGN +HDA== 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=jQq+vc9W06TACReKN0ej1GNxH6Z/P1l4L8dXBTGxx58=; b=kPErTQMc3bXPcZzz452OWzZRq8yckF/JOtWKsxZ1iI5lekA4XhHWOChuxUFONrvZqz 1pZkdhyPDh1LHAwX1lYFwyzcCEiNcTjlKI2XvqveOLE3LJ/VJ5ErNQlSyIxdVYch85wB bYRDCcioDiujavK19JgaM9NHoUcpq4QyINZCs/jOty06PFbp4QYp7U/T3BOEJ6atb0se d3E7kFUjYC2cC5+pyTJ7XT/1/bn6rS+DTiptr7nRbl2zqmxzvGZUGh4+cYFXidDpvWzw Ut27aRz2fzwfndVhmOY44LVqZO9gfOn929UdrCjGnFZ1DI+nGjVqLZ8t9fCW9ZiriQiW DjFg== X-Gm-Message-State: ACgBeo3PktvlhPmjG5Z3542mGL5DrcRvPqHRyNp1XrxaJGgSH8qdM+NN XLAmm5WjLZPsIQ+iizfm3Rk= X-Google-Smtp-Source: AA6agR6dxlvks48trcQz6Zz8fABO1KOAbvdZkvC7cafvq34AzsFD6CR/RYjhKENudvduK7UfkfTKPQ== X-Received: by 2002:a17:906:5a6a:b0:730:bc8a:57dd with SMTP id my42-20020a1709065a6a00b00730bc8a57ddmr16815474ejc.301.1660058420541; Tue, 09 Aug 2022 08:20:20 -0700 (PDT) Received: from localhost.localdomain (host-79-27-108-198.retail.telecomitalia.it. [79.27.108.198]) by smtp.gmail.com with ESMTPSA id m21-20020a170906721500b0073093eaf53esm1222162ejk.131.2022.08.09.08.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 08:20:19 -0700 (PDT) From: "Fabio M. De Francesco" To: "Matthew Wilcox (Oracle)" , "Fabio M. De Francesco" , Andrew Morton , Damien Le Moal , Jeff Layton , Arnd Bergmann , Muchun Song , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ira Weiny Subject: [PATCH 3/3] hfs: Replace kmap() with kmap_local_page() in btree.c Date: Tue, 9 Aug 2022 17:20:04 +0200 Message-Id: <20220809152004.9223-4-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809152004.9223-1-fmdefrancesco@gmail.com> References: <20220809152004.9223-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org kmap() is being deprecated in favor of kmap_local_page(). Two main problems with kmap(): (1) It comes with an overhead as mapping space is restricted and protected by a global lock for synchronization and (2) it also requires global TLB invalidation when the kmap’s pool wraps and it might block when the mapping space is fully utilized until a slot becomes available. With kmap_local_page() the mappings are per thread, CPU local, can take page faults, and can be called from any context (including interrupts). It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. Since its use in btree.c is safe everywhere, it should be preferred. Therefore, replace kmap() with kmap_local_page() in btree.c. Where possible, use the suited standard helpers (memzero_page(), memcpy_page()) instead of open coding kmap_local_page() plus memset() or memcpy(). Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled. Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco Reviewed-by: Viacheslav Dubeyko --- fs/hfs/btree.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c index 56c6782436e9..2fa4b1f8cc7f 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -80,7 +80,8 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke goto free_inode; /* Load the header */ - head = (struct hfs_btree_header_rec *)(kmap(page) + sizeof(struct hfs_bnode_desc)); + head = (struct hfs_btree_header_rec *)(kmap_local_page(page) + + sizeof(struct hfs_bnode_desc)); tree->root = be32_to_cpu(head->root); tree->leaf_count = be32_to_cpu(head->leaf_count); tree->leaf_head = be32_to_cpu(head->leaf_head); @@ -119,12 +120,12 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke tree->node_size_shift = ffs(size) - 1; tree->pages_per_bnode = (tree->node_size + PAGE_SIZE - 1) >> PAGE_SHIFT; - kunmap(page); + kunmap_local(head); put_page(page); return tree; fail_page: - kunmap(page); + kunmap_local(head); put_page(page); free_inode: tree->inode->i_mapping->a_ops = &hfs_aops; @@ -170,7 +171,8 @@ void hfs_btree_write(struct hfs_btree *tree) return; /* Load the header */ page = node->page[0]; - head = (struct hfs_btree_header_rec *)(kmap(page) + sizeof(struct hfs_bnode_desc)); + head = (struct hfs_btree_header_rec *)(kmap_local_page(page) + + sizeof(struct hfs_bnode_desc)); head->root = cpu_to_be32(tree->root); head->leaf_count = cpu_to_be32(tree->leaf_count); @@ -181,7 +183,7 @@ void hfs_btree_write(struct hfs_btree *tree) head->attributes = cpu_to_be32(tree->attributes); head->depth = cpu_to_be16(tree->depth); - kunmap(page); + kunmap_local(head); set_page_dirty(page); hfs_bnode_put(node); } @@ -269,7 +271,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) off += node->page_offset; pagep = node->page + (off >> PAGE_SHIFT); - data = kmap(*pagep); + data = kmap_local_page(*pagep); off &= ~PAGE_MASK; idx = 0; @@ -282,7 +284,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) idx += i; data[off] |= m; set_page_dirty(*pagep); - kunmap(*pagep); + kunmap_local(data); tree->free_nodes--; mark_inode_dirty(tree->inode); hfs_bnode_put(node); @@ -291,14 +293,14 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) } } if (++off >= PAGE_SIZE) { - kunmap(*pagep); - data = kmap(*++pagep); + kunmap_local(data); + data = kmap_local_page(*++pagep); off = 0; } idx += 8; len--; } - kunmap(*pagep); + kunmap_local(data); nidx = node->next; if (!nidx) { printk(KERN_DEBUG "create new bmap node...\n"); @@ -314,7 +316,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) off = off16; off += node->page_offset; pagep = node->page + (off >> PAGE_SHIFT); - data = kmap(*pagep); + data = kmap_local_page(*pagep); off &= ~PAGE_MASK; } } @@ -361,20 +363,20 @@ void hfs_bmap_free(struct hfs_bnode *node) } off += node->page_offset + nidx / 8; page = node->page[off >> PAGE_SHIFT]; - data = kmap(page); + data = kmap_local_page(page); off &= ~PAGE_MASK; m = 1 << (~nidx & 7); byte = data[off]; if (!(byte & m)) { pr_crit("trying to free free bnode %u(%d)\n", node->this, node->type); - kunmap(page); + kunmap_local(data); hfs_bnode_put(node); return; } data[off] = byte & ~m; set_page_dirty(page); - kunmap(page); + kunmap_local(data); hfs_bnode_put(node); tree->free_nodes++; mark_inode_dirty(tree->inode);