]> git.hungrycats.org Git - linux/commitdiff
btrfs: Update btrfs qgroup status item when rescan is done.
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Fri, 27 Feb 2015 08:24:25 +0000 (16:24 +0800)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Sun, 19 Apr 2015 15:56:56 +0000 (11:56 -0400)
Update qgroup status when rescan is done.

Before this patch, status item is not updated on rescan finish, which
causing the RESCAN and INCONSISTENT flags never cleared.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 53b7cde9d5aa58cf7605664f0e34419156b02698)

fs/btrfs/qgroup.c

index c3156ea17caaaa80ca632cfaab8506d261429705..a1954a92de862a4ca8f4e4c87528d241d6cc8e26 100644 (file)
@@ -2667,6 +2667,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
        struct ulist *tmp = NULL, *qgroups = NULL;
        struct extent_buffer *scratch_leaf = NULL;
        int err = -ENOMEM;
+       int ret = 0;
 
        path = btrfs_alloc_path();
        if (!path)
@@ -2717,6 +2718,28 @@ out:
        }
        mutex_unlock(&fs_info->qgroup_rescan_lock);
 
+       /*
+        * only update status, since the previous part has alreay updated the
+        * qgroup info.
+        */
+       trans = btrfs_start_transaction(fs_info->quota_root, 1);
+       if (IS_ERR(trans)) {
+               err = PTR_ERR(trans);
+               btrfs_err(fs_info,
+                         "fail to start transaction for status update: %d\n",
+                         err);
+               goto done;
+       }
+       ret = update_qgroup_status_item(trans, fs_info, fs_info->quota_root);
+       if (ret < 0) {
+               err = ret;
+               btrfs_err(fs_info, "fail to update qgroup status: %d\n",
+                         err);
+               btrfs_abort_transaction(trans, fs_info->quota_root, err);
+               goto done;
+       }
+       btrfs_end_transaction(trans, fs_info->quota_root);
+
        if (err >= 0) {
                btrfs_info(fs_info, "qgroup scan completed%s",
                        err > 0 ? " (inconsistency flag cleared)" : "");
@@ -2724,6 +2747,7 @@ out:
                btrfs_err(fs_info, "qgroup scan failed with %d", err);
        }
 
+done:
        complete_all(&fs_info->qgroup_rescan_completion);
 }
 
@@ -2758,7 +2782,6 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
                        mutex_unlock(&fs_info->qgroup_rescan_lock);
                        goto err;
                }
-
                fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_RESCAN;
        }