From patchwork Wed Feb 12 07:16:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377649 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70C30921 for ; Wed, 12 Feb 2020 07:17:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5080620873 for ; Wed, 12 Feb 2020 07:17:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="eLpI5rWk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728342AbgBLHRK (ORCPT ); Wed, 12 Feb 2020 02:17:10 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728327AbgBLHRJ (ORCPT ); Wed, 12 Feb 2020 02:17:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491841; x=1613027841; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z2X4aHgnvPPXZMjaOmCVZ7Drr3KtgumDXJtALPCwaAw=; b=eLpI5rWkj3Mv0aUKORShZPu2B4WwXUQeXfSO7h8yXg2zEj3jx+zRlmTd IChZhicEjZjQrLiVkqoqxJj2SnaGkIACpaQf+nVip87z2ZyW8Mq/P9Rdd e01xl0xSxoypBvLoYtfulqsObv/vtbdMmH7uz6lxC8g+89Xisy6/NrKx4 +vk8FsgmAOvlwUMnx/fd0Ze3XmrsQVx1DaodJYG1I/qLlZL24zpbSYXdV JdY7QCZCNaUPuTkWlBOSWnVZfd6J8MZqK4NOStX65GesiqIy55Hl1ZwBo p74+F1Qrkrm9vd5aX9FkqTvL8HWC8qZic1QYKlUKBdUwMwYqBo5fCWZSt g==; IronPort-SDR: bNq3N4tcgvg50zQwR2lc/Qu0ClLp4CSXumKUST91zrN43LwnSvV7GBJpPqy0aCfrrJEs9czmhU LNE5UuJk8+pdc8C7dgiLamueL1JHtIwzK46g1QujDsI1sAONRJcLJuUmxhyF3vuCmqdOohejmE kvwGBWVymuQ3oWBduyBW80zJOlEzv3e/mE/nby6Y/ZB82/YAINss33aMyTLyXO++webwiu1Rjv 0wFjBK8C2HVYTMdED6eOfGcRjWWf1ceXby+ByX+BHRs59MESdn5CfUy9n9aKR+xdpukJhnt+jJ LnU= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448455" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:21 +0800 IronPort-SDR: OYBCrbuLcnoJ4pxfyDpUzRJ/5TkTPVrz6lAUoZ2bU+YIWUwt7cv2vzE+52MGG+iWTqNfGAUPrQ 65aDxCjh2vvyderfpkekXtBTmyZL0gCpNZv0FIZ9axiCeNhi0VdD6Y+yBtVkHniB20WULr8nvq +n7aN96SsRjuj5b56ZO0SvZzxF5b43FYDRq4eRDKN0pS33mOBMA5NzMsneU9YqDeAEYkZIiYwQ mOFdqho66rpQKUGy5FDkMDW9AAcJV14tJir6XROMbSAp3dlU4Pc6hh4h1rKGcHFisGUt2OcsFH JgAgOgGJixQonL3UWU2WV7CL Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:09:58 -0800 IronPort-SDR: LdsyK39Is5ddR80wu//BG5BCox2x+A9cpVc0Ih7F+jpKSWvEJv/Qwxv2+1Qp+uecB5KHLNmINV 0BmdNxsA9EFlktX6Gs0UomfR5H96WgfGAAALbCDLXfgxXX9/yKTfvNOcwkpN1fCf3Wpl3oNm8G RefsW5V5fY8JaEZteD8uCF+XZXsHdlNiCIHhpYTwuYfFObgKx9JyreiKoHr2YA8D91qyQAUWLu H1NTWIZX4DEqmuiZ8lLUdB6I4oBJWf50a68wZqikBJoS/crIS63WL0grK5iUH6W0lKCCqG5FxT CaE= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:09 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Nikolay Borisov , Johannes Thumshirn Subject: [PATCH v7 1/8] btrfs: Export btrfs_release_disk_super Date: Wed, 12 Feb 2020 16:16:57 +0900 Message-Id: <20200212071704.17505-2-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Nikolay Borisov Preparatory patch for removal of buffer_head usage in btrfs. Signed-off-by: Nikolay Borisov Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 2 +- fs/btrfs/volumes.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b092021e41e9..6ebdd95b798d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1247,7 +1247,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, return ret; } -static void btrfs_release_disk_super(struct page *page) +void btrfs_release_disk_super(struct page *page) { kunmap(page); put_page(page); diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 690d4f5a0653..b7f2edbc6581 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -483,6 +483,7 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset); struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info, u64 logical, u64 length); +void btrfs_release_disk_super(struct page *page); static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, int index) From patchwork Wed Feb 12 07:16:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377651 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F389109A for ; Wed, 12 Feb 2020 07:17:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E4542082F for ; Wed, 12 Feb 2020 07:17:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="g0Cwv36I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbgBLHRL (ORCPT ); Wed, 12 Feb 2020 02:17:11 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728341AbgBLHRK (ORCPT ); Wed, 12 Feb 2020 02:17:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491843; x=1613027843; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vQK7f590uXyS4KfFENEdWXR1w8x+Y6JgvW+SsUuXZXs=; b=g0Cwv36IjeJeegUL2n5tc0jcXWCtTuG5xVwCnRCYJUQUWuihOgAHVVsq foB6VmRGlggBUsxTlz2d9wv7BFtAAIfXt3Dqv/MvWHr6DqgUSlIe/tPuz XqQxaSNG45cuSxrzXV0pur7uyQK9dPrlZG/CVrACiTsTRqcDu+fTfw+Wj ChG4GHijx8fuet+zYEvb/2S2XIp3XXuCmzkFvE81lNejl7h/5NUJV7Y89 CcXXCE6ezATSSYRmehSv565SykYlmHL5VuDE10AHjv1I9/qoy3v13uTPR gh7wzjhKOJ44IEYlyktSKM5ts95D1ANbAk2hS1qa7Z6pIniUFbDuoXfzd g==; IronPort-SDR: 8xHH6EkKZq8ZZmChykc4+LUWLfT7EIBFfcUY80qoo4MuNhwq4RWU0vZuHctlayTrXcxlN/uM0I NzA2LJDAjU5UzPwFtfx3bLhKplhB6xClBsI8nrjKxF+9Z/UO6fwkAKAcb40OlqanQjhz516BZZ m09IE8MAxKcM3e+sHJkxoiLYZcihj/M9DNltepdEEY4vXz68pwAf2Xp30I/JvQI2I2baihUvci weeTaZ/b4H4WuJnfW6gO44sCMO/yKa7qNnxXOlYQTJLcuDx6KtDGAC29Yhrqf+MqS/5Hy0ceq0 jxM= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448458" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:22 +0800 IronPort-SDR: pdg3B3YytMGQQy8NTb7T1sEkgE39YirWqk+05CX84RdnzWWxIv7qrdvKOpldh3Qoy5dknbeip9 zaNA+qJ1BRyflTj5JYV+VXFenQ1Z1BZ5rSBqZNhqfbR+LNaSOlKa9D7BvuMvat1F9gzZVvKmxS xD1kzrMw7dsgDehsyYwsaCT8Tc1vWlhYrFvIpzYk/a6aUpvWqh9ObapPmzMqXCH5MKimopyNZ1 lE29P/3cCxnSjI0YdYW8vEILdiSIxXDWy9DL7jhW3BgULcsBX6IGhoI5w/oKX3JXmEEYujs4Sh PCVtW8G1pyX73PG2mOZvLb5g Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:09:59 -0800 IronPort-SDR: pHZEaYUJHfeeof9yq4/HgTCswb47TckrJibIauLNMLoCKjxj6w17JorlJJpBSNgYR8ZJPmqmv8 Rv7L0q13aVMJwVjejb55Ve/kSxzUmJVUcTmwB2TiMpNu09XpV2aAQZ1L4IakzD5masj0+w7vBI CWT27NrpC6yWjet4feJ0rzcWkG/wC4UibIWDIe9yZ+kgXin7YXIXmFYbjk3/P2JK01cNn4KtvD Bht1Y/g3BLoANqqC4gcmlLTrQpMWEqHKG0MIN2vJWlStkbi2kKaZhkJ5jC6cWCCBoGRAK8RC4V Zl4= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:10 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn , Christoph Hellwig Subject: [PATCH v7 2/8] btrfs: don't kmap() pages from block devices Date: Wed, 12 Feb 2020 16:16:58 +0900 Message-Id: <20200212071704.17505-3-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Block device mappings are never in highmem so kmap() / kunmap() calls for pages from block devices are unneeded. Use page_address() instead of kmap() to get to the virtual addreses. While we're at it, read_cache_page_gfp() doesn't return NULL on error, only an ERR_PTR, so use IS_ERR() to check for errors. Suggested-by: Christoph Hellwig Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- fs/btrfs/volumes.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6ebdd95b798d..620794f1ea64 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1249,7 +1249,6 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void btrfs_release_disk_super(struct page *page) { - kunmap(page); put_page(page); } @@ -1277,10 +1276,10 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr, *page = read_cache_page_gfp(bdev->bd_inode->i_mapping, index, GFP_KERNEL); - if (IS_ERR_OR_NULL(*page)) + if (IS_ERR(*page)) return 1; - p = kmap(*page); + p = page_address(*page); /* align our pointer to the offset of the super block */ *disk_super = p + offset_in_page(bytenr); From patchwork Wed Feb 12 07:16:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377653 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10304109A for ; Wed, 12 Feb 2020 07:17:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4ACE20873 for ; Wed, 12 Feb 2020 07:17:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="XxeMPIhx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728349AbgBLHRM (ORCPT ); Wed, 12 Feb 2020 02:17:12 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728344AbgBLHRL (ORCPT ); Wed, 12 Feb 2020 02:17:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491844; x=1613027844; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pY3fJIiL3drIDz7rHvz9Ma6Wjg4HzgFd91S282i+jdA=; b=XxeMPIhxv6nN/auHeVEXccaPrFsJ0/5sQ9RLXQHxMZ4Y4eRMtPcOaCkU MF6UbqIq4WhCG0/1LUzJUUAnozSWkJElrltA01M6GutABpfCAXiVPJpaI OENAXn10ikpN9TauAKJsNBsohkgwiDClsm3Ws/AOe+7vperNqKsyHJEIY oy21dVyQ+8VIzI2JTQNonGEM8qWf4qoXgz7FuLD6InqPlVOf7FoLpuYf1 e8s6bSJpG9JVCc+dJOSMtgr0hA22XOAdmxotR+xVg1u2X8IOZNSvPOskn 5z9GseO/j+livE15KvvP0d1e2TJ0TJ3CUT5HWIw2xAJKoILq27t7s9kOL Q==; IronPort-SDR: G5dj10IswFZvh6Lg+AkBWU1yIWgJqIgYfwbkDTIJGoULLZ2ZLL0GZFd8g3h+t0H5oFO0n5O1rH R2YDkDLfJaHOx2alp29Mv3l0CKGEirciKzVp4TZ//vbzAyn5fzsQ1tz/7AqsJyI2F7bVmH3J0u zVOEJ0BOqMSTQTLHnnitIsYSMchqCarUbVXoTdl5hwFrLKx/DTK+Dl9wTjVOzwP11RHW3TsM+C qfmjpOcahn272n+01AAgqnwHvQxbHepehDVSylhy6aD50vzJ025OZ+Kq4ED3rd5S4hsKzIQQvV F0I= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448461" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:24 +0800 IronPort-SDR: 0s/yG8RUbRH9t8DgvPrAxJbLe8P2IwGuGfR5SdVw1IkDggIG/cwjIv7Nhni4bWdXolIkCg3DHV gOU7vQs0KUQGQb81KuYvJ885ZFG6Uqpoe2ahLZg62yvpNKCi1V4Wpjzj2+t2LD+cmkpQyDB2ey tDbsoKDAhTz3/nuaRWKcjSp7c91fCliZpBVlgpZHWurziW2YR31sCXhSKo092ua/a3csuiiTY/ raEXJQTQO7hI8PpQvsH/CbKUF2UEf5Mq7a1oSh0Xpeq3WV7ddj8EytgafG4oQpZH5qYf+EzQlM ps8Oeq3S9gVMiYx0FA825gDG Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:10:00 -0800 IronPort-SDR: IF608znxfcHFFmA1q2Z/mwpXe+uGtDtYXxgi5YoZpKXcyHcQ8g0Q8l1D2yHPUgzATpZIgEc6bI R7aVRF+Ke7y6iAjP5HgBAWfunOnPUL3U/CNEj3lw1Z/LC8aEtgvrQ1gEXj6XwzaGtgUuMhhUfz hlCg00tO5qxZ4srKvxrMZw/gPVuuc2YjykeeYQXqlImm+4XGYmx1qgQZF6POfdgLgs12VsAh9G OsVucaPYTourSRb/Znb3yciAdzNJoe09BrnbWcNPj3QoR5imrM0+LgWU8G+T9NnRTxOj6JyYDQ BFI= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:11 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v7 3/8] btrfs: unexport btrfs_scratch_superblocks Date: Wed, 12 Feb 2020 16:16:59 +0900 Message-Id: <20200212071704.17505-4-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_scratch_superblocks() isn't used anywhere outside volumes.c so remove it from the header file and mark it as static. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 6 +++++- fs/btrfs/volumes.h | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 620794f1ea64..e17d4d7a6eb4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -32,6 +32,9 @@ #include "block-group.h" #include "discard.h" +static void btrfs_scratch_superblocks(struct block_device *bdev, + const char *device_path); + const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { [BTRFS_RAID_RAID10] = { .sub_stripes = 2, @@ -7316,7 +7319,8 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info, return 0; } -void btrfs_scratch_superblocks(struct block_device *bdev, const char *device_path) +static void btrfs_scratch_superblocks(struct block_device *bdev, + const char *device_path) { struct buffer_head *bh; struct btrfs_super_block *disk_super; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index b7f2edbc6581..a3d86ee6a883 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -473,7 +473,6 @@ int btrfs_run_dev_stats(struct btrfs_trans_handle *trans); void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_device *srcdev); void btrfs_rm_dev_replace_free_srcdev(struct btrfs_device *srcdev); void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev); -void btrfs_scratch_superblocks(struct block_device *bdev, const char *device_path); int btrfs_is_parity_mirror(struct btrfs_fs_info *fs_info, u64 logical, u64 len); unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info, From patchwork Wed Feb 12 07:17:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377655 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02644921 for ; Wed, 12 Feb 2020 07:17:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF41520848 for ; Wed, 12 Feb 2020 07:17:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="BbzInLxV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728352AbgBLHRM (ORCPT ); Wed, 12 Feb 2020 02:17:12 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728341AbgBLHRM (ORCPT ); Wed, 12 Feb 2020 02:17:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491845; x=1613027845; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H7SLEx5pAKOZvek04ltV7Q0qfzC6mC/2kvIz5PFcQz8=; b=BbzInLxVMJS6H+wTU9AARfj/NWlDIPp/2vzLv9Lkjyu6FAbhuo4GI1A3 Wk8tWJGhQ27Mxz+y+X8NWEqaHUmVZl/RJAFq65iBqGrBux+QFFPklQKRr dNDo57giN/30IOGgDs8eRw+PJYIJsGrrZAJQeyg+Nmgk6D3iLyrtrFw8C s4DUYHLuo6EtNQlQNegzoFMfZ97bObmO9sO+LMZ3ulaH8hJnOKDGBYlqM Y30apkD+e4/6fuhNTWDsBoN519AO52/AL28rQ/rHHuWb86dSpCMvjv7So 6Ddhay8ZVMgPIU0njGwMhlUHTDo91sev/bSLEXQQI/kiuvZfC3Dlp5VP1 w==; IronPort-SDR: g/gPLrbHQqGNZD74VIjCm7HKxkJ2naAEhlgX8P/raXaeCJFarDpSD57r8cU3X6BVM/ULedWjMC Iq/S5v/k/qq8oDuxGJfGXZdFR+7LgGlQja4vNZ0HVdpZlo+f9FZi9TyrXd893CCe+whP7Wy7sx lLgYnQSiR69xGekI+Px0bcxmm/a3WVkwOSUV/0SloB5EW+RMFwChnMyzQFtLalZh1IgTEjNmfK gvDefFK2QecqS7NNyEsCfmrgowWoc0q8DVnT6PNcAf32Rh7xRjCBAfyEKMtSw3YKKInG9HIyna s9c= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448462" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:25 +0800 IronPort-SDR: 1n8nZ+0XyxUi3fVnaR5OHerZGUW0uO5qSNwGu9NKyXVnN3k4cFddOfGDPmyqp3/essmwPpBAfH EFj9BK6tCwZkB1JrGBxDr3CYrdHls12dN54DjTdpmzlhZ7bIE1601PVzxNRyOpGlHmdAUeOW9v RnJbMLz00Hno/VVstfKbUnCqAb09t3YjVlvhtN+HdldCICnhcAEPm3f0EF3fIl9G+X4sLoPPuv tBzo0NpzEFRSVgb2rFE2VOgrXAwTn2lD959REsnhsd+z9/qBrP+zm0U5/poCHvNjTD+D1Hdzga bPRAmVigXKqOqhe4hM2eL7kE Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:10:01 -0800 IronPort-SDR: 6wtKSgEgXSMB0FEnX3bq7vXM/MBAJR/oK8Li4BXMxFUKd1tyIwT7eIOvy9Dnr/7yUwL9OFnSGD hIK0haJP9imM6FYzDoAwbdqLgh1K1w4iuSkyjiPJmR9jP/XuAYmyKuCHIHeHvYjTIq7mWA+Lho ChNqvfDUPvgfpAYaXcUweIShY3O4tPDdrO7/ddXZT824O5HGsTO2y/trWDjf+4qRteAoqijD7L /648M5hqJZkgqxO2nOu6x7wvv1K5rDQr5WUF2yYEPe2xvd5aiKL35/+9ImkBW7SZwOBXXV4YkP dvo= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:11 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn Subject: [PATCH v7 4/8] btrfs: use the page-cache for super block reading Date: Wed, 12 Feb 2020 16:17:00 +0900 Message-Id: <20200212071704.17505-5-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Super-block reading in BTRFS is done using buffer_heads. Buffer_heads have some drawbacks, like not being able to propagate errors from the lower layers. Directly use the page cache for reading the super-blocks from disk or invalidating an on-disk super-block. We have to use the page-cache so to avoid races between mkfs and udev. See also 6f60cbd3ae44 ("btrfs: access superblock via pagecache in scan_one_device"). Signed-off-by: Johannes Thumshirn --- Changes to v6: - Warn if we can't write out a page for a superblock (David) Changes to v5: - Removed kmap()/kunmap() calls (hch/David) Changes to v4: - Remove mapping_gfp_constraint() and GFP_NOFAIL (hch) Changes to v3: - Use read_cache_pages() and write_one_page() for IO (hch) - Changed subject (David) - Dropped Josef's R-b due to change Changes to v2: - open-code kunmap() + put_page() (David) - fix double kunmap() (David) - don't use bi_set_op_attrs() (David) Changes to v1: - move 'super_page' into for-loop in btrfs_scratch_superblocks() (Nikolay) - switch to using pagecahce instead of alloc_pages() (Nikolay, David) --- fs/btrfs/disk-io.c | 74 ++++++++++++++++++------------------------ fs/btrfs/disk-io.h | 6 ++-- fs/btrfs/volumes.c | 80 ++++++++++++++++++++++++++-------------------- fs/btrfs/volumes.h | 4 +-- 4 files changed, 80 insertions(+), 84 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 018681ec159b..9f422edd6cce 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2850,7 +2850,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device u64 features; u16 csum_type; struct btrfs_key location; - struct buffer_head *bh; struct btrfs_super_block *disk_super; struct btrfs_fs_info *fs_info = btrfs_sb(sb); struct btrfs_root *tree_root; @@ -2891,9 +2890,9 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device /* * Read super block and check the signature bytes only */ - bh = btrfs_read_dev_super(fs_devices->latest_bdev); - if (IS_ERR(bh)) { - err = PTR_ERR(bh); + disk_super = btrfs_read_dev_super(fs_devices->latest_bdev); + if (IS_ERR(disk_super)) { + err = PTR_ERR(disk_super); goto fail_alloc; } @@ -2901,18 +2900,19 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device * Verify the type first, if that or the the checksum value are * corrupted, we'll find out */ - csum_type = btrfs_super_csum_type((struct btrfs_super_block *)bh->b_data); + csum_type = btrfs_super_csum_type(disk_super); if (!btrfs_supported_super_csum(csum_type)) { btrfs_err(fs_info, "unsupported checksum algorithm: %u", csum_type); err = -EINVAL; - brelse(bh); + btrfs_release_disk_super(disk_super); goto fail_alloc; } ret = btrfs_init_csum_hash(fs_info, csum_type); if (ret) { err = ret; + btrfs_release_disk_super(disk_super); goto fail_alloc; } @@ -2920,10 +2920,10 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). */ - if (btrfs_check_super_csum(fs_info, bh->b_data)) { + if (btrfs_check_super_csum(fs_info, (u8 *) disk_super)) { btrfs_err(fs_info, "superblock checksum mismatch"); err = -EINVAL; - brelse(bh); + btrfs_release_disk_super(disk_super); goto fail_alloc; } @@ -2932,8 +2932,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device * following bytes up to INFO_SIZE, the checksum is calculated from * the whole block of INFO_SIZE */ - memcpy(fs_info->super_copy, bh->b_data, sizeof(*fs_info->super_copy)); - brelse(bh); + memcpy(fs_info->super_copy, disk_super, sizeof(*fs_info->super_copy)); + btrfs_release_disk_super(disk_super); disk_super = fs_info->super_copy; @@ -3419,45 +3419,38 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) put_bh(bh); } -int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num, - struct buffer_head **bh_ret) +struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev, + int copy_num) { - struct buffer_head *bh; struct btrfs_super_block *super; + struct page *page; u64 bytenr; + struct address_space *mapping = bdev->bd_inode->i_mapping; bytenr = btrfs_sb_offset(copy_num); if (bytenr + BTRFS_SUPER_INFO_SIZE >= i_size_read(bdev->bd_inode)) - return -EINVAL; + return ERR_PTR(-EINVAL); - bh = __bread(bdev, bytenr / BTRFS_BDEV_BLOCKSIZE, BTRFS_SUPER_INFO_SIZE); - /* - * If we fail to read from the underlying devices, as of now - * the best option we have is to mark it EIO. - */ - if (!bh) - return -EIO; + page = read_cache_page_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS); + if (IS_ERR(page)) + return ERR_PTR(-ENOMEM); - super = (struct btrfs_super_block *)bh->b_data; + super = page_address(page); if (btrfs_super_bytenr(super) != bytenr || btrfs_super_magic(super) != BTRFS_MAGIC) { - brelse(bh); - return -EINVAL; + btrfs_release_disk_super(super); + return ERR_PTR(-EINVAL); } - *bh_ret = bh; - return 0; + return super; } -struct buffer_head *btrfs_read_dev_super(struct block_device *bdev) +struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev) { - struct buffer_head *bh; - struct buffer_head *latest = NULL; - struct btrfs_super_block *super; + struct btrfs_super_block *super, *latest = NULL; int i; u64 transid = 0; - int ret = -EINVAL; /* we would like to check all the supers, but that would make * a btrfs mount succeed after a mkfs from a different FS. @@ -3465,25 +3458,20 @@ struct buffer_head *btrfs_read_dev_super(struct block_device *bdev) * later supers, using BTRFS_SUPER_MIRROR_MAX instead */ for (i = 0; i < 1; i++) { - ret = btrfs_read_dev_one_super(bdev, i, &bh); - if (ret) + super = btrfs_read_dev_one_super(bdev, i); + if (IS_ERR(super)) continue; - super = (struct btrfs_super_block *)bh->b_data; - if (!latest || btrfs_super_generation(super) > transid) { - brelse(latest); - latest = bh; + if (latest) + btrfs_release_disk_super(super); + + latest = super; transid = btrfs_super_generation(super); - } else { - brelse(bh); } } - if (!latest) - return ERR_PTR(ret); - - return latest; + return super; } /* diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index db21ab614357..59c885860bf8 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -56,9 +56,9 @@ int __cold open_ctree(struct super_block *sb, char *options); void __cold close_ctree(struct btrfs_fs_info *fs_info); int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors); -struct buffer_head *btrfs_read_dev_super(struct block_device *bdev); -int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num, - struct buffer_head **bh_ret); +struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev); +struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev, + int copy_num); int btrfs_commit_super(struct btrfs_fs_info *fs_info); struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root, struct btrfs_key *key); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e17d4d7a6eb4..daf9c10db337 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -32,7 +31,8 @@ #include "block-group.h" #include "discard.h" -static void btrfs_scratch_superblocks(struct block_device *bdev, +static void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, + struct block_device *bdev, const char *device_path); const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { @@ -503,7 +503,7 @@ static struct btrfs_fs_devices *find_fsid_with_metadata_uuid( static int btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder, int flush, struct block_device **bdev, - struct buffer_head **bh) + struct btrfs_super_block **disk_super) { int ret; @@ -522,9 +522,9 @@ btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder, goto error; } invalidate_bdev(*bdev); - *bh = btrfs_read_dev_super(*bdev); - if (IS_ERR(*bh)) { - ret = PTR_ERR(*bh); + *disk_super = btrfs_read_dev_super(*bdev); + if (IS_ERR(*disk_super)) { + ret = PTR_ERR(*disk_super); blkdev_put(*bdev, flags); goto error; } @@ -533,7 +533,6 @@ btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder, error: *bdev = NULL; - *bh = NULL; return ret; } @@ -614,7 +613,6 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, { struct request_queue *q; struct block_device *bdev; - struct buffer_head *bh; struct btrfs_super_block *disk_super; u64 devid; int ret; @@ -625,17 +623,16 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, return -EINVAL; ret = btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1, - &bdev, &bh); + &bdev, &disk_super); if (ret) return ret; - disk_super = (struct btrfs_super_block *)bh->b_data; devid = btrfs_stack_device_id(&disk_super->dev_item); if (devid != device->devid) - goto error_brelse; + goto error_free_page; if (memcmp(device->uuid, disk_super->dev_item.uuid, BTRFS_UUID_SIZE)) - goto error_brelse; + goto error_free_page; device->generation = btrfs_super_generation(disk_super); @@ -644,7 +641,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, BTRFS_FEATURE_INCOMPAT_METADATA_UUID) { pr_err( "BTRFS: Invalid seeding and uuid-changed device detected\n"); - goto error_brelse; + goto error_free_page; } clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); @@ -670,12 +667,12 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, fs_devices->rw_devices++; list_add_tail(&device->dev_alloc_list, &fs_devices->alloc_list); } - brelse(bh); + btrfs_release_disk_super(disk_super); return 0; -error_brelse: - brelse(bh); +error_free_page: + btrfs_release_disk_super(disk_super); blkdev_put(bdev, flags); return -EINVAL; @@ -1250,8 +1247,10 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, return ret; } -void btrfs_release_disk_super(struct page *page) +void btrfs_release_disk_super(struct btrfs_super_block *super) { + struct page *page = virt_to_page(super); + put_page(page); } @@ -1289,7 +1288,7 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr, if (btrfs_super_bytenr(*disk_super) != bytenr || btrfs_super_magic(*disk_super) != BTRFS_MAGIC) { - btrfs_release_disk_super(*page); + btrfs_release_disk_super(p); return 1; } @@ -1352,7 +1351,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags, btrfs_free_stale_devices(path, device); } - btrfs_release_disk_super(page); + btrfs_release_disk_super(disk_super); error_bdev_put: blkdev_put(bdev, flags); @@ -2069,7 +2068,8 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, * supers and free the device. */ if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) - btrfs_scratch_superblocks(device->bdev, device->name->str); + btrfs_scratch_superblocks(fs_info, device->bdev, + device->name->str); btrfs_close_bdev(device); synchronize_rcu(); @@ -2137,7 +2137,8 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_device *srcdev) if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &srcdev->dev_state)) { /* zero out the old super if it is writable */ - btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str); + btrfs_scratch_superblocks(fs_info, srcdev->bdev, + srcdev->name->str); } btrfs_close_bdev(srcdev); @@ -2196,7 +2197,8 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev) * is already out of device list, so we don't have to hold * the device_list_mutex lock. */ - btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str); + btrfs_scratch_superblocks(tgtdev->fs_info, tgtdev->bdev, + tgtdev->name->str); btrfs_close_bdev(tgtdev); synchronize_rcu(); @@ -2211,14 +2213,14 @@ static struct btrfs_device *btrfs_find_device_by_path( u64 devid; u8 *dev_uuid; struct block_device *bdev; - struct buffer_head *bh; struct btrfs_device *device; ret = btrfs_get_bdev_and_sb(device_path, FMODE_READ, - fs_info->bdev_holder, 0, &bdev, &bh); + fs_info->bdev_holder, 0, &bdev, + &disk_super); if (ret) return ERR_PTR(ret); - disk_super = (struct btrfs_super_block *)bh->b_data; + devid = btrfs_stack_device_id(&disk_super->dev_item); dev_uuid = disk_super->dev_item.uuid; if (btrfs_fs_incompat(fs_info, METADATA_UUID)) @@ -2228,7 +2230,7 @@ static struct btrfs_device *btrfs_find_device_by_path( device = btrfs_find_device(fs_info->fs_devices, devid, dev_uuid, disk_super->fsid, true); - brelse(bh); + btrfs_release_disk_super(disk_super); if (!device) device = ERR_PTR(-ENOENT); blkdev_put(bdev, FMODE_READ); @@ -7319,10 +7321,10 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info, return 0; } -static void btrfs_scratch_superblocks(struct block_device *bdev, - const char *device_path) +static void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, + struct block_device *bdev, + const char *device_path) { - struct buffer_head *bh; struct btrfs_super_block *disk_super; int copy_num; @@ -7331,16 +7333,24 @@ static void btrfs_scratch_superblocks(struct block_device *bdev, for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX; copy_num++) { + struct page *page; + int err; - if (btrfs_read_dev_one_super(bdev, copy_num, &bh)) + disk_super = btrfs_read_dev_one_super(bdev, copy_num); + if (IS_ERR(disk_super)) continue; - disk_super = (struct btrfs_super_block *)bh->b_data; - memset(&disk_super->magic, 0, sizeof(disk_super->magic)); - set_buffer_dirty(bh); - sync_dirty_buffer(bh); - brelse(bh); + + page = virt_to_page(disk_super); + set_page_dirty(page); + lock_page(page); /* write_on_page() unlocks the page */ + err = write_one_page(page); + if (err) + btrfs_warn(fs_info, "error clearing superblock number %d (%d)", + copy_num, err); + btrfs_release_disk_super(disk_super); + } /* Notify udev that device has changed */ diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index a3d86ee6a883..3f52c3a05af8 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -17,8 +17,6 @@ extern struct mutex uuid_mutex; #define BTRFS_STRIPE_LEN SZ_64K -struct buffer_head; - struct btrfs_io_geometry { /* remaining bytes before crossing a stripe */ u64 len; @@ -482,7 +480,7 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset); struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info, u64 logical, u64 length); -void btrfs_release_disk_super(struct page *page); +void btrfs_release_disk_super(struct btrfs_super_block *super); static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, int index) From patchwork Wed Feb 12 07:17:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEBEA109A for ; Wed, 12 Feb 2020 07:17:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C49942082F for ; Wed, 12 Feb 2020 07:17:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="panEP19a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728355AbgBLHRO (ORCPT ); Wed, 12 Feb 2020 02:17:14 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728353AbgBLHRN (ORCPT ); Wed, 12 Feb 2020 02:17:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491847; x=1613027847; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TSLibXESaLa+r35WM1/Knr7nO68CgtE4V5pJaROATsg=; b=panEP19aWLl67tQsvkS532YbhPaF5culFcQgbWthFMyMvQb5Y5hXdPnZ qFe/38hyOwoDXdItIpETkzx7mPH9aKocu0XPldTZX3ECLnYt/QZCStLVM wZxCXP88QvpFdrVtHAO3bogOXRORAyrVOh15drj0hVZu6ZXir9IvPWMp/ ixHb7NbuELNrI+BsgCin5XpoUhfYjfN1mYQzvd/8a9mbdmx2Q4exhNzQT QX/VRF8Iyh9jYThT7alDN4BrHwlao/2YmorXi8mL2ev/zQO9CAAeBwbtM xJa+4fEqnhapd6IAKGN5vowNvDVy3f5OQ86BBZ0zN3yf3DKF+ffMMiXCr g==; IronPort-SDR: 38BtkJIAZPmAZNV3zUo6FqHEkuakg3M0Shs5Ktlp8qzJt6uER0Uloq0sNLK+p/RJiNX2BOHE/9 H6PLTFU27WBkfgb3mJZFwfk0ISRcGHM5Q7sgVY2TbviSQucPVQv8fpYlVk9SMf0DX7L5EE4lig 3pbilyvymvhZ7KORmj+1+t4dm1upmTPlB4QnrJ8U+9OfV0qza2RSsuzkWQ4HOWADCCLNAnPO0m t4Q4WIxA6HdDtHRPlN6MgIML6RF7H9N36IbT/N88nR3e56FxCTcg309Cwb1gjNg83maocAXODe 6E4= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448463" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:26 +0800 IronPort-SDR: 8Cz2dqKLHYOh1J28DjhskGB6sbkubCODMqT2s6YjQ+Yiz6JApzM1fYgb5AcU6n5YmSTOb6cA6K ld5rV4FBzTDCTB9D04L36kLasHODph6s1ih6comRJdHceRpdKgxzJnVaA+IXcX/kaS9evwzm4h IROR+fIhTvpUsUREPierY0tX/k5VUIUaAnj9v/N+iWoOuziqEHrRfZFgSFBXD25EZEV4Vvn9/Z H7Tj/biZIeVC9b9vDSngV7aZUo0jS/JJn6t0y55J6tbM68HgMyQ6Daw/YBZbhQleCjTCynMC1u faSMgh1yQ++GW1Y/smUPjSE2 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:10:02 -0800 IronPort-SDR: R1khPgaL2D8sU9bDwntZQ9k3m+t9xU6hr0AIRv+Dtw/gRtBP1b5WyBHCphuvz0/O7dVuBIWJI4 sXbhlFinc3QGNePH8HV2KXCX4yJCc3N2HXHJ/YazNouhaK1Y7BwkQOWYDVbAQ878B3nBaBVdsS XmMHsSTM1fciKAyhqChKYCbh54dVqNsulS3WPCF3lYP7Tag0z2ZoKrmI4oX6SWDK2EUboqASW+ B1/uB1sjZyaxtgr++nUrpiANqhAwF8hJhK3l+N13JxL7d9cfzN0OQyhYLsfTEGLYVoD2XVi/El Vm4= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:12 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn , Nikolay Borisov , Josef Bacik Subject: [PATCH v7 5/8] btrfs: use BIOs instead of buffer_heads from superblock writeout Date: Wed, 12 Feb 2020 16:17:01 +0900 Message-Id: <20200212071704.17505-6-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Similar to the superblock read path, change the write path to using BIOs and pages instead of buffer_heads. This allows us to skip over the buffer_head code, for writing the superblock to disk. This is based on a patch originally authored by Nikolay Borisov. Co-developed-by: Nikolay Borisov Signed-off-by: Nikolay Borisov Signed-off-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov Reviewed-by: Josef Bacik Reviewed-by: Christoph Hellwig --- Changes to v4: - get rid of op_flags (hch) - don't use mapping_gfp_constraint() (hch) - print errno on error (hch) - use typed pointer (hch) Changes to v2: - Don't use bi_set_op_attrs() (David) Changes to v1: - Remove left-over buffer_head.h include (David) --- fs/btrfs/disk-io.c | 117 ++++++++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 50 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 9f422edd6cce..906a48f6c996 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -3398,25 +3397,34 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device } ALLOW_ERROR_INJECTION(open_ctree, ERRNO); -static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) +static void btrfs_end_super_write(struct bio *bio) { - if (uptodate) { - set_buffer_uptodate(bh); - } else { - struct btrfs_device *device = (struct btrfs_device *) - bh->b_private; - - btrfs_warn_rl_in_rcu(device->fs_info, - "lost page write due to IO error on %s", - rcu_str_deref(device->name)); - /* note, we don't set_buffer_write_io_error because we have - * our own ways of dealing with the IO errors - */ - clear_buffer_uptodate(bh); - btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_WRITE_ERRS); + struct btrfs_device *device = bio->bi_private; + struct bio_vec *bvec; + struct bvec_iter_all iter_all; + struct page *page; + + bio_for_each_segment_all(bvec, bio, iter_all) { + page = bvec->bv_page; + + if (bio->bi_status) { + btrfs_warn_rl_in_rcu(device->fs_info, + "lost page write due to IO error on %s (%d)", + rcu_str_deref(device->name), + blk_status_to_errno(bio->bi_status)); + ClearPageUptodate(page); + SetPageError(page); + btrfs_dev_stat_inc_and_print(device, + BTRFS_DEV_STAT_WRITE_ERRS); + } else { + SetPageUptodate(page); + } + + put_page(page); + unlock_page(page); } - unlock_buffer(bh); - put_bh(bh); + + bio_put(bio); } struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev, @@ -3482,19 +3490,17 @@ struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev) * the expected device size at commit time. Note that max_mirrors must be * same for write and wait phases. * - * Return number of errors when buffer head is not found or submission fails. + * Return number of errors when page is not found or submission fails. */ static int write_dev_supers(struct btrfs_device *device, struct btrfs_super_block *sb, int max_mirrors) { struct btrfs_fs_info *fs_info = device->fs_info; + struct address_space *mapping = device->bdev->bd_inode->i_mapping; SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); - struct buffer_head *bh; int i; - int ret; int errors = 0; u64 bytenr; - int op_flags; if (max_mirrors == 0) max_mirrors = BTRFS_SUPER_MIRROR_MAX; @@ -3502,6 +3508,10 @@ static int write_dev_supers(struct btrfs_device *device, shash->tfm = fs_info->csum_shash; for (i = 0; i < max_mirrors; i++) { + struct page *page; + struct bio *bio; + struct btrfs_super_block *disk_super; + bytenr = btrfs_sb_offset(i); if (bytenr + BTRFS_SUPER_INFO_SIZE >= device->commit_total_bytes) @@ -3514,37 +3524,44 @@ static int write_dev_supers(struct btrfs_device *device, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); crypto_shash_final(shash, sb->csum); - /* One reference for us, and we leave it for the caller */ - bh = __getblk(device->bdev, bytenr / BTRFS_BDEV_BLOCKSIZE, - BTRFS_SUPER_INFO_SIZE); - if (!bh) { + page = find_or_create_page(mapping, bytenr >> PAGE_SHIFT, + GFP_NOFS); + if (!page) { btrfs_err(device->fs_info, - "couldn't get super buffer head for bytenr %llu", + "couldn't get superblock page for bytenr %llu", bytenr); errors++; continue; } - memcpy(bh->b_data, sb, BTRFS_SUPER_INFO_SIZE); + /* Bump the refcount for wait_dev_supers() */ + get_page(page); - /* one reference for submit_bh */ - get_bh(bh); + disk_super = page_address(page); + memcpy(disk_super, sb, BTRFS_SUPER_INFO_SIZE); - set_buffer_uptodate(bh); - lock_buffer(bh); - bh->b_end_io = btrfs_end_buffer_write_sync; - bh->b_private = device; + /* + * Directly use BIOs here instead of relying on the page-cache + * to do I/O, so we don't loose the ability to do integrity + * checking. + */ + bio = bio_alloc(GFP_NOFS, 1); + bio_set_dev(bio, device->bdev); + bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT; + bio->bi_private = device; + bio->bi_end_io = btrfs_end_super_write; + __bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE, + offset_in_page(bytenr)); /* - * we fua the first super. The others we allow + * We fua the first super. The others we allow * to go down lazy. */ - op_flags = REQ_SYNC | REQ_META | REQ_PRIO; + bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PRIO; if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER)) - op_flags |= REQ_FUA; - ret = btrfsic_submit_bh(REQ_OP_WRITE, op_flags, bh); - if (ret) - errors++; + bio->bi_opf |= REQ_FUA; + + btrfsic_submit_bio(bio); } return errors < i ? 0 : -1; } @@ -3553,12 +3570,11 @@ static int write_dev_supers(struct btrfs_device *device, * Wait for write completion of superblocks done by write_dev_supers, * @max_mirrors same for write and wait phases. * - * Return number of errors when buffer head is not found or not marked up to + * Return number of errors when page is not found or not marked up to * date. */ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) { - struct buffer_head *bh; int i; int errors = 0; bool primary_failed = false; @@ -3568,32 +3584,33 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) max_mirrors = BTRFS_SUPER_MIRROR_MAX; for (i = 0; i < max_mirrors; i++) { + struct page *page; + bytenr = btrfs_sb_offset(i); if (bytenr + BTRFS_SUPER_INFO_SIZE >= device->commit_total_bytes) break; - bh = __find_get_block(device->bdev, - bytenr / BTRFS_BDEV_BLOCKSIZE, - BTRFS_SUPER_INFO_SIZE); - if (!bh) { + page = find_get_page(device->bdev->bd_inode->i_mapping, + bytenr >> PAGE_SHIFT); + if (!page) { errors++; if (i == 0) primary_failed = true; continue; } - wait_on_buffer(bh); - if (!buffer_uptodate(bh)) { + wait_on_page_locked(page); + if (PageError(page)) { errors++; if (i == 0) primary_failed = true; } /* drop our reference */ - brelse(bh); + put_page(page); /* drop the reference from the writing run */ - brelse(bh); + put_page(page); } /* log error, force error return */ From patchwork Wed Feb 12 07:17:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377659 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A496109A for ; Wed, 12 Feb 2020 07:17:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A5EE2082F for ; Wed, 12 Feb 2020 07:17:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="X9M9gZMr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbgBLHRP (ORCPT ); Wed, 12 Feb 2020 02:17:15 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbgBLHRO (ORCPT ); Wed, 12 Feb 2020 02:17:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491848; x=1613027848; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DY2WAUOAB3R4OVQ1t9StJaVgz7kaMPPbDphATbQMRVE=; b=X9M9gZMrof3tCredoxaq0K27+bgIQFAm9VcdCfEspN2+K4snwtyjkvTx +FMX62gFL873x+lZjeQrYmUodrIjk6bXwD0wl4wjmjdMY8nO5UFRdYc0S BFd8hLaGfb/3B4ZdPOwTR75aupmFQcHplbJV820R+0I3oKT9GGpyVSQIM tp8Ac+DcFMqyZSyGJyxIIIe7bu1P61cG8lcjlWjyTInDdolfisHPfWmxO haQnJ7peGaLPIPAfyEotRDR92r2o2Pz5DDh1qXtq03TEyDgpyZTi5bKcp HN+VEz6d3GOQIwII8Z3MMmDXSq1SDIjYLxkHWR76SK2CkVEFFCE3E/voF w==; IronPort-SDR: rvxGu/WxtBi1CE6gxhMwgmmRdimE8vW+JP0qa41GkYyk/Us1gpO9+zUVqKlflTtwXI6vDcpQnC Yp9lVnwamY3xpOK4X6/Jg9gllWKx87GNCFxFQcT5nMGpilawf5cV1STJERUWG4/Sy0fF7HVGqz BYmV+eIsfHDdnz0gIJFHly2rPCGYZznn3GasuyFtIi2/etzofhImMyqGB0kevT/OL++W3F/nn3 yzqGWXNA4NHoZw1lp0xCT5W5tdJp+g2iff56u14vTwzct82M4VI9u+qbvA7y+lyjJC9LVQ0YEh IsU= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448465" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:28 +0800 IronPort-SDR: +CoYsO8u1+kiU8RfHrVkga/szGgNVlW/mScefG6CbeJtaFZov1QhtKV0Ht5h+qQOxDtJhqmr6O kbmunwiH55+Gcv1HU39mHIF5vrgj7HR75M2kkgki7VXbAslq5JsCyyqQ5UpOYHLJNn32Siey6j NKJtau7LhgMfSOxfY2pA0V1BCu+KqiXdcKr1HkTawsTPLaneXkFFIjxJBddSFRJjdqwNP0y44c zD+0F/Ks1t1h4Y3+Gh7j1spG8F2DMVDfp87meQQVOX4FXxHXdx3PWAvHlyBjmJs10ooSwuA6HL NpnIRhZWQYiCS1qsrdetX+gZ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:10:03 -0800 IronPort-SDR: gc9AAr/xZRWGOy7OFWwBqXkmOJnXiKYCIAkNMkGIZjT5YixdIe8+MF804GFE3rrI77Nt1C3vrN bD/R9V/viqae38bl43AA32lE6nsTG4PHIIlvxAtZ94QW+p4Z3lLGdLpJUNDuEMhgaSGB/RXL1J z4rcG+j0VmK1HW6RGS2En2SLeEFyB8E0S2h6+tucwHsZnPsUK4C5bJ37sDPiP1Wmc1JtqIaO0C hCvBYBVJKY5zhcwYTQWGhFhhFStLb3JIHiJKkiUxBUWSlrAGQ8TA5/FCIck/J3AcsWJEGlHw06 5nQ= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:13 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn , Nikolay Borisov , Josef Bacik Subject: [PATCH v7 6/8] btrfs: remove btrfsic_submit_bh() Date: Wed, 12 Feb 2020 16:17:02 +0900 Message-Id: <20200212071704.17505-7-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that the last use of btrfsic_submit_bh() is gone, remove the function as well. Signed-off-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov Reviewed-by: Josef Bacik --- fs/btrfs/check-integrity.c | 57 -------------------------------------- fs/btrfs/check-integrity.h | 2 -- 2 files changed, 59 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index a0ce69f2d27c..e7507985435e 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -2730,63 +2730,6 @@ static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev) &btrfsic_dev_state_hashtable); } -int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh) -{ - struct btrfsic_dev_state *dev_state; - - if (!btrfsic_is_initialized) - return submit_bh(op, op_flags, bh); - - mutex_lock(&btrfsic_mutex); - /* since btrfsic_submit_bh() might also be called before - * btrfsic_mount(), this might return NULL */ - dev_state = btrfsic_dev_state_lookup(bh->b_bdev->bd_dev); - - /* Only called to write the superblock (incl. FLUSH/FUA) */ - if (NULL != dev_state && - (op == REQ_OP_WRITE) && bh->b_size > 0) { - u64 dev_bytenr; - - dev_bytenr = BTRFS_BDEV_BLOCKSIZE * bh->b_blocknr; - if (dev_state->state->print_mask & - BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) - pr_info("submit_bh(op=0x%x,0x%x, blocknr=%llu (bytenr %llu), size=%zu, data=%p, bdev=%p)\n", - op, op_flags, (unsigned long long)bh->b_blocknr, - dev_bytenr, bh->b_size, bh->b_data, bh->b_bdev); - btrfsic_process_written_block(dev_state, dev_bytenr, - &bh->b_data, 1, NULL, - NULL, bh, op_flags); - } else if (NULL != dev_state && (op_flags & REQ_PREFLUSH)) { - if (dev_state->state->print_mask & - BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) - pr_info("submit_bh(op=0x%x,0x%x FLUSH, bdev=%p)\n", - op, op_flags, bh->b_bdev); - if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) { - if ((dev_state->state->print_mask & - (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH | - BTRFSIC_PRINT_MASK_VERBOSE))) - pr_info("btrfsic_submit_bh(%s) with FLUSH but dummy block already in use (ignored)!\n", - dev_state->name); - } else { - struct btrfsic_block *const block = - &dev_state->dummy_block_for_bio_bh_flush; - - block->is_iodone = 0; - block->never_written = 0; - block->iodone_w_error = 0; - block->flush_gen = dev_state->last_flush_gen + 1; - block->submit_bio_bh_rw = op_flags; - block->orig_bio_bh_private = bh->b_private; - block->orig_bio_bh_end_io.bh = bh->b_end_io; - block->next_in_same_bio = NULL; - bh->b_private = block; - bh->b_end_io = btrfsic_bh_end_io; - } - } - mutex_unlock(&btrfsic_mutex); - return submit_bh(op, op_flags, bh); -} - static void __btrfsic_submit_bio(struct bio *bio) { struct btrfsic_dev_state *dev_state; diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h index 9bf4359cc44c..bcc730a06cb5 100644 --- a/fs/btrfs/check-integrity.h +++ b/fs/btrfs/check-integrity.h @@ -7,11 +7,9 @@ #define BTRFS_CHECK_INTEGRITY_H #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY -int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh); void btrfsic_submit_bio(struct bio *bio); int btrfsic_submit_bio_wait(struct bio *bio); #else -#define btrfsic_submit_bh submit_bh #define btrfsic_submit_bio submit_bio #define btrfsic_submit_bio_wait submit_bio_wait #endif From patchwork Wed Feb 12 07:17:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE98E921 for ; Wed, 12 Feb 2020 07:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C424A2082F for ; Wed, 12 Feb 2020 07:17:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="eXPXicl4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbgBLHRQ (ORCPT ); Wed, 12 Feb 2020 02:17:16 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbgBLHRP (ORCPT ); Wed, 12 Feb 2020 02:17:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491851; x=1613027851; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yDh38LT1oa9sKRSCEDcdZL8IbUvuFF4JQYQJ249BioA=; b=eXPXicl4dyGpCkPRnFJQm5gp+7aIzIt+zlY3rzWeyEb4zW0W3y705rrD 810yCJ8kxUoZY09uRdMl0Ge1mdiirg437nz1tSfizhnPOSslxu2NZtHA7 rpsaD3UihwVAC62fjCIjfav6GyBmk6vBcA99tb5z5pNyMwLe5L2fogAtj ZRl4E5Yh3Wn1keWGC8kCF0mqpzu3NhdsDHQV8qHKuU6IjwtrMaf51RPlP jZ/YJNA+LuRhEaxOc3vHGLJC5tMQ5ka91amURxbsY11eFIgOvy+ALYMzb Tp5XMnkZLHR+NrmurS6wpXRUXwvZRUOVHP21niDhRI6BwdTJofXuOZ1nX g==; IronPort-SDR: YsEZQiqcTg+f7pHw2H8UQv+2eFA7L9KwquN2rKnkOge/ibvIE4Fle+Y8D/WidfeWPQTtHLtClr A3UZj34ElXYc4s6vcm1P/8U8DMpunKOcQk9KfJLe/TmEN0kV51fwtPSbFJNKO8hQFnnhQ8eAfT 5ob7Xkr8vZmzVSnQRMdGG/zc3JuGOj7UMdMs+uns9Pu9PBSSzpqyCw2ZffwFdOeWfePiuROVtx 6asJ5kwbszozmokzp2Qv+nTsdQLu2xgptMsgdhHBx2ruZyv/jOyTTm5DwViSffUVRlaNgcCNE6 HQw= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448469" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:30 +0800 IronPort-SDR: a62WXcZXTcXB7eLMUwtxHsDLBUjKIxi5y8YbtyFnLYaNsc73wCQrOZ5mdjn2ARhdAUgQYmnP2M RG24QrF8M/rRCXVHCIUZSiXcztfK+lLDBnAzVyNMeVdN2uURJr3Pv0JZMELnEX7mC2McRHFvoh 5mJx9tQxzQsYtdtknngPV1kn34rN0omgMd91PUSwOPrqCvMMeV3n+758kuMkFPoLUqHxJJ77Mi G7pOPnDPxtewH0MGKryR8bV/BUuGpGyudfEdkQcRHNBhMGYepkmeQENi5LlQSVNl7MC1rAADcK TwOn4Y6+FgZ8e5XjhMalK1Y8 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:10:04 -0800 IronPort-SDR: l6mH/soTKiGx2C5eybJI9vuXmj9jCH5tYY9YwrS6wZYb8shS1m0V+rdm/b7p8ygd5a/UoBsZ// BrtrTWmtue/ys5OBCMXXe9bwMlLyd5PJtxwk2kZllOIJQvqCHuugVzO5U9C2wO/I14s4vKAeBc y0AwxfpQwAA2J68WiOmYEJVVLkg4Yuptu5zYFqESia+62uCgCQpZ30jK0TVBEb0VpiCr7oLZKZ myd8TPpkQtDZ/Zwiuze4G7kuGeWoy6C3Q/kmzoN1D16LI0lXKxWDIerkgkbNdtkT6I365JHYxt nhE= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:14 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn , Josef Bacik , Nikolay Borisov Subject: [PATCH v7 7/8] btrfs: remove buffer_heads from btrfsic_process_written_block() Date: Wed, 12 Feb 2020 16:17:03 +0900 Message-Id: <20200212071704.17505-8-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that the last caller of btrfsic_process_written_block() with buffer_heads is gone, remove the buffer_head processing path from it as well. Signed-off-by: Johannes Thumshirn Reviewed-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/check-integrity.c | 103 +++++++++---------------------------- 1 file changed, 25 insertions(+), 78 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index e7507985435e..4f6db2fe482a 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -152,11 +152,8 @@ struct btrfsic_block { struct list_head ref_to_list; /* list */ struct list_head ref_from_list; /* list */ struct btrfsic_block *next_in_same_bio; - void *orig_bio_bh_private; - union { - bio_end_io_t *bio; - bh_end_io_t *bh; - } orig_bio_bh_end_io; + void *orig_bio_private; + bio_end_io_t *orig_bio_end_io; int submit_bio_bh_rw; u64 flush_gen; /* only valid if !never_written */ }; @@ -325,14 +322,12 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, u64 dev_bytenr, char **mapped_datav, unsigned int num_pages, struct bio *bio, int *bio_is_patched, - struct buffer_head *bh, int submit_bio_bh_rw); static int btrfsic_process_written_superblock( struct btrfsic_state *state, struct btrfsic_block *const block, struct btrfs_super_block *const super_hdr); static void btrfsic_bio_end_io(struct bio *bp); -static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate); static int btrfsic_is_block_ref_by_superblock(const struct btrfsic_state *state, const struct btrfsic_block *block, int recursion_level); @@ -399,8 +394,8 @@ static void btrfsic_block_init(struct btrfsic_block *b) b->never_written = 0; b->mirror_num = 0; b->next_in_same_bio = NULL; - b->orig_bio_bh_private = NULL; - b->orig_bio_bh_end_io.bio = NULL; + b->orig_bio_private = NULL; + b->orig_bio_end_io = NULL; INIT_LIST_HEAD(&b->collision_resolving_node); INIT_LIST_HEAD(&b->all_blocks_node); INIT_LIST_HEAD(&b->ref_to_list); @@ -1743,7 +1738,6 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, u64 dev_bytenr, char **mapped_datav, unsigned int num_pages, struct bio *bio, int *bio_is_patched, - struct buffer_head *bh, int submit_bio_bh_rw) { int is_metadata; @@ -1902,9 +1896,9 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, block->is_iodone = 0; BUG_ON(NULL == bio_is_patched); if (!*bio_is_patched) { - block->orig_bio_bh_private = + block->orig_bio_private = bio->bi_private; - block->orig_bio_bh_end_io.bio = + block->orig_bio_end_io = bio->bi_end_io; block->next_in_same_bio = NULL; bio->bi_private = block; @@ -1916,25 +1910,17 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, bio->bi_private; BUG_ON(NULL == chained_block); - block->orig_bio_bh_private = - chained_block->orig_bio_bh_private; - block->orig_bio_bh_end_io.bio = - chained_block->orig_bio_bh_end_io. - bio; + block->orig_bio_private = + chained_block->orig_bio_private; + block->orig_bio_end_io = + chained_block->orig_bio_end_io; block->next_in_same_bio = chained_block; bio->bi_private = block; } - } else if (NULL != bh) { - block->is_iodone = 0; - block->orig_bio_bh_private = bh->b_private; - block->orig_bio_bh_end_io.bh = bh->b_end_io; - block->next_in_same_bio = NULL; - bh->b_private = block; - bh->b_end_io = btrfsic_bh_end_io; } else { block->is_iodone = 1; - block->orig_bio_bh_private = NULL; - block->orig_bio_bh_end_io.bio = NULL; + block->orig_bio_private = NULL; + block->orig_bio_end_io = NULL; block->next_in_same_bio = NULL; } } @@ -2042,8 +2028,8 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, block->is_iodone = 0; BUG_ON(NULL == bio_is_patched); if (!*bio_is_patched) { - block->orig_bio_bh_private = bio->bi_private; - block->orig_bio_bh_end_io.bio = bio->bi_end_io; + block->orig_bio_private = bio->bi_private; + block->orig_bio_end_io = bio->bi_end_io; block->next_in_same_bio = NULL; bio->bi_private = block; bio->bi_end_io = btrfsic_bio_end_io; @@ -2054,24 +2040,17 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, bio->bi_private; BUG_ON(NULL == chained_block); - block->orig_bio_bh_private = - chained_block->orig_bio_bh_private; - block->orig_bio_bh_end_io.bio = - chained_block->orig_bio_bh_end_io.bio; + block->orig_bio_private = + chained_block->orig_bio_private; + block->orig_bio_end_io = + chained_block->orig_bio_end_io; block->next_in_same_bio = chained_block; bio->bi_private = block; } - } else if (NULL != bh) { - block->is_iodone = 0; - block->orig_bio_bh_private = bh->b_private; - block->orig_bio_bh_end_io.bh = bh->b_end_io; - block->next_in_same_bio = NULL; - bh->b_private = block; - bh->b_end_io = btrfsic_bh_end_io; } else { block->is_iodone = 1; - block->orig_bio_bh_private = NULL; - block->orig_bio_bh_end_io.bio = NULL; + block->orig_bio_private = NULL; + block->orig_bio_end_io = NULL; block->next_in_same_bio = NULL; } if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) @@ -2112,8 +2091,8 @@ static void btrfsic_bio_end_io(struct bio *bp) iodone_w_error = 1; BUG_ON(NULL == block); - bp->bi_private = block->orig_bio_bh_private; - bp->bi_end_io = block->orig_bio_bh_end_io.bio; + bp->bi_private = block->orig_bio_private; + bp->bi_end_io = block->orig_bio_end_io; do { struct btrfsic_block *next_block; @@ -2146,38 +2125,6 @@ static void btrfsic_bio_end_io(struct bio *bp) bp->bi_end_io(bp); } -static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate) -{ - struct btrfsic_block *block = (struct btrfsic_block *)bh->b_private; - int iodone_w_error = !uptodate; - struct btrfsic_dev_state *dev_state; - - BUG_ON(NULL == block); - dev_state = block->dev_state; - if ((dev_state->state->print_mask & BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) - pr_info("bh_end_io(error=%d) for %c @%llu (%s/%llu/%d)\n", - iodone_w_error, - btrfsic_get_block_type(dev_state->state, block), - block->logical_bytenr, block->dev_state->name, - block->dev_bytenr, block->mirror_num); - - block->iodone_w_error = iodone_w_error; - if (block->submit_bio_bh_rw & REQ_PREFLUSH) { - dev_state->last_flush_gen++; - if ((dev_state->state->print_mask & - BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) - pr_info("bh_end_io() new %s flush_gen=%llu\n", - dev_state->name, dev_state->last_flush_gen); - } - if (block->submit_bio_bh_rw & REQ_FUA) - block->flush_gen = 0; /* FUA completed means block is on disk */ - - bh->b_private = block->orig_bio_bh_private; - bh->b_end_io = block->orig_bio_bh_end_io.bh; - block->is_iodone = 1; /* for FLUSH, this releases the block */ - bh->b_end_io(bh, uptodate); -} - static int btrfsic_process_written_superblock( struct btrfsic_state *state, struct btrfsic_block *const superblock, @@ -2781,7 +2728,7 @@ static void __btrfsic_submit_bio(struct bio *bio) btrfsic_process_written_block(dev_state, dev_bytenr, mapped_datav, segs, bio, &bio_is_patched, - NULL, bio->bi_opf); + bio->bi_opf); bio_for_each_segment(bvec, bio, iter) kunmap(bvec.bv_page); kfree(mapped_datav); @@ -2805,8 +2752,8 @@ static void __btrfsic_submit_bio(struct bio *bio) block->iodone_w_error = 0; block->flush_gen = dev_state->last_flush_gen + 1; block->submit_bio_bh_rw = bio->bi_opf; - block->orig_bio_bh_private = bio->bi_private; - block->orig_bio_bh_end_io.bio = bio->bi_end_io; + block->orig_bio_private = bio->bi_private; + block->orig_bio_end_io = bio->bi_end_io; block->next_in_same_bio = NULL; bio->bi_private = block; bio->bi_end_io = btrfsic_bio_end_io; From patchwork Wed Feb 12 07:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11377663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C702109A for ; Wed, 12 Feb 2020 07:17:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F00BA2082F for ; Wed, 12 Feb 2020 07:17:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="EOeIkCqL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728365AbgBLHRS (ORCPT ); Wed, 12 Feb 2020 02:17:18 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46465 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728364AbgBLHRQ (ORCPT ); Wed, 12 Feb 2020 02:17:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1581491852; x=1613027852; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KhzX+Ed9N8URGpxMD3mmu5ZshsLiHOwaKqwRZ/TRbbc=; b=EOeIkCqLhZAgB3Nu0UScyszSTZWjG43R7q5xIUpIa5sN/GDhZbmGHmF7 xEPw5nhvFA67xMXdPWwKBPETgxulXfP6SWKWM5juYJCMpjhK4C1RzkZk+ ItpPsDGiYlA2vGC98J9Nl5VxxZA5D62vBvtk+L0GZ1yPvgeRZ4ez2600m czgfPeU/BDQnkPLGsnpioZD3Nzb5N1Z5N5y/W0z4hrZKx/8ounl/43BTC wwdWhcITKs689HaygK0r2YJmFDAQENyAV8hXPUvMCR+b032mzE0nFokW8 23FeTMoX55YBVPFkpz9KidEq1ugKBwRbWpvwynNfwduK+pUlQJjOyWLyS A==; IronPort-SDR: RTzC5nSHnWT/N7CERlHuHNXFKcW2X6g9lfMuST5wtOfZ3Zi1hWlpdbILP4wRkqiDabQHNkj5lc trmStcinwP6ukExyNAL2r4c2vmytqkIcpa5NlaDr8DTQDnzEPU5DJUx1o+bSs89gwTScnMUzg1 si/UvoXrB8E13WNw50MRLNBAqig5SWNpbIaJFM82wrPk1fUOu3tUBTYTNqC/WNLZ6AXRce4Ig3 r8QP+TTpEYFJBR7OpkobfbtwTLbWNEC3F2mtCW1fBYMmpuJGgEDNhUmGlFHy3P1KLGDz4Y5bnf k7E= X-IronPort-AV: E=Sophos;i="5.70,428,1574092800"; d="scan'208";a="231448471" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2020 15:17:32 +0800 IronPort-SDR: 0mNvYOJ1HjWJa53/uHUHZU/I6SrGmijBVO03BAROhDM3+XySNkOp48u0jch2HXmaPo06C+DRh/ 14Sqr9XpJwGV5W8zD6nPMhLvtt6/1LBvFI/2SxGYqNeyVXvFdFcQs8GYzAp47bSYweQm7bpp4K f7dxYnBxMhwXNSHupBKAF3sKB+yP/Stfw/xdSqX7CEWPIKyRJGbOEC2YpvIaobRmo+QWZ0Xus9 zXdX+gBIzw+tqHeDR5LBZx7bTPkmzONK1PsLKimgtnrsNW9ar1imoWVAoYM9ZflVIo1O646lYk wgofqaaAMePZms7sx2GkzVr8 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 23:10:05 -0800 IronPort-SDR: gjBPEkBsbsarBMUF/r5yWOFYjJTxWr3FX2VN39FEKyi6vfNu8PxD0SWyPsbcS1e9GeB3Yt9rin H5dsXi0txMSRKJYTNEodDdQXiqJItszldZhe5qjK9/U7tGehlQimjrYBdOVygvZx41aU3i/Spi XGynWYzignNHymKoUsiOWOiSZLbOBT9P0clJ8cdmYu6EJRkx41Lwk2gHO6ov5e6wNagQGJMBn+ pqa00uniojvx7JkpPBmHZfPe51Py6Cxw/EgQuoAkMHmAwTWtpnznfNUvnyyFwn7QjkUvS8+NHq NHY= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip01.wdc.com with ESMTP; 11 Feb 2020 23:17:16 -0800 From: Johannes Thumshirn To: David Sterba Cc: "linux-btrfs @ vger . kernel . org" , Johannes Thumshirn , Josef Bacik , Nikolay Borisov Subject: [PATCH v7 8/8] btrfs: remove buffer_heads form superblock mirror integrity checking Date: Wed, 12 Feb 2020 16:17:04 +0900 Message-Id: <20200212071704.17505-9-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200212071704.17505-1-johannes.thumshirn@wdc.com> References: <20200212071704.17505-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The integrity checking code for the superblock mirrors is the last remaining user of buffer_heads in BTRFS, change it to using plain BIOs as well. Signed-off-by: Johannes Thumshirn Reviewed-by: Josef Bacik Reviewed-by: Nikolay Borisov --- Changes to v4: - Remove mapping_gfp_constraint() Changes to v2: - Open-code kunmap() + put_page() (David) - Remove __GFP_NOFAIL from allocation (Josef) - Merge error paths (David) Changes to v1: - Convert from alloc_page() to find_or_create_page() --- fs/btrfs/check-integrity.c | 55 +++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 4f6db2fe482a..e10a27d6db08 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -77,7 +77,6 @@ #include #include -#include #include #include #include @@ -762,29 +761,45 @@ static int btrfsic_process_superblock_dev_mirror( struct btrfs_fs_info *fs_info = state->fs_info; struct btrfs_super_block *super_tmp; u64 dev_bytenr; - struct buffer_head *bh; struct btrfsic_block *superblock_tmp; int pass; struct block_device *const superblock_bdev = device->bdev; + struct page *page; + struct bio bio; + struct bio_vec bio_vec; + struct address_space *mapping = superblock_bdev->bd_inode->i_mapping; + int ret; /* super block bytenr is always the unmapped device bytenr */ dev_bytenr = btrfs_sb_offset(superblock_mirror_num); if (dev_bytenr + BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes) return -1; - bh = __bread(superblock_bdev, dev_bytenr / BTRFS_BDEV_BLOCKSIZE, - BTRFS_SUPER_INFO_SIZE); - if (NULL == bh) + + page = find_or_create_page(mapping, dev_bytenr >> PAGE_SHIFT, GFP_NOFS); + if (!page) + return -1; + + bio_init(&bio, &bio_vec, 1); + bio.bi_iter.bi_sector = dev_bytenr >> SECTOR_SHIFT; + bio_set_dev(&bio, superblock_bdev); + bio_set_op_attrs(&bio, REQ_OP_READ, 0); + bio_add_page(&bio, page, BTRFS_SUPER_INFO_SIZE, 0); + + ret = submit_bio_wait(&bio); + if (ret) return -1; - super_tmp = (struct btrfs_super_block *) - (bh->b_data + (dev_bytenr & (BTRFS_BDEV_BLOCKSIZE - 1))); + + unlock_page(page); + + super_tmp = kmap(page); if (btrfs_super_bytenr(super_tmp) != dev_bytenr || btrfs_super_magic(super_tmp) != BTRFS_MAGIC || memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) || btrfs_super_nodesize(super_tmp) != state->metablock_size || btrfs_super_sectorsize(super_tmp) != state->datablock_size) { - brelse(bh); - return 0; + ret = 0; + goto out_unmap; } superblock_tmp = @@ -795,8 +810,8 @@ static int btrfsic_process_superblock_dev_mirror( superblock_tmp = btrfsic_block_alloc(); if (NULL == superblock_tmp) { pr_info("btrfsic: error, kmalloc failed!\n"); - brelse(bh); - return -1; + ret = -1; + goto out_unmap; } /* for superblock, only the dev_bytenr makes sense */ superblock_tmp->dev_bytenr = dev_bytenr; @@ -880,8 +895,8 @@ static int btrfsic_process_superblock_dev_mirror( mirror_num)) { pr_info("btrfsic: btrfsic_map_block(bytenr @%llu, mirror %d) failed!\n", next_bytenr, mirror_num); - brelse(bh); - return -1; + ret = -1; + goto out_unmap; } next_block = btrfsic_block_lookup_or_add( @@ -890,8 +905,8 @@ static int btrfsic_process_superblock_dev_mirror( mirror_num, NULL); if (NULL == next_block) { btrfsic_release_block_ctx(&tmp_next_block_ctx); - brelse(bh); - return -1; + ret = -1; + goto out_unmap; } next_block->disk_key = tmp_disk_key; @@ -902,16 +917,18 @@ static int btrfsic_process_superblock_dev_mirror( BTRFSIC_GENERATION_UNKNOWN); btrfsic_release_block_ctx(&tmp_next_block_ctx); if (NULL == l) { - brelse(bh); - return -1; + ret = -1; + goto out_unmap; } } } if (state->print_mask & BTRFSIC_PRINT_MASK_INITIAL_ALL_TREES) btrfsic_dump_tree_sub(state, superblock_tmp, 0); - brelse(bh); - return 0; +out_unmap: + kunmap(page); + put_page(page); + return ret; } static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void)