btrfs: qgroup: Remove qgroup item along with subvolume deletion
PATCH 1/1 btrfs: qgroup: Remove qgroup item along with subvolume deletion
In reply to a message not in the archiveWhen qgroup is on, subvolume deletion does not remove qgroup items of the subvolume (qgroup info, limits, relation) from quota tree and they need to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted.
---
I don't see any reason to keep these items after subvolume deletion, but is there something I'm missing?
fs/btrfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/inode.c +4 -0
@@ -4372,6 +4372,10 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) } } + ret =btrfs_remove_qgroup (trans, dest->root_key.objectid); +if (ret == -EINVAL || ret == -ENOENT ) + ret =0 ; + out_end_trans: trans->block_rsv =NULL ; trans->bytes_reserved =0 ;
Signature · 1 line
2.14.4
Quoted 21 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup items of the subvolume (qgroup info, limits, relation) from quota tree and they need to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted.
Signed-off-by Misono Tomohiro <[email protected]>---
I don't see any reason to keep these items after subvolume deletion, but is there something I'm missing?
fs/btrfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)fs/btrfs/inode.c +0
-0
fs/btrfs/inode.c int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) · line 4375
Quoted 4 lines
fs/btrfs/inode.c +1
-0@@ -4372,6 +4372,10 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) } } + ret =btrfs_remove_qgroup (trans, dest->root_key.objectid);
According to the caller, it only unlinks the subvolume without really delete the whole subvolume.
I'm wondering if we should call btrfs_remove_qgroup() only after we have deleted the whole subvolume, e.g inside btrfs_drop_snapshot().
Thanks,
Qu
Quoted 7 lines
fs/btrfs/inode.c +3
-0+if (ret == -EINVAL || ret == -ENOENT ) + ret =0 ; + out_end_trans: trans->block_rsv =NULL ; trans->bytes_reserved =0 ;
Quoted 27 lines · Qu Wenruo
Quoted 24 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup items of the subvolume (qgroup info, limits, relation) from quota tree and they need to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted.
Signed-off-by Misono Tomohiro <[email protected]>---
I don't see any reason to keep these items after subvolume deletion, but is there something I'm missing?
fs/btrfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)fs/btrfs/inode.c +0
-0@@ -4372,6 +4372,10 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) } }
Quoted 7 lines
fs/btrfs/inode.c int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) · line 4375
Quoted 1 line
fs/btrfs/inode.c +1
-0+ ret =btrfs_remove_qgroup (trans, dest->root_key.objectid);According to the caller, it only unlinks the subvolume without really delete the whole subvolume.
I'm wondering if we should call
btrfs_remove_qgroup()only after we have deleted the whole subvolume, e.g insidebtrfs_drop_snapshot().
I agree with Qu's point, because the ongoing online undelete subvolume will be able to recover the subvolume which is intact ondisk, including the qgroup.
Signature · 2 lines
Thanks, Lu
Quoted 12 lines
Thanks,
QuQuoted 7 lines
fs/btrfs/inode.c +3
-0+if (ret == -EINVAL || ret == -ENOENT ) + ret =0 ; + out_end_trans: trans->block_rsv =NULL ; trans->bytes_reserved =0 ;
Quoted 33 lines · Lu Fengqi
Quoted 32 lines · Qu Wenruo
Quoted 21 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup items of the subvolume (qgroup info, limits, relation) from quota tree and they need to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted.
Signed-off-by Misono Tomohiro <[email protected]>---
I don't see any reason to keep these items after subvolume deletion, but is there something I'm missing?
fs/btrfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)fs/btrfs/inode.c +0
-0fs/btrfs/inode.c int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) · line 4375
Quoted 4 lines
fs/btrfs/inode.c +1
-0@@ -4372,6 +4372,10 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry) } } + ret =btrfs_remove_qgroup (trans, dest->root_key.objectid);According to the caller, it only unlinks the subvolume without really delete the whole subvolume.
Quoted 6 lines
Quoted 2 lines
I'm wondering if we should call
btrfs_remove_qgroup()only after we have deleted the whole subvolume, e.g insidebtrfs_drop_snapshot().I agree with Qu's point, because the ongoing online undelete subvolume will be able to recover the subvolume which is intact ondisk, including the qgroup.
Thanks to both of you, I'll update the patch.
Misono
PATCH v2 1/1 btrfs: qgroup: Remove qgroup item along with subvolume deletion
In reply to Misono TomohiroWhen qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
---
Note that btrfs/057 fails, but it is the problem of testcase. I will update it too.
v1 -> v2:
Move call of btrfs_remove_qgroup() from btrfs_delete_subvolume() to btrfs_snapshot_destroy() so that it will be called after the subvolume root is really dropped
fs/btrfs/extent-tree.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/btrfs/extent-tree.c +12 -4
@@ -8871,12 +8871,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,struct btrfs_root_item *root_item = &root->root_item;struct walk_control *wc;struct btrfs_key key; +u64 objectid = root->objectid;int err =0 ;int ret;int level;bool root_dropped = false; -btrfs_debug (fs_info,"Drop subvolume %llu" , root->objectid); +btrfs_debug (fs_info,"Drop subvolume %llu" , objectid); path =btrfs_alloc_path ();if (!path) {
@@ -9030,7 +9031,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, goto out_end_trans; } -if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) { ret =btrfs_find_root (tree_root, &root->root_key, path,NULL ,NULL );if (ret <0 ) {
@@ -9043,8 +9044,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,* * The most common failure here is just -ENOENT. */ -btrfs_del_orphan_item (trans, tree_root, - root->root_key.objectid); +btrfs_del_orphan_item (trans, tree_root, objectid); } }
@@ -9056,6 +9056,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,btrfs_put_fs_root (root); } root_dropped = true; + +/* Remove level-0 qgroup items since no other subvolume can use them */ + ret =btrfs_remove_qgroup (trans, objectid); +if (ret && ret != -EINVAL && ret != -ENOENT ) { +btrfs_abort_transaction (trans, ret); + err = ret; + } + out_end_trans:btrfs_end_transaction_throttle (trans); out_free:
Signature · 1 line
2.14.4
Quoted 9 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
Signed-off-by Misono Tomohiro <[email protected]>
Looks good to me.
There is an off-topic question below.
Quoted 32 lines
---
Note that btrfs/057 fails, but it is the problem of testcase. I will update it too.v1 -> v2:
Move call ofbtrfs_remove_qgroup()frombtrfs_delete_subvolume()tobtrfs_snapshot_destroy()so that it will be called after the subvolume root is really dropped
fs/btrfs/extent-tree.c| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)fs/btrfs/extent-tree.c +2
-1@@ -8871,12 +8871,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,struct btrfs_root_item *root_item = &root->root_item;struct walk_control *wc;struct btrfs_key key; +u64 objectid = root->objectid;int err =0 ;int ret;int level;bool root_dropped = false; -btrfs_debug (fs_info,"Drop subvolume %llu" , root->objectid); +btrfs_debug (fs_info,"Drop subvolume %llu" , objectid); path =btrfs_alloc_path ();if (!path) {
fs/btrfs/extent-tree.c int btrfs_drop_snapshot(struct btrfs_root *root, · line 9034
Quoted 5 lines
fs/btrfs/extent-tree.c +1
-1@@ -9030,7 +9031,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, goto out_end_trans; } -if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) {
Here use root->objectid instead of root->root_key.objectid. If I recall correctly, the root->objectid and root->root_key.objectid are set to the identical value. I just wonder if there is any difference between the two "objectid"s after the btrfs_root was created?
--
Thanks,
Lu
Quoted 38 lines
fs/btrfs/extent-tree.c +9
-2ret =btrfs_find_root (tree_root, &root->root_key, path,NULL ,NULL );if (ret <0 ) {@@ -9043,8 +9044,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,* * The most common failure here is just -ENOENT. */ -btrfs_del_orphan_item (trans, tree_root, - root->root_key.objectid); +btrfs_del_orphan_item (trans, tree_root, objectid); } }@@ -9056,6 +9056,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,btrfs_put_fs_root (root); } root_dropped = true; + +/* Remove level-0 qgroup items since no other subvolume can use them */ + ret =btrfs_remove_qgroup (trans, objectid); +if (ret && ret != -EINVAL && ret != -ENOENT ) { +btrfs_abort_transaction (trans, ret); + err = ret; + } +
out_end_trans:btrfs_end_transaction_throttle(trans);
out_free:Signature · 7 lines
2.14.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Lu Fengqi
Quoted 8 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
Quoted 5 lines
Quoted 1 line
Signed-off-by Misono Tomohiro <[email protected]>Looks good to me.
Reviewed-by Lu Fengqi <[email protected]>
Thanks for the review.
Quoted 38 lines
There is an off-topic question below.
Quoted 35 lines
---
Note that btrfs/057 fails, but it is the problem of testcase. I will update it too.v1 -> v2:
Move call ofbtrfs_remove_qgroup()frombtrfs_delete_subvolume()tobtrfs_snapshot_destroy()so that it will be called after the subvolume root is really dropped
fs/btrfs/extent-tree.c| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)fs/btrfs/extent-tree.c +2
-1@@ -8871,12 +8871,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,struct btrfs_root_item *root_item = &root->root_item;struct walk_control *wc;struct btrfs_key key; +u64 objectid = root->objectid;int err =0 ;int ret;int level;bool root_dropped = false; -btrfs_debug (fs_info,"Drop subvolume %llu" , root->objectid); +btrfs_debug (fs_info,"Drop subvolume %llu" , objectid); path =btrfs_alloc_path ();if (!path) {@@ -9030,7 +9031,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, goto out_end_trans; }
Quoted 7 lines
fs/btrfs/extent-tree.c int btrfs_drop_snapshot(struct btrfs_root *root, · line 9034
Quoted 2 lines
fs/btrfs/extent-tree.c +1
-1-if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) {Here use
root->objectidinstead ofroot->root_key.objectid. If I recall correctly, theroot->objectidandroot->root_key.objectidare set to the identical value. I just wonder if there is any difference between the two "objectid"s after thebtrfs_rootwas created?
in __setup_root(root, fs_info, objectid):
<snip>
root->objectid = objectid;
<snip>
root->root_key.objectid = objectid;
<snip>
and I don't see any update of objectid from "grep -r "root_key.objectid ="", I think it the same too (and fstests is ok), but any comment from those who more familiar with code is helpful.
thanks,
Misono
Quoted 50 lines
--
Thanks,
LuQuoted 26 lines
fs/btrfs/extent-tree.c +9
-2ret =btrfs_find_root (tree_root, &root->root_key, path,NULL ,NULL );if (ret <0 ) {@@ -9043,8 +9044,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,* * The most common failure here is just -ENOENT. */ -btrfs_del_orphan_item (trans, tree_root, - root->root_key.objectid); +btrfs_del_orphan_item (trans, tree_root, objectid); } }@@ -9056,6 +9056,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,btrfs_put_fs_root (root); } root_dropped = true; + +/* Remove level-0 qgroup items since no other subvolume can use them */ + ret =btrfs_remove_qgroup (trans, objectid); +if (ret && ret != -EINVAL && ret != -ENOENT ) { +btrfs_abort_transaction (trans, ret); + err = ret; + } +
out_end_trans:Quoted 12 lines
btrfs_end_transaction_throttle(trans);
out_free:Signature · 7 lines
2.14.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 71 lines · Misono Tomohiro
Quoted 9 lines · Lu Fengqi
Quoted 8 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
Quoted 5 lines
Quoted 1 line
Signed-off-by Misono Tomohiro <[email protected]>Looks good to me.
Reviewed-by Lu Fengqi <[email protected]>Thanks for the review.
Quoted 38 lines
There is an off-topic question below.
Quoted 35 lines
---
Note that btrfs/057 fails, but it is the problem of testcase. I will update it too.v1 -> v2:
Move call ofbtrfs_remove_qgroup()frombtrfs_delete_subvolume()tobtrfs_snapshot_destroy()so that it will be called after the subvolume root is really dropped
fs/btrfs/extent-tree.c| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)fs/btrfs/extent-tree.c +2
-1@@ -8871,12 +8871,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,struct btrfs_root_item *root_item = &root->root_item;struct walk_control *wc;struct btrfs_key key; +u64 objectid = root->objectid;int err =0 ;int ret;int level;bool root_dropped = false; -btrfs_debug (fs_info,"Drop subvolume %llu" , root->objectid); +btrfs_debug (fs_info,"Drop subvolume %llu" , objectid); path =btrfs_alloc_path ();if (!path) {@@ -9030,7 +9031,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, goto out_end_trans; }Quoted 7 lines
fs/btrfs/extent-tree.c int btrfs_drop_snapshot(struct btrfs_root *root, · line 9034
Quoted 2 lines
fs/btrfs/extent-tree.c +1
-1-if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) {Here use
root->objectidinstead ofroot->root_key.objectid. If I recall correctly, theroot->objectidandroot->root_key.objectidare set to the identical value. I just wonder if there is any difference between the two "objectid"s after thebtrfs_rootwas created?in
__setup_root(root, fs_info, objectid):
<snip>
root->objectid= objectid;
<snip>
root->root_key.objectid= objectid;
<snip>
Quoted 3 lines
and I don't see any update of objectid from "grep -r "root_key.objectid ="", I think it the same too (and fstests is ok), but any comment from those who more familiar with code is helpful.
Perhaps root->objectid should be removed altogether, if it's a duplicate of root->root_key.objectid
Quoted 60 lines
thanks,
MisonoQuoted 37 lines
--
Thanks,
LuQuoted 32 lines
fs/btrfs/extent-tree.c +9
-2ret =btrfs_find_root (tree_root, &root->root_key, path,NULL ,NULL );if (ret <0 ) {@@ -9043,8 +9044,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,* * The most common failure here is just -ENOENT. */ -btrfs_del_orphan_item (trans, tree_root, - root->root_key.objectid); +btrfs_del_orphan_item (trans, tree_root, objectid); } }@@ -9056,6 +9056,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,btrfs_put_fs_root (root); } root_dropped = true; + +/* Remove level-0 qgroup items since no other subvolume can use them */ + ret =btrfs_remove_qgroup (trans, objectid); +if (ret && ret != -EINVAL && ret != -ENOENT ) { +btrfs_abort_transaction (trans, ret); + err = ret; + } +
out_end_trans:btrfs_end_transaction_throttle(trans);
out_free:Signature · 1 line
2.14.4Quoted 13 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Qu Wenruo
Reviewed-byQuoted 13 lines · Nikolay Borisov
Quoted 10 lines · Misono Tomohiro
Quoted 9 lines · Lu Fengqi
Quoted 8 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Misono Tomohiro <[email protected]>Looks good to me.
Reviewed-by Lu Fengqi <[email protected]>
[snip]
Quoted 15 lines
Quoted 15 lines
Quoted 7 lines
fs/btrfs/extent-tree.c int btrfs_drop_snapshot(struct btrfs_root *root, · line 9034
Quoted 2 lines
fs/btrfs/extent-tree.c +1
-1-if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) {Here use
root->objectidinstead ofroot->root_key.objectid. If I recall correctly, theroot->objectidandroot->root_key.objectidare set to the identical value. I just wonder if there is any difference between the two "objectid"s after thebtrfs_rootwas created?in
__setup_root(root, fs_info, objectid):
<snip>
root->objectid= objectid;
<snip>
root->root_key.objectid= objectid;
<snip>
Quoted 6 lines
Quoted 3 lines
and I don't see any update of objectid from "grep -r "root_key.objectid ="", I think it the same too (and fstests is ok), but any comment from those who more familiar with code is helpful.
Perhaps
root->objectidshould be removed altogether, if it's a duplicate ofroot->root_key.objectid
Yep, cleaning up root->objectid looks pretty good to me.
In fact, root->objectid is not enough to distinguish tree reloc trees. So using root->root_key should be a safer way to go.
Thanks,
Qu
Quoted 66 lines
Quoted 56 lines
thanks,
MisonoQuoted 37 lines
--
Thanks,
LuQuoted 32 lines
ret = btrfs_find_root(tree_root, &root->root_key, path, NULL, NULL); if (ret < 0) {fs/btrfs/extent-tree.c +9
-2@@ -9043,8 +9044,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,* * The most common failure here is just -ENOENT. */ -btrfs_del_orphan_item (trans, tree_root, - root->root_key.objectid); +btrfs_del_orphan_item (trans, tree_root, objectid); } }@@ -9056,6 +9056,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,btrfs_put_fs_root (root); } root_dropped = true; + +/* Remove level-0 qgroup items since no other subvolume can use them */ + ret =btrfs_remove_qgroup (trans, objectid); +if (ret && ret != -EINVAL && ret != -ENOENT ) { +btrfs_abort_transaction (trans, ret); + err = ret; + } +
out_end_trans:btrfs_end_transaction_throttle(trans);
out_free:Signature · 1 line
2.14.4Quoted 13 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 74 lines · Nikolay Borisov
Quoted 71 lines · Misono Tomohiro
Quoted 9 lines · Lu Fengqi
Quoted 8 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
Quoted 5 lines
Quoted 1 line
Signed-off-by Misono Tomohiro <[email protected]>Looks good to me.
Reviewed-by Lu Fengqi <[email protected]>Thanks for the review.
Quoted 38 lines
There is an off-topic question below.
Quoted 35 lines
---
Note that btrfs/057 fails, but it is the problem of testcase. I will update it too.v1 -> v2:
Move call ofbtrfs_remove_qgroup()frombtrfs_delete_subvolume()tobtrfs_snapshot_destroy()so that it will be called after the subvolume root is really dropped
fs/btrfs/extent-tree.c| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)fs/btrfs/extent-tree.c +2
-1@@ -8871,12 +8871,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,struct btrfs_root_item *root_item = &root->root_item;struct walk_control *wc;struct btrfs_key key; +u64 objectid = root->objectid;int err =0 ;int ret;int level;bool root_dropped = false; -btrfs_debug (fs_info,"Drop subvolume %llu" , root->objectid); +btrfs_debug (fs_info,"Drop subvolume %llu" , objectid); path =btrfs_alloc_path ();if (!path) {@@ -9030,7 +9031,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, goto out_end_trans; }Quoted 7 lines
fs/btrfs/extent-tree.c int btrfs_drop_snapshot(struct btrfs_root *root, · line 9034
Quoted 2 lines
fs/btrfs/extent-tree.c +1
-1-if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) {Here use
root->objectidinstead ofroot->root_key.objectid. If I recall correctly, theroot->objectidandroot->root_key.objectidare set to the identical value. I just wonder if there is any difference between the two "objectid"s after thebtrfs_rootwas created?in
__setup_root(root, fs_info, objectid):
<snip>
root->objectid= objectid;
<snip>
root->root_key.objectid= objectid;
<snip>
Quoted 6 lines
Quoted 3 lines
and I don't see any update of objectid from "grep -r "root_key.objectid ="", I think it the same too (and fstests is ok), but any comment from those who more familiar with code is helpful.
Perhaps
root->objectidshould be removed altogether, if it's a duplicate ofroot->root_key.objectid
That's great! I hate these useless redundancies because they always make me confused. So Misono could you update this patch to use root->root_key.objectid?
Signature · 2 lines
Thanks, Lu
Quoted 66 lines
Quoted 56 lines
thanks,
MisonoQuoted 37 lines
--
Thanks,
LuQuoted 32 lines
fs/btrfs/extent-tree.c +9
-2ret =btrfs_find_root (tree_root, &root->root_key, path,NULL ,NULL );if (ret <0 ) {@@ -9043,8 +9044,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,* * The most common failure here is just -ENOENT. */ -btrfs_del_orphan_item (trans, tree_root, - root->root_key.objectid); +btrfs_del_orphan_item (trans, tree_root, objectid); } }@@ -9056,6 +9056,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,btrfs_put_fs_root (root); } root_dropped = true; + +/* Remove level-0 qgroup items since no other subvolume can use them */ + ret =btrfs_remove_qgroup (trans, objectid); +if (ret && ret != -EINVAL && ret != -ENOENT ) { +btrfs_abort_transaction (trans, ret); + err = ret; + } +
out_end_trans:btrfs_end_transaction_throttle(trans);
out_free:Signature · 1 line
2.14.4Quoted 13 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 79 lines · Lu Fengqi
Quoted 78 lines · Nikolay Borisov
Quoted 74 lines · Misono Tomohiro
Quoted 9 lines · Lu Fengqi
Quoted 8 lines · Misono Tomohiro
When qgroup is on, subvolume deletion does not remove qgroup item of the subvolume (qgroup info, limits, relation) from quota tree and they needs to get removed manually by "btrfs qgroup destroy".
Since level 0 qgroup cannot be used/inherited by any other subvolume, let's remove them automatically when subvolume is deleted (to be precise, when the subvolume root is dropped).
Quoted 5 lines
Quoted 1 line
Signed-off-by Misono Tomohiro <[email protected]>Looks good to me.
Reviewed-by Lu Fengqi <[email protected]>Thanks for the review.
Quoted 38 lines
There is an off-topic question below.
Quoted 35 lines
---
Note that btrfs/057 fails, but it is the problem of testcase. I will update it too.v1 -> v2:
Move call ofbtrfs_remove_qgroup()frombtrfs_delete_subvolume()tobtrfs_snapshot_destroy()so that it will be called after the subvolume root is really dropped
fs/btrfs/extent-tree.c| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)fs/btrfs/extent-tree.c +2
-1@@ -8871,12 +8871,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,struct btrfs_root_item *root_item = &root->root_item;struct walk_control *wc;struct btrfs_key key; +u64 objectid = root->objectid;int err =0 ;int ret;int level;bool root_dropped = false; -btrfs_debug (fs_info,"Drop subvolume %llu" , root->objectid); +btrfs_debug (fs_info,"Drop subvolume %llu" , objectid); path =btrfs_alloc_path ();if (!path) {@@ -9030,7 +9031,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, goto out_end_trans; }Quoted 7 lines
fs/btrfs/extent-tree.c int btrfs_drop_snapshot(struct btrfs_root *root, · line 9034
Quoted 2 lines
fs/btrfs/extent-tree.c +1
-1-if (root->root_key.objectid !=BTRFS_TREE_RELOC_OBJECTID ) { +if (objectid !=BTRFS_TREE_RELOC_OBJECTID ) {Here use
root->objectidinstead ofroot->root_key.objectid. If I recall correctly, theroot->objectidandroot->root_key.objectidare set to the identical value. I just wonder if there is any difference between the two "objectid"s after thebtrfs_rootwas created?in
__setup_root(root, fs_info, objectid):
<snip>
root->objectid= objectid;
<snip>
root->root_key.objectid= objectid;
<snip>and I don't see any update of objectid from "grep -r "root_key.objectid ="", I think it the same too (and fstests is ok), but any comment from those who more familiar with code is helpful.
Quoted 6 lines
Quoted 2 lines
Perhaps
root->objectidshould be removed altogether, if it's a duplicate ofroot->root_key.objectidThat's great! I hate these useless redundancies because they always make me confused. So Misono could you update this patch to use
root->root_key.objectid?
Ok. Also I'll try to see if it is possible to remove root->objectid. Misono