aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2018-04-04 19:04:49 -0400
committerDavid Sterba <dsterba@suse.com>2018-10-15 11:23:38 -0400
commit7f8d236ae132a8886a0186008c828e21f7460474 (patch)
tree63bf1e2dd346ebefa152cc911919eb9f47254e33 /fs/btrfs/dev-replace.c
parentaa144bfeaa7f87c536ab323edfe2692285343e68 (diff)
btrfs: dev-replace: move replace members out of fs_info
The replace_wait and bio_counter were mistakenly added to fs_info in commit c404e0dc2c843b154f ("Btrfs: fix use-after-free in the finishing procedure of the device replace"), but they logically belong to fs_info::dev_replace. Besides, bio_counter is a very generic name and is confusing in bare fs_info context. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index c7f2d6b91a6f..d1ea76bccaaf 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -545,8 +545,8 @@ int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
545static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) 545static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info)
546{ 546{
547 set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); 547 set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state);
548 wait_event(fs_info->replace_wait, !percpu_counter_sum( 548 wait_event(fs_info->dev_replace.replace_wait, !percpu_counter_sum(
549 &fs_info->bio_counter)); 549 &fs_info->dev_replace.bio_counter));
550} 550}
551 551
552/* 552/*
@@ -555,7 +555,7 @@ static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info)
555static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info) 555static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info)
556{ 556{
557 clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); 557 clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state);
558 wake_up(&fs_info->replace_wait); 558 wake_up(&fs_info->dev_replace.replace_wait);
559} 559}
560 560
561static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, 561static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
@@ -997,25 +997,25 @@ void btrfs_dev_replace_set_lock_blocking(
997 997
998void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info) 998void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info)
999{ 999{
1000 percpu_counter_inc(&fs_info->bio_counter); 1000 percpu_counter_inc(&fs_info->dev_replace.bio_counter);
1001} 1001}
1002 1002
1003void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount) 1003void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount)
1004{ 1004{
1005 percpu_counter_sub(&fs_info->bio_counter, amount); 1005 percpu_counter_sub(&fs_info->dev_replace.bio_counter, amount);
1006 cond_wake_up_nomb(&fs_info->replace_wait); 1006 cond_wake_up_nomb(&fs_info->dev_replace.replace_wait);
1007} 1007}
1008 1008
1009void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info) 1009void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info)
1010{ 1010{
1011 while (1) { 1011 while (1) {
1012 percpu_counter_inc(&fs_info->bio_counter); 1012 percpu_counter_inc(&fs_info->dev_replace.bio_counter);
1013 if (likely(!test_bit(BTRFS_FS_STATE_DEV_REPLACING, 1013 if (likely(!test_bit(BTRFS_FS_STATE_DEV_REPLACING,
1014 &fs_info->fs_state))) 1014 &fs_info->fs_state)))
1015 break; 1015 break;
1016 1016
1017 btrfs_bio_counter_dec(fs_info); 1017 btrfs_bio_counter_dec(fs_info);
1018 wait_event(fs_info->replace_wait, 1018 wait_event(fs_info->dev_replace.replace_wait,
1019 !test_bit(BTRFS_FS_STATE_DEV_REPLACING, 1019 !test_bit(BTRFS_FS_STATE_DEV_REPLACING,
1020 &fs_info->fs_state)); 1020 &fs_info->fs_state));
1021 } 1021 }