1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_ASYNC_OBJS_H 3 #define _BCACHEFS_ASYNC_OBJS_H 4 5 #ifdef CONFIG_BCACHEFS_ASYNC_OBJECT_LISTS 6 static inline void __async_object_list_del(struct fast_list *head, unsigned idx) 7 { 8 fast_list_remove(head, idx); 9 } 10 11 static inline int __async_object_list_add(struct fast_list *head, void *obj, unsigned *idx) 12 { 13 int ret = fast_list_add(head, obj); 14 *idx = ret > 0 ? ret : 0; 15 return ret < 0 ? ret : 0; 16 } 17 18 #define async_object_list_del(_c, _list, idx) \ 19 __async_object_list_del(&(_c)->async_objs[BCH_ASYNC_OBJ_LIST_##_list].list, idx) 20 21 #define async_object_list_add(_c, _list, obj, idx) \ 22 __async_object_list_add(&(_c)->async_objs[BCH_ASYNC_OBJ_LIST_##_list].list, obj, idx) 23 24 void bch2_fs_async_obj_debugfs_init(struct bch_fs *); 25 void bch2_fs_async_obj_exit(struct bch_fs *); 26 int bch2_fs_async_obj_init(struct bch_fs *); 27 28 #else /* CONFIG_BCACHEFS_ASYNC_OBJECT_LISTS */ 29 30 #define async_object_list_del(_c, _n, idx) do {} while (0) 31 32 static inline int __async_object_list_add(void) 33 { 34 return 0; 35 } 36 #define async_object_list_add(_c, _n, obj, idx) __async_object_list_add() 37 38 static inline void bch2_fs_async_obj_debugfs_init(struct bch_fs *c) {} 39 static inline void bch2_fs_async_obj_exit(struct bch_fs *c) {} 40 static inline int bch2_fs_async_obj_init(struct bch_fs *c) { return 0; } 41 42 #endif /* CONFIG_BCACHEFS_ASYNC_OBJECT_LISTS */ 43 44 #endif /* _BCACHEFS_ASYNC_OBJS_H */ 45