1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_SNAPSHOT_TYPES_H 3 #define _BCACHEFS_SNAPSHOT_TYPES_H 4 5 #include "bbpos_types.h" 6 #include "darray.h" 7 #include "subvolume_types.h" 8 9 typedef DARRAY(u32) snapshot_id_list; 10 11 #define IS_ANCESTOR_BITMAP 128 12 13 struct snapshot_t { 14 enum snapshot_id_state { 15 SNAPSHOT_ID_empty, 16 SNAPSHOT_ID_live, 17 SNAPSHOT_ID_deleted, 18 } state; 19 u32 parent; 20 u32 skip[3]; 21 u32 depth; 22 u32 children[2]; 23 u32 subvol; /* Nonzero only if a subvolume points to this node: */ 24 u32 tree; 25 unsigned long is_ancestor[BITS_TO_LONGS(IS_ANCESTOR_BITMAP)]; 26 }; 27 28 struct snapshot_table { 29 struct rcu_head rcu; 30 size_t nr; 31 #ifndef RUST_BINDGEN 32 DECLARE_FLEX_ARRAY(struct snapshot_t, s); 33 #else 34 struct snapshot_t s[0]; 35 #endif 36 }; 37 38 struct snapshot_interior_delete { 39 u32 id; 40 u32 live_child; 41 }; 42 typedef DARRAY(struct snapshot_interior_delete) interior_delete_list; 43 44 struct snapshot_delete { 45 struct mutex lock; 46 struct work_struct work; 47 48 struct mutex progress_lock; 49 snapshot_id_list deleting_from_trees; 50 snapshot_id_list delete_leaves; 51 interior_delete_list delete_interior; 52 53 bool running; 54 struct bbpos pos; 55 }; 56 57 #endif /* _BCACHEFS_SNAPSHOT_TYPES_H */ 58