Skip to content

Commit

Permalink
Btrfs: fix sync subvol/snapshot creation
Browse files Browse the repository at this point in the history
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: Sage Weil <sage@newdream.net>
Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Sage Weil authored and Chris Mason committed Dec 10, 2010
1 parent 24ae636 commit 75eaa0e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,23 +964,25 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
name = async_vol_args->name;
fd = async_vol_args->fd;
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 {
vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args))
return PTR_ERR(vol_args);
name = vol_args->name;
fd = vol_args->fd;
vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
}

ret = btrfs_ioctl_snap_create_transid(file, name, fd,
subvol, &transid);

if (!ret && async) {
if (copy_to_user(arg +
offsetof(struct btrfs_ioctl_async_vol_args,
transid), &transid, sizeof(transid)))
return -EFAULT;
ret = btrfs_ioctl_snap_create_transid(file, name, fd,
subvol, NULL);
}

kfree(vol_args);
Expand Down

0 comments on commit 75eaa0e

Please sign in to comment.