Commit 0bc19f90 authored by Zhao Lei's avatar Zhao Lei Committed by Chris Mason

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: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent ee22f0c4
...@@ -3641,6 +3641,7 @@ int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans, ...@@ -3641,6 +3641,7 @@ int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans,
int __get_raid_index(u64 flags); int __get_raid_index(u64 flags);
int btrfs_start_write_no_snapshoting(struct btrfs_root *root); int btrfs_start_write_no_snapshoting(struct btrfs_root *root);
void btrfs_end_write_no_snapshoting(struct btrfs_root *root); void btrfs_end_write_no_snapshoting(struct btrfs_root *root);
void btrfs_wait_for_snapshot_creation(struct btrfs_root *root);
void check_system_chunk(struct btrfs_trans_handle *trans, void check_system_chunk(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
const u64 type); const u64 type);
......
...@@ -10817,3 +10817,23 @@ int btrfs_start_write_no_snapshoting(struct btrfs_root *root) ...@@ -10817,3 +10817,23 @@ int btrfs_start_write_no_snapshoting(struct btrfs_root *root)
} }
return 1; return 1;
} }
static int wait_snapshoting_atomic_t(atomic_t *a)
{
schedule();
return 0;
}
void btrfs_wait_for_snapshot_creation(struct btrfs_root *root)
{
while (true) {
int ret;
ret = btrfs_start_write_no_snapshoting(root);
if (ret)
break;
wait_on_atomic_t(&root->will_be_snapshoted,
wait_snapshoting_atomic_t,
TASK_UNINTERRUPTIBLE);
}
}
...@@ -4871,26 +4871,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size) ...@@ -4871,26 +4871,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
return err; return err;
} }
static int wait_snapshoting_atomic_t(atomic_t *a)
{
schedule();
return 0;
}
static void wait_for_snapshot_creation(struct btrfs_root *root)
{
while (true) {
int ret;
ret = btrfs_start_write_no_snapshoting(root);
if (ret)
break;
wait_on_atomic_t(&root->will_be_snapshoted,
wait_snapshoting_atomic_t,
TASK_UNINTERRUPTIBLE);
}
}
static int btrfs_setsize(struct inode *inode, struct iattr *attr) static int btrfs_setsize(struct inode *inode, struct iattr *attr)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
...@@ -4922,7 +4902,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -4922,7 +4902,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
* truncation, it must capture all writes that happened before * truncation, it must capture all writes that happened before
* this truncation. * this truncation.
*/ */
wait_for_snapshot_creation(root); btrfs_wait_for_snapshot_creation(root);
ret = btrfs_cont_expand(inode, oldsize, newsize); ret = btrfs_cont_expand(inode, oldsize, newsize);
if (ret) { if (ret) {
btrfs_end_write_no_snapshoting(root); btrfs_end_write_no_snapshoting(root);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment