1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2018 Red Hat, Inc. 4 */ 5 #ifndef __LIBXFS_GROUP_H 6 #define __LIBXFS_GROUP_H 1 7 8 struct xfs_group { 9 struct xfs_mount *xg_mount; 10 uint32_t xg_gno; 11 enum xfs_group_type xg_type; 12 atomic_t xg_ref; /* passive reference count */ 13 atomic_t xg_active_ref; /* active reference count */ 14 15 #ifdef __KERNEL__ 16 /* -- kernel only structures below this line -- */ 17 18 /* 19 * Bitsets of per-ag metadata that have been checked and/or are sick. 20 * Callers should hold xg_state_lock before accessing this field. 21 */ 22 uint16_t xg_checked; 23 uint16_t xg_sick; 24 spinlock_t xg_state_lock; 25 26 /* 27 * We use xfs_drain to track the number of deferred log intent items 28 * that have been queued (but not yet processed) so that waiters (e.g. 29 * scrub) will not lock resources when other threads are in the middle 30 * of processing a chain of intent items only to find momentary 31 * inconsistencies. 32 */ 33 struct xfs_defer_drain xg_intents_drain; 34 35 /* 36 * Hook to feed rmapbt updates to an active online repair. 37 */ 38 struct xfs_hooks xg_rmap_update_hooks; 39 #endif /* __KERNEL__ */ 40 }; 41 42 struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index, 43 enum xfs_group_type type); 44 struct xfs_group *xfs_group_hold(struct xfs_group *xg); 45 void xfs_group_put(struct xfs_group *xg); 46 47 struct xfs_group *xfs_group_grab(struct xfs_mount *mp, uint32_t index, 48 enum xfs_group_type type); 49 struct xfs_group *xfs_group_next_range(struct xfs_mount *mp, 50 struct xfs_group *xg, uint32_t start_index, uint32_t end_index, 51 enum xfs_group_type type); 52 struct xfs_group *xfs_group_grab_next_mark(struct xfs_mount *mp, 53 struct xfs_group *xg, xa_mark_t mark, enum xfs_group_type type); 54 void xfs_group_rele(struct xfs_group *xg); 55 56 void xfs_group_free(struct xfs_mount *mp, uint32_t index, 57 enum xfs_group_type type, void (*uninit)(struct xfs_group *xg)); 58 int xfs_group_insert(struct xfs_mount *mp, struct xfs_group *xg, 59 uint32_t index, enum xfs_group_type); 60 61 #define xfs_group_set_mark(_xg, _mark) \ 62 xa_set_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ 63 (_xg)->xg_gno, (_mark)) 64 #define xfs_group_clear_mark(_xg, _mark) \ 65 xa_clear_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ 66 (_xg)->xg_gno, (_mark)) 67 #define xfs_group_marked(_mp, _type, _mark) \ 68 xa_marked(&(_mp)->m_groups[(_type)].xa, (_mark)) 69 70 #endif /* __LIBXFS_GROUP_H */ 71