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 16 struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index, 17 enum xfs_group_type type); 18 struct xfs_group *xfs_group_hold(struct xfs_group *xg); 19 void xfs_group_put(struct xfs_group *xg); 20 21 struct xfs_group *xfs_group_grab(struct xfs_mount *mp, uint32_t index, 22 enum xfs_group_type type); 23 struct xfs_group *xfs_group_next_range(struct xfs_mount *mp, 24 struct xfs_group *xg, uint32_t start_index, uint32_t end_index, 25 enum xfs_group_type type); 26 struct xfs_group *xfs_group_grab_next_mark(struct xfs_mount *mp, 27 struct xfs_group *xg, xa_mark_t mark, enum xfs_group_type type); 28 void xfs_group_rele(struct xfs_group *xg); 29 30 void xfs_group_free(struct xfs_mount *mp, uint32_t index, 31 enum xfs_group_type type, void (*uninit)(struct xfs_group *xg)); 32 int xfs_group_insert(struct xfs_mount *mp, struct xfs_group *xg, 33 uint32_t index, enum xfs_group_type); 34 35 #define xfs_group_set_mark(_xg, _mark) \ 36 xa_set_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ 37 (_xg)->xg_gno, (_mark)) 38 #define xfs_group_clear_mark(_xg, _mark) \ 39 xa_clear_mark(&(_xg)->xg_mount->m_groups[(_xg)->xg_type].xa, \ 40 (_xg)->xg_gno, (_mark)) 41 #define xfs_group_marked(_mp, _type, _mark) \ 42 xa_marked(&(_mp)->m_groups[(_type)].xa, (_mark)) 43 44 #endif /* __LIBXFS_GROUP_H */ 45