1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_BTREE_WRITE_BUFFER_TYPES_H 3 #define _BCACHEFS_BTREE_WRITE_BUFFER_TYPES_H 4 5 #include "darray.h" 6 #include "journal_types.h" 7 8 #define BTREE_WRITE_BUFERED_VAL_U64s_MAX 4 9 #define BTREE_WRITE_BUFERED_U64s_MAX (BKEY_U64s + BTREE_WRITE_BUFERED_VAL_U64s_MAX) 10 11 struct wb_key_ref { 12 union { 13 struct { 14 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 15 unsigned idx:24; 16 u8 pos[sizeof(struct bpos)]; 17 enum btree_id btree:8; 18 #else 19 enum btree_id btree:8; 20 u8 pos[sizeof(struct bpos)]; 21 unsigned idx:24; 22 #endif 23 } __packed; 24 struct { 25 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 26 u64 lo; 27 u64 mi; 28 u64 hi; 29 #else 30 u64 hi; 31 u64 mi; 32 u64 lo; 33 #endif 34 }; 35 }; 36 }; 37 38 struct btree_write_buffered_key { 39 enum btree_id btree:8; 40 u64 journal_seq:56; 41 __BKEY_PADDED(k, BTREE_WRITE_BUFERED_VAL_U64s_MAX); 42 }; 43 44 struct btree_write_buffer_keys { 45 DARRAY(struct btree_write_buffered_key) keys; 46 struct journal_entry_pin pin; 47 struct mutex lock; 48 }; 49 50 struct btree_write_buffer { 51 DARRAY(struct wb_key_ref) sorted; 52 struct btree_write_buffer_keys inc; 53 struct btree_write_buffer_keys flushing; 54 struct work_struct flush_work; 55 56 DARRAY(struct btree_write_buffered_key) accounting; 57 }; 58 59 #endif /* _BCACHEFS_BTREE_WRITE_BUFFER_TYPES_H */ 60