Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ec706c8 authored by Stefan Behrens's avatar Stefan Behrens Committed by Josef Bacik
Browse files

Btrfs: pass fs_info to btrfs_map_block() instead of mapping_tree



This is required for the device replace procedure in a later step.
Two calling functions also had to be changed to have the fs_info
pointer: repair_io_failure() and scrub_setup_recheck_block().

Signed-off-by: default avatarStefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 5d964051
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1582,7 +1582,7 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,
	struct btrfs_device *device;

	length = len;
	ret = btrfs_map_block(&state->root->fs_info->mapping_tree, READ,
	ret = btrfs_map_block(state->root->fs_info, READ,
			      bytenr, &length, &multi, mirror_num);

	device = multi->stripes[0].dev;
+1 −1
Original line number Diff line number Diff line
@@ -1818,7 +1818,7 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,


	/* Tell the block device(s) that the sectors can be discarded */
	ret = btrfs_map_block(&root->fs_info->mapping_tree, REQ_DISCARD,
	ret = btrfs_map_block(root->fs_info, REQ_DISCARD,
			      bytenr, &num_bytes, &bbio, 0);
	/* Error condition is -ENOMEM */
	if (!ret) {
+9 −10
Original line number Diff line number Diff line
@@ -1917,12 +1917,12 @@ static void repair_io_failure_callback(struct bio *bio, int err)
 * the standard behavior is to write all copies in a raid setup. here we only
 * want to write the one bad copy. so we do the mapping for ourselves and issue
 * submit_bio directly.
 * to avoid any synchonization issues, wait for the data after writing, which
 * to avoid any synchronization issues, wait for the data after writing, which
 * actually prevents the read that triggered the error from finishing.
 * currently, there can be no more than two copies of every data bit. thus,
 * exactly one rewrite is required.
 */
int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
			u64 length, u64 logical, struct page *page,
			int mirror_num)
{
@@ -1944,7 +1944,7 @@ int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
	bio->bi_size = 0;
	map_length = length;

	ret = btrfs_map_block(map_tree, WRITE, logical,
	ret = btrfs_map_block(fs_info, WRITE, logical,
			      &map_length, &bbio, mirror_num);
	if (ret) {
		bio_put(bio);
@@ -1982,14 +1982,13 @@ int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb,
			 int mirror_num)
{
	struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree;
	u64 start = eb->start;
	unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
	int ret = 0;

	for (i = 0; i < num_pages; i++) {
		struct page *p = extent_buffer_page(eb, i);
		ret = repair_io_failure(map_tree, start, PAGE_CACHE_SIZE,
		ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE,
					start, p, mirror_num);
		if (ret)
			break;
@@ -2008,7 +2007,7 @@ static int clean_io_failure(u64 start, struct page *page)
	u64 private;
	u64 private_failure;
	struct io_failure_record *failrec;
	struct btrfs_mapping_tree *map_tree;
	struct btrfs_fs_info *fs_info;
	struct extent_state *state;
	int num_copies;
	int did_repair = 0;
@@ -2044,11 +2043,11 @@ static int clean_io_failure(u64 start, struct page *page)
	spin_unlock(&BTRFS_I(inode)->io_tree.lock);

	if (state && state->start == failrec->start) {
		num_copies = btrfs_num_copies(BTRFS_I(inode)->root->fs_info,
					      failrec->logical, failrec->len);
		fs_info = BTRFS_I(inode)->root->fs_info;
		num_copies = btrfs_num_copies(fs_info, failrec->logical,
					      failrec->len);
		if (num_copies > 1)  {
			map_tree = &BTRFS_I(inode)->root->fs_info->mapping_tree;
			ret = repair_io_failure(map_tree, start, failrec->len,
			ret = repair_io_failure(fs_info, start, failrec->len,
						failrec->logical, page,
						failrec->failed_mirror);
			did_repair = !ret;
+2 −2
Original line number Diff line number Diff line
@@ -337,9 +337,9 @@ struct bio *
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
		gfp_t gfp_flags);

struct btrfs_mapping_tree;
struct btrfs_fs_info;

int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start,
int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
			u64 length, u64 logical, struct page *page,
			int mirror_num);
int end_extent_writepage(struct page *page, int err, u64 start, u64 end);
+5 −7
Original line number Diff line number Diff line
@@ -1549,7 +1549,6 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
			 unsigned long bio_flags)
{
	struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
	struct btrfs_mapping_tree *map_tree;
	u64 logical = (u64)bio->bi_sector << 9;
	u64 length = 0;
	u64 map_length;
@@ -1559,11 +1558,10 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
		return 0;

	length = bio->bi_size;
	map_tree = &root->fs_info->mapping_tree;
	map_length = length;
	ret = btrfs_map_block(map_tree, READ, logical,
	ret = btrfs_map_block(root->fs_info, READ, logical,
			      &map_length, NULL, 0);
	/* Will always return 0 or 1 with map_multi == NULL */
	/* Will always return 0 with map_multi == NULL */
	BUG_ON(ret < 0);
	if (map_length < length + size)
		return 1;
@@ -6364,7 +6362,6 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
{
	struct inode *inode = dip->inode;
	struct btrfs_root *root = BTRFS_I(inode)->root;
	struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree;
	struct bio *bio;
	struct bio *orig_bio = dip->orig_bio;
	struct bio_vec *bvec = orig_bio->bi_io_vec;
@@ -6377,7 +6374,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
	int async_submit = 0;

	map_length = orig_bio->bi_size;
	ret = btrfs_map_block(map_tree, READ, start_sector << 9,
	ret = btrfs_map_block(root->fs_info, READ, start_sector << 9,
			      &map_length, NULL, 0);
	if (ret) {
		bio_put(orig_bio);
@@ -6431,7 +6428,8 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
			bio->bi_end_io = btrfs_end_dio_bio;

			map_length = orig_bio->bi_size;
			ret = btrfs_map_block(map_tree, READ, start_sector << 9,
			ret = btrfs_map_block(root->fs_info, READ,
					      start_sector << 9,
					      &map_length, NULL, 0);
			if (ret) {
				bio_put(bio);
Loading