diff options
author | Wang Shilong <wangsl-fnst@cn.fujitsu.com> | 2013-04-07 06:50:18 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 15:54:39 -0400 |
commit | b7fef4f593007d52ba7fe4427e099bd71c63c521 (patch) | |
tree | 44a7d1bf7d8bb70cd125e435082c1244466e2e0e | |
parent | 58400fce5ac5939aadac8ce682edc192c6172f80 (diff) |
Btrfs: fix missing check before creating a qgroup relation
Step to reproduce:
mkfs.btrfs <disk>
mount <disk> <mnt>
btrfs quota enable <mnt>
btrfs qgroup assign 0/1 1/1 <mnt>
umount <mnt>
btrfs-debug-tree <disk> | grep QGROUP
If we want to add a qgroup relation, we should gurantee that
'src' and 'dst' exist, otherwise, such qgroup relation should
not be allowed to create.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-rw-r--r-- | fs/btrfs/qgroup.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 49c4e6398f18..0932b839550c 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -954,6 +954,8 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, | |||
954 | struct btrfs_fs_info *fs_info, u64 src, u64 dst) | 954 | struct btrfs_fs_info *fs_info, u64 src, u64 dst) |
955 | { | 955 | { |
956 | struct btrfs_root *quota_root; | 956 | struct btrfs_root *quota_root; |
957 | struct btrfs_qgroup *parent; | ||
958 | struct btrfs_qgroup *member; | ||
957 | int ret = 0; | 959 | int ret = 0; |
958 | 960 | ||
959 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 961 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
@@ -962,6 +964,12 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, | |||
962 | ret = -EINVAL; | 964 | ret = -EINVAL; |
963 | goto out; | 965 | goto out; |
964 | } | 966 | } |
967 | member = find_qgroup_rb(fs_info, src); | ||
968 | parent = find_qgroup_rb(fs_info, dst); | ||
969 | if (!member || !parent) { | ||
970 | ret = -EINVAL; | ||
971 | goto out; | ||
972 | } | ||
965 | 973 | ||
966 | ret = add_qgroup_relation_item(trans, quota_root, src, dst); | 974 | ret = add_qgroup_relation_item(trans, quota_root, src, dst); |
967 | if (ret) | 975 | if (ret) |