linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: qgroup: Always remove all qgroup relation in btrfs_remove_qgroup()
       [not found] <cover.1533787467.git.misono.tomohiro@jp.fujitsu.com>
@ 2018-08-09  4:10 ` Misono Tomohiro
  2018-08-09  5:41   ` Qu Wenruo
  0 siblings, 1 reply; 2+ messages in thread
From: Misono Tomohiro @ 2018-08-09  4:10 UTC (permalink / raw)
  To: linux-btrfs

In btrfs_remove_qgroup(), each qgroup relation is removed by calling
__del_qgroup_relation(). However, __del_qgroup_relation() returns 1
if deletion of qgroup relation causes inconsistency and current code
exits immediately  in that case.

Therefore if there are several qgroup relations and removing first
relation causes inconsistency, remaining items will not be removed.

Fix this by continuing to remove items if return value of
__del_qgroup_relation() is 1.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
 fs/btrfs/qgroup.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 2ba29f0609d9..f18284253e77 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1428,12 +1428,21 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
 		goto out;
 
 	while (!list_empty(&qgroup->groups)) {
+		int ret2;
+
 		list = list_first_entry(&qgroup->groups,
 					struct btrfs_qgroup_list, next_group);
-		ret = __del_qgroup_relation(trans, qgroupid,
+		ret2 = __del_qgroup_relation(trans, qgroupid,
 					    list->group->qgroupid);
-		if (ret)
-			goto out;
+		if (ret2) {
+			ret = ret2;
+			/*
+			 * __del_qgroup_relation() returns 1 if qgroup becomes
+			 * inconsistent. Continue to remove items in that case.
+			 */
+			if (ret != 1)
+				goto out;
+		}
 	}
 
 	spin_lock(&fs_info->qgroup_lock);
-- 
2.14.4



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

* Re: [PATCH] btrfs: qgroup: Always remove all qgroup relation in btrfs_remove_qgroup()
  2018-08-09  4:10 ` [PATCH] btrfs: qgroup: Always remove all qgroup relation in btrfs_remove_qgroup() Misono Tomohiro
@ 2018-08-09  5:41   ` Qu Wenruo
  0 siblings, 0 replies; 2+ messages in thread
From: Qu Wenruo @ 2018-08-09  5:41 UTC (permalink / raw)
  To: Misono Tomohiro, linux-btrfs


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



On 8/9/18 12:10 PM, Misono Tomohiro wrote:
> In btrfs_remove_qgroup(), each qgroup relation is removed by calling
> __del_qgroup_relation(). However, __del_qgroup_relation() returns 1
> if deletion of qgroup relation causes inconsistency and current code
> exits immediately  in that case.
> 
> Therefore if there are several qgroup relations and removing first
> relation causes inconsistency, remaining items will not be removed.
> 
> Fix this by continuing to remove items if return value of
> __del_qgroup_relation() is 1.
> 
> Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>

Indeed we still need to remove all qgroup relationship even we will make
qgroup inconsistent.

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

Thanks,
Qu

> ---
>  fs/btrfs/qgroup.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 2ba29f0609d9..f18284253e77 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -1428,12 +1428,21 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
>  		goto out;
>  
>  	while (!list_empty(&qgroup->groups)) {
> +		int ret2;
> +
>  		list = list_first_entry(&qgroup->groups,
>  					struct btrfs_qgroup_list, next_group);
> -		ret = __del_qgroup_relation(trans, qgroupid,
> +		ret2 = __del_qgroup_relation(trans, qgroupid,
>  					    list->group->qgroupid);
> -		if (ret)
> -			goto out;
> +		if (ret2) {
> +			ret = ret2;
> +			/*
> +			 * __del_qgroup_relation() returns 1 if qgroup becomes
> +			 * inconsistent. Continue to remove items in that case.
> +			 */
> +			if (ret != 1)
> +				goto out;
> +		}
>  	}
>  
>  	spin_lock(&fs_info->qgroup_lock);
> 


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

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

end of thread, other threads:[~2018-08-09  8:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1533787467.git.misono.tomohiro@jp.fujitsu.com>
2018-08-09  4:10 ` [PATCH] btrfs: qgroup: Always remove all qgroup relation in btrfs_remove_qgroup() Misono Tomohiro
2018-08-09  5:41   ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).