Message ID | 20220625091547.102882-1-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: don't take a bio_counter reference for cloned bios | expand |
On 25.06.22 г. 12:15 ч., Christoph Hellwig wrote: > There is no need for multiple bio_counter references for a single I/O. > Just release the reference when completing the bio and avoid additional > counter roundtrips. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Though this doesn't apply cleanly on current misc-next so had to manually clean it up. Also the changelog is somewhat terse essentially the block count is now being "carried" by the top-level bio or rather the bio_io_context since btrfs_bio_counter_dec() call shall be moved into btrfs_end_bioc.
On Tue, Jul 05, 2022 at 03:38:32PM +0300, Nikolay Borisov wrote: > Though this doesn't apply cleanly on current misc-next so had to manually > clean it up. This applies against the for-next branch fine, which still has a big chunk of bio related patches in it that didn't make it to misc-next. > Also the changelog is somewhat terse essentially the block > count is now being "carried" by the top-level bio or rather the > bio_io_context since btrfs_bio_counter_dec() call shall be moved into > btrfs_end_bioc. btrfs_end_bioc is gone in for-next.
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 4e2569f84aabc..ad15c0c602a61 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3987,7 +3987,6 @@ static inline void btrfs_init_full_stripe_locks_tree( /* dev-replace.c */ void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info); -void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info); void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount); static inline void btrfs_bio_counter_dec(struct btrfs_fs_info *fs_info) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index a7dd6ba25e990..aa435d04e8ef3 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -1288,11 +1288,6 @@ int __pure btrfs_dev_replace_is_ongoing(struct btrfs_dev_replace *dev_replace) return 1; } -void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info) -{ - percpu_counter_inc(&fs_info->dev_replace.bio_counter); -} - void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount) { percpu_counter_sub(&fs_info->dev_replace.bio_counter, amount); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6aa6bc769569a..207e136d1a721 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6647,8 +6647,6 @@ static void btrfs_end_bio(struct bio *bio) } } - btrfs_bio_counter_dec(bioc->fs_info); - if (bio != orig_bio) { bio_endio(orig_bio); bio_put(bio); @@ -6664,6 +6662,7 @@ static void btrfs_end_bio(struct bio *bio) else orig_bio->bi_status = BLK_STS_OK; + btrfs_bio_counter_dec(bioc->fs_info); bbio->mirror_num = bioc->mirror_num; orig_bio->bi_end_io = bioc->end_io; orig_bio->bi_private = bioc->private; @@ -6698,8 +6697,6 @@ static void submit_stripe_bio(struct btrfs_io_context *bioc, bio->bi_end_io = btrfs_end_bio; bio->bi_iter.bi_sector = physical >> 9; - btrfs_bio_counter_inc_noblocked(fs_info); - if (!dev || !dev->bdev || test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) || (btrfs_op(bio) == BTRFS_MAP_WRITE && @@ -6780,7 +6777,6 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror submit_stripe_bio(bioc, bio, dev_nr, should_clone); } - btrfs_bio_counter_dec(fs_info); } static bool dev_args_match_fs_devices(const struct btrfs_dev_lookup_args *args,
There is no need for multiple bio_counter references for a single I/O. Just release the reference when completing the bio and avoid additional counter roundtrips. Signed-off-by: Christoph Hellwig <hch@lst.de> --- This is against the for-next branch as it is a follow up the review feeback to the "cleanup btrfs bio submission v2" series. fs/btrfs/ctree.h | 1 - fs/btrfs/dev-replace.c | 5 ----- fs/btrfs/volumes.c | 6 +----- 3 files changed, 1 insertion(+), 11 deletions(-)