diff mbox series

[19/19] btrfs: replace btrfs_delayed_*_ref with btrfs_*_ref

Message ID 803b5e1780c28bb432930ab7df4459c0f3d4edaf.1713052088.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: delayed refs cleanups | expand

Commit Message

Josef Bacik April 13, 2024, 11:53 p.m. UTC
Now that these two structs are the same, move the btrfs_data_ref and
btrfs_tree_ref up and use these in the btrfs_delayed_ref_node.  Then
remove the btrfs_delayed_*_ref structs.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/delayed-ref.c | 10 +++-----
 fs/btrfs/delayed-ref.h | 57 ++++++++++++++++++------------------------
 2 files changed, 28 insertions(+), 39 deletions(-)

Comments

Filipe Manana April 15, 2024, 1:11 p.m. UTC | #1
On Sun, Apr 14, 2024 at 12:55 AM Josef Bacik <josef@toxicpanda.com> wrote:
>
> Now that these two structs are the same, move the btrfs_data_ref and
> btrfs_tree_ref up and use these in the btrfs_delayed_ref_node.  Then
> remove the btrfs_delayed_*_ref structs.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/delayed-ref.c | 10 +++-----
>  fs/btrfs/delayed-ref.h | 57 ++++++++++++++++++------------------------
>  2 files changed, 28 insertions(+), 39 deletions(-)
>
> diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
> index 397e1d0b4010..582660833c1b 100644
> --- a/fs/btrfs/delayed-ref.c
> +++ b/fs/btrfs/delayed-ref.c
> @@ -982,12 +982,10 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
>         RB_CLEAR_NODE(&ref->ref_node);
>         INIT_LIST_HEAD(&ref->add_list);
>
> -       if (generic_ref->type == BTRFS_REF_DATA) {
> -               ref->data_ref.objectid = generic_ref->data_ref.objectid;
> -               ref->data_ref.offset = generic_ref->data_ref.offset;
> -       } else {
> -               ref->tree_ref.level = generic_ref->tree_ref.level;
> -       }
> +       if (generic_ref->type == BTRFS_REF_DATA)
> +               ref->data_ref = generic_ref->data_ref;
> +       else
> +               ref->tree_ref = generic_ref->tree_ref;
>  }
>
>  void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
> diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
> index 84bc990e34fd..dfacbafb1b00 100644
> --- a/fs/btrfs/delayed-ref.h
> +++ b/fs/btrfs/delayed-ref.h
> @@ -30,13 +30,30 @@ enum btrfs_delayed_ref_action {
>         BTRFS_UPDATE_DELAYED_HEAD,
>  } __packed;
>
> -struct btrfs_delayed_tree_ref {
> -       int level;
> +struct btrfs_data_ref {
> +       /* For EXTENT_DATA_REF */
> +
> +       /* Inode which refers to this data extent */
> +       u64 objectid;
> +
> +       /*
> +        * file_offset - extent_offset
> +        *
> +        * file_offset is the key.offset of the EXTENT_DATA key.
> +        * extent_offset is btrfs_file_extent_offset() of the EXTENT_DATA data.
> +        */
> +       u64 offset;
>  };
>
> -struct btrfs_delayed_data_ref {
> -       u64 objectid;
> -       u64 offset;
> +struct btrfs_tree_ref {
> +       /*
> +        * Level of this tree block

Add missing punctuation at the end of the sentence.

Otherwise it looks good, so:

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Thanks.


> +        *
> +        * Shared for skinny (TREE_BLOCK_REF) and normal tree ref.
> +        */
> +       int level;
> +
> +       /* For non-skinny metadata, no special member needed */
>  };
>
>  struct btrfs_delayed_ref_node {
> @@ -84,8 +101,8 @@ struct btrfs_delayed_ref_node {
>         unsigned int type:8;
>
>         union {
> -               struct btrfs_delayed_tree_ref tree_ref;
> -               struct btrfs_delayed_data_ref data_ref;
> +               struct btrfs_tree_ref tree_ref;
> +               struct btrfs_data_ref data_ref;
>         };
>  };
>
> @@ -222,32 +239,6 @@ enum btrfs_ref_type {
>         BTRFS_REF_LAST,
>  } __packed;
>
> -struct btrfs_data_ref {
> -       /* For EXTENT_DATA_REF */
> -
> -       /* Inode which refers to this data extent */
> -       u64 objectid;
> -
> -       /*
> -        * file_offset - extent_offset
> -        *
> -        * file_offset is the key.offset of the EXTENT_DATA key.
> -        * extent_offset is btrfs_file_extent_offset() of the EXTENT_DATA data.
> -        */
> -       u64 offset;
> -};
> -
> -struct btrfs_tree_ref {
> -       /*
> -        * Level of this tree block
> -        *
> -        * Shared for skinny (TREE_BLOCK_REF) and normal tree ref.
> -        */
> -       int level;
> -
> -       /* For non-skinny metadata, no special member needed */
> -};
> -
>  struct btrfs_ref {
>         enum btrfs_ref_type type;
>         enum btrfs_delayed_ref_action action;
> --
> 2.43.0
>
>
diff mbox series

Patch

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 397e1d0b4010..582660833c1b 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -982,12 +982,10 @@  static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
 	RB_CLEAR_NODE(&ref->ref_node);
 	INIT_LIST_HEAD(&ref->add_list);
 
-	if (generic_ref->type == BTRFS_REF_DATA) {
-		ref->data_ref.objectid = generic_ref->data_ref.objectid;
-		ref->data_ref.offset = generic_ref->data_ref.offset;
-	} else {
-		ref->tree_ref.level = generic_ref->tree_ref.level;
-	}
+	if (generic_ref->type == BTRFS_REF_DATA)
+		ref->data_ref = generic_ref->data_ref;
+	else
+		ref->tree_ref = generic_ref->tree_ref;
 }
 
 void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index 84bc990e34fd..dfacbafb1b00 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -30,13 +30,30 @@  enum btrfs_delayed_ref_action {
 	BTRFS_UPDATE_DELAYED_HEAD,
 } __packed;
 
-struct btrfs_delayed_tree_ref {
-	int level;
+struct btrfs_data_ref {
+	/* For EXTENT_DATA_REF */
+
+	/* Inode which refers to this data extent */
+	u64 objectid;
+
+	/*
+	 * file_offset - extent_offset
+	 *
+	 * file_offset is the key.offset of the EXTENT_DATA key.
+	 * extent_offset is btrfs_file_extent_offset() of the EXTENT_DATA data.
+	 */
+	u64 offset;
 };
 
-struct btrfs_delayed_data_ref {
-	u64 objectid;
-	u64 offset;
+struct btrfs_tree_ref {
+	/*
+	 * Level of this tree block
+	 *
+	 * Shared for skinny (TREE_BLOCK_REF) and normal tree ref.
+	 */
+	int level;
+
+	/* For non-skinny metadata, no special member needed */
 };
 
 struct btrfs_delayed_ref_node {
@@ -84,8 +101,8 @@  struct btrfs_delayed_ref_node {
 	unsigned int type:8;
 
 	union {
-		struct btrfs_delayed_tree_ref tree_ref;
-		struct btrfs_delayed_data_ref data_ref;
+		struct btrfs_tree_ref tree_ref;
+		struct btrfs_data_ref data_ref;
 	};
 };
 
@@ -222,32 +239,6 @@  enum btrfs_ref_type {
 	BTRFS_REF_LAST,
 } __packed;
 
-struct btrfs_data_ref {
-	/* For EXTENT_DATA_REF */
-
-	/* Inode which refers to this data extent */
-	u64 objectid;
-
-	/*
-	 * file_offset - extent_offset
-	 *
-	 * file_offset is the key.offset of the EXTENT_DATA key.
-	 * extent_offset is btrfs_file_extent_offset() of the EXTENT_DATA data.
-	 */
-	u64 offset;
-};
-
-struct btrfs_tree_ref {
-	/*
-	 * Level of this tree block
-	 *
-	 * Shared for skinny (TREE_BLOCK_REF) and normal tree ref.
-	 */
-	int level;
-
-	/* For non-skinny metadata, no special member needed */
-};
-
 struct btrfs_ref {
 	enum btrfs_ref_type type;
 	enum btrfs_delayed_ref_action action;