aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2016-01-06 05:56:36 -0500
committerChris Mason <clm@fb.com>2016-01-20 10:22:13 -0500
commit0bc19f9031e0c59770286f82b8561c1d35064a65 (patch)
tree2469a01dbf180d1e95d6aebd5f61271dd877ea0a /fs
parentee22f0c4ec428e7f16d3c5fa1d55fd7860cb304a (diff)
btrfs: merge functions for wait snapshot creation
wait_for_snapshot_creation() is in same group with oher two: btrfs_start_write_no_snapshoting() btrfs_end_write_no_snapshoting() Rename wait_for_snapshot_creation() and move it into same place with other two. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/extent-tree.c20
-rw-r--r--fs/btrfs/inode.c22
3 files changed, 22 insertions, 21 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e9c2f8895eab..a9496644f47d 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3641,6 +3641,7 @@ int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans,
3641int __get_raid_index(u64 flags); 3641int __get_raid_index(u64 flags);
3642int btrfs_start_write_no_snapshoting(struct btrfs_root *root); 3642int btrfs_start_write_no_snapshoting(struct btrfs_root *root);
3643void btrfs_end_write_no_snapshoting(struct btrfs_root *root); 3643void btrfs_end_write_no_snapshoting(struct btrfs_root *root);
3644void btrfs_wait_for_snapshot_creation(struct btrfs_root *root);
3644void check_system_chunk(struct btrfs_trans_handle *trans, 3645void check_system_chunk(struct btrfs_trans_handle *trans,
3645 struct btrfs_root *root, 3646 struct btrfs_root *root,
3646 const u64 type); 3647 const u64 type);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index abcffa4b8231..8e8079808728 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -10817,3 +10817,23 @@ int btrfs_start_write_no_snapshoting(struct btrfs_root *root)
10817 } 10817 }
10818 return 1; 10818 return 1;
10819} 10819}
10820
10821static int wait_snapshoting_atomic_t(atomic_t *a)
10822{
10823 schedule();
10824 return 0;
10825}
10826
10827void btrfs_wait_for_snapshot_creation(struct btrfs_root *root)
10828{
10829 while (true) {
10830 int ret;
10831
10832 ret = btrfs_start_write_no_snapshoting(root);
10833 if (ret)
10834 break;
10835 wait_on_atomic_t(&root->will_be_snapshoted,
10836 wait_snapshoting_atomic_t,
10837 TASK_UNINTERRUPTIBLE);
10838 }
10839}
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8ad9e2200442..b8bb7591ff9f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4871,26 +4871,6 @@ next:
4871 return err; 4871 return err;
4872} 4872}
4873 4873
4874static int wait_snapshoting_atomic_t(atomic_t *a)
4875{
4876 schedule();
4877 return 0;
4878}
4879
4880static void wait_for_snapshot_creation(struct btrfs_root *root)
4881{
4882 while (true) {
4883 int ret;
4884
4885 ret = btrfs_start_write_no_snapshoting(root);
4886 if (ret)
4887 break;
4888 wait_on_atomic_t(&root->will_be_snapshoted,
4889 wait_snapshoting_atomic_t,
4890 TASK_UNINTERRUPTIBLE);
4891 }
4892}
4893
4894static int btrfs_setsize(struct inode *inode, struct iattr *attr) 4874static int btrfs_setsize(struct inode *inode, struct iattr *attr)
4895{ 4875{
4896 struct btrfs_root *root = BTRFS_I(inode)->root; 4876 struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -4922,7 +4902,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
4922 * truncation, it must capture all writes that happened before 4902 * truncation, it must capture all writes that happened before
4923 * this truncation. 4903 * this truncation.
4924 */ 4904 */
4925 wait_for_snapshot_creation(root); 4905 btrfs_wait_for_snapshot_creation(root);
4926 ret = btrfs_cont_expand(inode, oldsize, newsize); 4906 ret = btrfs_cont_expand(inode, oldsize, newsize);
4927 if (ret) { 4907 if (ret) {
4928 btrfs_end_write_no_snapshoting(root); 4908 btrfs_end_write_no_snapshoting(root);