btrfs: qgroup: return EINVAL if level of parent is not higher than child's.
authorDongsheng Yang <yangds.fnst@cn.fujitsu.com>
Tue, 11 Nov 2014 12:18:22 +0000 (07:18 -0500)
committerChris Mason <clm@fb.com>
Mon, 13 Apr 2015 14:52:51 +0000 (07:52 -0700)
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>
fs/btrfs/qgroup.c

index 17881ad..4ec86b3 100644 (file)
@@ -2230,6 +2230,11 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
                                ret = -EINVAL;
                                goto out;
                        }
+
+                       if ((srcgroup->qgroupid >> 48) <= (objectid >> 48)) {
+                               ret = -EINVAL;
+                               goto out;
+                       }
                        ++i_qgroups;
                }
        }