From 674b50c719c0f90d8492626a15344fc4b7b4f8be Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 6 Aug 2024 14:39:07 +0200 Subject: [PATCH] libbtrfs: use stub for list_head and drop list.h The list_head is used in struct definitions but otherwise not at all as it was copied from kernel code. For ctree.h add stub definition that won't change the containing structure size. Drop list.h from libbtrfs. This may break some builds if they used the header, though this was never meant to be exported. Signed-off-by: David Sterba --- Makefile | 2 +- libbtrfs/ctree.h | 30 ++++++++++++++++++------------ tests/library-test.c | 2 -- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index c0428c57..e6b3e5e6 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,7 @@ libbtrfs_objects = \ libbtrfs/crc32c.o libbtrfs_headers = libbtrfs/send-stream.h libbtrfs/send-utils.h libbtrfs/send.h kernel-lib/rbtree.h \ - kernel-lib/list.h kernel-lib/rbtree_types.h libbtrfs/kerncompat.h \ + kernel-lib/rbtree_types.h libbtrfs/kerncompat.h \ libbtrfs/ioctl.h libbtrfs/ctree.h libbtrfs/version.h libbtrfs_version = $(LIBBTRFS_MAJOR).$(LIBBTRFS_MINOR).$(LIBBTRFS_PATCHLEVEL) diff --git a/libbtrfs/ctree.h b/libbtrfs/ctree.h index 60428cab..9de771f7 100644 --- a/libbtrfs/ctree.h +++ b/libbtrfs/ctree.h @@ -23,16 +23,22 @@ #if BTRFS_FLAT_INCLUDES #include "libbtrfs/kerncompat.h" -#include "kernel-lib/list.h" #include "kernel-lib/rbtree.h" #include "libbtrfs/ioctl.h" #else #include -#include #include #include #endif /* BTRFS_FLAT_INCLUDES */ +/* + * Stub definition used only for struct declarations, change the name so it + * does not clash with a real struct list_head if included. + */ +struct list_head_ { + struct list_head_ *next, *prev; +}; + struct btrfs_root; struct btrfs_trans_handle; struct btrfs_free_space_ctl; @@ -224,7 +230,7 @@ struct cache_extent { struct extent_io_tree { struct cache_tree state; struct cache_tree cache; - struct list_head lru; + struct list_head_ lru; u64 cache_size; u64 max_cache_size; }; @@ -241,8 +247,8 @@ struct extent_state { struct extent_buffer { struct cache_extent cache_node; u64 start; - struct list_head lru; - struct list_head recow; + struct list_head_ lru; + struct list_head_ recow; u32 len; int refs; u32 flags; @@ -1193,7 +1199,7 @@ struct btrfs_space_info { */ u64 bytes_reserved; int full; - struct list_head list; + struct list_head_ list; }; struct btrfs_block_group { @@ -1222,7 +1228,7 @@ struct btrfs_block_group { struct rb_node cache_node; /* For dirty block groups */ - struct list_head dirty_list; + struct list_head_ dirty_list; /* * Allocation offset for the block group to implement sequential @@ -1280,11 +1286,11 @@ struct btrfs_fs_info { u64 total_pinned; u64 nr_global_roots; - struct list_head dirty_cowonly_roots; - struct list_head recow_ebs; + struct list_head_ dirty_cowonly_roots; + struct list_head_ recow_ebs; struct btrfs_fs_devices *fs_devices; - struct list_head space_info; + struct list_head_ space_info; unsigned int system_allocs:1; unsigned int readonly:1; @@ -1354,10 +1360,10 @@ struct btrfs_root { u32 type; u64 last_inode_alloc; - struct list_head unaligned_extent_recs; + struct list_head_ unaligned_extent_recs; /* the dirty list is only used by non-reference counted roots */ - struct list_head dirty_list; + struct list_head_ dirty_list; struct rb_node rb_node; }; diff --git a/tests/library-test.c b/tests/library-test.c index e4662bf4..11e991eb 100644 --- a/tests/library-test.c +++ b/tests/library-test.c @@ -21,7 +21,6 @@ #include "libbtrfs/version.h" #include "libbtrfs/ioctl.h" #include "kernel-lib/rbtree.h" -#include "kernel-lib/list.h" #include "kernel-shared/ctree.h" #include "kernel-shared/send.h" #include "common/send-stream.h" @@ -34,7 +33,6 @@ #include "btrfs/kerncompat.h" #include "btrfs/version.h" #include "btrfs/rbtree.h" -#include "btrfs/list.h" #include "btrfs/ctree.h" #include "btrfs/ioctl.h" #include "btrfs/send.h"