1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __XFS_REFCOUNT_H__
21#define __XFS_REFCOUNT_H__
22
23extern int xfs_refcount_lookup_le(struct xfs_btree_cur *cur,
24 xfs_agblock_t bno, int *stat);
25extern int xfs_refcount_lookup_ge(struct xfs_btree_cur *cur,
26 xfs_agblock_t bno, int *stat);
27extern int xfs_refcount_get_rec(struct xfs_btree_cur *cur,
28 struct xfs_refcount_irec *irec, int *stat);
29
30enum xfs_refcount_intent_type {
31 XFS_REFCOUNT_INCREASE = 1,
32 XFS_REFCOUNT_DECREASE,
33 XFS_REFCOUNT_ALLOC_COW,
34 XFS_REFCOUNT_FREE_COW,
35};
36
37struct xfs_refcount_intent {
38 struct list_head ri_list;
39 enum xfs_refcount_intent_type ri_type;
40 xfs_fsblock_t ri_startblock;
41 xfs_extlen_t ri_blockcount;
42};
43
44extern int xfs_refcount_increase_extent(struct xfs_mount *mp,
45 struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec);
46extern int xfs_refcount_decrease_extent(struct xfs_mount *mp,
47 struct xfs_defer_ops *dfops, struct xfs_bmbt_irec *irec);
48
49extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp,
50 struct xfs_btree_cur *rcur, int error);
51extern int xfs_refcount_finish_one(struct xfs_trans *tp,
52 struct xfs_defer_ops *dfops, enum xfs_refcount_intent_type type,
53 xfs_fsblock_t startblock, xfs_extlen_t blockcount,
54 xfs_fsblock_t *new_fsb, xfs_extlen_t *new_len,
55 struct xfs_btree_cur **pcur);
56
57extern int xfs_refcount_find_shared(struct xfs_btree_cur *cur,
58 xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno,
59 xfs_extlen_t *flen, bool find_end_of_shared);
60
61extern int xfs_refcount_alloc_cow_extent(struct xfs_mount *mp,
62 struct xfs_defer_ops *dfops, xfs_fsblock_t fsb,
63 xfs_extlen_t len);
64extern int xfs_refcount_free_cow_extent(struct xfs_mount *mp,
65 struct xfs_defer_ops *dfops, xfs_fsblock_t fsb,
66 xfs_extlen_t len);
67extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp,
68 xfs_agnumber_t agno);
69
70
71
72
73
74
75
76
77
78
79#define XFS_REFCOUNT_ITEM_OVERHEAD 32
80
81static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res)
82{
83 return (log_res * 3 / 4) / XFS_REFCOUNT_ITEM_OVERHEAD;
84}
85
86extern int xfs_refcount_has_record(struct xfs_btree_cur *cur,
87 xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
88
89#endif
90