linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: David Sterba <dsterba@suse.cz>,
	"linux-btrfs @ vger . kernel . org" <linux-btrfs@vger.kernel.org>,
	Josef Bacik <josef@toxicpanda.com>,
	Nikolay Borisov <nborisov@suse.com>
Subject: Re: [PATCH v7 8/8] btrfs: remove buffer_heads form superblock mirror integrity checking
Date: Wed, 12 Feb 2020 18:06:08 +0100	[thread overview]
Message-ID: <20200212170608.GN2902@twin.jikos.cz> (raw)
In-Reply-To: <20200212071704.17505-9-johannes.thumshirn@wdc.com>

On Wed, Feb 12, 2020 at 04:17:04PM +0900, Johannes Thumshirn wrote:
> @@ -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);

I beleve the same reasoning applies here regarding kmap, it's the bdev
mapping and we won't get a highmem 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 =

  reply	other threads:[~2020-02-12 17:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12  7:16 [PATCH v7 0/8] btrfs: remove buffer heads form superblock handling Johannes Thumshirn
2020-02-12  7:16 ` [PATCH v7 1/8] btrfs: Export btrfs_release_disk_super Johannes Thumshirn
2020-02-12  7:16 ` [PATCH v7 2/8] btrfs: don't kmap() pages from block devices Johannes Thumshirn
2020-02-12  7:25   ` Christoph Hellwig
2020-02-12  7:16 ` [PATCH v7 3/8] btrfs: unexport btrfs_scratch_superblocks Johannes Thumshirn
2020-02-12  7:27   ` Christoph Hellwig
2020-02-12  7:51     ` Johannes Thumshirn
2020-02-12  7:17 ` [PATCH v7 4/8] btrfs: use the page-cache for super block reading Johannes Thumshirn
2020-02-12  7:28   ` Christoph Hellwig
2020-02-12  7:43     ` Johannes Thumshirn
2020-02-12  7:17 ` [PATCH v7 5/8] btrfs: use BIOs instead of buffer_heads from superblock writeout Johannes Thumshirn
2020-02-12  7:30   ` Christoph Hellwig
2020-02-12  7:17 ` [PATCH v7 6/8] btrfs: remove btrfsic_submit_bh() Johannes Thumshirn
2020-02-12  7:17 ` [PATCH v7 7/8] btrfs: remove buffer_heads from btrfsic_process_written_block() Johannes Thumshirn
2020-02-12  7:17 ` [PATCH v7 8/8] btrfs: remove buffer_heads form superblock mirror integrity checking Johannes Thumshirn
2020-02-12 17:06   ` David Sterba [this message]
2020-02-13  9:12     ` 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=20200212170608.GN2902@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=johannes.thumshirn@wdc.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).