[07/10] block-progs: block_group: add dirty_bgs list related memebers
diff mbox series

Message ID 20191205042921.25316-8-Damenly_Su@gmx.com
State New
Headers show
Series
  • unify origanization structure of block group cache
Related show

Commit Message

Damenly Su Dec. 5, 2019, 4:29 a.m. UTC
From: Su Yue <Damenly_Su@gmx.com>

The old style uses extent bit BLOCK_GROUP_DIRTY to mark dirty block
groups in extent cache. To replace it, add btrfs_trans_handle::dirty_bgs
and btrfs_block_group_cache::dirty_list.

Signed-off-by: Su Yue <Damenly_Su@gmx.com>
---
 ctree.h       | 3 +++
 extent-tree.c | 4 ++++
 transaction.c | 1 +
 transaction.h | 3 ++-
 4 files changed, 10 insertions(+), 1 deletion(-)

Comments

Qu Wenruo Dec. 5, 2019, 7:43 a.m. UTC | #1
On 2019/12/5 下午12:29, damenly.su@gmail.com wrote:
> From: Su Yue <Damenly_Su@gmx.com>
> 
> The old style uses extent bit BLOCK_GROUP_DIRTY to mark dirty block
> groups in extent cache. To replace it, add btrfs_trans_handle::dirty_bgs
> and btrfs_block_group_cache::dirty_list.
> 
> Signed-off-by: Su Yue <Damenly_Su@gmx.com>

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

Thanks,
Qu

> ---
>  ctree.h       | 3 +++
>  extent-tree.c | 4 ++++
>  transaction.c | 1 +
>  transaction.h | 3 ++-
>  4 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/ctree.h b/ctree.h
> index f3f5f52f2559..61ce53c46302 100644
> --- a/ctree.h
> +++ b/ctree.h
> @@ -1119,6 +1119,9 @@ struct btrfs_block_group_cache {
>  
>  	/* Block group cache stuff */
>  	struct rb_node cache_node;
> +
> +	/* For dirty block groups */
> +	struct list_head dirty_list;
>  };
>  
>  struct btrfs_device;
> diff --git a/extent-tree.c b/extent-tree.c
> index ff3db5ca2e0c..981622e37ab7 100644
> --- a/extent-tree.c
> +++ b/extent-tree.c
> @@ -2819,6 +2819,8 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info,
>  	cache->pinned = 0;
>  	cache->flags = btrfs_block_group_flags(&bgi);
>  	cache->used = btrfs_block_group_used(&bgi);
> +	INIT_LIST_HEAD(&cache->dirty_list);
> +
>  	if (cache->flags & BTRFS_BLOCK_GROUP_DATA) {
>  		bit = BLOCK_GROUP_DATA;
>  	} else if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
> @@ -2900,6 +2902,7 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type,
>  	cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
>  	cache->used = bytes_used;
>  	cache->flags = type;
> +	INIT_LIST_HEAD(&cache->dirty_list);
>  
>  	exclude_super_stripes(fs_info, cache);
>  	ret = update_space_info(fs_info, cache->flags, size, bytes_used,
> @@ -2997,6 +3000,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
>  		cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
>  		cache->used = 0;
>  		cache->flags = group_type;
> +		INIT_LIST_HEAD(&cache->dirty_list);
>  
>  		ret = update_space_info(fs_info, group_type, group_size,
>  					0, &cache->space_info);
> diff --git a/transaction.c b/transaction.c
> index c9035c765a74..269e52c01d29 100644
> --- a/transaction.c
> +++ b/transaction.c
> @@ -52,6 +52,7 @@ struct btrfs_trans_handle* btrfs_start_transaction(struct btrfs_root *root,
>  	root->last_trans = h->transid;
>  	root->commit_root = root->node;
>  	extent_buffer_get(root->node);
> +	INIT_LIST_HEAD(&h->dirty_bgs);
>  
>  	return h;
>  }
> diff --git a/transaction.h b/transaction.h
> index 750f456b3cc0..8fa65508fa8d 100644
> --- a/transaction.h
> +++ b/transaction.h
> @@ -22,6 +22,7 @@
>  #include "kerncompat.h"
>  #include "ctree.h"
>  #include "delayed-ref.h"
> +#include "kernel-lib/list.h"
>  
>  struct btrfs_trans_handle {
>  	struct btrfs_fs_info *fs_info;
> @@ -35,7 +36,7 @@ struct btrfs_trans_handle {
>  	unsigned long blocks_used;
>  	struct btrfs_block_group_cache *block_group;
>  	struct btrfs_delayed_ref_root delayed_refs;
> -
> +	struct list_head dirty_bgs;
>  };
>  
>  struct btrfs_trans_handle* btrfs_start_transaction(struct btrfs_root *root,
>

Patch
diff mbox series

diff --git a/ctree.h b/ctree.h
index f3f5f52f2559..61ce53c46302 100644
--- a/ctree.h
+++ b/ctree.h
@@ -1119,6 +1119,9 @@  struct btrfs_block_group_cache {
 
 	/* Block group cache stuff */
 	struct rb_node cache_node;
+
+	/* For dirty block groups */
+	struct list_head dirty_list;
 };
 
 struct btrfs_device;
diff --git a/extent-tree.c b/extent-tree.c
index ff3db5ca2e0c..981622e37ab7 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2819,6 +2819,8 @@  static int read_one_block_group(struct btrfs_fs_info *fs_info,
 	cache->pinned = 0;
 	cache->flags = btrfs_block_group_flags(&bgi);
 	cache->used = btrfs_block_group_used(&bgi);
+	INIT_LIST_HEAD(&cache->dirty_list);
+
 	if (cache->flags & BTRFS_BLOCK_GROUP_DATA) {
 		bit = BLOCK_GROUP_DATA;
 	} else if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
@@ -2900,6 +2902,7 @@  btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type,
 	cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
 	cache->used = bytes_used;
 	cache->flags = type;
+	INIT_LIST_HEAD(&cache->dirty_list);
 
 	exclude_super_stripes(fs_info, cache);
 	ret = update_space_info(fs_info, cache->flags, size, bytes_used,
@@ -2997,6 +3000,7 @@  int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
 		cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
 		cache->used = 0;
 		cache->flags = group_type;
+		INIT_LIST_HEAD(&cache->dirty_list);
 
 		ret = update_space_info(fs_info, group_type, group_size,
 					0, &cache->space_info);
diff --git a/transaction.c b/transaction.c
index c9035c765a74..269e52c01d29 100644
--- a/transaction.c
+++ b/transaction.c
@@ -52,6 +52,7 @@  struct btrfs_trans_handle* btrfs_start_transaction(struct btrfs_root *root,
 	root->last_trans = h->transid;
 	root->commit_root = root->node;
 	extent_buffer_get(root->node);
+	INIT_LIST_HEAD(&h->dirty_bgs);
 
 	return h;
 }
diff --git a/transaction.h b/transaction.h
index 750f456b3cc0..8fa65508fa8d 100644
--- a/transaction.h
+++ b/transaction.h
@@ -22,6 +22,7 @@ 
 #include "kerncompat.h"
 #include "ctree.h"
 #include "delayed-ref.h"
+#include "kernel-lib/list.h"
 
 struct btrfs_trans_handle {
 	struct btrfs_fs_info *fs_info;
@@ -35,7 +36,7 @@  struct btrfs_trans_handle {
 	unsigned long blocks_used;
 	struct btrfs_block_group_cache *block_group;
 	struct btrfs_delayed_ref_root delayed_refs;
-
+	struct list_head dirty_bgs;
 };
 
 struct btrfs_trans_handle* btrfs_start_transaction(struct btrfs_root *root,