aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 93d69b32028e..dc5a19ed07f3 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2028,6 +2028,36 @@ long btrfs_ioctl_trans_end(struct file *file)
2028 return 0; 2028 return 0;
2029} 2029}
2030 2030
2031static noinline long btrfs_ioctl_start_sync(struct file *file, void __user *argp)
2032{
2033 struct btrfs_root *root = BTRFS_I(file->f_dentry->d_inode)->root;
2034 struct btrfs_trans_handle *trans;
2035 u64 transid;
2036
2037 trans = btrfs_start_transaction(root, 0);
2038 transid = trans->transid;
2039 btrfs_commit_transaction_async(trans, root, 0);
2040
2041 if (argp)
2042 if (copy_to_user(argp, &transid, sizeof(transid)))
2043 return -EFAULT;
2044 return 0;
2045}
2046
2047static noinline long btrfs_ioctl_wait_sync(struct file *file, void __user *argp)
2048{
2049 struct btrfs_root *root = BTRFS_I(file->f_dentry->d_inode)->root;
2050 u64 transid;
2051
2052 if (argp) {
2053 if (copy_from_user(&transid, argp, sizeof(transid)))
2054 return -EFAULT;
2055 } else {
2056 transid = 0; /* current trans */
2057 }
2058 return btrfs_wait_for_commit(root, transid);
2059}
2060
2031long btrfs_ioctl(struct file *file, unsigned int 2061long btrfs_ioctl(struct file *file, unsigned int
2032 cmd, unsigned long arg) 2062 cmd, unsigned long arg)
2033{ 2063{
@@ -2078,6 +2108,10 @@ long btrfs_ioctl(struct file *file, unsigned int
2078 case BTRFS_IOC_SYNC: 2108 case BTRFS_IOC_SYNC:
2079 btrfs_sync_fs(file->f_dentry->d_sb, 1); 2109 btrfs_sync_fs(file->f_dentry->d_sb, 1);
2080 return 0; 2110 return 0;
2111 case BTRFS_IOC_START_SYNC:
2112 return btrfs_ioctl_start_sync(file, argp);
2113 case BTRFS_IOC_WAIT_SYNC:
2114 return btrfs_ioctl_wait_sync(file, argp);
2081 } 2115 }
2082 2116
2083 return -ENOTTY; 2117 return -ENOTTY;