btrfs: qgroup: return EINVAL if level of parent is not higher than child's.

When we create a subvol inheriting a qgroup, we need to check the level
of them. Otherwise, there is a chance a qgroup can inherit another qgroup
at the same level.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Dongsheng Yang 2014-11-11 07:18:22 -05:00 committed by Chris Mason
parent e2d1f92399
commit 09870d2772
1 changed files with 5 additions and 0 deletions

View File

@ -2230,6 +2230,11 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if ((srcgroup->qgroupid >> 48) <= (objectid >> 48)) {
ret = -EINVAL;
goto out;
}
++i_qgroups; ++i_qgroups;
} }
} }