All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: David Sterba <dsterba@suse.cz>
Cc: Nikolay Borisov <nborisov@suse.com>,
	Josef Bacik <josef@toxicpanda.com>,
	"linux-btrfs @ vger . kernel . org" <linux-btrfs@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH v6 2/7] btrfs: don't kmap() pages from block devices
Date: Tue, 11 Feb 2020 03:32:20 +0900	[thread overview]
Message-ID: <20200210183225.10137-3-johannes.thumshirn@wdc.com> (raw)
In-Reply-To: <20200210183225.10137-1-johannes.thumshirn@wdc.com>

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 <hch@lst.de>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 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);
-- 
2.24.1


  parent reply	other threads:[~2020-02-10 18:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 18:32 [PATCH v6 0/7] btrfs: remove buffer heads form superblock handling Johannes Thumshirn
2020-02-10 18:32 ` [PATCH v6 1/7] btrfs: Export btrfs_release_disk_super Johannes Thumshirn
2020-02-10 18:32 ` Johannes Thumshirn [this message]
2020-02-10 18:32 ` [PATCH v6 3/7] btrfs: use the page-cache for super block reading Johannes Thumshirn
2020-02-11 18:53   ` David Sterba
2020-02-11 19:03     ` Johannes Thumshirn
2020-02-10 18:32 ` [PATCH v6 4/7] btrfs: use BIOs instead of buffer_heads from superblock writeout Johannes Thumshirn
2020-02-10 18:32 ` [PATCH v6 5/7] btrfs: remove btrfsic_submit_bh() Johannes Thumshirn
2020-02-10 18:32 ` [PATCH v6 6/7] btrfs: remove buffer_heads from btrfsic_process_written_block() Johannes Thumshirn
2020-02-10 18:32 ` [PATCH v6 7/7] btrfs: remove buffer_heads form superblock mirror integrity checking Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200210183225.10137-3-johannes.thumshirn@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=dsterba@suse.cz \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.