Commit 75eaa0e2 authored by Sage Weil's avatar Sage Weil Committed by Chris Mason

Btrfs: fix sync subvol/snapshot creation

We were incorrectly taking the async path even for the sync ioctls by
passing in &transid unconditionally.

There's ample room for further cleanup here, but this keeps the fix simple.
Signed-off-by: default avatarSage Weil <sage@newdream.net>
Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 24ae6365
...@@ -964,6 +964,15 @@ static noinline int btrfs_ioctl_snap_create(struct file *file, ...@@ -964,6 +964,15 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
name = async_vol_args->name; name = async_vol_args->name;
fd = async_vol_args->fd; fd = async_vol_args->fd;
async_vol_args->name[BTRFS_SNAPSHOT_NAME_MAX] = '\0'; async_vol_args->name[BTRFS_SNAPSHOT_NAME_MAX] = '\0';
ret = btrfs_ioctl_snap_create_transid(file, name, fd,
subvol, &transid);
if (ret == 0 &&
copy_to_user(arg +
offsetof(struct btrfs_ioctl_async_vol_args,
transid), &transid, sizeof(transid)))
ret = -EFAULT;
} else { } else {
vol_args = memdup_user(arg, sizeof(*vol_args)); vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args)) if (IS_ERR(vol_args))
...@@ -971,16 +980,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file, ...@@ -971,16 +980,9 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
name = vol_args->name; name = vol_args->name;
fd = vol_args->fd; fd = vol_args->fd;
vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
}
ret = btrfs_ioctl_snap_create_transid(file, name, fd, ret = btrfs_ioctl_snap_create_transid(file, name, fd,
subvol, &transid); subvol, NULL);
if (!ret && async) {
if (copy_to_user(arg +
offsetof(struct btrfs_ioctl_async_vol_args,
transid), &transid, sizeof(transid)))
return -EFAULT;
} }
kfree(vol_args); kfree(vol_args);
......
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