Commit b9af128d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba
Browse files

btrfs: raid56: transfer the bio counter reference to the raid submission helpers



Transfer the bio counter reference acquired by btrfs_submit_bio to
raid56_parity_write and raid56_parity_recovery together with the bio
that the reference was acquired for instead of acquiring another
reference in those helpers and dropping the original one in
btrfs_submit_bio.

Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Tested-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6065fd95
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -1815,12 +1815,11 @@ void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc)
	if (IS_ERR(rbio)) {
		btrfs_put_bioc(bioc);
		ret = PTR_ERR(rbio);
		goto out;
		goto out_dec_counter;
	}
	rbio->operation = BTRFS_RBIO_WRITE;
	rbio_add_bio(rbio, bio);

	btrfs_bio_counter_inc_noblocked(fs_info);
	rbio->generic_bio_cnt = 1;

	/*
@@ -1852,7 +1851,6 @@ void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc)

out_dec_counter:
	btrfs_bio_counter_dec(fs_info);
out:
	bio->bi_status = errno_to_blk_status(ret);
	bio_endio(bio);
}
@@ -2208,6 +2206,8 @@ void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc,
	if (generic_io) {
		ASSERT(bioc->mirror_num == mirror_num);
		btrfs_bio(bio)->mirror_num = mirror_num;
	} else {
		btrfs_get_bioc(bioc);
	}

	rbio = alloc_rbio(fs_info, bioc);
@@ -2230,12 +2230,8 @@ void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc,
		goto out_end_bio;
	}

	if (generic_io) {
		btrfs_bio_counter_inc_noblocked(fs_info);
	if (generic_io)
		rbio->generic_bio_cnt = 1;
	} else {
		btrfs_get_bioc(bioc);
	}

	/*
	 * Loop retry:
@@ -2265,7 +2261,7 @@ void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc,
	return;

out_end_bio:
	if (generic_io)
	btrfs_bio_counter_dec(fs_info);
	btrfs_put_bioc(bioc);
	bio_endio(bio);
}
+7 −8
Original line number Diff line number Diff line
@@ -6750,8 +6750,12 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
	btrfs_bio_counter_inc_blocked(fs_info);
	ret = __btrfs_map_block(fs_info, btrfs_op(bio), logical,
				&map_length, &bioc, mirror_num, 1);
	if (ret)
		goto out_dec;
	if (ret) {
		btrfs_bio_counter_dec(fs_info);
		bio->bi_status = errno_to_blk_status(ret);
		bio_endio(bio);
		return;
	}

	total_devs = bioc->num_stripes;
	bioc->orig_bio = bio;
@@ -6765,7 +6769,7 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
			raid56_parity_write(bio, bioc);
		else
			raid56_parity_recover(bio, bioc, mirror_num, true);
		goto out_dec;
		return;
	}

	if (map_length < length) {
@@ -6780,12 +6784,7 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror

		submit_stripe_bio(bioc, bio, dev_nr, should_clone);
	}
out_dec:
	btrfs_bio_counter_dec(fs_info);
	if (ret) {
		bio->bi_status = errno_to_blk_status(ret);
		bio_endio(bio);
	}
}

static bool dev_args_match_fs_devices(const struct btrfs_dev_lookup_args *args,