diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2013-05-15 03:48:24 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-06-14 11:29:42 -0400 |
commit | 6a03843df4d29593912e558c72a2ce39274d2366 (patch) | |
tree | 90f049cfcebd10dde5b32446a4d5d7c3a243a0b1 /fs/btrfs/transaction.c | |
parent | 199c2a9c3d1389db7f7a211e64f6809d352ce5f6 (diff) |
Btrfs: just flush the delalloc inodes in the source tree before snapshot creation
Before applying this patch, we need flush all the delalloc inodes in
the fs when we want to create a snapshot, it wastes time, and make
the transaction commit be blocked for a long time. It means some other
user operation would also be blocked for a long time.
This patch improves this problem, we just flush the delalloc inodes that
in the source trees before snapshot creation, so the transaction commit
will complete quickly.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 2b17213571a0..bc22be9b69b4 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -1491,17 +1491,9 @@ static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans, | |||
1491 | struct btrfs_root *root) | 1491 | struct btrfs_root *root) |
1492 | { | 1492 | { |
1493 | int flush_on_commit = btrfs_test_opt(root, FLUSHONCOMMIT); | 1493 | int flush_on_commit = btrfs_test_opt(root, FLUSHONCOMMIT); |
1494 | int snap_pending = 0; | ||
1495 | int ret; | 1494 | int ret; |
1496 | 1495 | ||
1497 | if (!flush_on_commit) { | 1496 | if (flush_on_commit) { |
1498 | spin_lock(&root->fs_info->trans_lock); | ||
1499 | if (!list_empty(&trans->transaction->pending_snapshots)) | ||
1500 | snap_pending = 1; | ||
1501 | spin_unlock(&root->fs_info->trans_lock); | ||
1502 | } | ||
1503 | |||
1504 | if (flush_on_commit || snap_pending) { | ||
1505 | ret = btrfs_start_all_delalloc_inodes(root->fs_info, 1); | 1497 | ret = btrfs_start_all_delalloc_inodes(root->fs_info, 1); |
1506 | if (ret) | 1498 | if (ret) |
1507 | return ret; | 1499 | return ret; |