aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-19 17:36:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-19 17:36:00 -0500
commit2b9fb532d4168e8974fe49709e2c4c8d5352a64c (patch)
tree610cbe2d1bb32e28db135a767f158ade31452e2e /fs/btrfs/dev-replace.c
parent4533f6e27a366ecc3da4876074ebfe0cc0ea4f0f (diff)
parenta742994aa2e271eb8cd8e043d276515ec858ed73 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs updates from Chris Mason: "This pull is mostly cleanups and fixes: - The raid5/6 cleanups from Zhao Lei fixup some long standing warts in the code and add improvements on top of the scrubbing support from 3.19. - Josef has round one of our ENOSPC fixes coming from large btrfs clusters here at FB. - Dave Sterba continues a long series of cleanups (thanks Dave), and Filipe continues hammering on corner cases in fsync and others This all was held up a little trying to track down a use-after-free in btrfs raid5/6. It's not clear yet if this is just made easier to trigger with this pull or if its a new bug from the raid5/6 cleanups. Dave Sterba is the only one to trigger it so far, but he has a consistent way to reproduce, so we'll get it nailed shortly" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (68 commits) Btrfs: don't remove extents and xattrs when logging new names Btrfs: fix fsync data loss after adding hard link to inode Btrfs: fix BUG_ON in btrfs_orphan_add() when delete unused block group Btrfs: account for large extents with enospc Btrfs: don't set and clear delalloc for O_DIRECT writes Btrfs: only adjust outstanding_extents when we do a short write btrfs: Fix out-of-space bug Btrfs: scrub, fix sleep in atomic context Btrfs: fix scheduler warning when syncing log Btrfs: Remove unnecessary placeholder in btrfs_err_code btrfs: cleanup init for list in free-space-cache btrfs: delete chunk allocation attemp when setting block group ro btrfs: clear bio reference after submit_one_bio() Btrfs: fix scrub race leading to use-after-free Btrfs: add missing cleanup on sysfs init failure Btrfs: fix race between transaction commit and empty block group removal btrfs: add more checks to btrfs_read_sys_array btrfs: cleanup, rename a few variables in btrfs_read_sys_array btrfs: add checks for sys_chunk_array sizes btrfs: more superblock checks, lower bounds on devices and sectorsize/nodesize ...
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c25
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 */
441static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) 441static 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
933void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info) 924void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info)
934{ 925{
935 DEFINE_WAIT(wait); 926 while (1) {
936again: 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}