diff mbox series

btrfs-progs: libbtrfs: fix API compatibility change

Message ID 4d54ca8fb8605704260aad205acd6185fe73fb49.1693561063.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: libbtrfs: fix API compatibility change | expand

Commit Message

Qu Wenruo Sept. 1, 2023, 9:37 a.m. UTC
In commit 83ab92512e79 ("libbtrfs: remove the support for fs without
uuid tree"), the change to libbtrfs leads to an incompatible API change.

It's mostly in the subvol_info structure, that with the removed rb_node
structures, the subvol_info can no longer be compatible to older
versions due to the changed offset of the new members.

Fix it by adding back the old rb_node members mostly as a place holder.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 libbtrfs/send-utils.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

David Sterba Sept. 1, 2023, 10:06 a.m. UTC | #1
On Fri, Sep 01, 2023 at 05:37:44PM +0800, Qu Wenruo wrote:
> In commit 83ab92512e79 ("libbtrfs: remove the support for fs without
> uuid tree"), the change to libbtrfs leads to an incompatible API change.
> 
> It's mostly in the subvol_info structure, that with the removed rb_node
> structures, the subvol_info can no longer be compatible to older
> versions due to the changed offset of the new members.
> 
> Fix it by adding back the old rb_node members mostly as a place holder.

Thanks but I'd rather do a revert of the patch that caused the breakage.

> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  libbtrfs/send-utils.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/libbtrfs/send-utils.h b/libbtrfs/send-utils.h
> index be6f91b1d7bb..02f519c84804 100644
> --- a/libbtrfs/send-utils.h
> +++ b/libbtrfs/send-utils.h
> @@ -43,6 +43,14 @@ enum subvol_search_type {
>  };
>  
>  struct subvol_info {
> +	/*
> +	 * Those members are not longre utilized, but still need to be there
> +	 * for API compatibility.
> +	 */
> +	struct rb_node rb_root_id_node;
> +	struct rb_node rb_local_node;
> +	struct rb_node rb_received_node;
> +	struct rb_node rb_path_node;
>  
>  	u64 root_id;
>  	u8 uuid[BTRFS_UUID_SIZE];
> @@ -58,6 +66,14 @@ struct subvol_info {
>  
>  struct subvol_uuid_search {
>  	int mnt_fd;
> +
> +	/* The following members are deprecated. */
> +	int __uuid_tree_existed;
> +
> +	struct rb_root __root_id_subvols;

As pointed out in our bugzilla you've added "__" which is not 1:1 to the
original and could cause further problems.

> +	struct rb_root __local_subvols;
> +	struct rb_root __received_subvols;
> +	struct rb_root __path_subvols;
>  };
>  
>  int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s);
> -- 
> 2.41.0
diff mbox series

Patch

diff --git a/libbtrfs/send-utils.h b/libbtrfs/send-utils.h
index be6f91b1d7bb..02f519c84804 100644
--- a/libbtrfs/send-utils.h
+++ b/libbtrfs/send-utils.h
@@ -43,6 +43,14 @@  enum subvol_search_type {
 };
 
 struct subvol_info {
+	/*
+	 * Those members are not longre utilized, but still need to be there
+	 * for API compatibility.
+	 */
+	struct rb_node rb_root_id_node;
+	struct rb_node rb_local_node;
+	struct rb_node rb_received_node;
+	struct rb_node rb_path_node;
 
 	u64 root_id;
 	u8 uuid[BTRFS_UUID_SIZE];
@@ -58,6 +66,14 @@  struct subvol_info {
 
 struct subvol_uuid_search {
 	int mnt_fd;
+
+	/* The following members are deprecated. */
+	int __uuid_tree_existed;
+
+	struct rb_root __root_id_subvols;
+	struct rb_root __local_subvols;
+	struct rb_root __received_subvols;
+	struct rb_root __path_subvols;
 };
 
 int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s);