summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2017-12-12 02:34:29 -0500
committerDavid Sterba <dsterba@suse.com>2018-03-30 19:41:14 -0400
commit733e03a0b26a463d75aa86083c9fab856571e7fc (patch)
tree6b703eeb697165fdf06b8cad3930ec5143da224f /fs/btrfs/transaction.c
parent5c40507ffb1bbbc8eeeaa6d8da181f431cb83d97 (diff)
btrfs: qgroup: Split meta rsv type into meta_prealloc and meta_pertrans
Btrfs uses 2 different methods to reseve metadata qgroup space. 1) Reserve at btrfs_start_transaction() time This is quite straightforward, caller will use the trans handler allocated to modify b-trees. In this case, reserved metadata should be kept until qgroup numbers are updated. 2) Reserve by using block_rsv first, and later btrfs_join_transaction() This is more complicated, caller will reserve space using block_rsv first, and then later call btrfs_join_transaction() to get a trans handle. In this case, before we modify trees, the reserved space can be modified on demand, and after btrfs_join_transaction(), such reserved space should also be kept until qgroup numbers are updated. Since these two types behave differently, split the original "META" reservation type into 2 sub-types: META_PERTRANS: For above case 1) META_PREALLOC: For reservations that happened before btrfs_join_transaction() of case 2) NOTE: This patch will only convert existing qgroup meta reservation callers according to its situation, not ensuring all callers are at correct timing. Such fix will be added in later patches. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update comments ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 15f6541303bc..5c4cf0f9146b 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -498,8 +498,8 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
498 */ 498 */
499 if (num_items && root != fs_info->chunk_root) { 499 if (num_items && root != fs_info->chunk_root) {
500 qgroup_reserved = num_items * fs_info->nodesize; 500 qgroup_reserved = num_items * fs_info->nodesize;
501 ret = btrfs_qgroup_reserve_meta(root, qgroup_reserved, 501 ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved,
502 enforce_qgroups); 502 enforce_qgroups);
503 if (ret) 503 if (ret)
504 return ERR_PTR(ret); 504 return ERR_PTR(ret);
505 505
@@ -596,7 +596,7 @@ alloc_fail:
596 btrfs_block_rsv_release(fs_info, &fs_info->trans_block_rsv, 596 btrfs_block_rsv_release(fs_info, &fs_info->trans_block_rsv,
597 num_bytes); 597 num_bytes);
598reserve_fail: 598reserve_fail:
599 btrfs_qgroup_free_meta(root, qgroup_reserved); 599 btrfs_qgroup_free_meta_pertrans(root, qgroup_reserved);
600 return ERR_PTR(ret); 600 return ERR_PTR(ret);
601} 601}
602 602
@@ -1284,7 +1284,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans)
1284 spin_lock(&fs_info->fs_roots_radix_lock); 1284 spin_lock(&fs_info->fs_roots_radix_lock);
1285 if (err) 1285 if (err)
1286 break; 1286 break;
1287 btrfs_qgroup_free_meta_all(root); 1287 btrfs_qgroup_free_meta_all_pertrans(root);
1288 } 1288 }
1289 } 1289 }
1290 spin_unlock(&fs_info->fs_roots_radix_lock); 1290 spin_unlock(&fs_info->fs_roots_radix_lock);