Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
To: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup
Date: Wed, 03 Jun 2015 17:18:11 +0900	[thread overview]
Message-ID: <556EB843.4060003@jp.fujitsu.com> (raw)
In-Reply-To: <1433314653-548-2-git-send-email-yangds.fnst@cn.fujitsu.com>

On 2015/06/03 15:57, Dongsheng Yang wrote:
> Currently, we can only set a limitation on a qgroup, but we
> can not clear it.
> 
> This patch provide a choice to user to clear a limitation on
> qgroup by passing a value of CLEAR_VALUE(-1) to kernel.
> 
> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

Tested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>

> ---
>   fs/btrfs/qgroup.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
>   1 file changed, 41 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 3d65465..0412d5b 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -1317,6 +1317,11 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
>   	struct btrfs_root *quota_root;
>   	struct btrfs_qgroup *qgroup;
>   	int ret = 0;
> +	/* Sometimes we would want to clear the limit on this qgroup.
> +	 * To meet this requirement, we treat the -1 as a special value
> +	 * which tell kernel to clear the limit on this qgroup.
> +	 */
> +	const u64 CLEAR_VALUE = -1;
>   
>   	mutex_lock(&fs_info->qgroup_ioctl_lock);
>   	quota_root = fs_info->quota_root;
> @@ -1332,14 +1337,42 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
>   	}
>   
>   	spin_lock(&fs_info->qgroup_lock);
> -	if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_RFER)
> -		qgroup->max_rfer = limit->max_rfer;
> -	if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_EXCL)
> -		qgroup->max_excl = limit->max_excl;
> -	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER)
> -		qgroup->rsv_rfer = limit->rsv_rfer;
> -	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL)
> -		qgroup->rsv_excl = limit->rsv_excl;
> +	if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_RFER) {
> +		if (limit->max_rfer == CLEAR_VALUE) {
> +			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_MAX_RFER;
> +			limit->flags &= ~BTRFS_QGROUP_LIMIT_MAX_RFER;
> +			qgroup->max_rfer = 0;
> +		} else {
> +			qgroup->max_rfer = limit->max_rfer;
> +		}
> +	}
> +	if (limit->flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) {
> +		if (limit->max_excl == CLEAR_VALUE) {
> +			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_MAX_EXCL;
> +			limit->flags &= ~BTRFS_QGROUP_LIMIT_MAX_EXCL;
> +			qgroup->max_excl = 0;
> +		} else {
> +			qgroup->max_excl = limit->max_excl;
> +		}
> +	}
> +	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER) {
> +		if (limit->rsv_rfer == CLEAR_VALUE) {
> +			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
> +			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
> +			qgroup->rsv_rfer = 0;
> +		} else {
> +			qgroup->rsv_rfer = limit->rsv_rfer;
> +		}
> +	}
> +	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL) {
> +		if (limit->rsv_excl == CLEAR_VALUE) {
> +			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
> +			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
> +			qgroup->rsv_excl = 0;
> +		} else {
> +			qgroup->rsv_excl = limit->rsv_excl;
> +		}
> +	}
>   	qgroup->lim_flags |= limit->flags;
>   
>   	spin_unlock(&fs_info->qgroup_lock);
> 



  reply	other threads:[~2015-06-03  8:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03  6:57 [PATCH 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup Dongsheng Yang
2015-06-03  6:57 ` [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup Dongsheng Yang
2015-06-03  8:18   ` Tsutomu Itoh [this message]
2015-06-03  6:57 ` [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some " Dongsheng Yang
2015-06-03  8:40   ` Tsutomu Itoh
2015-06-03  8:41     ` Dongsheng Yang
2015-06-05 16:37   ` David Sterba
2015-06-03  8:14 ` [PATCH 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup Tsutomu Itoh
2015-06-05 16:36 ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556EB843.4060003@jp.fujitsu.com \
    --to=t-itoh@jp.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=yangds.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox