diff options
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r-- | fs/btrfs/dev-replace.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index ca6a3a3b6b6c..5ec03d999c37 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -440,18 +440,9 @@ leave: | |||
440 | */ | 440 | */ |
441 | static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) | 441 | static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) |
442 | { | 442 | { |
443 | s64 writers; | ||
444 | DEFINE_WAIT(wait); | ||
445 | |||
446 | set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); | 443 | set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); |
447 | do { | 444 | wait_event(fs_info->replace_wait, !percpu_counter_sum( |
448 | prepare_to_wait(&fs_info->replace_wait, &wait, | 445 | &fs_info->bio_counter)); |
449 | TASK_UNINTERRUPTIBLE); | ||
450 | writers = percpu_counter_sum(&fs_info->bio_counter); | ||
451 | if (writers) | ||
452 | schedule(); | ||
453 | finish_wait(&fs_info->replace_wait, &wait); | ||
454 | } while (writers); | ||
455 | } | 446 | } |
456 | 447 | ||
457 | /* | 448 | /* |
@@ -932,15 +923,15 @@ void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount) | |||
932 | 923 | ||
933 | void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info) | 924 | void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info) |
934 | { | 925 | { |
935 | DEFINE_WAIT(wait); | 926 | while (1) { |
936 | again: | 927 | percpu_counter_inc(&fs_info->bio_counter); |
937 | percpu_counter_inc(&fs_info->bio_counter); | 928 | if (likely(!test_bit(BTRFS_FS_STATE_DEV_REPLACING, |
938 | if (test_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state)) { | 929 | &fs_info->fs_state))) |
930 | break; | ||
931 | |||
939 | btrfs_bio_counter_dec(fs_info); | 932 | btrfs_bio_counter_dec(fs_info); |
940 | wait_event(fs_info->replace_wait, | 933 | wait_event(fs_info->replace_wait, |
941 | !test_bit(BTRFS_FS_STATE_DEV_REPLACING, | 934 | !test_bit(BTRFS_FS_STATE_DEV_REPLACING, |
942 | &fs_info->fs_state)); | 935 | &fs_info->fs_state)); |
943 | goto again; | ||
944 | } | 936 | } |
945 | |||
946 | } | 937 | } |