Skip to content

Commit e15e9f4

Browse files
adam900710kdave
authored andcommitted
btrfs: introduce BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING to skip qgroup accounting
The new flag will make btrfs qgroup skip all its time consuming qgroup accounting. The lifespan is the same as BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN, only get cleared after a new rescan. Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent e562a8b commit e15e9f4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

fs/btrfs/qgroup.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
336336
static void qgroup_mark_inconsistent(struct btrfs_fs_info *fs_info)
337337
{
338338
fs_info->qgroup_flags |= (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT |
339-
BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN);
339+
BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN |
340+
BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING);
340341
}
341342

342343
/*
@@ -1813,6 +1814,9 @@ int btrfs_qgroup_trace_extent_post(struct btrfs_trans_handle *trans,
18131814
*/
18141815
ASSERT(trans != NULL);
18151816

1817+
if (trans->fs_info->qgroup_flags & BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING)
1818+
return 0;
1819+
18161820
ret = btrfs_find_all_roots(NULL, trans->fs_info, bytenr, 0, &old_root,
18171821
true);
18181822
if (ret < 0) {
@@ -2627,7 +2631,8 @@ int btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, u64 bytenr,
26272631
* If quotas get disabled meanwhile, the resources need to be freed and
26282632
* we can't just exit here.
26292633
*/
2630-
if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
2634+
if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) ||
2635+
fs_info->qgroup_flags & BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING)
26312636
goto out_free;
26322637

26332638
if (new_roots) {
@@ -2723,7 +2728,8 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans)
27232728
num_dirty_extents++;
27242729
trace_btrfs_qgroup_account_extents(fs_info, record);
27252730

2726-
if (!ret) {
2731+
if (!ret && !(fs_info->qgroup_flags &
2732+
BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING)) {
27272733
/*
27282734
* Old roots should be searched when inserting qgroup
27292735
* extent record
@@ -3460,7 +3466,8 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
34603466

34613467
memset(&fs_info->qgroup_rescan_progress, 0,
34623468
sizeof(fs_info->qgroup_rescan_progress));
3463-
fs_info->qgroup_flags &= ~BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN;
3469+
fs_info->qgroup_flags &= ~(BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN |
3470+
BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING);
34643471
fs_info->qgroup_rescan_progress.objectid = progress_objectid;
34653472
init_completion(&fs_info->qgroup_rescan_completion);
34663473
mutex_unlock(&fs_info->qgroup_rescan_lock);

fs/btrfs/qgroup.h

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
*/
102102

103103
#define BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN (1UL << 3)
104+
#define BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING (1UL << 4)
104105

105106
/*
106107
* Record a dirty extent, and info qgroup to update quota on it

0 commit comments

Comments
 (0)