Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] Btrfs: create the qgroup that limits root subvolume automatically
@ 2013-02-22 12:02 Wang Shilong
  2013-02-22 13:19 ` Arne Jansen
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Shilong @ 2013-02-22 12:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: sensille

From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>

Creating the root subvolume qgroup when enabling quota,with
this patch,it will be ok to limit the whole filesystem size.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Cc: Arne Jansen <sensille@gmx.net>
---
 fs/btrfs/qgroup.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index a5c8562..c409096 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -777,6 +777,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
 	struct extent_buffer *leaf;
 	struct btrfs_key key;
 	int ret = 0;
+	struct btrfs_qgroup *qgroup = NULL;
 
 	spin_lock(&fs_info->qgroup_lock);
 	if (fs_info->quota_root) {
@@ -823,7 +824,18 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
 
 	btrfs_mark_buffer_dirty(leaf);
 
+	btrfs_release_path(path);
+	ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID);
+	if (ret)
+		goto out;
+
 	spin_lock(&fs_info->qgroup_lock);
+	qgroup = add_qgroup_rb(fs_info, BTRFS_FS_TREE_OBJECTID);
+	if (IS_ERR(qgroup)) {
+		spin_unlock(&fs_info->qgroup_lock);
+		ret = PTR_ERR(qgroup);
+		goto out;
+	}
 	fs_info->quota_root = quota_root;
 	fs_info->pending_quota_state = 1;
 	spin_unlock(&fs_info->qgroup_lock);
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Btrfs: create the qgroup that limits root subvolume automatically
  2013-02-22 12:02 [PATCH 1/2] Btrfs: create the qgroup that limits root subvolume automatically Wang Shilong
@ 2013-02-22 13:19 ` Arne Jansen
  2013-02-22 16:29   ` Shilong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Arne Jansen @ 2013-02-22 13:19 UTC (permalink / raw)
  To: Wang Shilong; +Cc: linux-btrfs

On 02/22/13 13:02, Wang Shilong wrote:
> From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
> 
> Creating the root subvolume qgroup when enabling quota,with

Why only create a qgroup for the root subvolume and not for
every existing subvolume?

> this patch,it will be ok to limit the whole filesystem size.

This will not limit the whole filesystem, but only the root
subvolume. To limit the whole filesystem you'd have to create
a level 1 qgroup and add all subvolumes to it.

-Arne

> 
> Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
> Cc: Arne Jansen <sensille@gmx.net>
> ---
>  fs/btrfs/qgroup.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index a5c8562..c409096 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -777,6 +777,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
>  	struct extent_buffer *leaf;
>  	struct btrfs_key key;
>  	int ret = 0;
> +	struct btrfs_qgroup *qgroup = NULL;
>  
>  	spin_lock(&fs_info->qgroup_lock);
>  	if (fs_info->quota_root) {
> @@ -823,7 +824,18 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
>  
>  	btrfs_mark_buffer_dirty(leaf);
>  
> +	btrfs_release_path(path);
> +	ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID);
> +	if (ret)
> +		goto out;
> +
>  	spin_lock(&fs_info->qgroup_lock);
> +	qgroup = add_qgroup_rb(fs_info, BTRFS_FS_TREE_OBJECTID);
> +	if (IS_ERR(qgroup)) {
> +		spin_unlock(&fs_info->qgroup_lock);
> +		ret = PTR_ERR(qgroup);
> +		goto out;
> +	}
>  	fs_info->quota_root = quota_root;
>  	fs_info->pending_quota_state = 1;
>  	spin_unlock(&fs_info->qgroup_lock);
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Btrfs: create the qgroup that limits root subvolume automatically
  2013-02-22 13:19 ` Arne Jansen
@ 2013-02-22 16:29   ` Shilong Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Shilong Wang @ 2013-02-22 16:29 UTC (permalink / raw)
  To: Arne Jansen; +Cc: linux-btrfs

2013/2/22 Arne Jansen <sensille@gmx.net>:
> On 02/22/13 13:02, Wang Shilong wrote:
>> From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
>>
>> Creating the root subvolume qgroup when enabling quota,with
>
> Why only create a qgroup for the root subvolume and not for
> every existing subvolume?
>

Yes,You are right.
Creating all the existed subvolume  qgroup is necessary when enabling
quota since we try to prevent
creating  group level 0...the subvolume/snapshot group should be
operated automatically...

Atfer this work.
I think it is necessary to delete the subvolume/snapshot qgroup  as
the deletion of sub volume/snapshot.

BTW, there is a thing  to think about...
During enabling quota...No new subvolume should be created before the
enabling quota is done.

I will try to implement such functions.....

>> this patch,it will be ok to limit the whole filesystem size.
>
> This will not limit the whole filesystem, but only the root
> subvolume. To limit the whole filesystem you'd have to create
> a level 1 qgroup and add all subvolumes to it.
>

Right, thanks for correcting it...

Thanks,
Wang


> -Arne
>
>>
>> Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
>> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
>> Cc: Arne Jansen <sensille@gmx.net>
>> ---
>>  fs/btrfs/qgroup.c |   12 ++++++++++++
>>  1 files changed, 12 insertions(+), 0 deletions(-)
>>
>> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
>> index a5c8562..c409096 100644
>> --- a/fs/btrfs/qgroup.c
>> +++ b/fs/btrfs/qgroup.c
>> @@ -777,6 +777,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
>>       struct extent_buffer *leaf;
>>       struct btrfs_key key;
>>       int ret = 0;
>> +     struct btrfs_qgroup *qgroup = NULL;
>>
>>       spin_lock(&fs_info->qgroup_lock);
>>       if (fs_info->quota_root) {
>> @@ -823,7 +824,18 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
>>
>>       btrfs_mark_buffer_dirty(leaf);
>>
>> +     btrfs_release_path(path);
>> +     ret = add_qgroup_item(trans, quota_root, BTRFS_FS_TREE_OBJECTID);
>> +     if (ret)
>> +             goto out;
>> +
>>       spin_lock(&fs_info->qgroup_lock);
>> +     qgroup = add_qgroup_rb(fs_info, BTRFS_FS_TREE_OBJECTID);
>> +     if (IS_ERR(qgroup)) {
>> +             spin_unlock(&fs_info->qgroup_lock);
>> +             ret = PTR_ERR(qgroup);
>> +             goto out;
>> +     }
>>       fs_info->quota_root = quota_root;
>>       fs_info->pending_quota_state = 1;
>>       spin_unlock(&fs_info->qgroup_lock);
>>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-22 16:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-22 12:02 [PATCH 1/2] Btrfs: create the qgroup that limits root subvolume automatically Wang Shilong
2013-02-22 13:19 ` Arne Jansen
2013-02-22 16:29   ` Shilong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox