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 #endif /* __KERNEL__ */ 35 }; 36 37 struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index, 38 enum xfs_group_type type); 39 struct xfs_group *xfs_group_hold(struct xfs_group *xg); 40 void xfs_group_put(struct xfs_group *xg); 41 42 struct xfs_group *xfs_group_grab(struct xfs_mount *mp, uint32_t index, 43 enum xfs_group_type type); 44 struct xfs_group *xfs_group_next_range(struct xfs_mount *mp, 45 struct xfs_group *xg, uint32_t start_index, uint32_t end_index, 46 enum xfs_group_type type); 47 struct xfs_group *xfs_group_grab_next_mark(struct xfs_mount *mp, 48 struct xfs_group *xg, xa_mark_t mark, enum xfs_group_type type); 49 void xfs_group_rele(struct xfs_group *xg); 50 51 void xfs_group_free(struct xfs_mount *mp, uint32_t index, 52 enum xfs_group_type type, void (*uninit)(struct xfs_group *xg)); 53 int xfs_group_insert(struct xfs_mount *mp, struct xfs_group *xg, 54 uint32_t index, enum xfs_group_type); 55 56 #define xfs_group_set_mark(_xg, _mark) \ 57 xa_set_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ 58 (_xg)->xg_gno, (_mark)) 59 #define xfs_group_clear_mark(_xg, _mark) \ 60 xa_clear_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ 61 (_xg)->xg_gno, (_mark)) 62 #define xfs_group_marked(_mp, _type, _mark) \ 63 xa_marked(&(_mp)->m_groups[(_type)].xa, (_mark)) 64 65 #endif /* __LIBXFS_GROUP_H */ 66