diff mbox

[v2,1/2] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation

Message ID 20180508054803.20851-1-lufq.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lu Fengqi May 8, 2018, 5:48 a.m. UTC
The QGROUP_RELATION item is very special, it always exists in pairs
(objectid and offset exchange). Its objectid and offset are the ids of a
pair of parent and child qgroups, respectively. The larger one is
parent and the smaller one is child. After the following commit, the order
of the parameters is wrong and causes qgroup show to output the wrong
qgroup parent-child relationship.

Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments")
Issue: #129
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
---
V2: Rename variables instead of the comment to make it clear.

 qgroup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Qu Wenruo May 8, 2018, 5:55 a.m. UTC | #1
On 2018年05月08日 13:48, Lu Fengqi wrote:
> The QGROUP_RELATION item is very special, it always exists in pairs
> (objectid and offset exchange). Its objectid and offset are the ids of a
> pair of parent and child qgroups, respectively. The larger one is
> parent and the smaller one is child. After the following commit, the order
> of the parameters is wrong and causes qgroup show to output the wrong
> qgroup parent-child relationship.
> 
> Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments")
> Issue: #129
> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
> V2: Rename variables instead of the comment to make it clear.
> 
>  qgroup.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/qgroup.c b/qgroup.c
> index 11659e8394dd..267cd7f11a9c 100644
> --- a/qgroup.c
> +++ b/qgroup.c
> @@ -1051,7 +1051,7 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
>  	struct btrfs_qgroup_limit_item *limit;
>  	u64 flags;
>  	u64 qgroupid;
> -	u64 qgroupid1;
> +	u64 child, parent;
>  
>  	memset(&args, 0, sizeof(args));
>  
> @@ -1119,14 +1119,14 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
>  							  qgroupid, limit);
>  				break;
>  			case BTRFS_QGROUP_RELATION_KEY:
> -				qgroupid = btrfs_search_header_offset(sh);
> -				qgroupid1 = btrfs_search_header_objectid(sh);
> +				child = btrfs_search_header_offset(sh);
> +				parent = btrfs_search_header_objectid(sh);
>  
> -				if (qgroupid < qgroupid1)
> +				if (parent <= child)
>  					break;
>  
>  				ret = update_qgroup_relation(qgroup_lookup,
> -							qgroupid, qgroupid1);
> +							     child, parent);
>  				break;
>  			default:
>  				return ret;
>
David Sterba May 8, 2018, 5:30 p.m. UTC | #2
On Tue, May 08, 2018 at 01:48:02PM +0800, Lu Fengqi wrote:
> The QGROUP_RELATION item is very special, it always exists in pairs
> (objectid and offset exchange). Its objectid and offset are the ids of a
> pair of parent and child qgroups, respectively. The larger one is
> parent and the smaller one is child. After the following commit, the order
> of the parameters is wrong and causes qgroup show to output the wrong
> qgroup parent-child relationship.
> 
> Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments")
> Issue: #129
> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
> ---
> V2: Rename variables instead of the comment to make it clear.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/qgroup.c b/qgroup.c
index 11659e8394dd..267cd7f11a9c 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -1051,7 +1051,7 @@  static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
 	struct btrfs_qgroup_limit_item *limit;
 	u64 flags;
 	u64 qgroupid;
-	u64 qgroupid1;
+	u64 child, parent;
 
 	memset(&args, 0, sizeof(args));
 
@@ -1119,14 +1119,14 @@  static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
 							  qgroupid, limit);
 				break;
 			case BTRFS_QGROUP_RELATION_KEY:
-				qgroupid = btrfs_search_header_offset(sh);
-				qgroupid1 = btrfs_search_header_objectid(sh);
+				child = btrfs_search_header_offset(sh);
+				parent = btrfs_search_header_objectid(sh);
 
-				if (qgroupid < qgroupid1)
+				if (parent <= child)
 					break;
 
 				ret = update_qgroup_relation(qgroup_lookup,
-							qgroupid, qgroupid1);
+							     child, parent);
 				break;
 			default:
 				return ret;