Commit 9da2b242 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba

btrfs: remove buffer_heads form super block mirror integrity checking

The integrity checking code for the super block mirrors is the last
remaining user of buffer_heads, change it to using plain bios as well.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 59aaad50
...@@ -77,7 +77,6 @@ ...@@ -77,7 +77,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/buffer_head.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/genhd.h> #include <linux/genhd.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
...@@ -762,29 +761,31 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -762,29 +761,31 @@ static int btrfsic_process_superblock_dev_mirror(
struct btrfs_fs_info *fs_info = state->fs_info; struct btrfs_fs_info *fs_info = state->fs_info;
struct btrfs_super_block *super_tmp; struct btrfs_super_block *super_tmp;
u64 dev_bytenr; u64 dev_bytenr;
struct buffer_head *bh;
struct btrfsic_block *superblock_tmp; struct btrfsic_block *superblock_tmp;
int pass; int pass;
struct block_device *const superblock_bdev = device->bdev; struct block_device *const superblock_bdev = device->bdev;
struct page *page;
struct address_space *mapping = superblock_bdev->bd_inode->i_mapping;
int ret = 0;
/* super block bytenr is always the unmapped device bytenr */ /* super block bytenr is always the unmapped device bytenr */
dev_bytenr = btrfs_sb_offset(superblock_mirror_num); dev_bytenr = btrfs_sb_offset(superblock_mirror_num);
if (dev_bytenr + BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes) if (dev_bytenr + BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes)
return -1; return -1;
bh = __bread(superblock_bdev, dev_bytenr / BTRFS_BDEV_BLOCKSIZE,
BTRFS_SUPER_INFO_SIZE); page = read_cache_page_gfp(mapping, dev_bytenr >> PAGE_SHIFT, GFP_NOFS);
if (NULL == bh) if (IS_ERR(page))
return -1; return -1;
super_tmp = (struct btrfs_super_block *)
(bh->b_data + (dev_bytenr & (BTRFS_BDEV_BLOCKSIZE - 1))); super_tmp = page_address(page);
if (btrfs_super_bytenr(super_tmp) != dev_bytenr || if (btrfs_super_bytenr(super_tmp) != dev_bytenr ||
btrfs_super_magic(super_tmp) != BTRFS_MAGIC || btrfs_super_magic(super_tmp) != BTRFS_MAGIC ||
memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) || memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) ||
btrfs_super_nodesize(super_tmp) != state->metablock_size || btrfs_super_nodesize(super_tmp) != state->metablock_size ||
btrfs_super_sectorsize(super_tmp) != state->datablock_size) { btrfs_super_sectorsize(super_tmp) != state->datablock_size) {
brelse(bh); ret = 0;
return 0; goto out;
} }
superblock_tmp = superblock_tmp =
...@@ -795,8 +796,8 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -795,8 +796,8 @@ static int btrfsic_process_superblock_dev_mirror(
superblock_tmp = btrfsic_block_alloc(); superblock_tmp = btrfsic_block_alloc();
if (NULL == superblock_tmp) { if (NULL == superblock_tmp) {
pr_info("btrfsic: error, kmalloc failed!\n"); pr_info("btrfsic: error, kmalloc failed!\n");
brelse(bh); ret = -1;
return -1; goto out;
} }
/* for superblock, only the dev_bytenr makes sense */ /* for superblock, only the dev_bytenr makes sense */
superblock_tmp->dev_bytenr = dev_bytenr; superblock_tmp->dev_bytenr = dev_bytenr;
...@@ -880,8 +881,8 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -880,8 +881,8 @@ static int btrfsic_process_superblock_dev_mirror(
mirror_num)) { mirror_num)) {
pr_info("btrfsic: btrfsic_map_block(bytenr @%llu, mirror %d) failed!\n", pr_info("btrfsic: btrfsic_map_block(bytenr @%llu, mirror %d) failed!\n",
next_bytenr, mirror_num); next_bytenr, mirror_num);
brelse(bh); ret = -1;
return -1; goto out;
} }
next_block = btrfsic_block_lookup_or_add( next_block = btrfsic_block_lookup_or_add(
...@@ -890,8 +891,8 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -890,8 +891,8 @@ static int btrfsic_process_superblock_dev_mirror(
mirror_num, NULL); mirror_num, NULL);
if (NULL == next_block) { if (NULL == next_block) {
btrfsic_release_block_ctx(&tmp_next_block_ctx); btrfsic_release_block_ctx(&tmp_next_block_ctx);
brelse(bh); ret = -1;
return -1; goto out;
} }
next_block->disk_key = tmp_disk_key; next_block->disk_key = tmp_disk_key;
...@@ -902,16 +903,17 @@ static int btrfsic_process_superblock_dev_mirror( ...@@ -902,16 +903,17 @@ static int btrfsic_process_superblock_dev_mirror(
BTRFSIC_GENERATION_UNKNOWN); BTRFSIC_GENERATION_UNKNOWN);
btrfsic_release_block_ctx(&tmp_next_block_ctx); btrfsic_release_block_ctx(&tmp_next_block_ctx);
if (NULL == l) { if (NULL == l) {
brelse(bh); ret = -1;
return -1; goto out;
} }
} }
} }
if (state->print_mask & BTRFSIC_PRINT_MASK_INITIAL_ALL_TREES) if (state->print_mask & BTRFSIC_PRINT_MASK_INITIAL_ALL_TREES)
btrfsic_dump_tree_sub(state, superblock_tmp, 0); btrfsic_dump_tree_sub(state, superblock_tmp, 0);
brelse(bh); out:
return 0; put_page(page);
return ret;
} }
static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void) static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment