diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2012-11-26 08:41:29 +0000 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-12-16 20:46:08 -0500 |
commit | ff7c1d33551862c86f7737fe88edc3e499d291e6 (patch) | |
tree | c6566284d5c411645a6e938f2659d478a801ab1b /fs/btrfs/ioctl.c | |
parent | 9a8c28bec1b40e934ed28149b7eaa7d2fafed92d (diff) | |
download | op-kernel-dev-ff7c1d33551862c86f7737fe88edc3e499d291e6.zip op-kernel-dev-ff7c1d33551862c86f7737fe88edc3e499d291e6.tar.gz |
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/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 5022e62..7b1f614 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, u64 transid; int ret; - trans = btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + trans = btrfs_attach_transaction(root); + if (IS_ERR(trans)) { + if (PTR_ERR(trans) != -ENOENT) + return PTR_ERR(trans); + + /* No running transaction, don't bother */ + transid = root->fs_info->last_trans_committed; + goto out; + } transid = trans->transid; ret = btrfs_commit_transaction_async(trans, root, 0); if (ret) { btrfs_end_transaction(trans, root); return ret; } - +out: if (argp) if (copy_to_user(argp, &transid, sizeof(transid))) return -EFAULT; |