Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup
@ 2015-06-03  6:57 Dongsheng Yang
  2015-06-03  6:57 ` [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup Dongsheng Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Dongsheng Yang @ 2015-06-03  6:57 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Dongsheng Yang

There are two understanding of the '0' value in btrfs qgroup show.
(1) is no-limitation on this qgroup. (2) is the max-limitation is 0.

This patch make it showing in different way.

(1). max-limitation for 0 is still showing '0'.
(2). no-limitation will show 'none'.

qgroupid         rfer         excl     max_rfer     max_excl parent
--------         ----         ----     --------     -------- ------
0/5           2.19GiB      2.19GiB         none         none ---
0/257       100.02MiB    100.02MiB         none         none ---

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 qgroup.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/qgroup.c b/qgroup.c
index 53815b5..dc04b03 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -237,10 +237,16 @@ static void print_qgroup_column(struct btrfs_qgroup *qgroup,
 		print_qgroup_column_add_blank(BTRFS_QGROUP_PARENT, len);
 		break;
 	case BTRFS_QGROUP_MAX_RFER:
-		len = printf("%*s", max_len, pretty_size_mode(qgroup->max_rfer, unit_mode));
+		if (qgroup->flags & BTRFS_QGROUP_LIMIT_MAX_RFER)
+			len = printf("%*s", max_len, pretty_size_mode(qgroup->max_rfer, unit_mode));
+		else
+			len = printf("%*s", max_len, "none");
 		break;
 	case BTRFS_QGROUP_MAX_EXCL:
-		len = printf("%*s", max_len, pretty_size_mode(qgroup->max_excl, unit_mode));
+		if (qgroup->flags & BTRFS_QGROUP_LIMIT_MAX_EXCL)
+			len = printf("%*s", max_len, pretty_size_mode(qgroup->max_excl, unit_mode));
+		else
+			len = printf("%*s", max_len, "none");
 		break;
 	case BTRFS_QGROUP_CHILD:
 		len = print_child_column(qgroup);
-- 
1.8.4.2


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

* [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup
  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 ` Dongsheng Yang
  2015-06-03  8:18   ` Tsutomu Itoh
  2015-06-03  6:57 ` [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some " Dongsheng Yang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Dongsheng Yang @ 2015-06-03  6:57 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Dongsheng Yang

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>
---
 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);
-- 
1.8.4.2


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

* [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some limitation on qgroup.
  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  6:57 ` Dongsheng Yang
  2015-06-03  8:40   ` Tsutomu Itoh
  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
  3 siblings, 2 replies; 9+ messages in thread
From: Dongsheng Yang @ 2015-06-03  6:57 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Dongsheng Yang

Currently, we can not clear a limitation on a qgroup. Although
there is a 'none' choice provided to user to do it, it does not
work well.

It does not set the flag which user want to clear, then kernel
will never know what the user want to do at all.

*Without this commit*
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB      5.00GiB         none
0/257       100.02MiB    100.02MiB         none         none
 # ./btrfs qgroup limit none /mnt
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB      5.00GiB         none
0/257       100.02MiB    100.02MiB         none         none

This patch will set the flag user want to clear and pass a
size=-1 to kernel. Then kernel will clear it correctly.

*With this commit*
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB      5.00GiB         none
0/257       100.02MiB    100.02MiB         none         none
 # ./btrfs qgroup limit none /mnt
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB         none         none
0/257       100.02MiB    100.02MiB         none         none

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 cmds-qgroup.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index b073250..00cc089 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -110,9 +110,10 @@ static int parse_limit(const char *p, unsigned long long *s)
 {
 	char *endptr;
 	unsigned long long size;
+	unsigned long long CLEAR_VALUE = -1;
 
 	if (strcasecmp(p, "none") == 0) {
-		*s = 0;
+		*s = CLEAR_VALUE;
 		return 1;
 	}
 	size = strtoull(p, &endptr, 10);
@@ -406,17 +407,15 @@ static int cmd_qgroup_limit(int argc, char **argv)
 	}
 
 	memset(&args, 0, sizeof(args));
-	if (size) {
-		if (compressed)
-			args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
-					  BTRFS_QGROUP_LIMIT_EXCL_CMPR;
-		if (exclusive) {
-			args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
-			args.lim.max_exclusive = size;
-		} else {
-			args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
-			args.lim.max_referenced = size;
-		}
+	if (compressed)
+		args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
+				  BTRFS_QGROUP_LIMIT_EXCL_CMPR;
+	if (exclusive) {
+		args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
+		args.lim.max_exclusive = size;
+	} else {
+		args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
+		args.lim.max_referenced = size;
 	}
 
 	if (argc - optind == 2) {
-- 
1.8.4.2


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

* Re: [PATCH 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup
  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  6:57 ` [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some " Dongsheng Yang
@ 2015-06-03  8:14 ` Tsutomu Itoh
  2015-06-05 16:36 ` David Sterba
  3 siblings, 0 replies; 9+ messages in thread
From: Tsutomu Itoh @ 2015-06-03  8:14 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-btrfs

On 2015/06/03 15:57, Dongsheng Yang wrote:
> There are two understanding of the '0' value in btrfs qgroup show.
> (1) is no-limitation on this qgroup. (2) is the max-limitation is 0.
> 
> This patch make it showing in different way.
> 
> (1). max-limitation for 0 is still showing '0'.
> (2). no-limitation will show 'none'.
> 
> qgroupid         rfer         excl     max_rfer     max_excl parent
> --------         ----         ----     --------     -------- ------
> 0/5           2.19GiB      2.19GiB         none         none ---
> 0/257       100.02MiB    100.02MiB         none         none ---
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

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

> ---
>   qgroup.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/qgroup.c b/qgroup.c
> index 53815b5..dc04b03 100644
> --- a/qgroup.c
> +++ b/qgroup.c
> @@ -237,10 +237,16 @@ static void print_qgroup_column(struct btrfs_qgroup *qgroup,
>   		print_qgroup_column_add_blank(BTRFS_QGROUP_PARENT, len);
>   		break;
>   	case BTRFS_QGROUP_MAX_RFER:
> -		len = printf("%*s", max_len, pretty_size_mode(qgroup->max_rfer, unit_mode));
> +		if (qgroup->flags & BTRFS_QGROUP_LIMIT_MAX_RFER)
> +			len = printf("%*s", max_len, pretty_size_mode(qgroup->max_rfer, unit_mode));
> +		else
> +			len = printf("%*s", max_len, "none");
>   		break;
>   	case BTRFS_QGROUP_MAX_EXCL:
> -		len = printf("%*s", max_len, pretty_size_mode(qgroup->max_excl, unit_mode));
> +		if (qgroup->flags & BTRFS_QGROUP_LIMIT_MAX_EXCL)
> +			len = printf("%*s", max_len, pretty_size_mode(qgroup->max_excl, unit_mode));
> +		else
> +			len = printf("%*s", max_len, "none");
>   		break;
>   	case BTRFS_QGROUP_CHILD:
>   		len = print_child_column(qgroup);
> 



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

* Re: [PATCH] btrfs: qgroup: allow user to clear the limitation on qgroup
  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
  0 siblings, 0 replies; 9+ messages in thread
From: Tsutomu Itoh @ 2015-06-03  8:18 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-btrfs

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);
> 



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

* Re: [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some limitation on qgroup.
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Tsutomu Itoh @ 2015-06-03  8:40 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-btrfs

On 2015/06/03 15:57, Dongsheng Yang wrote:
> Currently, we can not clear a limitation on a qgroup. Although
> there is a 'none' choice provided to user to do it, it does not
> work well.
> 
> It does not set the flag which user want to clear, then kernel
> will never know what the user want to do at all.
> 
> *Without this commit*
>   # ./btrfs qgroup show -re /mnt
> qgroupid         rfer         excl     max_rfer     max_excl
> --------         ----         ----     --------     --------
> 0/5           2.19GiB      2.19GiB      5.00GiB         none
> 0/257       100.02MiB    100.02MiB         none         none
>   # ./btrfs qgroup limit none /mnt
>   # ./btrfs qgroup show -re /mnt
> qgroupid         rfer         excl     max_rfer     max_excl
> --------         ----         ----     --------     --------
> 0/5           2.19GiB      2.19GiB      5.00GiB         none
> 0/257       100.02MiB    100.02MiB         none         none
> 
> This patch will set the flag user want to clear and pass a
> size=-1 to kernel. Then kernel will clear it correctly.
> 
> *With this commit*
>   # ./btrfs qgroup show -re /mnt
> qgroupid         rfer         excl     max_rfer     max_excl
> --------         ----         ----     --------     --------
> 0/5           2.19GiB      2.19GiB      5.00GiB         none
> 0/257       100.02MiB    100.02MiB         none         none
>   # ./btrfs qgroup limit none /mnt
>   # ./btrfs qgroup show -re /mnt
> qgroupid         rfer         excl     max_rfer     max_excl
> --------         ----         ----     --------     --------
> 0/5           2.19GiB      2.19GiB         none         none
> 0/257       100.02MiB    100.02MiB         none         none
> 
> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> ---
>   cmds-qgroup.c | 23 +++++++++++------------
>   1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/cmds-qgroup.c b/cmds-qgroup.c
> index b073250..00cc089 100644
> --- a/cmds-qgroup.c
> +++ b/cmds-qgroup.c
> @@ -110,9 +110,10 @@ static int parse_limit(const char *p, unsigned long long *s)
>   {
>   	char *endptr;
>   	unsigned long long size;
> +	unsigned long long CLEAR_VALUE = -1;

Even if a negative value is specified, it doesn't become an error...
So, it doesn't make an error of the following command.

# btrfs qg lim -- -1 sub1
# btrfs qg show -prce /test1
qgroupid         rfer         excl     max_rfer     max_excl parent  child
--------         ----         ----     --------     -------- ------  -----
0/5          16.00KiB     16.00KiB         none         none ---     ---
0/259         8.86GiB      7.88GiB         none         none ---     ---
# btrfs qg lim -- -2 sub1
# btrfs qg show -prce /test1
qgroupid         rfer         excl     max_rfer     max_excl parent  child
--------         ----         ----     --------     -------- ------  -----
0/5          16.00KiB     16.00KiB         none         none ---     ---
0/259         8.86GiB      7.88GiB     16.00EiB         none ---     ---

Otherwise OK,

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


>   
>   	if (strcasecmp(p, "none") == 0) {
> -		*s = 0;
> +		*s = CLEAR_VALUE;
>   		return 1;
>   	}
>   	size = strtoull(p, &endptr, 10);
> @@ -406,17 +407,15 @@ static int cmd_qgroup_limit(int argc, char **argv)
>   	}
>   
>   	memset(&args, 0, sizeof(args));
> -	if (size) {
> -		if (compressed)
> -			args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
> -					  BTRFS_QGROUP_LIMIT_EXCL_CMPR;
> -		if (exclusive) {
> -			args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
> -			args.lim.max_exclusive = size;
> -		} else {
> -			args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
> -			args.lim.max_referenced = size;
> -		}
> +	if (compressed)
> +		args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
> +				  BTRFS_QGROUP_LIMIT_EXCL_CMPR;
> +	if (exclusive) {
> +		args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
> +		args.lim.max_exclusive = size;
> +	} else {
> +		args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
> +		args.lim.max_referenced = size;
>   	}
>   
>   	if (argc - optind == 2) {
> 



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

* Re: [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some limitation on qgroup.
  2015-06-03  8:40   ` Tsutomu Itoh
@ 2015-06-03  8:41     ` Dongsheng Yang
  0 siblings, 0 replies; 9+ messages in thread
From: Dongsheng Yang @ 2015-06-03  8:41 UTC (permalink / raw)
  To: Tsutomu Itoh; +Cc: linux-btrfs

On 06/03/2015 04:40 PM, Tsutomu Itoh wrote:
> On 2015/06/03 15:57, Dongsheng Yang wrote:
>> Currently, we can not clear a limitation on a qgroup. Although
>> there is a 'none' choice provided to user to do it, it does not
>> work well.
>>
>> It does not set the flag which user want to clear, then kernel
>> will never know what the user want to do at all.
>>
>> *Without this commit*
>>    # ./btrfs qgroup show -re /mnt
>> qgroupid         rfer         excl     max_rfer     max_excl
>> --------         ----         ----     --------     --------
>> 0/5           2.19GiB      2.19GiB      5.00GiB         none
>> 0/257       100.02MiB    100.02MiB         none         none
>>    # ./btrfs qgroup limit none /mnt
>>    # ./btrfs qgroup show -re /mnt
>> qgroupid         rfer         excl     max_rfer     max_excl
>> --------         ----         ----     --------     --------
>> 0/5           2.19GiB      2.19GiB      5.00GiB         none
>> 0/257       100.02MiB    100.02MiB         none         none
>>
>> This patch will set the flag user want to clear and pass a
>> size=-1 to kernel. Then kernel will clear it correctly.
>>
>> *With this commit*
>>    # ./btrfs qgroup show -re /mnt
>> qgroupid         rfer         excl     max_rfer     max_excl
>> --------         ----         ----     --------     --------
>> 0/5           2.19GiB      2.19GiB      5.00GiB         none
>> 0/257       100.02MiB    100.02MiB         none         none
>>    # ./btrfs qgroup limit none /mnt
>>    # ./btrfs qgroup show -re /mnt
>> qgroupid         rfer         excl     max_rfer     max_excl
>> --------         ----         ----     --------     --------
>> 0/5           2.19GiB      2.19GiB         none         none
>> 0/257       100.02MiB    100.02MiB         none         none
>>
>> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>>    cmds-qgroup.c | 23 +++++++++++------------
>>    1 file changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/cmds-qgroup.c b/cmds-qgroup.c
>> index b073250..00cc089 100644
>> --- a/cmds-qgroup.c
>> +++ b/cmds-qgroup.c
>> @@ -110,9 +110,10 @@ static int parse_limit(const char *p, unsigned long long *s)
>>    {
>>    	char *endptr;
>>    	unsigned long long size;
>> +	unsigned long long CLEAR_VALUE = -1;
> 
> Even if a negative value is specified, it doesn't become an error...
> So, it doesn't make an error of the following command.
> 
> # btrfs qg lim -- -1 sub1
> # btrfs qg show -prce /test1
> qgroupid         rfer         excl     max_rfer     max_excl parent  child
> --------         ----         ----     --------     -------- ------  -----
> 0/5          16.00KiB     16.00KiB         none         none ---     ---
> 0/259         8.86GiB      7.88GiB         none         none ---     ---
> # btrfs qg lim -- -2 sub1
> # btrfs qg show -prce /test1
> qgroupid         rfer         excl     max_rfer     max_excl parent  child
> --------         ----         ----     --------     -------- ------  -----
> 0/5          16.00KiB     16.00KiB         none         none ---     ---
> 0/259         8.86GiB      7.88GiB     16.00EiB         none ---     ---

Agreed, I understand your point here.

If we pass a negative value to limit command, we should Error out. But
currently, btrfs-progs are treating it as a unsigned value in parsing
it. Yes, that's a bit of confusing.

We need to cover it in parsing steps with another patch I think.
> 
> Otherwise OK,
> 
> Tested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>

Thanx


Yang
> 
> 
>>    
>>    	if (strcasecmp(p, "none") == 0) {
>> -		*s = 0;
>> +		*s = CLEAR_VALUE;
>>    		return 1;
>>    	}
>>    	size = strtoull(p, &endptr, 10);
>> @@ -406,17 +407,15 @@ static int cmd_qgroup_limit(int argc, char **argv)
>>    	}
>>    
>>    	memset(&args, 0, sizeof(args));
>> -	if (size) {
>> -		if (compressed)
>> -			args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
>> -					  BTRFS_QGROUP_LIMIT_EXCL_CMPR;
>> -		if (exclusive) {
>> -			args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
>> -			args.lim.max_exclusive = size;
>> -		} else {
>> -			args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
>> -			args.lim.max_referenced = size;
>> -		}
>> +	if (compressed)
>> +		args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
>> +				  BTRFS_QGROUP_LIMIT_EXCL_CMPR;
>> +	if (exclusive) {
>> +		args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
>> +		args.lim.max_exclusive = size;
>> +	} else {
>> +		args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
>> +		args.lim.max_referenced = size;
>>    	}
>>    
>>    	if (argc - optind == 2) {
>>
> 
> 
> .
> 


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

* Re: [PATCH 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup
  2015-06-03  6:57 [PATCH 1/2] btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup Dongsheng Yang
                   ` (2 preceding siblings ...)
  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
  3 siblings, 0 replies; 9+ messages in thread
From: David Sterba @ 2015-06-05 16:36 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-btrfs

On Wed, Jun 03, 2015 at 02:57:31PM +0800, Dongsheng Yang wrote:
> There are two understanding of the '0' value in btrfs qgroup show.
> (1) is no-limitation on this qgroup. (2) is the max-limitation is 0.
> 
> This patch make it showing in different way.
> 
> (1). max-limitation for 0 is still showing '0'.
> (2). no-limitation will show 'none'.
> 
> qgroupid         rfer         excl     max_rfer     max_excl parent
> --------         ----         ----     --------     -------- ------
> 0/5           2.19GiB      2.19GiB         none         none ---
> 0/257       100.02MiB    100.02MiB         none         none ---
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

Applied, thanks.

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

* Re: [PATCH 2/2] btrfs-progs: qgroup: allow user to clear some limitation on qgroup.
  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-05 16:37   ` David Sterba
  1 sibling, 0 replies; 9+ messages in thread
From: David Sterba @ 2015-06-05 16:37 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-btrfs

On Wed, Jun 03, 2015 at 02:57:33PM +0800, Dongsheng Yang wrote:
> Currently, we can not clear a limitation on a qgroup. Although
> there is a 'none' choice provided to user to do it, it does not
> work well.
> 
...
> 
> Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

Applied, thanks.

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

end of thread, other threads:[~2015-06-05 16:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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