diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2017-09-01 18:14:29 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-10-30 07:27:55 -0400 |
commit | 45bac0f3d24a76f127a118e7b95a54e616449d16 (patch) | |
tree | 9d4d89f959643ca7c8717009f11d43cafea20394 /fs/btrfs/ioctl.c | |
parent | 69cc7151ee8055e6bf7241a21211231a1a208abd (diff) |
Btrfs: use wait_event instead of a single function
Since TASK_UNINTERRUPTIBLE has been used here, wait_event() can do the
same job.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 1d4f8a7a128c..95bd5336e85b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -609,23 +609,6 @@ fail_free: | |||
609 | return ret; | 609 | return ret; |
610 | } | 610 | } |
611 | 611 | ||
612 | static void btrfs_wait_for_no_snapshotting_writes(struct btrfs_root *root) | ||
613 | { | ||
614 | s64 writers; | ||
615 | DEFINE_WAIT(wait); | ||
616 | |||
617 | do { | ||
618 | prepare_to_wait(&root->subv_writers->wait, &wait, | ||
619 | TASK_UNINTERRUPTIBLE); | ||
620 | |||
621 | writers = percpu_counter_sum(&root->subv_writers->counter); | ||
622 | if (writers) | ||
623 | schedule(); | ||
624 | |||
625 | } while (writers); | ||
626 | finish_wait(&root->subv_writers->wait, &wait); | ||
627 | } | ||
628 | |||
629 | static int create_snapshot(struct btrfs_root *root, struct inode *dir, | 612 | static int create_snapshot(struct btrfs_root *root, struct inode *dir, |
630 | struct dentry *dentry, | 613 | struct dentry *dentry, |
631 | u64 *async_transid, bool readonly, | 614 | u64 *async_transid, bool readonly, |
@@ -654,7 +637,9 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir, | |||
654 | 637 | ||
655 | atomic_inc(&root->will_be_snapshotted); | 638 | atomic_inc(&root->will_be_snapshotted); |
656 | smp_mb__after_atomic(); | 639 | smp_mb__after_atomic(); |
657 | btrfs_wait_for_no_snapshotting_writes(root); | 640 | /* wait for no snapshot writes */ |
641 | wait_event(root->subv_writers->wait, | ||
642 | percpu_counter_sum(&root->subv_writers->counter) == 0); | ||
658 | 643 | ||
659 | ret = btrfs_start_delalloc_inodes(root, 0); | 644 | ret = btrfs_start_delalloc_inodes(root, 0); |
660 | if (ret) | 645 | if (ret) |