All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation
@ 2018-05-07  8:50 Lu Fengqi
  2018-05-07 11:19 ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: Lu Fengqi @ 2018-05-07  8:50 UTC (permalink / raw)
  To: linux-btrfs

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>
---
 qgroup.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/qgroup.c b/qgroup.c
index 11659e8394dd..e7e127daf5ce 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -1122,11 +1122,16 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
 				qgroupid = btrfs_search_header_offset(sh);
 				qgroupid1 = btrfs_search_header_objectid(sh);
 
-				if (qgroupid < qgroupid1)
+				if (qgroupid <= qgroupid1)
 					break;
 
+				/*
+				 * because of qgroupid > qgroupid1, qgroupid is
+				 * the id of parent, and qgroupid1 is the id of
+				 * child.
+				 */
 				ret = update_qgroup_relation(qgroup_lookup,
-							qgroupid, qgroupid1);
+							qgroupid1, qgroupid);
 				break;
 			default:
 				return ret;
-- 
2.17.0




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

* Re: [PATCH] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation
  2018-05-07  8:50 [PATCH] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation Lu Fengqi
@ 2018-05-07 11:19 ` Qu Wenruo
  2018-05-08  0:41   ` Lu Fengqi
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2018-05-07 11:19 UTC (permalink / raw)
  To: Lu Fengqi, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 1624 bytes --]



On 2018年05月07日 16:50, 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>
> ---
>  qgroup.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/qgroup.c b/qgroup.c
> index 11659e8394dd..e7e127daf5ce 100644
> --- a/qgroup.c
> +++ b/qgroup.c
> @@ -1122,11 +1122,16 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
>  				qgroupid = btrfs_search_header_offset(sh);
>  				qgroupid1 = btrfs_search_header_objectid(sh);
>  
> -				if (qgroupid < qgroupid1)
> +				if (qgroupid <= qgroupid1)
>  					break;
>  
> +				/*
> +				 * because of qgroupid > qgroupid1, qgroupid is
> +				 * the id of parent, and qgroupid1 is the id of
> +				 * child.
> +				 */

Instead of such comment, renaming @qgroupid to @parent, and @qgroupid1
to @child makes more sense.

And a test case would definitely help in this case.

Thanks,
Qu

>  				ret = update_qgroup_relation(qgroup_lookup,
> -							qgroupid, qgroupid1);
> +							qgroupid1, qgroupid);
>  				break;
>  			default:
>  				return ret;
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation
  2018-05-07 11:19 ` Qu Wenruo
@ 2018-05-08  0:41   ` Lu Fengqi
  0 siblings, 0 replies; 3+ messages in thread
From: Lu Fengqi @ 2018-05-08  0:41 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Mon, May 07, 2018 at 07:19:32PM +0800, Qu Wenruo wrote:
>
>
>On 2018年05月07日 16:50, 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>
>> ---
>>  qgroup.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>> 
>> diff --git a/qgroup.c b/qgroup.c
>> index 11659e8394dd..e7e127daf5ce 100644
>> --- a/qgroup.c
>> +++ b/qgroup.c
>> @@ -1122,11 +1122,16 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
>>  				qgroupid = btrfs_search_header_offset(sh);
>>  				qgroupid1 = btrfs_search_header_objectid(sh);
>>  
>> -				if (qgroupid < qgroupid1)
>> +				if (qgroupid <= qgroupid1)
>>  					break;
>>  
>> +				/*
>> +				 * because of qgroupid > qgroupid1, qgroupid is
>> +				 * the id of parent, and qgroupid1 is the id of
>> +				 * child.
>> +				 */
>
>Instead of such comment, renaming @qgroupid to @parent, and @qgroupid1
>to @child makes more sense.

Although we are not sure which one is the parent before this if statement,
renaming may indeed make the code clearer, so V2 is coming.

>
>And a test case would definitely help in this case.

Make sense.

-- 
Thanks,
Lu

>
>Thanks,
>Qu
>
>>  				ret = update_qgroup_relation(qgroup_lookup,
>> -							qgroupid, qgroupid1);
>> +							qgroupid1, qgroupid);
>>  				break;
>>  			default:
>>  				return ret;
>> 
>



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

end of thread, other threads:[~2018-05-08  0:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07  8:50 [PATCH] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation Lu Fengqi
2018-05-07 11:19 ` Qu Wenruo
2018-05-08  0:41   ` Lu Fengqi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.