]> git.hungrycats.org Git - linux/commitdiff
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)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Fri, 17 Apr 2015 16:00:46 +0000 (12:00 -0400)
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>
(cherry picked from commit 09870d2772b284d0061a5e4d1e1cdf6fb6764344)

fs/btrfs/qgroup.c

index de321c90130c05f498489d171ed958bdae4063c9..a3a05130cd1eb87a8e856d02a05d53be7d4a86db 100644 (file)
@@ -2226,6 +2226,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;
                }
        }