aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-11-26 03:41:29 -0500
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:08 -0500
commitff7c1d33551862c86f7737fe88edc3e499d291e6 (patch)
treec6566284d5c411645a6e938f2659d478a801ab1b /fs/btrfs
parent9a8c28bec1b40e934ed28149b7eaa7d2fafed92d (diff)
Btrfs: don't start a new transaction when starting sync
If there is no running transaction in the fs, we needn't start a new one when we want to start sync. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ioctl.c14
-rw-r--r--fs/btrfs/transaction.c13
2 files changed, 18 insertions, 9 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 5022e62e63a8..7b1f614f51f6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3065,16 +3065,22 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
3065 u64 transid; 3065 u64 transid;
3066 int ret; 3066 int ret;
3067 3067
3068 trans = btrfs_start_transaction(root, 0); 3068 trans = btrfs_attach_transaction(root);
3069 if (IS_ERR(trans)) 3069 if (IS_ERR(trans)) {
3070 return PTR_ERR(trans); 3070 if (PTR_ERR(trans) != -ENOENT)
3071 return PTR_ERR(trans);
3072
3073 /* No running transaction, don't bother */
3074 transid = root->fs_info->last_trans_committed;
3075 goto out;
3076 }
3071 transid = trans->transid; 3077 transid = trans->transid;
3072 ret = btrfs_commit_transaction_async(trans, root, 0); 3078 ret = btrfs_commit_transaction_async(trans, root, 0);
3073 if (ret) { 3079 if (ret) {
3074 btrfs_end_transaction(trans, root); 3080 btrfs_end_transaction(trans, root);
3075 return ret; 3081 return ret;
3076 } 3082 }
3077 3083out:
3078 if (argp) 3084 if (argp)
3079 if (copy_to_user(argp, &transid, sizeof(transid))) 3085 if (copy_to_user(argp, &transid, sizeof(transid)))
3080 return -EFAULT; 3086 return -EFAULT;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index bcc6b65be3b0..8db401fa2f8f 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1307,9 +1307,10 @@ static void do_async_commit(struct work_struct *work)
1307 * We've got freeze protection passed with the transaction. 1307 * We've got freeze protection passed with the transaction.
1308 * Tell lockdep about it. 1308 * Tell lockdep about it.
1309 */ 1309 */
1310 rwsem_acquire_read( 1310 if (ac->newtrans->type < TRANS_JOIN_NOLOCK)
1311 &ac->root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], 1311 rwsem_acquire_read(
1312 0, 1, _THIS_IP_); 1312 &ac->root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1],
1313 0, 1, _THIS_IP_);
1313 1314
1314 current->journal_info = ac->newtrans; 1315 current->journal_info = ac->newtrans;
1315 1316
@@ -1347,8 +1348,10 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
1347 * Tell lockdep we've released the freeze rwsem, since the 1348 * Tell lockdep we've released the freeze rwsem, since the
1348 * async commit thread will be the one to unlock it. 1349 * async commit thread will be the one to unlock it.
1349 */ 1350 */
1350 rwsem_release(&root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], 1351 if (trans->type < TRANS_JOIN_NOLOCK)
1351 1, _THIS_IP_); 1352 rwsem_release(
1353 &root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1],
1354 1, _THIS_IP_);
1352 1355
1353 schedule_delayed_work(&ac->work, 0); 1356 schedule_delayed_work(&ac->work, 0);
1354 1357