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